/* SmartBookmark Selector — styling inspired by landr.de:
   minimal, professional, navy + teal, generous whitespace, system fonts (no
   external requests, so the "nothing leaves your browser" promise is literal). */

:root {
  --navy: #0e1b2c;
  --ink: #16202e;
  --text: #33404e;
  --muted: #67757f;
  --accent: #10b3a3;
  --accent-600: #0e9b8e;
  --accent-700: #0b8478;
  --accent-050: #e6f7f4;
  --bg: #ffffff;
  --bg-soft: #f4f7f8;
  --card: #ffffff;
  --border: #e4e9ee;
  --border-strong: #cfd8df;
  --danger: #c2432f;
  --danger-bg: #fdecea;
  --danger-border: #f3c9c1;
  --shadow-sm: 0 1px 2px rgba(14, 27, 44, 0.05);
  --shadow: 0 1px 2px rgba(14, 27, 44, 0.04), 0 10px 30px rgba(14, 27, 44, 0.07);
  --radius: 16px;
  --radius-md: 12px;
  --radius-sm: 9px;
  --maxw: 1080px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-700); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { color: var(--ink); line-height: 1.2; margin: 0 0 0.5em; font-weight: 800; letter-spacing: -0.01em; }

.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: saturate(150%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  gap: 16px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; color: var(--ink); font-size: 1.05rem; letter-spacing: -0.02em; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 26px; height: 26px; flex: 0 0 auto; }
.header-nav { display: flex; align-items: center; gap: 6px; }
.header-nav a { color: var(--muted); font-weight: 600; padding: 8px 10px; border-radius: 8px; font-size: 0.92rem; }
.header-nav a:hover { color: var(--ink); background: var(--bg-soft); text-decoration: none; }

/* ---------- Language toggle ---------- */
.lang-toggle { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 999px; overflow: hidden; margin-left: 6px; }
.lang-toggle button {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  padding: 6px 12px; font: inherit; font-size: 0.82rem; font-weight: 700;
  color: var(--muted); letter-spacing: 0.02em;
}
.lang-toggle button[aria-pressed="true"] { background: var(--ink); color: #fff; }

/* ---------- Theme toggle (light / system / dark) ---------- */
.theme-toggle { display: inline-flex; align-items: stretch; border: 1px solid var(--border-strong); border-radius: 999px; overflow: hidden; }
.theme-toggle button {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  padding: 6px 10px; color: var(--muted); display: inline-grid; place-items: center;
}
.theme-toggle button:hover { color: var(--ink); background: var(--bg-soft); }
.theme-toggle button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.theme-toggle button svg { display: block; }

/* ---------- Buttons ---------- */
.btn {
  appearance: none; cursor: pointer; font: inherit; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px; border-radius: var(--radius-sm); border: 1px solid transparent;
  background: var(--accent); color: #fff; box-shadow: var(--shadow-sm);
  transition: background 0.15s ease, transform 0.05s ease, box-shadow 0.15s ease;
  text-decoration: none; line-height: 1.1;
}
.btn:hover { background: var(--accent-600); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; box-shadow: none; }
.btn-lg { padding: 15px 26px; font-size: 1.02rem; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--border-strong); box-shadow: none; }
.btn-ghost:hover { background: var(--bg-soft); }
.btn-sm { padding: 7px 12px; font-size: 0.86rem; border-radius: 8px; }
.btn:focus-visible, a:focus-visible, input:focus-visible, button:focus-visible, summary:focus-visible {
  outline: 3px solid var(--accent-050); outline-offset: 2px; box-shadow: 0 0 0 2px var(--accent);
  border-radius: 6px;
}
/* The pill containers clip anything drawn outside the buttons (overflow:hidden),
   so their focus ring must be drawn inset. */
.lang-toggle button:focus-visible, .theme-toggle button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: -2px; box-shadow: none; border-radius: 999px;
}

