/* =============================================================================
   FileNectar — premium layer
   Loaded after style.css. Everything here is a refinement of the base system:
   tokens, typography, surfaces, motion, dark theme, the command palette and the
   mobile shell. No markup is required for it (extra elements are added by
   js/shell.js), so pages keep working without it.
   ============================================================================= */

/* ---------- 1. tokens ---------- */
:root {
  color-scheme: light;
  --bg: #fbf9f5;
  --bg-elev: #ffffff;
  --bg-elev-2: #f4f1ea;
  --bg-elev-3: #ebe7dd;
  --border: rgba(22, 38, 79, 0.12);
  --border-strong: rgba(22, 38, 79, 0.26);
  --text: #14172a;
  --text-dim: #5b6073;
  --navy: #16264f;
  --navy-deep: #0d1730;
  --gold: #e0a82e;
  --gold-deep: #9f6209;
  --radius: 14px;
  --radius-sm: 10px;
  --mono: ui-monospace, 'SF Mono', 'Cascadia Mono', 'Roboto Mono', Consolas, Menlo, monospace;
  --ring: 0 0 0 3px rgba(224, 168, 46, 0.38);
  --shadow-1: 0 1px 2px rgba(13, 23, 48, 0.05), 0 0 0 1px rgba(13, 23, 48, 0.02);
  --shadow-2: 0 10px 28px -10px rgba(13, 23, 48, 0.18), 0 2px 6px rgba(13, 23, 48, 0.05);
  --shadow-3: 0 30px 70px -18px rgba(13, 23, 48, 0.38), 0 6px 16px rgba(13, 23, 48, 0.08);
  --glass: rgba(251, 249, 245, 0.82);
  --accent-bg: linear-gradient(180deg, #1f356d 0%, #16264f 100%);
  --accent-fg: #ffffff;
  --paper: #fbf9f5;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --topbar-h: 64px;
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #0a0f1f;
  --bg-elev: #121a31;
  --bg-elev-2: #182240;
  --bg-elev-3: #212d50;
  --border: rgba(186, 201, 255, 0.14);
  --border-strong: rgba(186, 201, 255, 0.3);
  --text: #e9ecf6;
  --text-dim: #9ba4be;
  --navy: #d8e0ff;
  --navy-deep: #ffffff;
  --gold: #f0bb45;
  --gold-deep: #f0bb45;
  --ring: 0 0 0 3px rgba(240, 187, 69, 0.4);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-2: 0 14px 34px -12px rgba(0, 0, 0, 0.6), 0 2px 6px rgba(0, 0, 0, 0.3);
  --shadow-3: 0 34px 80px -18px rgba(0, 0, 0, 0.8), 0 6px 18px rgba(0, 0, 0, 0.4);
  --glass: rgba(10, 15, 31, 0.8);
  --accent-bg: linear-gradient(180deg, #f5c862 0%, #e5ae33 100%);
  --accent-fg: #14172a;
  --danger-bg: rgba(214, 69, 69, 0.14);
  --success-bg: rgba(47, 158, 92, 0.14);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --bg: #0a0f1f;
    --bg-elev: #121a31;
    --bg-elev-2: #182240;
    --bg-elev-3: #212d50;
    --border: rgba(186, 201, 255, 0.14);
    --border-strong: rgba(186, 201, 255, 0.3);
    --text: #e9ecf6;
    --text-dim: #9ba4be;
    --navy: #d8e0ff;
    --navy-deep: #ffffff;
    --gold: #f0bb45;
    --gold-deep: #f0bb45;
    --ring: 0 0 0 3px rgba(240, 187, 69, 0.4);
    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-2: 0 14px 34px -12px rgba(0, 0, 0, 0.6), 0 2px 6px rgba(0, 0, 0, 0.3);
    --shadow-3: 0 34px 80px -18px rgba(0, 0, 0, 0.8), 0 6px 18px rgba(0, 0, 0, 0.4);
    --glass: rgba(10, 15, 31, 0.8);
    --accent-bg: linear-gradient(180deg, #f5c862 0%, #e5ae33 100%);
    --accent-fg: #14172a;
    --danger-bg: rgba(214, 69, 69, 0.14);
    --success-bg: rgba(47, 158, 92, 0.14);
  }
}

/* ---------- 2. base ---------- */
html { scroll-behavior: smooth; -webkit-tap-highlight-color: transparent; }
body {
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'tnum' 1, 'ss01' 1;
  overflow-x: hidden;
}
.app { background: var(--bg); }
::selection { background: rgba(224, 168, 46, 0.34); color: inherit; }
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
h1, h2, h3 { text-wrap: balance; }
p { text-wrap: pretty; }
:focus { outline: none; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 8px; }
button, a, select, input, textarea { -webkit-tap-highlight-color: transparent; }
button { touch-action: manipulation; }

.skip-link {
  position: fixed; left: 12px; top: -60px; z-index: 300; padding: 10px 16px; border-radius: 10px;
  background: var(--navy); color: var(--paper); font-weight: 700; font-size: 0.88rem; text-decoration: none;
  transition: top .2s var(--ease);
}
.skip-link:focus { top: 12px; }

/* ---------- 3. topbar ---------- */
.topbar {
  background: transparent; backdrop-filter: none; -webkit-backdrop-filter: none;
  border-bottom: 1px solid transparent; isolation: isolate;
  padding: 12px 32px; transition: border-color .25s ease, box-shadow .25s ease;
}
.topbar::before {
  content: ''; position: absolute; inset: 0; z-index: -1; background: var(--glass);
  backdrop-filter: blur(16px) saturate(1.5); -webkit-backdrop-filter: blur(16px) saturate(1.5);
}
.topbar.scrolled { border-bottom-color: var(--border); box-shadow: 0 8px 24px -16px rgba(13, 23, 48, 0.28); }
.brand { gap: 10px; text-decoration: none; }
.brand-name { font-family: var(--serif); font-weight: 900; letter-spacing: -0.02em; color: var(--navy); font-size: 1.2rem; }
:root[data-theme='dark'] .brand-mark { background: var(--paper); border-radius: 9px; padding: 3px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) .brand-mark { background: var(--paper); border-radius: 9px; padding: 3px; } }

.nav-btn { border-radius: 10px; padding: 9px 12px; font-weight: 600; color: var(--text-dim); letter-spacing: -0.005em; }
.nav-btn:hover { color: var(--text); background: var(--bg-elev-2); }
.nav-btn.active { background: var(--accent-bg); color: var(--accent-fg); box-shadow: var(--shadow-1); }
.nav-group.open > .nav-group-btn:not(.active) { background: var(--bg-elev-2); color: var(--text); }
.nav-group.open > .nav-group-btn.active, .nav-group-btn.active { color: var(--accent-fg); background: var(--accent-bg); }

.topbar-actions { display: flex; align-items: center; gap: 6px; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px;
  border-radius: 10px; border: 1px solid var(--border); background: var(--bg-elev); color: var(--text-dim);
  cursor: pointer; padding: 0; transition: all .16s var(--ease); box-shadow: var(--shadow-1); font-family: inherit;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); transform: translateY(-1px); }
