:root {
  --ink: #10282b;
  --ink-soft: #557174;
  --mist: #e8f0ef;
  --paper: #f8fbfa;
  --jade: #13766f;
  --jade-deep: #075f5a;
  --coral: #f16f55;
  --line: #c9d7d5;
  --white: #ffffff;
  --shadow: 0 18px 60px rgba(22, 60, 61, .11);
  --display: "STKaiti", "KaiTi", "Kaiti SC", serif;
  --body: "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  --mono: "SFMono-Regular", "Roboto Mono", monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { color-scheme: light; background: var(--mist); }
body { margin: 0; color: var(--ink); font-family: var(--body); }
button, input, textarea { color: inherit; font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
.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; }

.shell { min-height: 100vh; display: grid; grid-template-columns: minmax(290px, 25vw) 1fr; }
.rail { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 32px clamp(24px, 3vw, 48px); color: #ecf8f5; background: var(--jade-deep); overflow: hidden; }
.rail::after { content: ""; position: absolute; width: 360px; height: 360px; right: -220px; bottom: -120px; border: 70px solid rgba(255,255,255,.055); border-radius: 50%; pointer-events: none; }
.brand { display: inline-flex; align-items: center; gap: 12px; width: fit-content; color: inherit; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 47px; height: 47px; padding: 2px; overflow: hidden; background: #d8f1e9; border-radius: 14px 14px 14px 4px; transform: rotate(-3deg); transition: transform .2s ease; }
.brand:hover .brand-mark { transform: rotate(2deg) translateY(-1px); }
.brand-mark img { display: block; width: 100%; height: 100%; object-fit: contain; transform: rotate(3deg) scale(1.12); }
.brand strong { display: block; font: 25px/1.1 var(--display); letter-spacing: .08em; }
.brand small { display: block; margin-top: 4px; opacity: .6; font: 8px/1 var(--mono); letter-spacing: .18em; }
.intake { position: relative; z-index: 1; margin: auto 0; }
.eyebrow { margin: 0 0 10px; color: var(--jade); font: 600 10px/1 var(--mono); letter-spacing: .18em; text-transform: uppercase; }
.rail .eyebrow { color: #8fd2c3; }
.intake h1 { margin: 0 0 32px; max-width: 330px; font: 400 clamp(28px, 2.25vw, 40px)/1.35 var(--display); letter-spacing: .02em; }
.intake label { display: block; margin-bottom: 9px; color: rgba(240,255,251,.72); font-size: 12px; }
.intake textarea { width: 100%; resize: vertical; min-height: 126px; padding: 15px 16px; color: #effbf8; background: rgba(6, 65, 61, .75); border: 1px solid rgba(192,235,226,.23); border-radius: 8px; outline: none; line-height: 1.65; transition: border-color .2s, box-shadow .2s; }
.intake textarea::placeholder { color: rgba(224,246,241,.38); }
.intake textarea:focus { border-color: #8fd2c3; box-shadow: 0 0 0 3px rgba(143,210,195,.13); }
.primary { width: 100%; display: flex; justify-content: space-between; align-items: center; margin-top: 12px; padding: 14px 16px; color: #133b3a; background: #bce5da; border: 0; border-radius: 8px; font-weight: 700; transition: transform .2s, background .2s; }
.primary:hover { background: #d0eee6; transform: translateY(-1px); }
.primary:disabled { cursor: wait; opacity: .65; transform: none; }
.form-note { margin: 12px 0 0; color: rgba(232,249,245,.52); font-size: 11px; line-height: 1.6; }
.message { min-height: 20px; margin-top: 12px; color: #c9ede5; font-size: 12px; line-height: 1.5; }
.message.error { color: #ffb9aa; }
.rail-footer { position: relative; z-index: 1; display: flex; align-items: center; gap: 8px; color: rgba(235,251,247,.48); font-size: 10px; }
.pulse { width: 6px; height: 6px; background: #96dbc9; border-radius: 50%; box-shadow: 0 0 0 4px rgba(150,219,201,.1); }

.workspace { min-width: 0; padding: 48px clamp(28px, 5vw, 80px) 80px; background: var(--mist); }
.topbar { display: flex; justify-content: space-between; align-items: end; padding-bottom: 24px; border-bottom: 1px solid var(--line); }
.topbar h2 { margin: 0; font: 400 clamp(30px, 3.2vw, 52px)/1 var(--display); letter-spacing: .02em; }
.export-link { padding: 9px 0; color: var(--ink); border-bottom: 1px solid currentColor; text-decoration: none; font-size: 12px; }
.export-link:hover { color: var(--jade); }
.top-actions { display: flex; align-items: center; gap: 20px; }
.account-button { padding: 9px 12px; color: var(--jade-deep); background: rgba(255,255,255,.55); border: 1px solid var(--line); border-radius: 99px; font-size: 11px; }
.ledger { display: grid; grid-template-columns: .8fr .8fr 1.6fr 1fr; min-height: 92px; border-bottom: 1px solid var(--line); }
.ledger > div { display: flex; flex-direction: column; justify-content: center; padding: 18px 20px 16px 0; }
.ledger > div + div { padding-left: 28px; border-left: 1px solid var(--line); }
.ledger strong { font: 500 21px/1 var(--mono); }
.ledger span { margin-top: 7px; color: var(--ink-soft); font-size: 10px; }
.ledger .word-stat { align-items: flex-end; }
.library { margin-top: 34px; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.search { flex: 1; max-width: 440px; display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid #9db2b0; }
.search span { color: var(--jade); font-size: 22px; transform: rotate(-15deg); }
.search input { width: 100%; background: transparent; border: 0; outline: 0; font-size: 13px; }
.search input::placeholder { color: #7c9290; }
.filters { display: flex; gap: 5px; }
.filter { padding: 8px 12px; color: var(--ink-soft); background: transparent; border: 1px solid transparent; border-radius: 99px; font-size: 11px; }
.filter:hover { color: var(--ink); }
.filter.active { color: var(--jade-deep); background: rgba(255,255,255,.65); border-color: var(--line); }

.article-list { display: grid; gap: 12px; }
.article-card { position: relative; min-height: 136px; background: rgba(248,251,250,.88); border: 1px solid rgba(255,255,255,.9); border-radius: 11px; box-shadow: 0 1px 0 rgba(11,72,69,.06); transition: transform .2s, box-shadow .2s, background .2s; animation: card-in .35s both; }
.article-card:hover { z-index: 2; background: var(--white); box-shadow: var(--shadow); transform: translateY(-2px) rotate(-.12deg); }
.card-open { width: 100%; min-height: 136px; display: grid; grid-template-columns: 124px 1fr; gap: 22px; padding: 16px 54px 16px 16px; text-align: left; background: transparent; border: 0; border-radius: inherit; }
.cover-wrap { position: relative; display: grid; place-items: center; width: 124px; height: 104px; overflow: hidden; background: #d6e5e2; border-radius: 7px 7px 7px 2px; }
.cover { position: relative; z-index: 1; width: 100%; height: 100%; object-fit: cover; }
.cover[src=""] { display: none; }
.cover-fallback { color: rgba(19, 118, 111, .4); font: 46px/1 var(--display); }
.card-copy { min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.card-topline { display: flex; align-items: center; gap: 10px; margin-bottom: 7px; }
.account { overflow: hidden; color: var(--jade); font-size: 11px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.status-pill { padding: 3px 6px; color: #607b79; background: #e1ecea; border-radius: 3px; font: 8px/1 var(--mono); letter-spacing: .06em; }
.status-pill.failed { color: #a64d3b; background: #fbe3dc; }
.status-pill.working { color: #5d6b25; background: #eef1d6; }
.title { overflow: hidden; display: -webkit-box; color: var(--ink); font: 600 clamp(17px, 1.55vw, 22px)/1.35 var(--body); -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.summary { overflow: hidden; display: -webkit-box; margin-top: 7px; color: var(--ink-soft); font-size: 11px; line-height: 1.55; -webkit-box-orient: vertical; -webkit-line-clamp: 1; }
.card-meta { display: flex; gap: 14px; margin-top: 11px; color: #819391; font: 9px/1 var(--mono); }
.card-menu { position: absolute; top: 12px; right: 12px; }
.menu-trigger { width: 34px; height: 34px; color: #78908e; background: transparent; border: 0; border-radius: 50%; letter-spacing: 1px; }
.menu-trigger:hover { background: #edf4f2; }
.menu-popover { position: absolute; z-index: 5; right: 0; top: 34px; width: 105px; padding: 5px; background: white; border: 1px solid var(--line); border-radius: 7px; box-shadow: 0 12px 30px rgba(16,40,43,.15); }
.menu-popover button { width: 100%; padding: 8px 9px; text-align: left; background: none; border: 0; border-radius: 4px; font-size: 11px; }
.menu-popover button:hover { background: #eef5f3; }
.menu-popover .danger { color: #b14c39; }
.empty { display: grid; justify-items: center; padding: 82px 20px; text-align: center; }
.empty-mascot { position: relative; width: 96px; height: 96px; }
.empty-mascot img { display: block; width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 10px 18px rgba(7,95,90,.12)); transform: rotate(2deg); }
.empty-mascot span { position: absolute; right: 1px; bottom: 7px; display: grid; place-items: center; width: 28px; height: 28px; color: var(--jade-deep); background: #d8f1e9; border: 2px solid var(--mist); border-radius: 50%; font-weight: 700; }
.empty h3 { margin: 24px 0 7px; font: 400 21px/1.2 var(--display); }
.empty p { max-width: 340px; margin: 0; color: var(--ink-soft); font-size: 12px; line-height: 1.7; }

dialog { width: min(880px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 0; background: var(--paper); border: 0; border-radius: 12px; box-shadow: 0 30px 100px rgba(8,40,40,.28); }
dialog::backdrop { background: rgba(13,42,42,.56); backdrop-filter: blur(5px); }
.reader-shell { min-height: 80vh; }
.reader-bar { position: sticky; z-index: 2; top: 0; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 16px 22px; background: rgba(248,251,250,.93); border-bottom: 1px solid #dbe5e3; backdrop-filter: blur(10px); }
.icon-button { width: 34px; height: 34px; background: transparent; border: 1px solid var(--line); border-radius: 50%; font-size: 22px; line-height: 1; }
.reader-view-switch { display: flex; padding: 3px; background: #e7efed; border-radius: 99px; }
.reader-view-switch button { padding: 7px 12px; color: #667d7a; background: transparent; border: 0; border-radius: 99px; font-size: 10px; }
.reader-view-switch button.active { color: var(--jade-deep); background: var(--white); box-shadow: 0 1px 5px rgba(16,40,43,.1); }
.reader-view-switch button:disabled { cursor: not-allowed; opacity: .48; }
.reader-actions { justify-self: end; display: flex; gap: 22px; }
.reader-actions a { color: var(--jade-deep); text-decoration: none; font-size: 11px; }
.reader-content { max-width: 680px; margin: 0 auto; padding: 58px 34px 80px; }
.reader-account { margin: 0 0 12px; color: var(--jade); font-size: 12px; font-weight: 600; }
.reader-content > h2 { margin: 0; font: 500 clamp(28px, 4vw, 43px)/1.35 var(--display); }
.reader-meta { margin: 16px 0 46px; color: #81918f; font: 10px/1.4 var(--mono); }
.article-body { color: #203638; font-size: 16px; line-height: 1.95; overflow-wrap: anywhere; }
.article-body img, .article-body video { display: block; max-width: 100%; height: auto; margin: 24px auto; }
.article-body p { margin: 1.25em 0; }
.article-body pre { max-width: 100%; margin: 1.5em 0; padding: 16px; overflow-x: auto; background: #edf3f2; border-radius: 7px; white-space: pre; }
.article-body pre code { display: block; width: max-content; min-width: 100%; font: 12px/1.65 var(--mono); }
.article-body code { overflow-wrap: normal; word-break: normal; }
.article-body blockquote { margin: 1.5em 0; padding: 2px 0 2px 18px; color: #52706d; border-left: 3px solid #9bc6bc; }
.snapshot-view { min-height: 80vh; padding: 28px; background: #dce6e4; }
.snapshot-view > p { max-width: 760px; margin: 0 auto 18px; color: var(--ink-soft); font-size: 12px; }
.snapshot-view > img { display: block; width: min(100%, 1280px); height: auto; margin: 0 auto; background: white; box-shadow: 0 16px 50px rgba(16,40,43,.16); }
.comments { margin-top: 68px; padding-top: 28px; border-top: 1px solid var(--line); }
.comments-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; }
.comments-heading .eyebrow { margin: 0; }
.comments-heading span { color: #809391; font: 10px/1 var(--mono); }
.comment { display: grid; grid-template-columns: 34px 1fr; gap: 12px; padding: 18px 0; border-top: 1px solid #dae4e2; }
.comment:first-child { border-top: 0; }
.avatar { width: 34px; height: 34px; object-fit: cover; background: #dbe8e5; border-radius: 50%; }
.comment-head { display: flex; justify-content: space-between; gap: 12px; color: var(--jade); font-size: 11px; }
.comment-like { color: #829492; font: 9px/1 var(--mono); }
.comment p { margin: 7px 0 0; font-size: 13px; line-height: 1.7; }
.reply { margin-top: 10px; padding: 10px 12px; color: #46605e; background: #eaf2f0; border-radius: 5px; font-size: 12px; line-height: 1.6; }
.comments-note { color: var(--ink-soft); font-size: 12px; line-height: 1.7; }

.account-dialog { width: min(560px, calc(100vw - 32px)); }
.account-panel { padding: 30px; }
.account-panel > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.account-panel h2 { margin: 0; font: 500 22px/1.3 var(--body); overflow-wrap: anywhere; }
.account-panel section { padding: 26px 0; }
.account-panel h3 { margin: 0 0 6px; font: 500 19px/1.3 var(--display); }
.account-note { margin: 0 0 16px; color: var(--ink-soft); font-size: 11px; line-height: 1.6; }
.token-form { display: flex; gap: 8px; }
.token-form input { min-width: 0; flex: 1; padding: 10px 12px; background: white; border: 1px solid var(--line); border-radius: 6px; }
.token-form button, .account-panel footer button, .token-row button { padding: 9px 12px; background: white; border: 1px solid var(--line); border-radius: 6px; font-size: 11px; }
.token-secret { margin-top: 14px; padding: 12px; white-space: pre-wrap; overflow-wrap: anywhere; color: #163c39; background: #dcefe9; border-radius: 6px; font: 11px/1.6 var(--mono); }
.token-list { margin-top: 18px; border-top: 1px solid var(--line); }
.token-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.token-row strong, .token-row small { display: block; }
.token-row strong { font-size: 12px; }
.token-row small { margin-top: 4px; color: var(--ink-soft); font: 9px/1.4 var(--mono); }
.account-panel footer { display: flex; justify-content: space-between; gap: 12px; padding-top: 20px; border-top: 1px solid var(--line); }
.account-panel .danger { color: #b14c39; }

.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--jade-deep); }
.auth-page::before { content: ""; position: fixed; width: 520px; height: 520px; right: -180px; bottom: -240px; border: 90px solid rgba(255,255,255,.045); border-radius: 50%; }
.auth-card { position: relative; z-index: 1; width: min(430px, 100%); padding: 36px; background: var(--paper); border-radius: 13px 13px 13px 3px; box-shadow: 0 28px 90px rgba(0,28,27,.32); }
.auth-brand { color: var(--ink); }
.auth-brand small { color: var(--ink-soft); }
.auth-intro { margin: 48px 0 25px; }
.auth-intro h1 { margin: 0; font: 400 35px/1.25 var(--display); }
.auth-intro > p:last-child { margin: 10px 0 0; color: var(--ink-soft); font-size: 12px; }
.auth-tabs { display: flex; gap: 4px; margin-bottom: 20px; padding: 3px; background: #e7efed; border-radius: 99px; }
.auth-tabs button { flex: 1; padding: 8px; color: var(--ink-soft); background: transparent; border: 0; border-radius: 99px; font-size: 11px; }
.auth-tabs button.active { color: var(--jade-deep); background: white; box-shadow: 0 1px 5px rgba(16,40,43,.1); }
#auth-form label { display: block; margin-top: 13px; color: var(--ink-soft); font-size: 11px; }
#auth-form input { width: 100%; margin-top: 6px; padding: 12px; background: white; border: 1px solid var(--line); border-radius: 6px; outline: 0; }
#auth-form input:focus { border-color: var(--jade); box-shadow: 0 0 0 3px rgba(19,118,111,.1); }
.auth-submit { color: #133b3a; }
.oauth-button { width: 100%; margin-top: 10px; padding: 12px; color: var(--ink); background: white; border: 1px solid var(--line); border-radius: 7px; font-weight: 600; }
.google-button { color: #2b2f33; }
.auth-message { min-height: 18px; margin: 13px 0 0; color: var(--ink-soft); font-size: 11px; }
.auth-message.error { color: #b14c39; }

@keyframes card-in { from { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; } }
@media (max-width: 860px) {
  .shell { display: block; }
  .rail { position: relative; width: 100%; height: auto; min-height: 0; padding: 24px; }
  .intake { margin: 48px 0 26px; }
  .intake h1 { font-size: 32px; }
  .rail-footer { display: none; }
  .workspace { padding: 32px 20px 60px; }
  .ledger { grid-template-columns: repeat(2, 1fr); }
  .ledger > div:nth-child(3) { border-left: 0; border-top: 1px solid var(--line); }
  .ledger > div:nth-child(4) { border-top: 1px solid var(--line); }
  .ledger .word-stat { align-items: flex-start; }
}
@media (max-width: 560px) {
  .topbar { align-items: center; }
  .topbar h2 { font-size: 34px; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .search { max-width: none; }
  .card-open { grid-template-columns: 88px 1fr; gap: 14px; padding: 13px 42px 13px 13px; }
  .cover-wrap { width: 88px; height: 96px; }
  .summary { display: none; }
  .reader-content { padding: 42px 22px 60px; }
  .reader-bar { grid-template-columns: auto 1fr; gap: 10px; }
  .reader-view-switch { justify-self: end; }
  .reader-actions { gap: 12px; }
  .reader-actions { grid-column: 1 / -1; justify-self: stretch; justify-content: flex-end; }
  .reader-actions a { font-size: 10px; }
}