/* ---------- Hero ---------- */
.hero { padding: 72px 0 40px; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 0.8rem;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent-700);
  background: var(--accent-050); padding: 6px 12px; border-radius: 999px; margin-bottom: 18px;
}
.hero h1 { font-size: clamp(2.1rem, 5vw, 3.25rem); max-width: 18ch; }
.hero p.lead { font-size: clamp(1.05rem, 2.2vw, 1.3rem); color: var(--muted); max-width: 60ch; margin: 0.5em 0 0; }
.privacy-note { display: inline-flex; align-items: center; gap: 8px; margin-top: 22px; color: var(--ink); font-weight: 600; font-size: 0.95rem; }
.privacy-note svg { color: var(--accent); flex: 0 0 auto; }

/* ---------- Tool card ---------- */
.tool { padding: 8px 0 40px; }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 28px;
}
.card + .card { margin-top: 24px; }

.step-label { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; color: var(--muted); font-size: 0.82rem; letter-spacing: 0.05em; text-transform: uppercase; margin-bottom: 14px; }
.step-num { width: 22px; height: 22px; border-radius: 999px; background: var(--ink); color: #fff; display: inline-grid; place-items: center; font-size: 0.72rem; }

/* Dropzone */
.dropzone {
  border: 2px dashed var(--border-strong); border-radius: var(--radius-md);
  padding: 40px 24px; text-align: center; background: var(--bg-soft);
  transition: border-color 0.15s ease, background 0.15s ease;
}
.dropzone.dragover { border-color: var(--accent); background: var(--accent-050); }
.dropzone .dz-icon { color: var(--muted); margin-bottom: 12px; }
.dropzone .dz-title { font-weight: 700; color: var(--ink); font-size: 1.05rem; }
.dropzone .dz-sub { color: var(--muted); margin: 6px 0 18px; }
.dropzone .dz-hint { color: var(--muted); font-size: 0.85rem; margin-top: 16px; }
.dropzone code { font-family: var(--mono); background: #fff; border: 1px solid var(--border); padding: 2px 6px; border-radius: 6px; font-size: 0.82em; }

.error-banner {
  display: none; margin-top: 16px; padding: 12px 16px; border-radius: var(--radius-sm);
  background: var(--danger-bg); color: var(--danger); font-weight: 600; border: 1px solid var(--danger-border);
}
.error-banner.show { display: block; }

/* Loaded summary bar */
.filebar { display: none; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.filebar.show { display: flex; }
.filebar .file-meta { display: flex; align-items: center; gap: 12px; min-width: 0; }
.filebar .file-name { font-weight: 700; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40vw; }
.filebar .file-stats { color: var(--muted); font-size: 0.9rem; }
.file-icon { color: var(--accent); flex: 0 0 auto; }

/* Toolbar */
.toolbar { display: none; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--border); }
.toolbar.show { display: flex; }
.search {
  position: relative; flex: 1 1 240px; min-width: 180px;
}
.search input {
  width: 100%; font: inherit; padding: 10px 14px 10px 38px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); background: #fff; color: var(--text);
}
.search input::placeholder { color: var(--muted); }
.search .search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.toolbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Tree */
.tree-wrap { display: none; margin-top: 16px; }
.tree-wrap.show { display: block; }
.tree {
  max-height: min(58vh, 620px); overflow: auto; border: 1px solid var(--border);
  border-radius: var(--radius-md); background: #fff; padding: 6px;
}
.tree.search-active .subtree { display: block; }
.subtree { display: none; padding-left: 22px; }
.node.is-open > .subtree { display: block; }

.node.search-hidden { display: none; }
.node-row {
  display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 8px;
  min-height: 34px;
}
.node-row:hover { background: var(--bg-soft); }
.twisty {
  appearance: none; border: 0; background: transparent; cursor: pointer; color: var(--muted);
  width: 20px; height: 20px; display: inline-grid; place-items: center; flex: 0 0 auto; padding: 0;
  border-radius: 5px; transition: transform 0.12s ease;
}
.twisty:hover { background: var(--border); color: var(--ink); }
.twisty.leaf { visibility: hidden; }
.twisty svg { transition: transform 0.12s ease; }
.node.is-open > .node-row > .twisty svg { transform: rotate(90deg); }

.node-check { width: 17px; height: 17px; flex: 0 0 auto; accent-color: var(--accent); cursor: pointer; margin: 0; }
.node-icon { color: var(--muted); flex: 0 0 auto; display: inline-grid; place-items: center; }
.node.type-folder > .node-row > .node-icon { color: var(--accent-700); }
.node-label { min-width: 0; display: flex; align-items: baseline; gap: 8px; flex: 1 1 auto; }
.node-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.node.type-bookmark .node-title { font-weight: 400; color: var(--text); }
.node.type-folder .node-title { font-weight: 600; }
a.node-title:hover { color: var(--accent-700); }
.node-host { color: var(--muted); font-size: 0.8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 0 1 auto; }
.node-count { color: var(--muted); font-size: 0.78rem; background: var(--bg-soft); border: 1px solid var(--border); padding: 1px 7px; border-radius: 999px; flex: 0 0 auto; }
.node-row.checked-row { background: var(--accent-050); }
.node-row.checked-row:hover { background: #d7f1ed; }

.tree-empty { display: none; text-align: center; color: var(--muted); padding: 32px; }
.tree-empty.show { display: block; }

/* Actions */
.actions { display: none; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 22px; }
.actions.show { display: flex; }
.selection-count { color: var(--muted); font-weight: 600; }
.selection-count strong { color: var(--ink); }
.spacer { flex: 1 1 auto; }

/* ---------- Info section ---------- */
.info { background: var(--bg-soft); border-top: 1px solid var(--border); padding: 56px 0; margin-top: 24px; }
.info h2 { font-size: clamp(1.5rem, 3vw, 2rem); text-align: center; margin-bottom: 36px; }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.step-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius-md); padding: 24px; }
.step-card .n { width: 34px; height: 34px; border-radius: 999px; background: var(--accent-050); color: var(--accent-700); display: inline-grid; place-items: center; font-weight: 800; margin-bottom: 14px; }
.step-card h3 { font-size: 1.1rem; }
.step-card p { color: var(--muted); margin: 6px 0 0; font-size: 0.95rem; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); padding: 40px 0; color: var(--muted); font-size: 0.9rem; }
.site-footer .container { display: flex; flex-wrap: wrap; gap: 16px 32px; align-items: center; justify-content: space-between; }
.footer-links { display: flex; gap: 18px; flex-wrap: wrap; }
.footer-links a { color: var(--muted); font-weight: 600; }
.footer-links a:hover { color: var(--ink); }
.credit { max-width: 62ch; }
.credit strong { color: var(--text); font-weight: 700; }

