/* Bookmark Organizer: interface styles.
   One accent colour, a quiet neutral palette, generous spacing on an 8px grid. */

:root {
  --bg: #f5f6fb;
  --bg-glow: radial-gradient(900px 420px at 12% -8%, rgba(99, 102, 241, 0.13), transparent 70%),
    radial-gradient(700px 380px at 96% 0%, rgba(168, 85, 247, 0.09), transparent 70%);
  --surface: #ffffff;
  --surface-2: #f2f3f9;
  --surface-hover: #fafaff;
  --text: #131521;
  --text-2: #444a62;
  --muted: #62687f;
  --line: rgba(19, 21, 33, 0.09);
  --line-strong: rgba(19, 21, 33, 0.22);

  --accent: #4f46e5;
  --accent-2: #7c3aed;
  --accent-ink: #3730a3;
  --accent-soft: #eef0ff;
  --accent-line: rgba(79, 70, 229, 0.28);
  /* Filled buttons keep the same deep colours in both themes so white text stays readable. */
  --btn-1: #4f46e5;
  --btn-2: #7c3aed;

  --good: #166534;
  --good-soft: #e8f6ed;
  --warn: #a15c07;
  --warn-soft: #fdf3df;
  --bad: #b42318;
  --bad-soft: #fdecea;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 1px rgba(16, 24, 40, 0.03);
  --shadow-md: 0 1px 2px rgba(16, 24, 40, 0.04), 0 10px 28px rgba(16, 24, 40, 0.07);
  --shadow-lg: 0 2px 4px rgba(16, 24, 40, 0.06), 0 24px 56px rgba(16, 24, 40, 0.18);

  --r-lg: 20px;
  --r-md: 12px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0f17;
    --bg-glow: radial-gradient(900px 420px at 12% -8%, rgba(99, 102, 241, 0.2), transparent 70%),
      radial-gradient(700px 380px at 96% 0%, rgba(168, 85, 247, 0.13), transparent 70%);
    --surface: #161927;
    --surface-2: #1f2335;
    --surface-hover: #1b1f31;
    --text: #eceef8;
    --text-2: #b8bdd3;
    --muted: #9aa0b8;
    --line: rgba(255, 255, 255, 0.09);
    --line-strong: rgba(255, 255, 255, 0.28);

    --accent: #8b8dff;
    --accent-2: #b79cff;
    --accent-ink: #cdd0ff;
    --accent-soft: #23274a;
    --accent-line: rgba(139, 141, 255, 0.35);

    --good: #5fd48a;
    --good-soft: #12301f;
    --warn: #f2b84b;
    --warn-soft: #382b0f;
    --bad: #ff8a80;
    --bad-soft: #3b1816;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 10px 28px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 24px 56px rgba(0, 0, 0, 0.55);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

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

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg);
  background-image: var(--bg-glow);
  background-repeat: no-repeat;
  color: var(--text);
  font: 15px/1.55 ui-sans-serif, system-ui, -apple-system, "SF Pro Text", "Segoe UI Variable", "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.page { max-width: 1040px; margin: 0 auto; padding: 0 24px 140px; }

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 60%, transparent);
  outline-offset: 2px;
  border-radius: 8px;
}

/* ---------- masthead ---------- */
.masthead { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 24px 0 8px; }
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; color: #fff;
  background: linear-gradient(135deg, var(--btn-1), var(--btn-2));
  box-shadow: 0 6px 16px rgba(79, 70, 229, 0.35);
}
.brand-name { font-size: 16px; font-weight: 650; letter-spacing: -0.01em; }
.logo-img { display: block; border-radius: 10px; box-shadow: 0 4px 14px rgba(79, 70, 229, 0.28); }
.masthead-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px;
  font-size: 12.5px; font-weight: 550; border: 1px solid var(--line); background: var(--surface); color: var(--text-2);
}
.pill-private { color: var(--good); background: var(--good-soft); border-color: transparent; }
.pill-warn { color: var(--warn); background: var(--warn-soft); border-color: transparent; }

/* ---------- hero ---------- */
main { display: grid; gap: 20px; }

.hero {
  display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 32px; align-items: center;
  padding: 36px 40px; margin-top: 16px; border-radius: 28px; border: 1px solid var(--line);
  background: linear-gradient(135deg, var(--surface) 0%, color-mix(in srgb, var(--accent-soft) 70%, var(--surface)) 100%);
  box-shadow: var(--shadow-md);
}
.eyebrow { margin: 0 0 10px; font-size: 12.5px; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); }
.hero h2 { margin: 0; font-size: clamp(28px, 4.2vw, 42px); line-height: 1.12; font-weight: 720; letter-spacing: -0.03em; }
.hero h2 em {
  font-style: normal; color: var(--accent);
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.hero p.lead { margin: 14px 0 0; max-width: 46ch; font-size: 16px; color: var(--text-2); }
.hero-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 14px; margin-top: 26px; }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.stat {
  padding: 16px 16px 14px; border-radius: 16px; background: color-mix(in srgb, var(--surface) 82%, transparent);
  border: 1px solid var(--line); box-shadow: var(--shadow-sm);
}
.stat strong { display: block; font-size: 28px; line-height: 1.1; font-weight: 720; letter-spacing: -0.02em; }
.stat span { display: block; margin-top: 4px; font-size: 13px; color: var(--muted); }