.icon-btn:active { transform: scale(0.96); }
.icon-btn svg { width: 18px; height: 18px; display: block; }
.menu-btn { display: none; }
.theme-btn .ic-sun, .theme-btn .ic-moon, .theme-btn .ic-auto { display: none; }
.theme-btn[data-mode='light'] .ic-sun, .theme-btn[data-mode='dark'] .ic-moon, .theme-btn[data-mode='auto'] .ic-auto { display: block; }

.lang-toggle, .auth-toggle {
  border-radius: 10px; background: var(--bg-elev); border: 1px solid var(--border); color: var(--text);
  padding: 8px 12px; font-weight: 600; box-shadow: var(--shadow-1); height: 38px;
}
.lang-toggle { appearance: none; -webkit-appearance: none; padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath d='M1.5 3.5 5 7l3.5-3.5' fill='none' stroke='%237b8196' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; }
.auth-toggle.is-user { background: var(--accent-bg); color: var(--accent-fg); border-color: transparent; }
.admin-toggle-btn { color: var(--gold-deep); border-color: var(--gold-deep); }

/* ---------- 4. mega menu ---------- */
.mega {
  background: var(--bg-elev); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-3); animation: fn-drop .22s var(--ease);
}
.mega-side { background: var(--bg-elev-2); border-right: 1px solid var(--border); }
.mega-title { color: var(--navy); letter-spacing: -0.02em; }
.mega-all { background: var(--accent-bg); color: var(--accent-fg); border-radius: 10px; }
.mega-all:hover { filter: brightness(1.08); background: var(--accent-bg); }
.mega-item { border-radius: 8px; color: var(--text); }
.mega-item:hover, .mega-item:focus-visible { background: var(--bg-elev-2); color: var(--text); font-weight: 700; }
.mega-item.active { color: var(--gold-deep); background: var(--bg-elev-2); }
@keyframes fn-drop { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* ---------- 5. content frame ---------- */
.content { max-width: 1080px; padding: 48px 28px 96px; }
.tool-section { animation: fn-rise .38s var(--ease) both; }
.subtab-panel:not([hidden]) { animation: fn-rise .32s var(--ease) both; }
@keyframes fn-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.tool-section > h2, .tool-h1 {
  font-family: var(--serif); font-weight: 800; letter-spacing: -0.025em; color: var(--text);
  font-size: clamp(1.5rem, 2.6vw, 2rem); line-height: 1.25; margin: 0 0 8px;
}
.tool-h1 { color: var(--text); }
.section-desc { color: var(--text-dim); max-width: 68ch; line-height: 1.65; }

/* ---------- 6. home / hero ---------- */
.hero { padding: 40px 0 28px; border-radius: 0; gap: 48px; align-items: center; overflow: visible; }
.hero::before {
  top: -80px; left: 50%; width: 100vw; margin-left: -50vw; height: 560px; z-index: -1; right: auto; bottom: auto;
  background:
    radial-gradient(640px 320px at 20% 8%, rgba(224, 168, 46, 0.16), transparent 70%),
    radial-gradient(560px 300px at 88% 30%, rgba(22, 38, 79, 0.1), transparent 70%),
    linear-gradient(var(--border) 1px, transparent 1px) 0 0 / 100% 56px,
    linear-gradient(90deg, var(--border) 1px, transparent 1px) 0 0 / 56px 100%;
  -webkit-mask-image: linear-gradient(180deg, #000 0%, transparent 92%); mask-image: linear-gradient(180deg, #000 0%, transparent 92%);
  opacity: 0.55;
}
:root[data-theme='dark'] .hero::before { opacity: 0.35; }
.hero h1 {
  font-size: clamp(2.1rem, 4.7vw, 3.55rem); line-height: 1.22; letter-spacing: -0.035em; font-weight: 800;
  color: var(--text); margin-bottom: 20px;
}
.hero-sub { font-size: 1.04rem; line-height: 1.75; max-width: 56ch; color: var(--text-dim); }
.hero-sub strong { color: var(--gold-deep); }
.hero-lockup { display: none; }


.hero-search { margin: 28px 0 0; max-width: 640px; }
.search-trigger {
  width: 100%; display: flex; align-items: center; gap: 12px; height: 58px; padding: 0 14px 0 18px;
  background: var(--bg-elev); border: 1px solid var(--border-strong); border-radius: 16px; cursor: pointer;
  box-shadow: var(--shadow-2); color: var(--text-dim); font-family: inherit; font-size: 1rem; text-align: left;
  transition: transform .18s var(--ease), box-shadow .18s var(--ease), border-color .18s;
}
.search-trigger:hover { border-color: var(--gold); transform: translateY(-1px); }
.search-trigger svg { width: 20px; height: 20px; flex: 0 0 auto; color: var(--text-dim); }
.search-trigger .st-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kbd-group { display: inline-flex; gap: 4px; flex: 0 0 auto; }
kbd.kbd {
  font-family: var(--mono); font-size: 0.72rem; font-weight: 600; color: var(--text-dim); background: var(--bg-elev-2);
  border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 6px; padding: 2px 7px; line-height: 1.4;
}
.hero-chips { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 16px; max-width: 640px; }
.chips-label { font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-dim); margin-right: 4px; }
.chip {
  display: inline-flex; align-items: center; height: 32px; padding: 0 13px; border-radius: 999px; font-size: 0.85rem; font-weight: 600;
  color: var(--text); text-decoration: none; background: var(--bg-elev); border: 1px solid var(--border);
  transition: all .16s var(--ease); white-space: nowrap;
}
.chip:hover { border-color: var(--gold); color: var(--gold-deep); transform: translateY(-1px); box-shadow: var(--shadow-1); }

.trust { list-style: none; display: flex; flex-wrap: wrap; gap: 10px 26px; margin: 34px 0 6px; padding: 18px 0 0; border-top: 1px solid var(--border); }
.trust li { display: inline-flex; align-items: center; gap: 9px; font-family: var(--mono); font-size: 0.78rem; letter-spacing: 0.02em; color: var(--text-dim); }
.trust li::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 4px rgba(224, 168, 46, 0.2); }