/* ---------- Legal pages ---------- */
.legal { padding: 56px 0 72px; }
.legal .container { max-width: 800px; }
.legal h1 { font-size: clamp(1.8rem, 4vw, 2.4rem); margin-bottom: 8px; }
.legal h2 { font-size: 1.25rem; margin-top: 2em; }
.legal h3 { font-size: 1.05rem; margin-top: 1.4em; }
.legal p, .legal li { color: var(--text); }
.legal .muted { color: var(--muted); }
.legal address { font-style: normal; }
[data-lang] { display: none; }
[data-lang].lang-on { display: block; }

/* ---------- Utilities ---------- */
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 50; }
.skip-link:focus { left: 8px; }

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .hero { padding: 48px 0 24px; }
  .card { padding: 20px; }
  .steps { grid-template-columns: 1fr; }
  .filebar .file-name { max-width: 62vw; }
  .header-nav a.nav-text { display: none; }
  .actions .btn { flex: 1 1 auto; }
}

@media (max-width: 480px) {
  .container { padding: 0 16px; }
  .brand { font-size: 0.98rem; gap: 8px; }
  .brand-tail { display: none; }
  .header-nav { gap: 4px; }
  .lang-toggle { margin-left: 2px; }
  .lang-toggle button { padding: 5px 9px; }
  .theme-toggle button { padding: 5px 8px; }
}

