/* ==========================================================================
   SnipFerry tool workspace — shared by the JSON suite and the Text suite
   ========================================================================== */

/* Layout: horizontal tool strip on phones, sticky sidebar on desktop */
.tool-layout { width: 100%; max-width: 1440px; margin: 0 auto; flex: 1; }
.tool-sidebar { border-bottom: 1px solid var(--line); background: var(--bg); }
.tool-nav-bar { min-width: 0; }
.tool-nav-title { display: none; }
.tool-nav-more { display: none; }
.tool-tabs {
  display: flex; gap: 6px; overflow-x: auto; padding: 10px var(--gutter);
  scrollbar-width: none; -webkit-overflow-scrolling: touch; scroll-snap-type: x proximity;
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 12px, #000 calc(100% - 28px), transparent 100%);
  mask-image: linear-gradient(90deg, transparent 0, #000 12px, #000 calc(100% - 28px), transparent 100%);
}
.tool-tabs::-webkit-scrollbar { display: none; }
.tool-tab {
  flex: none; scroll-snap-align: center; display: inline-flex; align-items: center; gap: 7px;
  min-height: 38px; padding: 0 13px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink-2); font-size: 14px; font-weight: 600; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.tool-tab:hover { border-color: var(--line-strong); color: var(--ink); }
.tool-tab .tab-icon { font-size: 14px; line-height: 1; width: 18px; text-align: center; }
.tool-tab.active, .tool-tab[aria-current="page"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }

@media (min-width: 1024px) {
  .tool-layout { display: grid; grid-template-columns: 252px minmax(0, 1fr); padding-inline: var(--gutter); gap: 32px; }
  .tool-sidebar { border: 0; background: none; }
  .tool-nav-bar { position: sticky; top: var(--header-h); max-height: calc(100vh - var(--header-h)); overflow-y: auto; padding: 24px 0 32px; scrollbar-width: thin; }
  .tool-tabs { flex-direction: column; gap: 1px; overflow: visible; padding: 0; -webkit-mask-image: none; mask-image: none; }
  .tool-nav-title { display: block; margin: 0 0 6px; padding: 0 10px; font-size: 13px; font-weight: 650; color: var(--faint); }
  .tool-tabs .tool-nav-title:not(:first-child) { margin-top: 18px; }
  .tool-tab { border: 0; background: none; border-radius: 10px; min-height: 36px; padding: 0 10px; font-weight: 550; color: var(--ink-2); }
  .tool-tab:hover { background: var(--surface-2); }
  .tool-tab.active, .tool-tab[aria-current="page"] { background: var(--surface); color: var(--ink); font-weight: 650; box-shadow: inset 3px 0 0 var(--brand), var(--shadow-sm); border: 0; }
  .dark .tool-tab.active, .dark .tool-tab[aria-current="page"] { box-shadow: inset 3px 0 0 var(--lime); }
  .tool-nav-more { display: grid; gap: 1px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
  .tool-nav-more a { padding: 7px 10px; border-radius: 10px; font-size: 14px; color: var(--muted); }
  .tool-nav-more a:hover { background: var(--surface-2); color: var(--ink); }
}

/* Main column */
.json-main { min-width: 0; width: 100%; max-width: var(--max); margin: 0 auto; padding: 16px var(--gutter) 56px; }
@media (min-width: 1024px) { .json-main { padding: 24px 0 72px; } }
.tool-header-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 10px; }
.tool-header-left { min-width: 0; }
.tool-header-left h1 { font-size: clamp(26px, 6vw, 40px); letter-spacing: -.035em; margin: 0 0 6px; }
.tool-header-left p { color: var(--muted); margin: 0; font-size: 16px; max-width: 70ch; }
.tool-header-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: none; }

.privacy-banner { margin: 0 0 16px; font-size: 14px; color: var(--muted); line-height: 1.5; }
.privacy-banner strong { color: var(--ink-2); font-weight: 650; }
.privacy-banner-link { color: var(--brand-text); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }

/* Buttons */
.action-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 0 13px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--line-strong); color: var(--ink);
  font-size: 14px; font-weight: 600; white-space: nowrap; transition: background .15s, border-color .15s;
}
.action-btn:hover { background: var(--surface-2); }
.action-btn-primary { background: var(--btn); color: var(--btn-ink); border-color: transparent; }
.action-btn-primary:hover { background: var(--btn-hover); }
.share-trigger-btn { min-height: 42px; padding: 0 16px; background: var(--ink); color: var(--bg); border-color: transparent; border-radius: 12px; }
.share-trigger-btn:hover { background: var(--ink-2); }
.share-trigger-btn svg { color: var(--lime); }
.dark .share-trigger-btn { background: var(--lime); color: var(--lime-ink); }
.dark .share-trigger-btn svg { color: inherit; }