/* feature cards */
.card-grid { gap: 14px; margin-top: 24px; counter-reset: fc; }
.feature-card {
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px 22px 20px; gap: 8px;
  box-shadow: var(--shadow-1); counter-increment: fc; animation: fn-rise .5s var(--ease) both; animation-delay: calc(var(--i, 0) * 28ms);
  transition: transform .22s var(--ease), box-shadow .22s var(--ease), border-color .22s;
}
.feature-card::after {
  content: counter(fc, decimal-leading-zero); position: absolute; top: 20px; right: 22px; font-family: var(--mono);
  font-size: 0.7rem; color: var(--text-dim); opacity: 0.65; letter-spacing: 0.06em;
}
.feature-card:hover { transform: translateY(-3px); border-color: var(--gold); box-shadow: var(--shadow-2); }
.feature-card:active { transform: translateY(-1px) scale(0.99); }
.feature-icon-badge { width: 42px; height: 42px; border-radius: 12px; background: var(--bg-elev-2); color: var(--navy); border: 1px solid var(--border); margin-bottom: 6px; }
.feature-card:hover .feature-icon-badge { background: var(--accent-bg); color: var(--accent-fg); border-color: transparent; }
.feature-title { font-size: 1.04rem; letter-spacing: -0.015em; color: var(--text); }
.feature-desc { color: var(--text-dim); line-height: 1.55; }