.hero-tidy { grid-template-columns: auto minmax(0, 1fr); }
.big-check {
  display: grid; place-items: center; width: 64px; height: 64px; border-radius: 20px; color: #fff;
  background: linear-gradient(135deg, #22c55e, #15803d); box-shadow: 0 10px 24px rgba(34, 197, 94, 0.35);
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 18px;
  border-radius: var(--r-md); border: 1px solid transparent; font: inherit; font-weight: 620; font-size: 14px; cursor: pointer;
  transition: transform 0.15s var(--ease), box-shadow 0.2s var(--ease), background-color 0.2s var(--ease), opacity 0.2s;
}
.btn:active { transform: scale(0.98); }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; box-shadow: none; transform: none; }
.btn-primary {
  color: #fff; background: linear-gradient(135deg, var(--btn-1), var(--btn-2));
  box-shadow: 0 6px 16px rgba(79, 70, 229, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.btn-primary:not([disabled]):hover { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(79, 70, 229, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.18); }
.btn-lg { height: 50px; padding: 0 26px; font-size: 16px; border-radius: 14px; }
.btn-quiet { color: var(--text); background: var(--surface); border-color: var(--line); box-shadow: var(--shadow-sm); }
.btn-quiet:hover { background: var(--surface-2); }
.btn-small { height: 34px; padding: 0 14px; font-size: 13px; }

.textbtn {
  padding: 4px 2px; border: 0; background: none; font: inherit; font-size: 13.5px; font-weight: 600; color: var(--accent); cursor: pointer;
  text-underline-offset: 3px;
}
.textbtn:hover { text-decoration: underline; }

/* ---------- banner ---------- */
.banner {
  display: flex; align-items: center; gap: 14px; padding: 14px 18px; border-radius: 16px;
  background: var(--good-soft); border: 1px solid color-mix(in srgb, var(--good) 30%, transparent);
  animation: rise 0.35s var(--ease);
}
.banner .banner-icon { display: grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: 10px; color: #fff; background: #15803d; }
.banner-text { flex: 1; min-width: 0; font-size: 14.5px; color: var(--text); }
.banner-text strong { font-weight: 650; }

/* ---------- plan cards ---------- */
.card { border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm); overflow: hidden; }

.card-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px 16px; align-items: start; padding: 22px 24px 16px; }
.icon-badge { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 13px; color: var(--accent-ink); background: var(--accent-soft); }
.icon-badge.is-warn { color: var(--warn); background: var(--warn-soft); }
.icon-badge.is-bad { color: var(--bad); background: var(--bad-soft); }
.icon-badge.is-good { color: var(--good); background: var(--good-soft); }
.card-head h3 { margin: 1px 0 0; font-size: 18px; line-height: 1.3; font-weight: 680; letter-spacing: -0.015em; }
.card-head h3 .count { margin-left: 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
.card-head p { margin: 4px 0 0; max-width: 62ch; font-size: 14px; color: var(--muted); }

.tools { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.tool {
  height: 32px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface);
  font: inherit; font-size: 13px; font-weight: 600; color: var(--text-2); cursor: pointer; transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.tool:hover { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-ink); }

/* ---------- rows ---------- */
.rows { margin: 0; padding: 0; list-style: none; }
.row {
  position: relative; display: grid; grid-template-columns: 26px minmax(0, 1fr) minmax(0, 1.15fr); align-items: start;
  column-gap: 20px; row-gap: 10px; padding: 18px 24px; border-top: 1px solid var(--line);
  transition: background-color 0.15s var(--ease);
}
.row:hover { background: var(--surface-hover); }
.row.is-selected { background: color-mix(in srgb, var(--accent-soft) 55%, var(--surface)); }
.row.is-selected::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: linear-gradient(var(--accent), var(--accent-2)); }

.row > .check { margin-top: 6px; }
.check { position: relative; display: grid; place-items: center; width: 26px; height: 26px; cursor: pointer; }
.check input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.check .box {
  display: grid; place-items: center; width: 22px; height: 22px; border-radius: 7px; border: 1.5px solid var(--line-strong); background: var(--surface);
  color: transparent; transition: background-color 0.15s, border-color 0.15s, color 0.15s, transform 0.15s var(--ease);
}
.check:hover .box { border-color: var(--accent); }
.check input:checked + .box { color: #fff; border-color: transparent; background: linear-gradient(135deg, var(--btn-1), var(--btn-2)); transform: scale(1.04); }
.check input:focus-visible + .box { outline: 3px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 2px; }

.site { display: flex; align-items: flex-start; gap: 12px; min-width: 0; }
.site.is-link {
  color: inherit; text-decoration: none; margin: -6px -8px; padding: 6px 8px; border-radius: 14px; transition: background-color 0.15s;
}
.site.is-link:hover { background: color-mix(in srgb, var(--accent-soft) 70%, transparent); }
.site.is-link:hover .title { color: var(--accent-ink); text-decoration: underline; text-underline-offset: 3px; }
.site.is-link:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 1px; }
.avatar {
  --h: 220;
  display: grid; place-items: center; flex: none; width: 38px; height: 38px; border-radius: 12px; font-size: 15px; font-weight: 700;
  background: hsl(var(--h) 80% 93%); color: hsl(var(--h) 55% 30%);
}
@media (prefers-color-scheme: dark) {
  .avatar { background: hsl(var(--h) 32% 24%); color: hsl(var(--h) 85% 84%); }
}
.site-text { min-width: 0; }
.title { overflow-wrap: anywhere; font-weight: 620; font-size: 15px; line-height: 1.35; letter-spacing: -0.005em; }
.url {
  margin-top: 3px; font-size: 12.5px; line-height: 1.4; color: var(--muted); overflow-wrap: anywhere;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden;
}

.route { display: flex; align-items: flex-end; gap: 10px; min-width: 0; }
.route > svg { flex: none; color: var(--muted); margin-bottom: 9px; }
.leg { display: flex; flex: 1 1 0; flex-direction: column; align-items: flex-start; gap: 5px; min-width: 0; }
.leg-label { font-size: 11px; font-weight: 680; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.chip {
  display: inline-flex; flex-wrap: wrap; align-items: center; gap: 2px 7px; min-width: 0; max-width: 100%; padding: 7px 11px; border-radius: 11px;
  font-size: 13.5px; font-weight: 600; border: 1px solid var(--line); background: var(--surface-2); color: var(--text-2);
}
.chip svg { flex: none; }
.chip .name { overflow-wrap: break-word; line-height: 1.3; }
.chip .hint { flex: none; font-size: 12px; font-weight: 450; color: var(--muted); white-space: nowrap; }
.chip.to { color: var(--accent-ink); background: var(--accent-soft); border-color: var(--accent-line); }
.chip.remove { color: var(--bad); background: var(--bad-soft); border-color: transparent; }
.tag-new {
  flex: none; padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: 0.02em;
  color: var(--good); background: var(--good-soft);
}

.sure { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; font-size: 13px; font-weight: 600; color: var(--text-2); }
.meter { display: inline-flex; gap: 3px; }
.meter i { width: 6px; height: 6px; border-radius: 50%; background: var(--line-strong); opacity: 0.55; }
.meter i.on { background: var(--accent); opacity: 1; }

.row .route { grid-column: 3; grid-row: 1 / span 2; align-self: center; }
.meta { grid-column: 2; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 18px; }
.meta .keep { margin-left: auto; }
.evidence { font-size: 13px; color: var(--text-2); }
.meta:has(.keep) .evidence { flex: 1 1 100%; order: 5; }
.note-actions { padding: 4px 24px 20px; }
.why-text {
  grid-column: 2 / -1; margin: 0; padding: 10px 14px; border-radius: 12px; font-size: 13.5px; line-height: 1.45;
  color: var(--text-2); background: var(--surface-2);
}
.why-text[hidden] { display: none; }
.why-btn { padding: 2px 8px; border-radius: 8px; font-size: 13px; color: var(--muted); }
.why-btn:hover { color: var(--accent-ink); background: var(--accent-soft); text-decoration: none; }
.meta .keep, .why .textbtn { padding: 2px 10px; border-radius: 8px; font-size: 13px; color: var(--muted); }
.meta .keep:hover { color: var(--accent-ink); background: var(--accent-soft); text-decoration: none; }
.why { grid-column: 2 / -1; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin: 0; font-size: 13.5px; color: var(--text-2); }
.why > span { flex: 1 1 auto; min-width: 0; }
.why .textbtn { flex: none; margin-left: auto; padding: 2px 10px; border-radius: 8px; font-size: 12.5px; color: var(--muted); }
.why .textbtn:hover { color: var(--accent-ink); background: var(--accent-soft); text-decoration: none; }

.more {
  display: block; width: 100%; padding: 14px; border: 0; border-top: 1px solid var(--line); background: none; font: inherit;
  font-weight: 620; font-size: 14px; color: var(--accent); cursor: pointer;
}
.more:hover { background: var(--accent-soft); }

/* ---------- quiet cards (collapsible) ---------- */
details.card > summary {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 16px; align-items: center; padding: 18px 24px; cursor: pointer; list-style: none;
}
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary:hover { background: var(--surface-hover); }
details.card > summary h3 { margin: 0; font-size: 16px; font-weight: 660; }
details.card > summary p { margin: 2px 0 0; font-size: 13.5px; color: var(--muted); }
.chevron { color: var(--muted); transition: transform 0.2s var(--ease); }
details[open] > summary .chevron { transform: rotate(180deg); }

.row.simple { grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) auto; align-items: center; }
.row.simple .why { grid-column: auto; }
.note { margin: 0; padding: 14px 24px 4px; font-size: 14px; color: var(--text-2); }
.facts { margin: 0; padding: 12px 24px 18px 44px; display: grid; gap: 6px; font-size: 14px; color: var(--text-2); }

/* ---------- empty state ---------- */
.empty { padding: 28px 24px; text-align: center; color: var(--muted); }

/* ---------- action bar ---------- */
.actionbar {
  position: fixed; z-index: 20; left: 50%; bottom: 20px; width: min(760px, calc(100% - 32px)); transform: translateX(-50%);
  border-radius: 22px; border: 1px solid var(--line); box-shadow: var(--shadow-lg);
  background: color-mix(in srgb, var(--surface) 84%, transparent); -webkit-backdrop-filter: blur(18px) saturate(1.5); backdrop-filter: blur(18px) saturate(1.5);
  animation: rise 0.4s var(--ease);
}
.actionbar-inner { display: flex; align-items: center; gap: 16px; padding: 10px 12px 10px 22px; }
.selection { flex: 1; min-width: 0; font-weight: 640; font-size: 14.5px; }
.selection small { display: block; font-weight: 450; font-size: 12.5px; color: var(--muted); }
.actionbar-links { display: inline-flex; gap: 14px; }
.actionbar .btn-primary { height: 46px; padding: 0 26px; border-radius: 14px; font-size: 15px; }

/* ---------- dialog ---------- */
dialog {
  width: min(460px, calc(100% - 32px)); padding: 30px; border: 1px solid var(--line); border-radius: 26px; color: var(--text);
  background: var(--surface); box-shadow: var(--shadow-lg);
}
dialog[open] { animation: pop 0.25s var(--ease); }
dialog::backdrop { background: rgba(10, 12, 24, 0.5); -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px); }
dialog h2 { margin: 0 0 16px; font-size: 24px; line-height: 1.2; font-weight: 720; letter-spacing: -0.02em; }
.confirm-list { display: grid; gap: 10px; margin: 0 0 18px; padding: 0; list-style: none; }
.confirm-list li { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; background: var(--surface-2); font-weight: 600; font-size: 14.5px; }
.confirm-list li svg { flex: none; color: var(--accent); }
.confirm-note { margin: 0 0 24px; font-size: 14px; color: var(--muted); }
.confirm-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; z-index: 40; top: 20px; left: 50%; transform: translateX(-50%); max-width: min(560px, calc(100% - 32px)); padding: 12px 20px;
  border-radius: 14px; font-weight: 600; font-size: 14px; color: var(--bg); background: var(--text); box-shadow: var(--shadow-lg); animation: rise 0.3s var(--ease);
}
.toast.is-error { color: #fff; background: var(--bad); }

@keyframes rise { from { opacity: 0; transform: translate(var(--tx, 0), 10px); } to { opacity: 1; transform: translate(var(--tx, 0), 0); } }
.actionbar, .toast { --tx: -50%; }
@keyframes pop { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }

/* ---------- narrow screens ---------- */
@media (max-width: 820px) {
  .page { padding: 0 16px 150px; }
  .hero { grid-template-columns: 1fr; padding: 28px 24px; gap: 24px; }
  .card-head { grid-template-columns: auto minmax(0, 1fr); }
  .card-head .tools { grid-column: 1 / -1; justify-content: flex-start; }
  .row { grid-template-columns: 26px minmax(0, 1fr); padding: 16px 18px; }
  .row .route, .row .meta, .row .why, .row .why-text { grid-column: 2; grid-row: auto; }
  .route { flex-wrap: wrap; }
  .row.simple { grid-template-columns: minmax(0, 1fr); }
  .actionbar-inner { flex-wrap: wrap; row-gap: 8px; }
  .selection { flex-basis: 100%; }
  .actionbar-links { margin-right: auto; }
  .masthead { flex-wrap: wrap; }
}

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