/* Toolbar + options */
.master-toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; padding: 8px; margin-bottom: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); }
.toolbar-group { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.toolbar-output { margin-left: auto; }
.toolbar-output .pane-meta { padding-inline: 4px; }
@media (max-width: 559px) {
  .master-toolbar { display: grid; grid-template-columns: 1fr; }
  .toolbar-group { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); }
  .toolbar-output { margin: 0; display: flex; flex-wrap: wrap; justify-content: space-between; border-top: 1px solid var(--line); padding-top: 8px; }
  .toolbar-output .action-btn { flex: 1 1 40%; }
  .toolbar-output .pane-meta, .toolbar-output .status-pill { order: 2; }
}
.options-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 14px; padding: 10px 12px; margin-bottom: 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md); font-size: 14px; }
.options-bar:not(:has(.tool-options-group:not([hidden]))) { display: none; }
.tool-options-group { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 14px; }
.options-label { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; color: var(--ink-2); }
.options-label select, .options-label input[type="text"], .options-label input[type="number"], .tool-options-group > input[type="text"] {
  min-height: 36px; border: 1px solid var(--line-strong); border-radius: 9px; background-color: var(--surface); color: var(--ink);
  padding: 0 10px; font-size: 14px; font-weight: 500; outline: none; max-width: 100%;
}
.options-label input[type="text"] { width: 150px; }
.options-label select:focus, .options-label input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 20%, transparent); }
.options-checkbox { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; font-weight: 550; color: var(--ink-2); min-height: 32px; }
.options-hint { margin-left: auto; font-size: 13px; color: var(--faint); }
@media (max-width: 559px) { .options-hint { display: none; } .tool-options-group { width: 100%; } .options-label { flex-wrap: wrap; } }
.muted-hint { color: var(--faint); font-style: italic; }
.epoch-ticker { font-family: var(--font-mono); font-weight: 650; color: var(--brand-text); font-size: 14px; }

/* Status pill inside the tool toolbar (independent of the room status pill) */
.master-toolbar .status-pill { padding: 3px 10px; font-size: 12px; font-weight: 650; gap: 0; }
.status-valid { background: var(--brand-soft); color: var(--brand-text); }
.status-invalid { background: var(--danger-soft) !important; color: var(--danger) !important; }
.status-idle { background: var(--surface-2) !important; color: var(--muted) !important; }