/* ---------- Dark theme ----------
   The palette applies via two entry points — KEEP THE TWO BLOCKS IN SYNC:
   1. html[data-theme="dark"]  — explicit user choice, set by theme.js
   2. the prefers-color-scheme media query — OS preference, unless the user
      explicitly chose light. No attribute = "system" (the default). */
html[data-theme="light"] { color-scheme: light; }
html[data-theme="dark"] { color-scheme: dark; }

html[data-theme="dark"] {
  --navy: #e7edf3; --ink: #f1f5f8; --text: #c3ccd4; --muted: #8b98a4;
  --accent: #2fccbb; --accent-600: #45d6c6; --accent-700: #6fe0d3; --accent-050: #10312f;
  --bg: #0c141d; --bg-soft: #111c26; --card: #131f2b; --border: #223141; --border-strong: #33465a;
  --danger: #ff9d8e; --danger-bg: #2c1714; --danger-border: #5c2b22;
  --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 10px 30px rgba(0,0,0,0.35);
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
}
html[data-theme="dark"] .site-header { background: rgba(12, 20, 29, 0.85); }
html[data-theme="dark"] .btn { color: #05201d; }
html[data-theme="dark"] .btn-ghost { color: var(--ink); }
html[data-theme="dark"] .step-num,
html[data-theme="dark"] .skip-link { background: var(--accent); color: #05201d; }
html[data-theme="dark"] .lang-toggle button[aria-pressed="true"],
html[data-theme="dark"] .theme-toggle button[aria-pressed="true"] { background: var(--accent); color: #05201d; }
html[data-theme="dark"] .dropzone code,
html[data-theme="dark"] .search input,
html[data-theme="dark"] .tree,
html[data-theme="dark"] .step-card,
html[data-theme="dark"] .card { background: var(--card); }
html[data-theme="dark"] .node-count { background: var(--bg-soft); }
html[data-theme="dark"] .node-row.checked-row:hover { background: #163b38; }

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    --navy: #e7edf3; --ink: #f1f5f8; --text: #c3ccd4; --muted: #8b98a4;
    --accent: #2fccbb; --accent-600: #45d6c6; --accent-700: #6fe0d3; --accent-050: #10312f;
    --bg: #0c141d; --bg-soft: #111c26; --card: #131f2b; --border: #223141; --border-strong: #33465a;
    --danger: #ff9d8e; --danger-bg: #2c1714; --danger-border: #5c2b22;
    --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 10px 30px rgba(0,0,0,0.35);
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  }
  html:not([data-theme="light"]) .site-header { background: rgba(12, 20, 29, 0.85); }
  html:not([data-theme="light"]) .btn { color: #05201d; }
  html:not([data-theme="light"]) .btn-ghost { color: var(--ink); }
  html:not([data-theme="light"]) .step-num,
  html:not([data-theme="light"]) .skip-link { background: var(--accent); color: #05201d; }
  html:not([data-theme="light"]) .lang-toggle button[aria-pressed="true"],
  html:not([data-theme="light"]) .theme-toggle button[aria-pressed="true"] { background: var(--accent); color: #05201d; }
  html:not([data-theme="light"]) .dropzone code,
  html:not([data-theme="light"]) .search input,
  html:not([data-theme="light"]) .tree,
  html:not([data-theme="light"]) .step-card,
  html:not([data-theme="light"]) .card { background: var(--card); }
  html:not([data-theme="light"]) .node-count { background: var(--bg-soft); }
  html:not([data-theme="light"]) .node-row.checked-row:hover { background: #163b38; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
