:root {
  --ink: #24221f;
  --muted: #746f67;
  --paper: #f6f3ed;
  --card: #fffdf9;
  --line: #e7e1d7;
  --accent: #a94827;
  --accent-deep: #81361e;
  --accent-soft: #f2e1d8;
  --sage: #547263;
  --sage-soft: #e2ece6;
  --amber: #aa7220;
  --amber-soft: #f5ead6;
  --sidebar: #eee9df;
  --shadow: 0 20px 60px rgba(55, 43, 29, .13);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--paper); }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.hidden { display: none !important; }

.app-shell { display: grid; grid-template-columns: 264px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: 264px; display: flex; flex-direction: column; padding: 28px 18px 20px; background: var(--sidebar); border-right: 1px solid var(--line); z-index: 10; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 10px 26px; color: var(--ink); text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 39px; height: 39px; border-radius: 11px; color: var(--card); background: var(--accent); box-shadow: 0 8px 20px rgba(169,72,39,.2); }
.brand-mark svg { width: 24px; }
.brand strong { display: block; font: 700 19px/1.1 Georgia, serif; letter-spacing: -.02em; }
.brand small { display: block; margin-top: 4px; font-size: 11px; color: var(--muted); letter-spacing: .08em; }
.nav { display: grid; gap: 5px; }
.nav-item, .settings-button { width: 100%; display: flex; align-items: center; gap: 11px; border: 0; border-radius: 10px; padding: 11px 12px; color: #5e5952; background: transparent; text-align: left; cursor: pointer; transition: .18s ease; }
.nav-item svg, .settings-button svg { width: 19px; flex: 0 0 auto; }
.nav-item:hover, .settings-button:hover { background: rgba(255,255,255,.48); color: var(--ink); }
.nav-item.active { color: var(--accent-deep); background: rgba(255,253,249,.82); box-shadow: 0 1px 0 rgba(255,255,255,.8); font-weight: 650; }
.nav-badge { margin-left: auto; min-width: 24px; padding: 2px 7px; border-radius: 999px; color: var(--accent); background: var(--accent-soft); text-align: center; font-size: 11px; }
.sidebar-section { margin-top: 28px; min-height: 0; overflow: auto; }
.section-label { display: flex; justify-content: space-between; align-items: center; padding: 0 10px 8px; color: #918a80; font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.icon-button { width: 25px; height: 25px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); cursor: pointer; font-size: 19px; line-height: 1; }
.icon-button:hover { background: rgba(255,255,255,.55); color: var(--accent); }
.direction-nav { display: grid; gap: 3px; }
.direction-row { display: grid; grid-template-columns: minmax(0, 1fr) 27px; align-items: center; }
.direction-link { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 9px; background: transparent; color: #625d56; cursor: pointer; text-align: left; }
.direction-link:hover { background: rgba(255,255,255,.45); }
.direction-link .dot { width: 8px; height: 8px; border: 2px solid var(--accent); border-radius: 50%; }
.direction-link.inactive { opacity: .52; }
.direction-link span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.direction-count { margin-left: auto; font-size: 11px; color: #938c83; }
.direction-menu { width: 27px; height: 27px; border: 0; border-radius: 7px; background: transparent; color: #8f887e; cursor: pointer; letter-spacing: .08em; }
.direction-menu:hover { color: var(--accent); background: rgba(255,255,255,.5); }
.settings-button { margin-top: auto; border-top: 1px solid rgba(112,99,83,.13); border-radius: 0; padding-top: 17px; }
.health-dot { width: 8px; height: 8px; margin-left: auto; border-radius: 50%; background: #d1953e; box-shadow: 0 0 0 3px rgba(209,149,62,.12); }
.health-dot.ok { background: #5d8a70; box-shadow: 0 0 0 3px rgba(93,138,112,.14); }

.main { grid-column: 2; width: 100%; max-width: 1500px; padding: 34px 44px 80px; margin: auto; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 28px; margin-bottom: 28px; }
.eyebrow { margin: 0 0 8px; color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; letter-spacing: -.025em; }
h1 { margin: 0; font-size: clamp(30px, 3vw, 43px); font-weight: 500; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.date-chip { color: var(--muted); font-size: 13px; white-space: nowrap; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; border: 1px solid transparent; border-radius: 9px; padding: 9px 16px; cursor: pointer; font-weight: 680; transition: .18s ease; }
.button.primary { color: #fffaf3; background: var(--accent); box-shadow: 0 9px 22px rgba(169,72,39,.18); }
.button.primary:hover { background: var(--accent-deep); transform: translateY(-1px); }
.button.secondary { border-color: var(--line); background: #fff; }
.button.secondary:hover { border-color: #cfc6b9; }
.button:disabled { opacity: .55; cursor: wait; transform: none !important; }

.config-banner { display: flex; align-items: center; gap: 14px; margin: 0 0 22px; padding: 14px 16px; border: 1px solid #e7cfaa; border-radius: 12px; background: var(--amber-soft); }
.banner-icon { display: grid; place-items: center; flex: 0 0 auto; width: 26px; height: 26px; border: 1px solid #c7974c; border-radius: 50%; color: var(--amber); font-family: Georgia, serif; font-weight: 800; }
.config-banner strong { font-size: 13px; }
.config-banner p { margin: 3px 0 0; color: #785d37; font-size: 12px; }
.text-button { margin-left: auto; padding: 5px 8px; border: 0; background: transparent; color: var(--amber); font-size: 12px; font-weight: 700; cursor: pointer; white-space: nowrap; }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; margin-bottom: 34px; }
.stat-card { position: relative; overflow: hidden; min-height: 112px; padding: 18px 19px; border: 1px solid var(--line); border-radius: 13px; background: rgba(255,253,249,.72); }
.stat-label { color: var(--muted); font-size: 12px; }
.stat-value { display: block; margin-top: 8px; font: 500 28px/1 Georgia, serif; }
.stat-note { display: block; margin-top: 8px; color: #969087; font-size: 11px; }
.stat-icon { position: absolute; right: 15px; top: 15px; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; color: var(--sage); background: var(--sage-soft); }
.stat-icon svg { width: 16px; }
.stat-card-button { width: 100%; color: inherit; text-align: left; cursor: pointer; font: inherit; transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease; }
.stat-card-button:hover { border-color: #cdbeb0; box-shadow: 0 9px 28px rgba(55,43,29,.07); transform: translateY(-1px); }
.stat-card-button:focus-visible { outline: 3px solid rgba(169,72,39,.2); outline-offset: 2px; }
.stat-card-button .stat-note { color: var(--accent); font-weight: 680; }

.view { display: none; }
.view.active { display: block; animation: fadeIn .24s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(3px); } }
.content-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 16px; }
.content-heading h2 { margin: 0; font-size: 24px; font-weight: 500; }
.content-heading p { margin: 6px 0 0; color: var(--muted); font-size: 12px; }
.toolbar { display: flex; gap: 9px; }
.search-box { display: flex; align-items: center; gap: 7px; min-width: 210px; height: 38px; padding: 0 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--card); }
.search-box svg { width: 16px; color: #938d83; }
.search-box input { min-width: 0; width: 100%; border: 0; outline: 0; background: transparent; font-size: 12px; }
.toolbar select { height: 38px; max-width: 170px; padding: 0 30px 0 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--card); color: #615b54; font-size: 12px; }

.papers-list { display: grid; gap: 13px; }
.paper-card { scroll-margin-top: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); transition: border-color .18s ease, box-shadow .18s ease; }
.paper-card:hover { border-color: #d5ccbf; box-shadow: 0 10px 34px rgba(55,43,29,.06); }
.paper-main { display: grid; grid-template-columns: 74px minmax(0, 1fr) auto; gap: 18px; align-items: start; padding: 20px 22px; }
.score-ring { --score: 0; display: grid; place-items: center; width: 59px; height: 59px; border-radius: 50%; background: conic-gradient(var(--accent) calc(var(--score) * 1%), #eae4db 0); }
.score-ring::before { content: ""; grid-area: 1/1; width: 49px; height: 49px; border-radius: 50%; background: var(--card); }
.score-ring span { grid-area: 1/1; position: relative; font: 600 13px Georgia, serif; }
.score-ring small { display: block; margin-top: 5px; color: var(--muted); text-align: center; font-size: 9px; letter-spacing: .05em; }
.paper-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; margin-bottom: 7px; color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.source-pill, .status-pill { padding: 3px 7px; border-radius: 999px; background: var(--sage-soft); color: var(--sage); }
.status-pill.pending { color: var(--amber); background: var(--amber-soft); }
.status-pill.failed { color: #9d4332; background: #f4ddd7; }
.paper-title { margin: 0; font: 500 20px/1.32 Georgia, serif; }
.paper-title-button { display: inline; margin: 0; padding: 0; border: 0; color: inherit; background: transparent; cursor: pointer; font: inherit; text-align: left; }
.paper-title-button:hover { color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px; }
.paper-title-button:focus-visible { border-radius: 3px; outline: 3px solid rgba(169,72,39,.18); outline-offset: 3px; }
.paper-authors { margin: 8px 0 0; color: var(--muted); font-size: 12px; }
.paper-summary-line { margin: 12px 0 0; color: #4b4741; font-size: 13px; line-height: 1.65; }
.retry-summary-button { display: inline-flex; align-items: center; gap: 6px; margin-top: 11px; padding: 7px 10px; border: 1px solid #d9b8aa; border-radius: 8px; color: var(--accent); background: #fff8f4; cursor: pointer; font-size: 10px; font-weight: 750; }
.retry-summary-button:hover { border-color: var(--accent); background: #fff3ec; }
.retry-summary-button:disabled { opacity: .55; cursor: wait; }
.paper-actions { display: flex; gap: 7px; }
.paper-link { display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 8px; color: #686159; background: #fff; text-decoration: none; }
.paper-link:hover { color: var(--accent); border-color: #d4b3a5; }
.paper-link svg { width: 15px; }
.summary-toggle { width: 100%; display: flex; align-items: center; justify-content: center; gap: 7px; padding: 9px; border: 0; border-top: 1px solid #eee9e1; border-radius: 0 0 14px 14px; background: #fcfaf6; color: #736d64; cursor: pointer; font-size: 11px; }
.summary-toggle svg { width: 13px; transition: transform .2s; }
.paper-card.open .summary-toggle svg { transform: rotate(180deg); }
.summary-panel { display: none; padding: 4px 22px 24px 114px; border-top: 1px solid #eee9e1; }
.paper-card.open .summary-panel { display: block; }
.summary-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 30px; padding-top: 20px; }
.summary-section h4 { margin: 0 0 7px; color: var(--accent); font-size: 10px; letter-spacing: .11em; text-transform: uppercase; }
.summary-section p, .summary-section li { color: #4f4a43; font-size: 12.5px; line-height: 1.67; }
.summary-section p { margin: 0; }
.summary-section ul { margin: 0; padding-left: 17px; }
.finding { margin-bottom: 9px; }
.finding cite { display: block; margin-top: 2px; color: #8a837a; font-size: 10px; font-style: normal; }
.summary-footer { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 20px; padding-top: 14px; border-top: 1px solid #ece6dd; color: #888178; font-size: 10px; }

.paper-detail-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 14px; }
.paper-detail-toolbar span { color: var(--muted); font-size: 11px; }
.detail-back-button { min-height: 38px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 9px; color: #5e5851; background: var(--card); cursor: pointer; font-size: 12px; font-weight: 700; }
.detail-back-button:hover { border-color: #cdbeb0; color: var(--accent); }
.paper-report { overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: var(--card); box-shadow: 0 16px 48px rgba(55,43,29,.07); }
.paper-report-header { padding: clamp(24px, 4vw, 48px); border-bottom: 1px solid var(--line); background: linear-gradient(145deg, #fffdf9, #f7eee7); }
.paper-report-header h2 { max-width: 1000px; margin: 12px 0 0; font-size: clamp(28px, 4vw, 46px); font-weight: 500; line-height: 1.18; }
.paper-report-authors { margin: 14px 0 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.paper-report-lead { max-width: 960px; margin: 26px 0 0; color: #403b35; font: 500 clamp(17px, 2vw, 21px)/1.65 Georgia, serif; }
.paper-report-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 24px; }
.paper-report-actions .button { min-height: 38px; font-size: 11px; text-decoration: none; }
.paper-report-actions svg { width: 15px; }
.paper-report-body { padding: 8px clamp(24px, 4vw, 48px) clamp(30px, 5vw, 58px); }
.paper-report-body .summary-grid { gap: 30px 50px; padding-top: 34px; }
.paper-report-body .summary-section h4 { font-size: 11px; }
.paper-report-body .summary-section p, .paper-report-body .summary-section li { font-size: 14px; line-height: 1.78; }
.paper-report-body .finding cite { margin-top: 5px; font-size: 11px; }
.paper-report-body .summary-footer { margin-top: 34px; padding-top: 18px; font-size: 11px; }
.empty-state { display: grid; place-items: center; min-height: 320px; padding: 38px; border: 1px dashed #d8d0c4; border-radius: 14px; text-align: center; }
.empty-illustration { position: relative; width: 84px; height: 84px; margin-bottom: 18px; border-radius: 50%; background: var(--accent-soft); }
.empty-illustration::before { content: ""; position: absolute; width: 36px; height: 46px; left: 24px; top: 17px; border: 2px solid var(--accent); border-radius: 4px; background: var(--card); transform: rotate(-6deg); }
.empty-illustration::after { content: ""; position: absolute; width: 20px; height: 2px; left: 33px; top: 35px; background: var(--accent); box-shadow: 0 7px var(--accent), 0 14px var(--accent); transform: rotate(-6deg); }
.empty-state h3 { margin: 0; font-size: 20px; font-weight: 500; }
.empty-state p { max-width: 430px; margin: 9px 0 18px; color: var(--muted); font-size: 12px; line-height: 1.6; }

.runs-list { display: grid; gap: 9px; }
.run-row { display: grid; grid-template-columns: 1.3fr 1fr repeat(4, .55fr) auto; gap: 14px; align-items: center; padding: 14px 16px; border: 1px solid var(--line); border-radius: 11px; background: var(--card); font-size: 12px; }
.run-row strong { font-size: 13px; }
.run-cell small { display: block; margin-bottom: 3px; color: #9a9389; font-size: 9px; letter-spacing: .06em; text-transform: uppercase; }
.run-status { justify-self: end; padding: 4px 8px; border-radius: 999px; background: var(--sage-soft); color: var(--sage); font-size: 10px; }
.run-status.running { color: var(--amber); background: var(--amber-soft); }
.run-status.failed { color: #9d4332; background: #f4ddd7; }

.modal-backdrop { position: fixed; inset: 0; display: grid; place-items: center; padding: 24px; background: rgba(39,33,26,.42); backdrop-filter: blur(4px); z-index: 50; }
.modal { width: min(720px, 100%); max-height: calc(100vh - 48px); overflow: auto; border: 1px solid rgba(255,255,255,.6); border-radius: 16px; background: var(--card); box-shadow: var(--shadow); animation: modalIn .2s ease; }
@keyframes modalIn { from { opacity: 0; transform: translateY(9px) scale(.99); } }
.modal-header { display: flex; justify-content: space-between; align-items: flex-start; padding: 23px 26px 17px; border-bottom: 1px solid var(--line); }
.modal-header h2 { margin: 0; font-size: 24px; font-weight: 500; }
.close-button { border: 0; background: transparent; color: #817a71; cursor: pointer; font: 300 29px/1 sans-serif; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 15px; padding: 22px 26px 12px; }
.form-grid.compact { padding-top: 16px; }
.field { display: grid; gap: 7px; align-content: start; }
.field.full { grid-column: 1 / -1; }
.field > span, .source-fieldset legend { color: #514b44; font-size: 11px; font-weight: 750; }
.field em { color: #a09a91; font-style: normal; font-weight: 400; }
.field input, .field textarea, .field select { width: 100%; border: 1px solid #ddd5ca; border-radius: 8px; padding: 10px 11px; outline: 0; background: #fff; color: var(--ink); font-size: 12px; transition: .15s; }
.field textarea { resize: vertical; line-height: 1.5; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: #bd7c62; box-shadow: 0 0 0 3px rgba(169,72,39,.09); }
.field small { color: #938c83; font-size: 10px; line-height: 1.4; }
.source-fieldset { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin: 4px 26px 0; padding: 0; border: 0; }
.source-fieldset legend { grid-column: 1/-1; width: 100%; margin-bottom: 8px; }
.source-option { position: relative; display: flex; align-items: center; gap: 11px; min-height: 61px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.source-option:has(input:checked) { border-color: #c69580; background: #fdf7f3; }
.source-option input { position: absolute; opacity: 0; }
.source-logo { display: grid; place-items: center; flex: 0 0 auto; width: 32px; height: 32px; border-radius: 8px; color: #fff; font: 700 17px Georgia, serif; }
.source-logo.arxiv { background: #a64429; }
.source-logo.openalex { background: #4e6f76; }
.source-option strong, .source-option small { display: block; }
.source-option strong { font-size: 12px; }
.source-option small { margin-top: 3px; color: #8c857c; font-size: 9px; }
.source-option i { width: 14px; height: 14px; margin-left: auto; border: 1px solid #c7beb2; border-radius: 50%; }
.source-option input:checked ~ i { border: 4px solid var(--accent); }
.range-field > span { display: flex; justify-content: space-between; }
.range-field output { color: var(--accent); }
.range-field input { height: 5px; padding: 0; border: 0; accent-color: var(--accent); }
.modal-footer { display: flex; justify-content: flex-end; gap: 9px; padding: 17px 26px 22px; }
.footer-spacer { flex: 1; }
.danger-button { border: 0; background: transparent; color: #a14431; cursor: pointer; font-size: 11px; font-weight: 700; }

.directions-modal { width: min(640px, 100%); }
.direction-manager-list { display: grid; gap: 11px; padding: 20px 26px 8px; }
.direction-manager-empty { padding: 34px 18px; color: var(--muted); text-align: center; font-size: 12px; }
.direction-manager-card { padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: #fffdfa; }
.direction-manager-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.direction-manager-heading h3 { margin: 4px 0 0; font-size: 18px; font-weight: 500; }
.direction-state { color: var(--sage); font-size: 9px; font-weight: 800; letter-spacing: .08em; }
.direction-state.inactive { color: #999187; }
.direction-query { margin: 10px 0 0; color: #5e5851; font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
.direction-manager-meta { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.direction-manager-meta span { padding: 5px 8px; border-radius: 7px; color: #777067; background: #f3efe8; font-size: 10px; }
.direction-last-run { margin: 11px 0 0; color: var(--muted); font-size: 10px; }
.direction-manager-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 14px; padding-top: 13px; border-top: 1px solid #eee8df; }
.direction-manager-actions .button { min-height: 36px; padding: 7px 12px; font-size: 10px; }

.settings-modal { width: min(580px, 100%); }
.integration-list { display: grid; gap: 9px; padding: 22px 26px; }
.integration-row { display: grid; grid-template-columns: 36px 1fr auto; gap: 11px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 10px; }
.integration-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; color: var(--sage); background: var(--sage-soft); font-weight: 800; }
.integration-row strong, .integration-row small { display: block; }
.integration-row strong { font-size: 12px; }
.integration-row small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.integration-state { padding: 4px 8px; border-radius: 999px; color: var(--sage); background: var(--sage-soft); font-size: 10px; }
.integration-state.missing { color: var(--amber); background: var(--amber-soft); }
.balance-card { margin: 0 26px 14px; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: linear-gradient(135deg, #fbfaf7, #f2eee7); }
.balance-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.balance-heading h3 { margin: 3px 0 0; font-family: Georgia, serif; font-size: 16px; }
.balance-kicker { color: var(--sage); font-size: 8px; font-weight: 800; letter-spacing: .14em; }
.balance-refresh { border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; color: var(--ink); background: rgba(255,255,255,.72); cursor: pointer; font-size: 10px; font-weight: 700; }
.balance-refresh:hover { border-color: #aaa094; background: #fff; }
.balance-refresh:disabled { opacity: .55; cursor: wait; }
.balance-summary { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-top: 14px; }
.balance-total small, .balance-breakdown span, .balance-meta { color: var(--muted); font-size: 9px; }
.balance-total strong { display: block; margin-top: 3px; font-family: Georgia, serif; font-size: 23px; font-weight: 500; }
.balance-state { align-self: flex-start; padding: 4px 8px; border-radius: 999px; color: var(--sage); background: var(--sage-soft); font-size: 9px; font-weight: 700; }
.balance-state.insufficient, .balance-state.error { color: #9a4936; background: #f5e5df; }
.balance-breakdown { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.balance-breakdown div { padding: 9px 10px; border-radius: 8px; background: rgba(255,255,255,.7); }
.balance-breakdown strong { display: block; margin-top: 3px; font-size: 11px; }
.balance-meta { margin: 10px 0 0; line-height: 1.5; }
.balance-message { margin: 13px 0 0; color: var(--muted); font-size: 10px; line-height: 1.55; }
.balance-message.error { color: #984431; }
.pwa-card { margin: 0 26px 14px; padding: 16px; border: 1px solid #dcc9bd; border-radius: 12px; background: #fdf6f1; }
.pwa-card h3 { margin: 3px 0 0; font-family: Georgia, serif; font-size: 16px; }
.pwa-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 13px; }
.pwa-actions .button { min-height: 36px; padding: 7px 11px; font-size: 10px; }
.pwa-install-banner { border-color: #c9d8ce; background: var(--sage-soft); }
.pwa-install-banner .banner-icon { border-color: #7fa18d; color: var(--sage); }
.pwa-install-banner p { color: #4d6759; }
.pwa-install-banner .text-button { color: var(--sage); }
.settings-note { margin: 0 26px 4px; padding: 13px 14px; border-radius: 10px; background: #f3f0ea; }
.settings-note strong { font-size: 11px; }
.settings-note p { margin: 5px 0 0; color: var(--muted); font-size: 10px; line-height: 1.55; }

.auth-gate { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 22px; background: radial-gradient(circle at 50% 15%, #f8e9df, var(--paper) 55%); }
.auth-card { width: min(420px, 100%); padding: 30px; border: 1px solid var(--line); border-radius: 20px; background: var(--card); box-shadow: var(--shadow); }
.auth-mark { display: grid; place-items: center; width: 48px; height: 48px; margin-bottom: 22px; border-radius: 14px; color: #fff; background: var(--accent); font: 700 22px Georgia, serif; }
.auth-card h1 { margin: 0; font-size: 29px; }
.auth-card > p:not(.eyebrow):not(.auth-error) { margin: 10px 0 22px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.auth-card .button { width: 100%; margin-top: 17px; }
.auth-error { margin: 9px 0 0; color: #9b402e; font-size: 11px; }

.toast { position: fixed; right: 24px; bottom: 24px; z-index: 80; max-width: 360px; padding: 12px 15px; border-radius: 10px; color: #fff; background: #302c27; box-shadow: var(--shadow); font-size: 12px; opacity: 0; transform: translateY(12px); pointer-events: none; transition: .24s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #913f2e; }

@media (max-width: 1000px) {
  .app-shell { grid-template-columns: 78px minmax(0, 1fr); }
  .sidebar { width: 78px; padding-inline: 11px; }
  .brand { padding-inline: 8px; justify-content: center; }
  .brand > span:last-child, .nav-item:not(.active) span:not(.nav-badge), .nav-item { font-size: 0; }
  .nav-item { justify-content: center; }
  .nav-item svg { width: 20px; }
  .nav-badge { position: absolute; margin: -24px 0 0 24px; font-size: 9px; min-width: 18px; padding: 1px 4px; }
  .sidebar-section, .settings-button { display: none; }
  .main { grid-column: 2; padding-inline: 28px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 700px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; inset: auto 0 0; width: 100%; height: 62px; padding: 7px 12px; border: 0; border-top: 1px solid var(--line); flex-direction: row; background: rgba(246,243,237,.96); backdrop-filter: blur(12px); }
  .brand { display: none; }
  .nav { width: 75%; grid-template-columns: repeat(3, 1fr); }
  .nav-item, .nav-item:not(.active) { justify-content: center; flex-direction: column; gap: 2px; padding: 5px; font-size: 9px; }
  .nav-item.active { font-size: 9px; }
  .nav-item svg { width: 18px; }
  .nav-badge { display: none; }
  .sidebar .settings-button { display: flex; width: 25%; height: 100%; margin: 0; padding: 5px; border: 0; justify-content: center; flex-direction: column; gap: 2px; font-size: 9px; }
  .sidebar .settings-button svg { width: 18px; }
  .sidebar .settings-button .health-dot { display: none; }
  .main { padding: 22px 16px 90px; }
  .topbar { align-items: flex-start; }
  .topbar h1 { font-size: 32px; line-height: 1.25; }
  .topbar-actions .date-chip { display: none; }
  .topbar .button.primary { min-width: 94px; padding-inline: 11px; white-space: nowrap; font-size: 11px; }
  .button.primary span { display: none; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .stat-card { min-height: 100px; padding: 15px; }
  .content-heading { align-items: stretch; flex-direction: column; }
  .toolbar { display: grid; grid-template-columns: 1fr 120px; }
  .search-box { min-width: 0; }
  .paper-main { grid-template-columns: 50px minmax(0,1fr); gap: 12px; padding: 17px 14px; }
  .score-ring { width: 46px; height: 46px; }
  .score-ring::before { width: 39px; height: 39px; }
  .score-ring small { display: none; }
  .paper-actions { grid-column: 2; }
  .summary-panel { padding: 4px 16px 20px; }
  .summary-grid { grid-template-columns: 1fr; }
  .paper-detail-toolbar { align-items: flex-start; flex-direction: column; gap: 7px; }
  .paper-detail-toolbar span { padding-left: 2px; }
  .paper-report-header { padding: 24px 19px 27px; }
  .paper-report-header h2 { font-size: 28px; }
  .paper-report-lead { margin-top: 20px; font-size: 17px; }
  .paper-report-body { padding: 2px 19px 32px; }
  .paper-report-body .summary-grid { grid-template-columns: 1fr; gap: 25px; padding-top: 27px; }
  .paper-report-body .summary-section p, .paper-report-body .summary-section li { font-size: 13.5px; }
  .form-grid, .source-fieldset { grid-template-columns: 1fr; }
  .modal-backdrop { padding: 0; align-items: end; }
  .modal { max-height: 92vh; border-radius: 18px 18px 0 0; }
  .run-row { grid-template-columns: 1fr 1fr; }
  .run-status { justify-self: start; }
  .config-banner { align-items: flex-start; }
  .pwa-actions { display: grid; grid-template-columns: 1fr; }
  .pwa-actions .button { width: 100%; }
  .direction-manager-list { padding: 16px 16px 6px; }
  .direction-manager-actions { display: grid; grid-template-columns: repeat(3, 1fr); }
  .direction-manager-actions .button { width: 100%; padding-inline: 7px; }
}