/* full directory (built by shell.js) */
.directory { margin-top: 72px; }
.directory-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 26px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.directory-head h2 { margin: 0; font-family: var(--serif); font-size: clamp(1.4rem, 2.4vw, 1.8rem); letter-spacing: -0.025em; font-weight: 800; color: var(--text); }
.directory-head p { margin: 0; color: var(--text-dim); font-size: 0.92rem; }
.dir-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 34px 40px; }
.dir-group h3 { display: flex; align-items: baseline; gap: 10px; margin: 0 0 8px; font-size: 0.8rem; font-family: var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-dim); font-weight: 600; }
.dir-group h3 .dir-n { color: var(--gold-deep); }
.dir-group h3 .dir-count { margin-left: auto; opacity: 0.7; }
.dir-group ul { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--border); }
.dir-group li { border-bottom: 1px solid var(--border); }
.dir-group a {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 2px; color: var(--text);
  text-decoration: none; font-size: 0.93rem; font-weight: 500; transition: padding .18s var(--ease), color .18s;
}
.dir-group a::after { content: '\2192'; font-family: var(--mono); color: var(--gold-deep); opacity: 0; transform: translateX(-6px); transition: all .18s var(--ease); }
.dir-group a:hover { padding-left: 8px; color: var(--gold-deep); }
.dir-group a:hover::after { opacity: 1; transform: none; }

.privacy-note, .plan-banner {
  border-radius: var(--radius); background: var(--bg-elev-2); border: 1px solid var(--border); color: var(--text-dim);
  text-align: left; font-size: 0.86rem; line-height: 1.65; padding: 14px 18px;
}
.plan-banner { background: linear-gradient(90deg, rgba(224, 168, 46, 0.14), transparent); border-color: rgba(224, 168, 46, 0.45); color: var(--text); }
.install-block { background: var(--accent-bg); color: var(--accent-fg); border-radius: var(--radius); box-shadow: var(--shadow-2); }
.install-text p, .install-ios-note { color: inherit; opacity: 0.8; }
.install-block .secondary-btn { background: var(--paper); color: #14172a; border-color: transparent; }
.about-block { border-top: 1px solid var(--border); }

/* ---------- 7. tools: dropzone, buttons, fields ---------- */
.subtabs {
  display: flex; flex-wrap: wrap; gap: 4px; padding: 4px; margin-bottom: 26px; border: 1px solid var(--border);
  background: var(--bg-elev-2); border-radius: 14px; width: fit-content; max-width: 100%;
}
.subtab-btn {
  background: transparent; border: 1px solid transparent; border-radius: 10px; color: var(--text-dim); font-weight: 600;
  padding: 8px 14px; transition: all .16s var(--ease); white-space: nowrap;
}
.subtab-btn:hover { color: var(--text); background: transparent; }
.subtab-btn.active { background: var(--bg-elev); color: var(--text); border-color: var(--border); box-shadow: var(--shadow-1); }

.dropzone {
  position: relative; padding: 44px 24px 38px; border: 1.5px dashed var(--border-strong); border-radius: 18px;
  background: var(--bg-elev); transition: all .2s var(--ease);
}
.dropzone::before {
  content: ''; display: block; width: 46px; height: 46px; margin: 0 auto 16px; border-radius: 14px;
  background: var(--bg-elev-2); border: 1px solid var(--border); box-shadow: var(--shadow-1);
}
.dropzone::after {
  content: ''; position: absolute; left: 50%; top: 67px; width: 22px; height: 22px; transform: translate(-50%, -50%);
  background-color: var(--navy);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 16V4M7 9l5-5 5 5'/%3E%3Cpath d='M4 16v3a1 1 0 0 0 1 1h14a1 1 0 0 0 1-1v-3'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 16V4M7 9l5-5 5 5'/%3E%3Cpath d='M4 16v3a1 1 0 0 0 1 1h14a1 1 0 0 0 1-1v-3'/%3E%3C/svg%3E") center / contain no-repeat;
  transition: transform .25s var(--ease);
}
.dropzone p { color: var(--text); font-weight: 600; font-size: 0.98rem; }
.dropzone .dropzone-limit { color: var(--text-dim); font-weight: 400; }
.dropzone:hover, .dropzone.dragover {
  border-color: var(--gold); background: linear-gradient(180deg, rgba(224, 168, 46, 0.1), transparent 70%), var(--bg-elev);
  box-shadow: 0 0 0 4px rgba(224, 168, 46, 0.14);
}
.dropzone:hover::after, .dropzone.dragover::after { transform: translate(-50%, -62%); }
.file-info { color: var(--text-dim); font-family: var(--mono); font-size: 0.78rem; letter-spacing: 0.01em; }

.file-item { background: var(--bg-elev); border: 1px solid var(--border); border-radius: 12px; padding: 9px 12px; box-shadow: var(--shadow-1); }
.file-item .fname { color: var(--text); font-weight: 500; }
.file-item button { background: var(--bg-elev-2); border-radius: 8px; color: var(--text-dim); }

.primary-btn {
  background: var(--accent-bg); color: var(--accent-fg); border-radius: 12px; padding: 13px 26px; font-weight: 700; letter-spacing: -0.005em;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.18) inset, 0 8px 18px -8px rgba(22, 38, 79, 0.55);
  transition: transform .16s var(--ease), filter .16s, box-shadow .16s;
}
:root[data-theme='dark'] .primary-btn { box-shadow: 0 1px 0 rgba(255, 255, 255, 0.35) inset, 0 8px 22px -10px rgba(240, 187, 69, 0.55); }
.primary-btn:hover:not(:disabled) { background: var(--accent-bg); filter: brightness(1.1); transform: translateY(-1px); }
.primary-btn:active:not(:disabled) { transform: scale(0.98); }
.primary-btn:disabled { opacity: 0.4; box-shadow: none; }
.secondary-btn { background: var(--bg-elev); color: var(--text); border: 1px solid var(--border-strong); border-radius: 12px; font-weight: 600; box-shadow: var(--shadow-1); }
.secondary-btn:hover { border-color: var(--gold); color: var(--text); transform: translateY(-1px); }
.secondary-btn:active { transform: scale(0.98); }
.danger-btn { border-radius: 12px; }

