:root {
  color-scheme: light;
  --bg: #f4f5f0;
  --surface: rgba(255, 255, 252, 0.82);
  --surface-solid: #fffffc;
  --ink: #17231e;
  --muted: #68736c;
  --line: rgba(23, 35, 30, 0.11);
  --primary: #1d5b43;
  --primary-hover: #164a36;
  --accent: #dbe8dc;
  --shadow: 0 18px 50px rgba(28, 48, 39, 0.08);
  --radius: 22px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101714;
  --surface: rgba(24, 34, 29, 0.86);
  --surface-solid: #18221d;
  --ink: #edf2ed;
  --muted: #a0ada5;
  --line: rgba(232, 241, 235, 0.12);
  --primary: #75b895;
  --primary-hover: #8bc8a8;
  --accent: #253c30;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 3px solid rgba(64, 132, 98, 0.35); outline-offset: 2px; }
.hidden { display: none !important; }
.ambient { position: fixed; border-radius: 50%; filter: blur(1px); pointer-events: none; z-index: -1; opacity: .7; }
.ambient-one { width: 420px; height: 420px; background: radial-gradient(circle, rgba(181, 211, 187, .48), transparent 68%); top: -160px; right: -90px; }
.ambient-two { width: 380px; height: 380px; background: radial-gradient(circle, rgba(224, 199, 151, .26), transparent 70%); bottom: -160px; left: -110px; }

.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 28px 18px; }
.auth-card { width: min(100%, 470px); background: var(--surface); border: 1px solid var(--line); border-radius: 30px; padding: 46px; box-shadow: var(--shadow); backdrop-filter: blur(20px); }
.brand-mark { display: grid; place-items: center; width: 54px; height: 54px; border-radius: 17px; margin-bottom: 30px; color: #fff; background: var(--primary); font: 600 24px Georgia, serif; box-shadow: 0 9px 24px rgba(29, 91, 67, .2); }
.brand-mark.small { width: 36px; height: 36px; margin: 0; border-radius: 11px; font-size: 17px; }
.eyebrow { margin: 0 0 8px; color: var(--primary); font-size: 12px; font-weight: 750; letter-spacing: .14em; text-transform: uppercase; }
h1, h2, h3, p { overflow-wrap: anywhere; }
h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; font-weight: 500; letter-spacing: -.025em; }
h1 { margin: 0; font-size: clamp(36px, 5vw, 62px); line-height: 1.02; }
.auth-card h1 { font-size: 39px; }
.auth-lead, .hero-copy { color: var(--muted); line-height: 1.65; }
.auth-lead { margin: 16px 0 30px; }
.stack-form, .field-group { display: grid; gap: 8px; }
.stack-form { gap: 16px; }
label { color: var(--ink); font-size: 13px; font-weight: 680; }
label span { color: var(--muted); font-weight: 500; }
input, select { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 13px 14px; color: var(--ink); background: color-mix(in srgb, var(--surface-solid) 90%, transparent); transition: border .2s, box-shadow .2s; }
input:hover, select:hover { border-color: color-mix(in srgb, var(--primary) 35%, var(--line)); }
input::placeholder { color: color-mix(in srgb, var(--muted) 72%, transparent); }
.password-field { position: relative; }
.password-field input { padding-right: 72px; }
.icon-button { border: 0; background: transparent; color: var(--muted); }
.reveal-button { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); padding: 6px; font-size: 12px; font-weight: 700; }
.primary-button, .secondary-button, .danger-button { border-radius: 12px; padding: 11px 17px; font-weight: 720; border: 1px solid transparent; transition: transform .15s, background .2s, border .2s; }
.primary-button { color: #fff; background: var(--primary); box-shadow: 0 8px 18px rgba(29, 91, 67, .13); }
:root[data-theme="dark"] .primary-button { color: #0c2419; }
.primary-button:hover { background: var(--primary-hover); transform: translateY(-1px); }
.secondary-button { color: var(--ink); background: transparent; border-color: var(--line); }
.secondary-button:hover { background: var(--accent); border-color: transparent; }
.danger-button { color: #9d332f; background: #f9e8e5; }
.wide { width: 100%; padding: 13px 18px; }
.compact { padding: 9px 14px; }
.form-error { min-height: 18px; margin: -5px 0 0; color: #b33a35; font-size: 13px; }
.auth-actions { display: flex; justify-content: center; gap: 16px; margin-top: 18px; }
.text-button { padding: 4px; border: 0; color: var(--primary); background: transparent; font-size: 13px; font-weight: 700; }
.danger-text { color: #b33a35; }
.security-note { display: flex; gap: 9px; align-items: flex-start; margin: 26px 0 0; padding-top: 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; line-height: 1.5; }
.enrollment-title { margin: 0; font-size: 27px; }
.compact-copy { margin: 9px 0 18px; font-size: 14px; }
.qr-shell { display: grid; place-items: center; width: min(100%, 245px); margin: 0 auto 14px; padding: 12px; border: 1px solid var(--line); border-radius: 18px; background: #fff; }
.qr-shell img { display: block; width: 100%; height: auto; }
.manual-secret { margin: 0 0 17px; color: var(--muted); font-size: 12px; }
.manual-secret summary { cursor: pointer; }
.manual-secret code { display: block; overflow-wrap: anywhere; margin-top: 8px; padding: 9px; border-radius: 9px; color: var(--ink); background: var(--accent); font-size: 11px; letter-spacing: .08em; }
.otp-confirm-form { gap: 10px; }
.otp-input { font-variant-numeric: tabular-nums; letter-spacing: .16em; }
.account-name { max-width: 150px; overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.dialog-copy { margin: -11px 0 20px; color: var(--muted); font-size: 13px; line-height: 1.55; }
.recovery-codes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.recovery-codes code { padding: 10px; border-radius: 9px; color: var(--ink); background: var(--accent); text-align: center; font-size: 12px; letter-spacing: .07em; }

.app-shell { width: min(1180px, calc(100% - 48px)); margin: 0 auto; }
.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 84px; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; font-family: Georgia, serif; font-size: 21px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.circle-button { display: grid; place-items: center; width: 39px; height: 39px; padding: 0; border: 1px solid var(--line); border-radius: 50%; color: var(--ink); background: transparent; font-size: 18px; }
.circle-button:hover { background: var(--accent); border-color: transparent; }
.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 32px; padding: clamp(66px, 10vw, 120px) 0 58px; }
.hero-copy { margin: 18px 0 0; font-size: 17px; }
.add-button { flex: 0 0 auto; padding: 13px 19px; }
.add-button span { font-size: 20px; line-height: 0; vertical-align: -1px; }
.tools { display: grid; grid-template-columns: minmax(280px, 1fr) 1.7fr; align-items: center; gap: 26px; padding: 17px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.search-box { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 0 13px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); }
.search-box > span { color: var(--muted); font-size: 24px; transform: rotate(-18deg); }
.search-box input { min-width: 0; padding: 11px 0; border: 0; background: transparent; outline: none; }
kbd { padding: 2px 7px; border: 1px solid var(--line); border-radius: 5px; color: var(--muted); background: var(--bg); font: 11px ui-monospace, monospace; }
.category-filters { display: flex; gap: 7px; overflow-x: auto; scrollbar-width: none; }
.category-filters::-webkit-scrollbar { display: none; }
.filter-button { flex: 0 0 auto; padding: 9px 13px; border: 0; border-radius: 999px; color: var(--muted); background: transparent; font-size: 13px; font-weight: 680; }
.filter-button:hover, .filter-button.active { color: var(--ink); background: var(--accent); }
.content-section { padding: 58px 0 86px; min-height: 450px; }
.section-heading { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 24px; }
.section-heading h2 { margin: 0; font-size: 31px; }
.count-pill { min-width: 34px; padding: 6px 10px; border-radius: 999px; color: var(--muted); background: var(--accent); text-align: center; font-size: 12px; font-weight: 750; }
.links-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 15px; }
.link-card { position: relative; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 15px; min-width: 0; padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 1px 0 rgba(255,255,255,.4); transition: transform .2s, box-shadow .2s, border-color .2s; }
.link-card:hover { transform: translateY(-3px); border-color: transparent; box-shadow: var(--shadow); }
.link-card-main { min-width: 0; color: inherit; text-decoration: none; }
.link-card-main::after { position: absolute; inset: 0; content: ""; border-radius: inherit; }
.link-icon { display: grid; place-items: center; width: 45px; height: 45px; border-radius: 14px; font: 600 18px Georgia, serif; text-transform: uppercase; }
.link-icon.sage { color: #28583e; background: #dcebdc; }
.link-icon.ocean { color: #24536c; background: #dbeaf0; }
.link-icon.amber { color: #72501e; background: #f3e7cb; }
.link-icon.plum { color: #674466; background: #eadfea; }
.link-icon.clay { color: #7b4338; background: #f1ddd7; }
:root[data-theme="dark"] .link-icon { filter: brightness(.78) saturate(.75); }
.link-title { display: block; overflow: hidden; color: var(--ink); font-weight: 740; text-overflow: ellipsis; white-space: nowrap; }
.link-description { display: block; overflow: hidden; margin-top: 5px; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.card-menu { position: relative; z-index: 2; border: 0; padding: 8px; color: var(--muted); background: transparent; font-weight: 800; }
.category-label { grid-column: 2 / -1; margin-top: -7px; color: var(--primary); font-size: 10px; font-weight: 770; letter-spacing: .08em; text-transform: uppercase; }
.empty-state { display: grid; justify-items: center; padding: 72px 20px; border: 1px dashed var(--line); border-radius: var(--radius); text-align: center; }
.empty-symbol { display: grid; place-items: center; width: 55px; height: 55px; margin-bottom: 14px; border-radius: 18px; color: var(--primary); background: var(--accent); font-size: 25px; }
.empty-state h3 { margin: 0; font-size: 25px; }
.empty-state p { margin: 9px 0 22px; color: var(--muted); }
footer { display: flex; justify-content: space-between; gap: 20px; padding: 28px 0 38px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }

.modal { width: min(calc(100% - 28px), 590px); max-height: calc(100vh - 32px); padding: 30px; border: 1px solid var(--line); border-radius: 25px; color: var(--ink); background: var(--surface-solid); box-shadow: 0 30px 90px rgba(10, 25, 18, .25); }
.modal::backdrop { background: rgba(8, 20, 14, .5); backdrop-filter: blur(4px); }
.small-modal { width: min(calc(100% - 28px), 460px); }
.modal-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 27px; }
.modal-heading h2 { margin: 0; font-size: 30px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 17px; }
.full { grid-column: 1 / -1; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 24px; }
.split-actions { justify-content: space-between; }
.split-actions > div { display: flex; gap: 9px; }
.settings-list { display: grid; }
.setting-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 18px; padding: 18px 0; border-bottom: 1px solid var(--line); }
.setting-row:first-child { padding-top: 0; }
.setting-row strong, .setting-row span { display: block; }
.setting-row span { margin-top: 5px; color: var(--muted); font-size: 12px; line-height: 1.4; }
.settings-message { min-height: 18px; margin: 17px 0 0; color: var(--primary); font-size: 13px; }
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 20; transform: translate(-50%, 20px); padding: 12px 17px; border-radius: 12px; color: #fff; background: #17231e; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; font-size: 13px; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 850px) {
  .links-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tools { grid-template-columns: 1fr; gap: 13px; }
}

@media (max-width: 590px) {
  .app-shell { width: min(100% - 28px, 1180px); }
  .auth-card { padding: 30px 23px; border-radius: 24px; }
  .auth-card h1 { font-size: 34px; }
  .hero { display: grid; padding: 58px 0 36px; }
  .hero h1 { font-size: 43px; }
  .add-button { width: 100%; }
  .links-grid { grid-template-columns: 1fr; }
  .content-section { padding-top: 44px; }
  .topbar { min-height: 72px; }
  .topbar-actions .circle-button:first-child { display: none; }
  .account-name { display: none; }
  .modal { padding: 24px 18px; border-radius: 21px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
  .setting-row { grid-template-columns: 1fr; }
  .setting-row button { justify-self: start; }
  .split-actions { align-items: flex-end; }
  footer { flex-direction: column; gap: 6px; }
  .recovery-codes { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
