:root {
  --ink: #181a20;
  --muted: #686c78;
  --soft: #8d919c;
  --canvas: #f5f6f8;
  --panel: #ffffff;
  --line: #e5e7eb;
  --line-strong: #d8dbe1;
  --sidebar: #17191e;
  --sidebar-soft: #9499a6;
  --accent: #6d5dfc;
  --accent-dark: #5848eb;
  --accent-soft: #eeecff;
  --success: #217a55;
  --shadow-sm: 0 1px 2px rgba(22, 25, 31, .04), 0 5px 18px rgba(22, 25, 31, .035);
  --shadow-lg: 0 24px 70px rgba(18, 21, 28, .16);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--canvas); }
body { margin: 0; min-height: 100vh; }
a { color: inherit; }
button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
.icon { width: 20px; height: 20px; flex: 0 0 auto; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* Application shell */
.app-shell, .workspace { min-width: 0; min-height: 100vh; }
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 12px; color: #fff; background: linear-gradient(145deg, #897cff, #5c4ce9); box-shadow: 0 7px 20px rgba(109, 93, 252, .28); font-size: 19px; font-weight: 760; letter-spacing: -.04em; }
.brand-copy { display: flex; min-width: 0; flex-direction: column; }
.brand-copy strong { font-size: 15px; letter-spacing: .01em; }
.brand-copy small { margin-top: 2px; color: var(--sidebar-soft); font-size: 11px; }
.topbar { position: sticky; top: 0; z-index: 10; height: 72px; display: flex; align-items: center; gap: clamp(13px, 1.7vw, 24px); padding: 0 clamp(18px, 3vw, 44px); border-bottom: 1px solid var(--line); background: rgba(255, 255, 255, .9); backdrop-filter: blur(16px); }
.top-brand { flex: 0 0 auto; }
.top-brand .brand-copy small { color: var(--soft); }
.top-nav { min-width: 0; display: flex; align-items: center; gap: 2px; }
.nav-item { min-height: 38px; display: flex; align-items: center; padding: 0 10px; border-radius: 9px; color: #626671; text-decoration: none; font-size: 12px; font-weight: 620; transition: color .14s ease, background .14s ease; }
.nav-item:hover { color: var(--ink); background: #f1f2f5; }
.nav-item.is-active { color: var(--accent); background: var(--accent-soft); }
.global-search { position: relative; min-width: 170px; max-width: 310px; flex: 1 1 260px; margin-left: auto; }
.global-search > .icon { position: absolute; top: 50%; left: 14px; width: 17px; height: 17px; color: #8b8f99; transform: translateY(-50%); pointer-events: none; }
.global-search input { width: 100%; height: 40px; padding: 0 14px 0 41px; border: 1px solid transparent; border-radius: 10px; outline: none; color: var(--ink); background: #f3f4f6; transition: border .15s, background .15s, box-shadow .15s; }
.global-search input::placeholder { color: #9296a0; }
.global-search input:focus { border-color: #c9c3ff; background: #fff; box-shadow: 0 0 0 4px rgba(109, 93, 252, .09); }
.topbar-account { display: flex; align-items: center; gap: 9px; }
.account-avatar { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid var(--line-strong); border-radius: 50%; color: #555a65; background: #f4f5f7; font-size: 12px; font-weight: 750; }
.sign-out { width: 34px; height: 34px; display: grid; place-items: center; border: 0; border-radius: 9px; color: #777c87; background: transparent; cursor: pointer; }
.sign-out:hover { color: var(--ink); background: #f1f2f5; }
.sign-out .icon { width: 17px; height: 17px; }
.private-badge { display: flex; align-items: center; gap: 7px; color: #656a74; font-size: 11px; font-weight: 650; }
.private-badge > span { width: 7px; height: 7px; border-radius: 50%; background: #38a878; box-shadow: 0 0 0 4px rgba(56, 168, 120, .11); }
.mobile-nav { display: none; }
.content { width: min(1180px, calc(100% - 64px)); margin: 0 auto; padding: 54px 0 88px; }

/* Typography and shared controls */
.eyebrow { margin: 0 0 8px; color: var(--accent); font-size: 10px; font-weight: 780; letter-spacing: .15em; text-transform: uppercase; }
h1, h2, p { text-wrap: pretty; }
.dashboard-intro h1, .page-header h1, .detail-card h1 { margin: 0; letter-spacing: -.045em; }
.dashboard-intro h1 { font-size: clamp(34px, 4.4vw, 50px); line-height: 1.08; font-weight: 680; }
.page-header h1 { font-size: clamp(31px, 4vw, 44px); line-height: 1.08; font-weight: 680; }
.lede { margin: 10px 0 0; color: var(--muted); font-size: 15px; line-height: 1.6; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 17px; }
.section-heading h2 { margin: 0; font-size: 21px; line-height: 1.3; letter-spacing: -.025em; }
.text-link { display: inline-flex; align-items: center; gap: 7px; padding: 6px 0; color: var(--accent); text-decoration: none; font-size: 13px; font-weight: 650; }
.text-link .icon { width: 15px; transition: transform .14s ease; }
.text-link:hover .icon { transform: translateX(3px); }
.primary-button, .secondary-button, .icon-button { border: 0; cursor: pointer; }
.primary-button { min-height: 43px; display: inline-flex; align-items: center; justify-content: center; gap: 9px; padding: 0 18px; border-radius: 11px; color: #fff; background: var(--accent); box-shadow: 0 7px 18px rgba(109, 93, 252, .2); font-size: 13px; font-weight: 700; transition: transform .12s ease, background .12s ease, box-shadow .12s ease; }
.primary-button:hover { background: var(--accent-dark); box-shadow: 0 10px 25px rgba(109, 93, 252, .25); transform: translateY(-1px); }
.primary-button:active { transform: translateY(0); }
.primary-button .icon { width: 17px; height: 17px; }
.secondary-button { min-height: 43px; padding: 0 17px; border: 1px solid var(--line-strong); border-radius: 11px; color: #555a65; background: #fff; font-size: 13px; font-weight: 650; }
.secondary-button:hover { background: #f7f7f8; }
.icon-button { width: 36px; height: 36px; border-radius: 9px; color: #777b85; background: #f3f4f6; font-size: 25px; line-height: 1; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible { outline: 3px solid rgba(109, 93, 252, .35); outline-offset: 2px; }

/* Dashboard */
.dashboard-intro { display: flex; align-items: flex-end; justify-content: space-between; gap: 32px; }
.system-status { display: flex; align-items: center; gap: 12px; min-width: 172px; padding: 13px 15px; border: 1px solid var(--line); border-radius: 13px; background: rgba(255, 255, 255, .7); }
.system-status > span { width: 9px; height: 9px; flex: 0 0 auto; border-radius: 50%; background: #38a878; box-shadow: 0 0 0 5px rgba(56, 168, 120, .11); }
.system-status div { display: flex; flex-direction: column; }
.system-status strong { font-size: 11px; }
.system-status small { margin-top: 2px; color: var(--soft); font-size: 10px; }
.item-icon, .page-icon, .empty-icon { display: grid; place-items: center; color: #6556e9; background: var(--accent-soft); }
.item-icon-read, .page-icon-read { color: #28765f; background: #e6f4ee; }
.item-icon-media, .page-icon-media { color: #ae5a2c; background: #fff0e5; }
.item-icon-mist, .page-icon-mist { color: #26758b; background: #e5f4f7; }
.item-icon-dict, .page-icon-dict { color: #95558d; background: #f8eaf5; }
.item-icon-sum, .page-icon-sum { color: #31759d; background: #e8f3fa; }
.item-icon-summary, .page-icon-summary { color: #a36a20; background: #faf0de; }
.recent-section { margin-top: 49px; }

/* Library rows */
.library-panel { margin-top: 47px; }
.library-card { overflow: hidden; border: 1px solid var(--line); border-radius: 15px; background: var(--panel); box-shadow: var(--shadow-sm); }
.item-list { display: flex; flex-direction: column; }
.item-row { min-height: 76px; display: grid; grid-template-columns: 40px minmax(0, 1fr) auto auto; align-items: center; gap: 14px; padding: 12px 17px; color: inherit; text-decoration: none; transition: background .12s ease; }
.item-row + .item-row { border-top: 1px solid #eff0f2; }
.item-row:hover { background: #fafaff; }
.item-icon { width: 40px; height: 40px; border-radius: 11px; }
.item-icon .icon { width: 18px; height: 18px; }
.item-copy { min-width: 0; display: flex; flex-direction: column; }
.item-copy strong { overflow: hidden; font-size: 13px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.item-copy small { margin-top: 5px; overflow: hidden; color: var(--soft); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.item-status { display: inline-flex; align-items: center; min-height: 24px; padding: 0 9px; border-radius: 99px; color: #656a74; background: #f0f1f3; font-size: 9px; font-weight: 760; letter-spacing: .05em; text-transform: uppercase; }
.status-ready, .status-complete, .status-done { color: #267553; background: #e7f5ed; }
.status-queued, .status-processing { color: #92631f; background: #fff3d9; }
.row-arrow { display: grid; place-items: center; color: #b0b3ba; }
.row-arrow .icon { width: 17px; }
.item-row:hover .row-arrow { color: var(--accent); }
.empty { min-height: 190px; display: flex; align-items: center; justify-content: center; flex-direction: column; padding: 30px; color: var(--muted); text-align: center; }
.empty-icon { width: 45px; height: 45px; margin-bottom: 13px; border-radius: 13px; }
.empty-icon .icon { width: 20px; }
.empty strong { color: var(--ink); font-size: 14px; }
.empty p { max-width: 380px; margin: 6px 0 0; font-size: 12px; line-height: 1.55; }

/* Page headers and forms */
.page-header { min-height: 110px; display: flex; align-items: center; justify-content: space-between; gap: 32px; }
.page-title { display: flex; align-items: center; gap: 20px; }
.page-icon { width: 58px; height: 58px; flex: 0 0 auto; border-radius: 17px; }
.page-icon .icon { width: 25px; height: 25px; }
.page-icon-search { color: var(--accent); background: var(--accent-soft); }
dialog { width: min(600px, calc(100% - 30px)); max-height: calc(100vh - 40px); padding: 0; overflow: auto; border: 0; border-radius: 18px; color: var(--ink); background: #fff; box-shadow: var(--shadow-lg); }
dialog::backdrop { background: rgba(16, 18, 24, .62); backdrop-filter: blur(4px); }
dialog .stacked-form { padding: 27px; }
.dialog-heading, .dialog-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.dialog-heading { margin-bottom: 22px; }
.dialog-heading h2 { margin: 0; font-size: 25px; letter-spacing: -.035em; }
.dialog-actions { justify-content: flex-end; margin-top: 25px; padding-top: 19px; border-top: 1px solid var(--line); }
.stacked-form p { margin: 0 0 17px; }
.stacked-form label { display: block; margin-bottom: 7px; color: #454952; font-size: 12px; font-weight: 680; }
input, textarea { width: 100%; border: 1px solid var(--line-strong); border-radius: 10px; padding: 11px 13px; outline: 0; color: var(--ink); background: #fff; transition: border .15s, box-shadow .15s; }
textarea { min-height: 135px; resize: vertical; line-height: 1.55; }
input:focus, textarea:focus { border-color: #aea5ff; box-shadow: 0 0 0 4px rgba(109, 93, 252, .09); }
.stacked-form .helptext { display: block; margin-top: 6px; color: var(--soft); font-size: 10px; line-height: 1.45; }
.errorlist { margin: 0 0 7px; padding: 9px 12px; border-radius: 8px; color: #9d332f; background: #fff0ef; font-size: 11px; list-style: none; }
.messages { margin: -25px 0 26px; padding: 11px 14px; border: 1px solid #cfe9da; border-radius: 11px; color: #216c4b; background: #edfaf2; font-size: 12px; }
.messages p { display: flex; align-items: center; gap: 8px; margin: 0; }
.messages .icon { width: 16px; }

/* Search */
.search-header { min-height: auto; }
.search-page { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; margin: 36px 0 18px; }
.search-page > .icon { position: absolute; top: 50%; left: 16px; z-index: 1; width: 19px; color: #9296a0; transform: translateY(-50%); }
.search-page input { height: 48px; padding-left: 47px; border-radius: 12px; }
.results-summary { margin: 0 0 13px; color: var(--muted); font-size: 11px; font-weight: 620; }

/* Detail */
.detail-layout { width: min(850px, 100%); margin: 0 auto; }
.back-link { display: inline-block; margin-bottom: 17px; color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 640; }
.back-link:hover { color: var(--accent); }
.detail-card { padding: clamp(24px, 5vw, 49px); border: 1px solid var(--line); border-radius: 18px; background: #fff; box-shadow: var(--shadow-sm); }
.detail-header { display: flex; align-items: flex-start; gap: 20px; }
.detail-heading { min-width: 0; }
.detail-meta { display: flex; align-items: center; gap: 9px; margin-bottom: 11px; color: var(--accent); font-size: 10px; font-weight: 760; letter-spacing: .1em; text-transform: uppercase; }
.detail-card h1 { font-size: clamp(29px, 4.6vw, 44px); line-height: 1.13; overflow-wrap: anywhere; }
.source-link { display: inline-flex; align-items: center; gap: 7px; margin: 27px 0 0 78px; color: var(--accent); text-decoration: none; font-size: 12px; font-weight: 700; }
.source-link .icon { width: 15px; }
.prose { margin: 34px 0 0 78px; color: #353840; font: 16px/1.78 ui-serif, Georgia, serif; }
.prose p { margin: 0 0 1.25em; }
.detail-card footer { display: flex; gap: 16px; margin: 44px 0 0 78px; padding-top: 18px; border-top: 1px solid var(--line); color: var(--soft); font-size: 10px; }
.document-list { margin: 34px 0 0 78px; }
.document-list h2 { margin-bottom: 14px; font-size: 18px; }
.document-list details, .document-list > article { margin-bottom: 10px; padding: 13px 15px; border: 1px solid var(--line); border-radius: 10px; }
.document-list summary { cursor: pointer; font-size: 12px; font-weight: 700; }
.document-text { max-height: 420px; margin: 14px 0 0; padding: 14px; overflow: auto; border-radius: 8px; color: #343740; background: #f7f8fa; font: 12px/1.55 ui-monospace, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.board-strip { display: flex; gap: 10px; margin: 0 0 14px; overflow-x: auto; }
.board-chip { min-width: 150px; display: grid; gap: 4px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 11px; background: #fff; }
.board-chip strong { font-size: 12px; }
.board-chip small { color: var(--soft); font-size: 10px; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 18px; color: var(--muted); font-size: 11px; }
.dictionary-form { max-width: 720px; margin-bottom: 24px; }
.dictionary-form > label { display: block; margin-bottom: 8px; font-size: 12px; font-weight: 700; }
.dictionary-search { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
.dictionary-result { max-width: 820px; padding: clamp(20px, 4vw, 36px); }
.dictionary-result h2 { margin: 0 0 20px; font-size: 34px; }
.dictionary-result h3 { margin: 22px 0 8px; font-size: 14px; text-transform: capitalize; }
.dictionary-result li { margin-bottom: 9px; line-height: 1.6; }
.source-note { margin-top: 24px; color: var(--soft); font-size: 10px; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 24px 0 0 78px; }
.detail-actions form { margin: 0; }
.delete-form { margin: 24px 0 0 78px; }
.subscription-panel { margin-bottom: 14px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 11px; background: #fff; }
.subscription-panel > summary { cursor: pointer; font-size: 12px; font-weight: 700; }
.subscription-panel ul { margin: 14px 0; padding: 0; list-style: none; }
.subscription-panel li { display: grid; gap: 3px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.subscription-panel li small { color: var(--soft); overflow-wrap: anywhere; }
.subscription-form { max-width: 650px; padding-top: 8px; }
.subscription-form p { margin: 0 0 10px; }
.subscription-form label, .board-capture label { display: block; margin-bottom: 6px; font-size: 11px; font-weight: 700; }
.notes-board { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.note-card { min-height: 140px; padding: 16px; border: 1px solid var(--line); border-radius: 13px; background: #fff; box-shadow: var(--shadow-sm); }
.note-card > span { color: var(--soft); font-size: 9px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.note-card > div { margin-top: 10px; font-size: 13px; line-height: 1.55; }
.note-card.is-archived { opacity: .55; }
.board-capture { max-width: 620px; margin-top: 28px; padding: 18px; border: 1px solid var(--line); border-radius: 13px; background: #fff; }

/* Sign in */
.guest-body { color: #f7f8fb; background: var(--sidebar); }
.guest-main { min-height: 100vh; }
.login-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(360px, .92fr) 1.08fr; }
.login-aside { position: relative; min-height: 100vh; display: flex; flex-direction: column; padding: clamp(28px, 4vw, 58px); overflow: hidden; background: #17191e; }
.login-aside::before { content: ""; position: absolute; width: 520px; height: 520px; right: -250px; bottom: -250px; border: 1px solid rgba(255, 255, 255, .07); border-radius: 50%; box-shadow: 0 0 0 70px rgba(255,255,255,.018), 0 0 0 140px rgba(255,255,255,.012); }
.login-brand { position: relative; z-index: 1; width: max-content; }
.login-promise { position: relative; z-index: 1; max-width: 500px; margin: auto 0; padding: 70px 0; }
.login-spark { width: 46px; height: 46px; display: grid; place-items: center; margin-bottom: 27px; border: 1px solid #343740; border-radius: 14px; color: #a49aff; background: #21242b; }
.login-spark .icon { width: 22px; }
.login-promise .eyebrow { color: #a49aff; }
.login-promise h1 { margin: 0; font-size: clamp(43px, 5vw, 68px); line-height: 1.04; letter-spacing: -.055em; font-weight: 630; }
.login-promise > p:last-child { max-width: 470px; margin: 25px 0 0; color: #959aa5; font-size: 15px; line-height: 1.7; }
.login-footnote { position: relative; z-index: 1; margin: 0; color: #5f646f; font-size: 10px; }
.login-main { min-height: 100vh; display: grid; place-items: center; padding: 40px; color: var(--ink); background: #f7f8fa; }
.login-card { width: min(410px, 100%); }
.login-card h2 { margin: 0; font-size: 31px; letter-spacing: -.04em; }
.login-lede { margin: 10px 0 30px; color: var(--muted); font-size: 13px; }
.login-card .stacked-form { margin-top: 0; }
.login-button { width: 100%; margin-top: 5px; }
.privacy-note { margin: 23px 0 0; color: #a0a3ab; font-size: 10px; text-align: center; }

@media (max-width: 1180px) {
  .top-brand .brand-copy small, .private-badge { display: none; }
  .topbar { gap: 12px; }
  .nav-item { padding-inline: 8px; }
}

@media (max-width: 900px) {
  .top-nav { display: none; }
  .mobile-nav { position: sticky; top: 72px; z-index: 9; display: flex; gap: 4px; padding: 8px 16px; overflow-x: auto; border-bottom: 1px solid var(--line); background: rgba(255, 255, 255, .94); backdrop-filter: blur(16px); scrollbar-width: none; }
  .mobile-nav::-webkit-scrollbar { display: none; }
  .mobile-nav a { min-height: 34px; display: flex; align-items: center; flex: 0 0 auto; padding: 0 12px; border-radius: 9px; color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 670; }
  .mobile-nav a.is-active { color: var(--accent); background: var(--accent-soft); }
  .global-search { max-width: none; }
  .content { width: min(100% - 44px, 1120px); }
  .login-shell { grid-template-columns: .9fr 1.1fr; }
}

@media (max-width: 740px) {
  .topbar { height: 64px; gap: 11px; padding: 10px 14px; }
  .top-brand { gap: 9px; }
  .top-brand .brand-mark { width: 34px; height: 34px; border-radius: 10px; font-size: 17px; }
  .top-brand .brand-copy strong { font-size: 14px; }
  .global-search { min-width: 0; flex: 1; }
  .global-search input { height: 40px; }
  .mobile-nav { top: 64px; padding-inline: 12px; }
  .account-avatar { display: none; }
  .content { width: min(100% - 32px, 680px); padding: 37px 0 64px; }
  .dashboard-intro { align-items: flex-start; flex-direction: column; gap: 24px; }
  .system-status { min-width: 0; }
  .page-header { align-items: flex-start; flex-direction: column; gap: 24px; }
  .page-header .primary-button { width: 100%; }
  .page-title { align-items: flex-start; gap: 15px; }
  .page-icon { width: 50px; height: 50px; border-radius: 14px; }
  .page-icon .icon { width: 22px; }
  .library-panel { margin-top: 39px; }
  .item-row { grid-template-columns: 40px minmax(0, 1fr) auto; padding-inline: 13px; }
  .item-status { display: none; }
  .search-page { grid-template-columns: 1fr; }
  .search-page > .icon { top: 24px; }
  .detail-header { gap: 14px; }
  .detail-card { padding: 22px 18px; }
  .source-link, .prose, .document-list, .detail-actions, .delete-form, .detail-card footer { margin-left: 0; }
  .detail-card footer { align-items: flex-start; flex-direction: column; gap: 5px; }
  .login-shell { display: block; min-height: 100vh; background: #f7f8fa; }
  .login-aside { min-height: 330px; padding: 26px; }
  .login-promise { padding: 60px 0 30px; }
  .login-promise h1 { font-size: clamp(38px, 11vw, 52px); }
  .login-promise > p:last-child, .login-spark, .login-footnote { display: none; }
  .login-main { min-height: auto; padding: 43px 24px 60px; }
}

@media (max-width: 430px) {
  .top-brand .brand-copy { display: none; }
  .dashboard-intro h1 { font-size: 34px; }
  .content { width: calc(100% - 26px); }
  .section-heading { align-items: flex-start; }
  .item-copy small { max-width: 220px; }
}

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