select, input[type='text'], input[type='number'], input[type='password'], input[type='email'], .imgedit-text-input, .text-io, .ocr-result {
  background-color: var(--bg-elev); color: var(--text); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  transition: border-color .15s, box-shadow .15s;
}
select:focus, input:focus, textarea:focus { border-color: var(--gold); box-shadow: var(--ring); outline: none; }
select { appearance: none; -webkit-appearance: none; padding-right: 32px; background-repeat: no-repeat; background-position: right 11px center;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath d='M1.5 3.5 5 7l3.5-3.5' fill='none' stroke='%237b8196' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
.option label { font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-dim); }
input[type='range'] { accent-color: var(--gold); }
.progress-wrap { height: 6px; background: var(--bg-elev-3); border: none; }
.progress-bar { background: linear-gradient(90deg, var(--gold), #f3cf75); box-shadow: 0 0 12px rgba(224, 168, 46, 0.6); }
.status { font-family: var(--mono); font-size: 0.82rem; }
.pdf-page-card, .resource-card, .devtools-hash-row, .account-card, .account-stat { background: var(--bg-elev); border-color: var(--border); box-shadow: var(--shadow-1); }
.pdf-page-controls button, .imgedit-presets button { background: var(--bg-elev-2); color: var(--text); border-color: var(--border); }
.imgedit-presets button.active, .imgedit-presets button:hover { background: var(--accent-bg); color: var(--accent-fg); border-color: transparent; }
.imgedit-anchor.active, .imgedit-anchor:hover { background: var(--gold); border-color: var(--gold); }
.compare-stage, .diff-view, .admin-table-wrap, .md-preview { border-color: var(--border); }
.toast { background: rgba(14, 20, 40, 0.94); color: #f4f1e8; border: 1px solid rgba(255, 255, 255, 0.08); border-radius: 12px; backdrop-filter: blur(12px); box-shadow: var(--shadow-3); }
.toast.error { background: #b53838; }
.toast .toast-action { margin-left: 12px; color: var(--gold); background: none; border: none; font-weight: 700; cursor: pointer; font-family: inherit; pointer-events: auto; }

/* ---------- 8. footer ---------- */
.footer { border-top: 1px solid var(--border); padding: 32px 24px calc(32px + env(safe-area-inset-bottom)); color: var(--text-dim); background: transparent; }
.footer-links { gap: 6px 22px; }
.footer-links button { text-decoration: none; font-weight: 500; padding: 6px 0; }
.footer-links button:hover { color: var(--text); text-decoration: underline; text-underline-offset: 4px; }

/* ---------- 9. command palette ---------- */
.palette-overlay {
  position: fixed; inset: 0; z-index: 400; display: flex; align-items: flex-start; justify-content: center; padding: 11vh 16px 16px;
  background: rgba(8, 12, 28, 0.55); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); animation: fn-fade .16s ease;
}
.palette-overlay[hidden] { display: none; }
.palette {
  width: 100%; max-width: 660px; max-height: min(620px, 76vh); display: flex; flex-direction: column; overflow: hidden;
  background: var(--bg-elev); border: 1px solid var(--border-strong); border-radius: 20px; box-shadow: var(--shadow-3);
  animation: fn-pop .22s var(--ease);
}
.palette-input-row { display: flex; align-items: center; gap: 12px; padding: 0 18px; border-bottom: 1px solid var(--border); }
.palette-input-row svg { width: 20px; height: 20px; color: var(--text-dim); flex: 0 0 auto; }
.palette-input { flex: 1; min-width: 0; height: 62px; border: none !important; background: transparent !important; box-shadow: none !important; font-size: 1.05rem; color: var(--text); font-family: inherit; padding: 0; }
.palette-input::placeholder { color: var(--text-dim); }
.palette-list { overflow-y: auto; padding: 8px; flex: 1; overscroll-behavior: contain; }
.palette-label { font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-dim); padding: 10px 12px 6px; }
.palette-item {
  display: flex; align-items: center; gap: 14px; width: 100%; padding: 10px 12px; border: none; background: transparent; border-radius: 12px;
  text-align: left; cursor: pointer; color: var(--text); font-family: inherit; text-decoration: none; position: relative;
}
.palette-item .pi-tile { flex: 0 0 auto; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--bg-elev-2); border: 1px solid var(--border); font-family: var(--mono); font-size: 0.7rem; font-weight: 700; color: var(--navy); }
.palette-item .pi-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.palette-item .pi-name { font-weight: 700; font-size: 0.95rem; letter-spacing: -0.01em; }
.palette-item .pi-desc { font-size: 0.8rem; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-item .pi-group { font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-dim); flex: 0 0 auto; }
.palette-item mark { background: rgba(224, 168, 46, 0.3); color: inherit; border-radius: 3px; padding: 0 1px; }
.palette-item.is-active { background: var(--bg-elev-2); }
.palette-item.is-active::before { content: ''; position: absolute; left: 0; top: 12px; bottom: 12px; width: 3px; border-radius: 3px; background: var(--gold); }
.palette-empty { padding: 36px 16px; text-align: center; color: var(--text-dim); font-size: 0.92rem; }
.palette-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; border-top: 1px solid var(--border); font-family: var(--mono); font-size: 0.7rem; color: var(--text-dim); background: var(--bg-elev-2); }
@keyframes fn-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes fn-pop { from { opacity: 0; transform: translateY(10px) scale(0.985); } to { opacity: 1; transform: none; } }