/* Editor panes */
.split-pane-grid { display: grid; gap: 12px; }
@media (min-width: 900px) { .split-pane-grid { grid-template-columns: 1fr 1fr; gap: 14px; } }
.pane-card { display: flex; flex-direction: column; min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.pane-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 44px; padding: 0 14px; border-bottom: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.pane-title { display: flex; align-items: center; gap: 8px; color: var(--ink); font-weight: 650; font-size: 14px; }
.pane-meta { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.editor-container { position: relative; display: flex; flex: 1 1 auto; height: 300px; min-height: 0; background: var(--code-bg); overflow: hidden; transition: background .15s, box-shadow .15s; }
.split-pane-grid .editor-container { height: 240px; }
@media (min-width: 900px) { .editor-container, .split-pane-grid .editor-container { height: clamp(380px, 62vh, 640px); } }
.editor-container.drag-over { background: var(--brand-soft); box-shadow: inset 0 0 0 2px var(--brand); }
.code-rail { min-width: 44px; padding: 14px 8px 14px 0; text-align: right; color: var(--faint); border-right: 1px solid var(--line); font: 13px/1.65 var(--font-mono); white-space: pre; user-select: none; overflow: hidden; }
.code-textarea { flex: 1; width: 100%; height: 100%; margin: 0; padding: 14px; resize: none; border: 0; outline: 0; background: transparent; color: var(--ink); font: 13.5px/1.65 var(--font-mono); tab-size: 2; white-space: pre; overflow: auto; }
.code-textarea::placeholder { color: var(--faint); }
.code-display { flex: 1; min-width: 0; margin: 0; padding: 14px; font: 13.5px/1.65 var(--font-mono); tab-size: 2; white-space: pre; overflow: auto; color: var(--ink); outline: none; }
.code-display:focus-visible { box-shadow: inset 0 0 0 2px var(--brand); border-radius: 0; }

/* Syntax colours */
.tok-key { color: #96368c; font-weight: 600; }
.tok-string { color: #2f7425; }
.tok-number { color: #b0581a; }
.tok-bool { color: #1f6aa0; font-weight: 650; }
.tok-null { color: var(--faint); font-style: italic; }
.tok-tag { color: #23638f; font-weight: 600; }
.dark .tok-key { color: #e7a0dc; }
.dark .tok-string { color: #a8dd8a; }
.dark .tok-number { color: #f4b27c; }
.dark .tok-bool { color: #8ec8f2; }
.dark .tok-tag { color: #8ec8f2; }

/* Tree viewer */
.json-tree-root { font: 13.5px/1.6 var(--font-mono); padding: 4px 0; }
.tree-node { margin: 1px 0; }
.tree-header { display: flex; align-items: center; gap: 6px; padding: 3px 6px; border-radius: 6px; }
.tree-header:hover { background: var(--surface-2); }
.tree-header.tree-highlight { background: var(--warn-soft); }
.tree-toggle { display: inline-block; width: 18px; text-align: center; font-size: 10px; color: var(--muted); cursor: pointer; user-select: none; }
.tree-key { color: #96368c; font-weight: 650; }
.dark .tree-key { color: #e7a0dc; }
.tree-badge { font-size: 11px; padding: 1px 6px; border-radius: 5px; font-weight: 650; font-family: var(--font-body); }
.tree-badge-object { background: #e3edf9; color: #22598f; }
.tree-badge-array { background: #f7ead9; color: #985420; }
.dark .tree-badge-object { background: #1c3349; color: #8bb5e4; }
.dark .tree-badge-array { background: #3f2c19; color: #e5a472; }
.tree-children { padding-left: 18px; border-left: 1px dashed var(--line-strong); margin-left: 9px; }
.tree-children.collapsed { display: none; }
.tree-path-copy { margin-left: auto; opacity: 0; background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 7px; font-size: 11px; color: var(--brand-text); font-weight: 650; font-family: var(--font-body); }
.tree-header:hover .tree-path-copy, .tree-path-copy:focus-visible { opacity: 1; }
@media (hover: none) { .tree-path-copy { opacity: .8; } }

/* Diff */
.diff-view-container { display: flex; flex-direction: column; gap: 12px; }
.diff-inputs-grid { display: grid; gap: 12px; }
@media (min-width: 900px) { .diff-inputs-grid { grid-template-columns: 1fr 1fr; gap: 14px; } .diff-inputs-grid .editor-container { height: clamp(260px, 40vh, 420px); } }
.diff-inputs-grid .editor-container { height: 220px; }
.diff-result-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.diff-result-body { font: 13.5px/1.65 var(--font-mono); padding: 8px 0; max-height: 520px; overflow: auto; }
.diff-line { display: flex; padding: 1px 14px; }
.diff-gutter { width: 22px; flex: none; font-weight: 700; user-select: none; }
.diff-text { flex: 1; white-space: pre; }
.diff-added { background: #e6f5da; color: #255f1b; }
.diff-deleted { background: #fbe5e1; color: #9c2d20; }
.diff-modified { background: #fbf3d6; color: #7d5e08; }
.dark .diff-added { background: #17331c; color: #a7e9b0; }
.dark .diff-deleted { background: #3a1b17; color: #f7a9a4; }
.dark .diff-modified { background: #383012; color: #eed17c; }
.diff-add { color: #2e6822; font-weight: 700; }
.diff-del { color: var(--danger); font-weight: 700; }
.diff-mod { color: var(--warn); font-weight: 700; }
.dark .diff-add { color: #a7e9b0; }

/* CSV table */
.table-scroll { max-height: 100%; overflow: auto; width: 100%; }
.csv-table { width: 100%; border-collapse: collapse; font: 13px var(--font-body); }
.csv-table th { background: var(--surface-2); border: 1px solid var(--line); padding: 8px 12px; text-align: left; font-weight: 650; position: sticky; top: 0; }
.csv-table td { border: 1px solid var(--line); padding: 7px 12px; }
.csv-table tr:nth-child(even) td { background: color-mix(in srgb, var(--surface-2) 50%, transparent); }

.tool-alert { background: var(--danger-soft); border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent); color: var(--danger); padding: 12px 14px; border-radius: var(--r-sm); font: 14px/1.5 var(--font-body); white-space: normal; margin: 4px 0; }

/* Share modal — a bottom sheet on phones, a dialog on larger screens */
.modal-overlay { position: fixed; inset: 0; z-index: 999; display: flex; align-items: flex-end; justify-content: center; background: rgba(9, 20, 13, .55); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); animation: fadeIn .18s ease; }
@media (min-width: 640px) { .modal-overlay { align-items: center; padding: 20px; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheetUp { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.share-modal-box { position: relative; width: 100%; max-width: 520px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl) var(--r-xl) 0 0; box-shadow: var(--shadow-lg); padding: 28px 20px calc(24px + env(safe-area-inset-bottom)); text-align: left; animation: sheetUp .25s var(--ease); }
@media (min-width: 640px) { .share-modal-box { border-radius: var(--r-xl); padding: 32px 30px; } }
.share-modal-icon { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; background: var(--brand); color: var(--lime); font-size: 24px; margin-bottom: 14px; }
.share-modal-box h2 { font-size: 24px; margin: 0 0 6px; }
.share-modal-box p { color: var(--muted); font-size: 15px; margin: 0 0 16px; }
.share-link-wrapper { display: flex; border: 1px solid var(--line-strong); border-radius: var(--r-md); overflow: hidden; background: var(--surface-2); margin-bottom: 10px; }
.share-link-wrapper input { flex: 1; min-width: 0; height: 46px; padding: 0 12px; border: 0; background: transparent; color: var(--ink); font: 14px var(--font-mono); outline: none; }
.share-link-wrapper button { flex: none; border: 0; background: var(--btn); color: var(--btn-ink); padding: 0 16px; font-weight: 650; font-size: 14px; }
.share-link-wrapper button:hover { background: var(--btn-hover); }
.share-modal-meta { font-size: 13px !important; }
.share-modal-meta strong { font-family: var(--font-mono); color: var(--ink); letter-spacing: .08em; }
.share-modal-actions { display: flex; gap: 10px; }
.share-modal-actions .action-btn { flex: 1; min-height: 46px; }
.modal-close-btn { position: absolute; top: 14px; right: 14px; width: 36px; height: 36px; border-radius: 10px; background: var(--surface-2); border: 0; font-size: 16px; color: var(--muted); }
.modal-close-btn:hover { color: var(--ink); }

/* SEO guide below the tool */
.seo-guide-section { margin-top: 48px; padding-top: 40px; border-top: 1px solid var(--line); }
.seo-guide-section .section-heading { margin-bottom: 22px; }
.seo-guide-section .section-heading h2 { font-size: clamp(24px, 5vw, 34px); }
.seo-guide-section .section-heading p { font-size: 16px; }
.seo-features-grid { display: grid; gap: 12px; margin: 0 0 40px; }
@media (min-width: 640px) { .seo-features-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1200px) { .seo-features-grid { grid-template-columns: repeat(4, 1fr); } }
.seo-feature-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px; }
.seo-feature-card h3 { font-size: 17px; margin: 0 0 6px; }
.seo-feature-card p { color: var(--muted); font-size: 15px; line-height: 1.55; margin: 0; }
.seo-faq-section { margin-bottom: 40px; }
.seo-faq-section h2, .cluster-links-section h2 { font-size: clamp(22px, 4.5vw, 30px); margin: 6px 0 16px; }
.faq-grid { display: grid; gap: 10px; }
.faq-item { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 0; }
.faq-item summary, .faq-item h3, .faq-item h4 { list-style: none; cursor: pointer; display: flex; justify-content: space-between; gap: 14px; align-items: center; margin: 0; padding: 15px 16px; font: 650 16px/1.4 var(--font-body); color: var(--ink); letter-spacing: 0; }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: '+'; font-size: 22px; line-height: 1; color: var(--faint); transition: transform .2s; flex: none; }
.faq-item[open] summary::after { transform: rotate(45deg); }
.faq-item p { margin: 0; padding: 0 16px 16px; color: var(--muted); font-size: 15px; line-height: 1.65; }
.cluster-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
@media (min-width: 640px) { .cluster-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1200px) { .cluster-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.cluster-card { min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); transition: border-color .15s, transform .15s var(--ease); }
.cluster-card:hover { border-color: var(--brand); transform: translateY(-1px); }
.cluster-card-info { min-width: 0; }
.cluster-card-info strong { display: block; font-size: 15px; font-weight: 650; margin-bottom: 2px; }
.cluster-card-info span { display: block; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cluster-arrow { color: var(--brand-text); font-size: 18px; flex: none; }

/* Shared JSON page */
.share-page-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
@media (max-width: 559px) { .share-page-actions { display: grid; grid-template-columns: 1fr 1fr; } .share-page-actions .share-trigger-btn { grid-column: 1 / -1; } }
.share-page-card .editor-container { height: clamp(320px, 60vh, 680px); }
.share-banner { display: block; line-height: 1.6; padding: 10px 14px; border-radius: var(--r-md); background: var(--brand-soft); color: var(--ink-2); font-size: 14px; margin-bottom: 16px; }
.share-banner code { font-weight: 700; color: var(--brand-text); letter-spacing: .08em; }