/* ---------- 10. dark-theme fixes for hard-coded surfaces ---------- */
:root[data-theme='dark'] .md-preview,
:root[data-theme='dark'] .qr-preview-wrap,
:root[data-theme='dark'] .sign-pad { background: #ffffff; }
:root[data-theme='dark'] .plan-banner { color: var(--text); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .md-preview, :root:not([data-theme='light']) .qr-preview-wrap, :root:not([data-theme='light']) .sign-pad { background: #ffffff; }
}

/* ---------- 11. tablet + phone ---------- */
@media (max-width: 1000px) {
  .topbar { position: sticky; top: 0; flex-wrap: nowrap; padding: calc(10px + env(safe-area-inset-top)) 16px 10px; gap: 8px; }
  .brand { flex: 1 1 auto; min-width: 0; }
  .brand-name { font-size: 1.12rem; }
  .menu-btn { display: inline-flex; }
  .topbar-actions { margin-left: auto; }
  .topnav { display: none !important; }
  .topbar-right { display: none !important; }
  .hero-lockup { display: none; }

  body.nav-open { overflow: hidden; }
  body.nav-open .topnav {
    display: flex !important; flex-direction: column; flex-wrap: nowrap; position: fixed; z-index: 60; left: 0; right: 0;
    top: var(--topbar-h); bottom: 0; overflow-y: auto; overscroll-behavior: contain; background: var(--bg); gap: 0;
    padding: 8px 18px calc(110px + env(safe-area-inset-bottom)); order: 0; justify-content: flex-start;
  }
  body.nav-open .topnav > .nav-btn { display: flex; text-align: left; justify-content: flex-start; width: 100%; padding: 16px 4px; font-size: 1.02rem; border-radius: 0; background: transparent; color: var(--text); border-bottom: 1px solid var(--border); box-shadow: none; }
  body.nav-open .topnav > .nav-btn.active { color: var(--gold-deep); }
  body.nav-open .nav-group { border-bottom: 1px solid var(--border); }
  body.nav-open .nav-group-btn { width: 100%; justify-content: space-between; padding: 16px 4px; font-size: 1.02rem; font-weight: 700; border-radius: 0; background: transparent !important; color: var(--text) !important; box-shadow: none; }
  body.nav-open .nav-group-btn.active { color: var(--gold-deep) !important; }
  body.nav-open .nav-chevron { width: 12px; height: 12px; }
  body.nav-open .mega { position: static; box-shadow: none; border: none; background: transparent; max-height: none; animation: none; display: block; }
  body.nav-open .mega[hidden] { display: none; }
  body.nav-open .mega-side { display: none; }
  body.nav-open .mega-list { grid-template-columns: 1fr 1fr; gap: 2px; padding: 0 0 14px; }
  body.nav-open .mega-item { padding: 12px 10px; font-size: 0.92rem; border-radius: 10px; }
  body.nav-open .topbar-right {
    display: flex !important; position: fixed; z-index: 61; left: 0; right: 0; bottom: 0; gap: 10px; padding: 12px 18px calc(12px + env(safe-area-inset-bottom));
    background: var(--bg); border-top: 1px solid var(--border);
  }
  body.nav-open .topbar-right .lang-toggle { flex: 1; }
  .content { padding: 28px 18px calc(72px + env(safe-area-inset-bottom)); }
  .dir-grid { grid-template-columns: repeat(2, 1fr); gap: 28px 28px; }
}

@media (max-width: 760px) {
  .hero { padding: 18px 0 10px; gap: 0; align-items: stretch; }
  .hero-text { flex: 0 0 auto; width: 100%; min-width: 0; }
  .hero h1 { font-size: clamp(1.95rem, 8.6vw, 2.5rem); margin-bottom: 14px; }
  .hero-text { text-align: left; }
  .hero-sub { font-size: 0.96rem; line-height: 1.7; }
  .hero-search { margin-top: 22px; }
  .search-trigger { height: 54px; border-radius: 14px; }
  .kbd-group { display: none; }
  .hero-chips { flex-wrap: nowrap; overflow-x: auto; margin: 14px -18px 0; padding: 2px 18px 6px; max-width: none; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .hero-chips::-webkit-scrollbar { display: none; }
  .chips-label { display: none; }
  .trust { gap: 8px 18px; margin-top: 26px; }
  .card-grid { grid-template-columns: 1fr; gap: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--bg-elev); box-shadow: var(--shadow-1); }
  .feature-card {
    display: grid; grid-template-columns: 44px 1fr; grid-template-rows: auto auto; column-gap: 14px; row-gap: 2px; padding: 16px 18px;
    border: none; border-radius: 0; border-bottom: 1px solid var(--border); box-shadow: none; background: transparent; align-items: center;
  }
  .feature-card:last-child { border-bottom: none; }
  .feature-card:hover { transform: none; box-shadow: none; background: var(--bg-elev-2); }
  .feature-card::after { top: 50%; right: 18px; transform: translateY(-50%); }
  .feature-icon-badge { grid-row: 1 / span 2; margin: 0; width: 44px; height: 44px; }
  .feature-title { grid-column: 2; }
  .feature-desc { grid-column: 2; font-size: 0.8rem; padding-right: 26px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .directory { margin-top: 52px; }
  .dir-grid { grid-template-columns: 1fr; gap: 26px; }
  .subtabs { width: 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; border-radius: 14px; scroll-snap-type: x proximity; }
  .subtabs::-webkit-scrollbar { display: none; }
  .subtab-btn { scroll-snap-align: start; flex: 0 0 auto; padding: 9px 14px; min-height: 40px; }
  .dropzone { padding: 38px 16px 32px; }
  .primary-btn, .secondary-btn { min-height: 46px; }
  .options-row { gap: 14px; }
  .option { flex: 1 1 140px; }
  .option select, .option input { width: 100%; min-height: 44px; }
  .palette-overlay { padding: calc(10px + env(safe-area-inset-top)) 10px 10px; align-items: flex-start; }
  .palette { max-height: 88vh; border-radius: 18px; }
  .palette-input { font-size: 16px; }
  .palette-item .pi-group { display: none; }
  .palette-foot { display: none; }
  .toast-wrap { bottom: calc(16px + env(safe-area-inset-bottom)); }
  .tool-section > h2, .tool-h1 { font-size: 1.5rem; }
}

@media (max-width: 380px) { .mega-list { grid-template-columns: 1fr !important; } }

/* standalone (installed) app: respect the notch, no rubber-band flash */
@media (display-mode: standalone), (display-mode: window-controls-overlay) {
  body { overscroll-behavior-y: none; user-select: none; -webkit-user-select: none; }
  input, textarea, .text-io, .ocr-result, [contenteditable] { user-select: text; -webkit-user-select: text; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-delay: 0ms !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}
@media print { .topbar, .footer, .palette-overlay { display: none !important; } }

/* hamburger / close glyph swap */
.menu-btn .ic-close { display: none; }
body.nav-open .menu-btn .ic-open { display: none; }
body.nav-open .menu-btn .ic-close { display: block; }

.palette-item .pi-tile svg { width: 18px; height: 18px; display: block; }
/* the last card of an odd-numbered grid spans the row instead of sitting alone */
@media (min-width: 861px) { .card-grid > .feature-card:last-child:nth-child(3n + 1) { grid-column: 1 / -1; flex-direction: row; align-items: center; gap: 18px; }
  .card-grid > .feature-card:last-child:nth-child(3n + 1) .feature-icon-badge { margin: 0; }
  .card-grid > .feature-card:last-child:nth-child(3n + 1) .feature-title { white-space: nowrap; }
  .card-grid > .feature-card:last-child:nth-child(3n + 1) .feature-desc { flex: 1; } }
@media (min-width: 561px) and (max-width: 860px) { .card-grid > .feature-card:last-child:nth-child(2n + 1) { grid-column: 1 / -1; } }

/* two-row header: keep the actions next to the account controls */
@media (min-width: 1001px) and (max-width: 1399px) { .topbar-actions { margin-left: auto; } }

/* the spaced mono "label" style is for Latin text; CJK reads better in the sans face */
:lang(ko) .chips-label, :lang(ja) .chips-label, :lang(zh) .chips-label,
:lang(ko) .option label, :lang(ja) .option label, :lang(zh) .option label,
:lang(ko) .dir-group h3, :lang(ja) .dir-group h3, :lang(zh) .dir-group h3,
:lang(ko) .palette-label, :lang(ja) .palette-label, :lang(zh) .palette-label,
:lang(ko) .palette-item .pi-group, :lang(ja) .palette-item .pi-group, :lang(zh) .palette-item .pi-group {
  font-family: var(--sans); letter-spacing: 0; text-transform: none; font-size: 0.78rem; font-weight: 600;
}
:lang(ko) .trust li, :lang(ja) .trust li, :lang(zh) .trust li, :lang(ko) .status, :lang(ja) .status, :lang(zh) .status,
:lang(ko) .file-info, :lang(ja) .file-info, :lang(zh) .file-info { font-family: var(--sans); letter-spacing: 0; font-size: 0.84rem; }
.trust { padding-left: 4px; }

/* ---------- tool guide (intro / how-to / FAQ / related), see js/guide.js ---------- */
.tool-guide { margin-top: 72px; padding-top: 40px; border-top: 1px solid var(--border); }
.tool-guide[hidden] { display: none; }
.tg-wrap { max-width: 820px; }
.tg-h { margin: 38px 0 14px; font-family: var(--serif); font-size: clamp(1.15rem, 2vw, 1.4rem); font-weight: 800; letter-spacing: -0.02em; color: var(--text); }
.tg-wrap > .tg-h:first-child { margin-top: 0; }
.tg-intro { margin: 0; color: var(--text-dim); line-height: 1.8; font-size: 1rem; max-width: 70ch; }
.tg-steps { list-style: none; margin: 0; padding: 0; counter-reset: tgs; display: grid; gap: 10px; }
.tg-steps li {
  counter-increment: tgs; position: relative; padding: 14px 16px 14px 58px; background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: 14px; color: var(--text); line-height: 1.6; box-shadow: var(--shadow-1);
}
.tg-steps li::before {
  content: counter(tgs); position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center; font-family: var(--mono); font-size: 0.82rem; font-weight: 700; color: var(--accent-fg); background: var(--accent-bg);
}
.tg-faq { display: grid; gap: 8px; }
.tg-q { background: var(--bg-elev); border: 1px solid var(--border); border-radius: 14px; transition: border-color .16s var(--ease), box-shadow .16s var(--ease); }
.tg-q[open] { border-color: var(--border-strong); box-shadow: var(--shadow-1); }
.tg-q summary {
  list-style: none; cursor: pointer; padding: 15px 48px 15px 18px; position: relative; font-weight: 700; color: var(--text); line-height: 1.5;
}
.tg-q summary::-webkit-details-marker { display: none; }
.tg-q summary::after {
  content: ''; position: absolute; right: 20px; top: 50%; width: 8px; height: 8px; margin-top: -6px; border-right: 2px solid var(--text-dim); border-bottom: 2px solid var(--text-dim);
  transform: rotate(45deg); transition: transform .2s var(--ease);
}
.tg-q[open] summary::after { transform: rotate(-135deg); margin-top: -2px; }
.tg-q summary:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 14px; }
.tg-q p { margin: 0; padding: 0 18px 16px; color: var(--text-dim); line-height: 1.75; }
.tg-rel { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.tg-rel a {
  display: inline-flex; align-items: center; min-height: 36px; padding: 0 15px; border-radius: 999px; font-size: 0.9rem; font-weight: 600; text-decoration: none;
  color: var(--text); background: var(--bg-elev); border: 1px solid var(--border); transition: all .16s var(--ease);
}
.tg-rel a:hover { border-color: var(--gold); color: var(--gold-deep); transform: translateY(-1px); box-shadow: var(--shadow-1); }
@media (max-width: 760px) {
  .tool-guide { margin-top: 48px; padding-top: 28px; }
  .tg-h { margin-top: 30px; }
  .tg-steps li { padding: 13px 14px 13px 54px; }
}

/* free resources: "download all" bar */
.resource-bar { display: flex; align-items: center; gap: 12px; margin: 18px 0 0; flex-wrap: wrap; }
.resource-grid { margin-top: 14px; }
.resource-card .r-name { word-break: break-word; }
