@import "tailwindcss";

:root {
  font-family: "Avenir Next", "PingFang SC", sans-serif;
  color: #25352f;
  background: #e9eeeb;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --ink: #20342d;
  --forest: #1f332c;
  --forest-2: #2b473e;
  --moss: #70897e;
  --paper: #f8f7f2;
  --paper-2: #efeee8;
  --line: #d5dcd8;
  --ember: #d6784d;
  --ember-dark: #a95434;
  --danger: #a4433c;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: #e9eeeb; }
button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }

.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; }
.eyebrow { margin: 0; font-size: .68rem; font-weight: 700; letter-spacing: .18em; text-transform: uppercase; color: var(--ember-dark); }

.app-shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 22px 16px 18px; color: #edf3ef; background: var(--forest); display: flex; flex-direction: column; overflow: hidden; }
.sidebar::after { content: ""; position: absolute; inset: auto -80px -100px auto; width: 220px; height: 220px; border: 1px solid rgba(255,255,255,.09); border-radius: 50%; box-shadow: 0 0 0 34px rgba(255,255,255,.025), 0 0 0 68px rgba(255,255,255,.018); pointer-events: none; }
.brand-lockup { display: flex; align-items: center; gap: 11px; padding: 0 4px 22px; border-bottom: 1px solid rgba(255,255,255,.1); }
.brand-lockup__mark { display: inline-grid; place-items: center; width: 32px; height: 32px; flex: none; color: white; background: var(--ember); border-radius: 9px 9px 3px 9px; font-family: Georgia, serif; font-size: 1.05rem; box-shadow: 0 7px 18px rgba(0,0,0,.16); }
.brand-lockup strong { display: block; font-size: .74rem; letter-spacing: .13em; }
.brand-lockup small { display: block; margin-top: 2px; color: #99ada5; font-size: .58rem; letter-spacing: .06em; }
.nav-label { margin: 26px 8px 10px; color: #82988f; font-size: .62rem; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; }
.primary-nav { display: grid; gap: 6px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 11px; border-radius: 8px; color: #bdcbc6; font-size: .85rem; transition: color .18s ease, background .18s ease, transform .18s ease; }
.nav-item:hover { color: white; background: rgba(255,255,255,.06); transform: translateX(2px); }
.nav-item--active { color: white; background: var(--forest-2); box-shadow: inset 3px 0 var(--ember); }
.sidebar-note { display: flex; gap: 9px; margin-top: auto; padding: 12px 10px; border: 1px solid rgba(255,255,255,.1); border-radius: 9px; background: rgba(0,0,0,.08); position: relative; z-index: 1; }
.status-dot { width: 7px; height: 7px; margin-top: 4px; flex: none; border-radius: 50%; background: #8ccba8; box-shadow: 0 0 0 4px rgba(140,203,168,.12); }
.sidebar-note strong, .sidebar-note small { display: block; }
.sidebar-note strong { font-size: .68rem; }
.sidebar-note small { margin-top: 3px; color: #91a69e; font-size: .59rem; line-height: 1.45; }
.sidebar-version { position: relative; z-index: 1; margin: 14px 8px 0; color: #627b71; font-size: .56rem; letter-spacing: .12em; }
.route-canvas { min-width: 0; min-height: 100vh; background: radial-gradient(circle at 90% 5%, rgba(214,120,77,.08), transparent 22%), var(--paper); }
.mobile-header { display: none; }

.placeholder-page { min-height: 100vh; display: grid; place-content: center; justify-items: center; padding: 40px; text-align: center; animation: page-enter .45s ease both; }
.placeholder-page__mark { display: grid; place-items: center; width: 58px; height: 58px; margin-bottom: 24px; color: var(--ember); border: 1px solid #d8c6bb; border-radius: 50%; background: rgba(255,255,255,.62); box-shadow: 0 15px 45px rgba(41,57,51,.08); }
.placeholder-page h1 { margin: 10px 0 8px; font-family: "Songti SC", Georgia, serif; font-size: clamp(2rem, 4vw, 3.8rem); font-weight: 600; letter-spacing: -.05em; }
.placeholder-page > p:last-child { margin: 0; color: #77847f; }

.button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 0; border-radius: 8px; cursor: pointer; font-weight: 650; transition: transform .15s ease, box-shadow .15s ease, background .15s ease; }
.button:focus-visible { outline: 3px solid rgba(214,120,77,.3); outline-offset: 2px; }
.button:disabled { opacity: .52; cursor: not-allowed; }
.button:not(:disabled):active { transform: translateY(1px); }
.button--md { min-height: 38px; padding: 0 14px; font-size: .8rem; }
.button--sm { min-height: 31px; padding: 0 10px; font-size: .72rem; }
.button--icon { width: 38px; height: 38px; padding: 0; }
.button--primary { color: white; background: var(--ember); box-shadow: 0 7px 18px rgba(166,79,48,.19); }
.button--primary:hover { background: #c9673f; }
.button--secondary { color: var(--ink); background: white; border: 1px solid var(--line); }
.button--ghost { color: inherit; background: transparent; }
.button--ghost:hover { background: rgba(72,94,85,.08); }
.button--danger { color: white; background: var(--danger); }
.badge { display: inline-flex; align-items: center; gap: 5px; min-height: 23px; padding: 0 8px; border-radius: 999px; background: var(--paper-2); color: #5b6b65; font-size: .66rem; font-weight: 700; }

.dialog-overlay { position: fixed; inset: 0; z-index: 50; background: rgba(13,24,20,.48); backdrop-filter: blur(4px); animation: fade-in .2s ease; }
.mobile-menu { position: fixed; inset: 0 auto 0 0; z-index: 51; width: min(310px, 88vw); padding: 22px 16px; color: #edf3ef; background: var(--forest); box-shadow: 24px 0 80px rgba(0,0,0,.3); animation: slide-in .25s ease; }
.mobile-menu__close { position: absolute; top: 12px; right: 10px; z-index: 2; }

.documents-workspace { display: grid; grid-template-columns: minmax(520px, 1fr) 340px; min-height: 100vh; }
.documents-main { min-width: 0; padding: 34px clamp(24px, 4vw, 58px); overflow: hidden; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.page-header h1 { margin: 7px 0 6px; font-family: "Songti SC", Georgia, serif; font-size: clamp(2rem, 3vw, 3rem); font-weight: 600; letter-spacing: -.045em; }
.page-header p:not(.eyebrow) { margin: 0; color: #7b8782; font-size: .84rem; }
.upload-control { display: flex; align-items: center; gap: 10px; }
.inline-error { position: absolute; margin-top: 68px; max-width: 260px; color: var(--danger); font-size: .7rem; }
.metric-strip { margin: 30px 0 24px; padding: 13px 18px; display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); border-radius: 11px; background: rgba(255,255,255,.6); box-shadow: 0 12px 40px rgba(38,54,48,.04); }
.metric-strip > div { display: flex; align-items: center; gap: 9px; min-width: 0; padding: 5px 14px; color: #75817d; border-right: 1px solid var(--line); }
.metric-strip > div:first-child { padding-left: 0; }
.metric-strip > div:last-child { border: 0; }
.metric-strip svg { flex: none; color: var(--ember); }
.metric-strip span { font-size: .7rem; white-space: nowrap; }
.metric-strip strong { margin-right: 3px; color: var(--ink); font-size: 1rem; }
.document-toolbar { min-height: 42px; margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.filter-tabs { display: flex; align-items: center; gap: 3px; padding: 3px; border-radius: 8px; color: #77847f; background: #eaece8; }
.filter-tabs > svg { margin: 0 5px 0 4px; }
.filter-tabs button { min-height: 29px; padding: 0 10px; color: inherit; border: 0; border-radius: 6px; background: transparent; cursor: pointer; font-size: .68rem; }
.filter-tabs button.is-active { color: var(--ink); background: white; box-shadow: 0 2px 9px rgba(35,51,45,.08); }
.detail-trigger { display: none; }
.document-list { display: grid; gap: 7px; }
.document-row { position: relative; min-height: 74px; padding: 12px 45px 12px 12px; display: grid; grid-template-columns: 42px minmax(140px, 1fr) auto auto; align-items: center; gap: 12px; border: 1px solid transparent; border-radius: 10px; cursor: pointer; transition: border .16s ease, background .16s ease, transform .16s ease; }
.document-row:hover { background: rgba(255,255,255,.7); transform: translateY(-1px); }
.document-row--selected { border-color: #c9d4ce; background: white; box-shadow: 0 8px 28px rgba(40,56,50,.07); }
.file-glyph { width: 42px; height: 45px; display: grid; place-items: center; color: #9a583a; border: 1px solid #e4c9b9; border-radius: 7px 7px 3px 7px; background: #fff5ef; font-size: .57rem; font-weight: 800; letter-spacing: .05em; }
.document-row__body { min-width: 0; }
.document-row__body strong, .document-row__body span, .document-row__body small { display: block; }
.document-row__body strong { overflow: hidden; color: #263a33; font-size: .82rem; text-overflow: ellipsis; white-space: nowrap; }
.document-row__body span { margin-top: 5px; color: #83908b; font-size: .66rem; }
.document-row__body small { margin-top: 4px; overflow: hidden; color: var(--danger); font-size: .62rem; text-overflow: ellipsis; white-space: nowrap; }
.status > span { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status--indexed { color: #38775e; background: #e5f1eb; }
.status--indexing, .status--pending { color: #9b653f; background: #f8eadf; }
.status--failed { color: #a4433c; background: #f8e5e3; }
.status--deleting { color: #697671; }
.row-actions { display: flex; align-items: center; }
.row-actions .button { color: #74817c; }
.row-cue { position: absolute; right: 14px; color: #a8b1ad; }
.list-empty, .loading-state { min-height: 310px; display: grid; place-content: center; justify-items: center; gap: 8px; color: #8a9691; text-align: center; }
.list-empty svg { color: var(--ember); }
.list-empty strong { color: var(--ink); font-family: "Songti SC", Georgia, serif; font-size: 1.05rem; }
.list-empty span { max-width: 280px; font-size: .74rem; }
.loading-state { grid-auto-flow: column; font-size: .76rem; }
.spin { animation: spin .9s linear infinite; }
.panel-error { padding: 10px 12px; color: var(--danger); border: 1px solid #e8c6c2; border-radius: 7px; background: #fff0ee; font-size: .72rem; }
.documents-detail-desktop { min-width: 0; border-left: 1px solid var(--line); background: #f0f3f1; }
.detail-panel { position: sticky; top: 0; height: 100vh; padding: 28px 22px 18px; display: flex; flex-direction: column; overflow: hidden; }
.detail-panel--empty { align-items: center; justify-content: center; gap: 7px; color: #84908b; text-align: center; }
.detail-panel--empty svg { margin-bottom: 5px; color: var(--ember); }
.detail-panel--empty strong { color: var(--ink); font-family: "Songti SC", Georgia, serif; }
.detail-panel--empty span { max-width: 230px; font-size: .7rem; line-height: 1.6; }
.detail-panel__header { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.detail-panel__header h2 { margin: 7px 0 0; overflow: hidden; font-family: "Songti SC", Georgia, serif; font-size: 1.25rem; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.document-meta { margin: 20px 0 16px; padding: 10px 0; display: grid; grid-template-columns: repeat(3, 1fr); border-block: 1px solid var(--line); }
.document-meta div { padding: 0 8px; border-right: 1px solid var(--line); }
.document-meta div:first-child { padding-left: 0; }
.document-meta div:last-child { border: 0; }
.document-meta dt { color: #8a9591; font-size: .58rem; text-transform: uppercase; }
.document-meta dd { margin: 4px 0 0; color: var(--ink); font-size: .7rem; font-weight: 700; }
.chunk-list { min-height: 0; flex: 1; display: grid; align-content: start; gap: 9px; overflow-y: auto; scrollbar-width: thin; }
.chunk-card { padding: 11px 12px; border: 1px solid #d9dfdc; border-radius: 8px; background: rgba(255,255,255,.72); }
.chunk-card > div { display: flex; gap: 7px; color: var(--ember-dark); font-size: .58rem; font-weight: 800; letter-spacing: .04em; }
.chunk-card p { margin: 7px 0 0; display: -webkit-box; overflow: hidden; color: #50605a; font-family: "Songti SC", Georgia, serif; font-size: .72rem; line-height: 1.7; -webkit-box-orient: vertical; -webkit-line-clamp: 5; }
.muted-copy { color: #8a9691; font-size: .72rem; line-height: 1.7; }
.detail-pagination { padding-top: 9px; display: flex; align-items: center; justify-content: center; gap: 10px; color: #84908b; border-top: 1px solid var(--line); font-size: .65rem; }
.evidence-drawer { position: fixed; inset: 0 0 0 auto; z-index: 51; width: min(390px, 92vw); background: #f0f3f1; box-shadow: -24px 0 80px rgba(0,0,0,.2); animation: drawer-in .25s ease; }

.session-rail { min-height: 0; margin-top: 14px; display: flex; flex: 1; flex-direction: column; }
.new-session { width: 100%; justify-content: flex-start; }
.session-rail .nav-label { margin-top: 18px; }
.session-list { min-height: 0; display: grid; align-content: start; gap: 4px; overflow-y: auto; scrollbar-width: thin; }
.session-item { display: grid; grid-template-columns: minmax(0, 1fr) 30px; align-items: center; border-radius: 7px; color: #aebdb7; }
.session-item > button:first-child { min-width: 0; padding: 8px 7px; color: inherit; border: 0; background: transparent; text-align: left; cursor: pointer; }
.session-item strong, .session-item span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-item strong { font-size: .68rem; font-weight: 650; }
.session-item span { margin-top: 3px; color: #748b82; font-size: .56rem; }
.session-item .button { width: 28px; height: 28px; opacity: 0; color: #91a49d; }
.session-item:hover { background: rgba(255,255,255,.05); }
.session-item:hover .button { opacity: 1; }
.session-item--active { color: white; background: var(--forest-2); box-shadow: inset 3px 0 var(--ember); }
.session-empty { margin: 8px; color: #70867d; font-size: .62rem; }

.chat-workspace { display: grid; grid-template-columns: minmax(500px, 1fr) 330px; min-height: 100vh; }
.chat-main { min-width: 0; height: 100vh; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; background: rgba(250,250,247,.82); }
.chat-header { min-height: 78px; padding: 20px clamp(20px, 3vw, 38px); display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.62); backdrop-filter: blur(12px); }
.chat-header h1 { margin: 5px 0 0; font-family: "Songti SC", Georgia, serif; font-size: 1.35rem; font-weight: 600; }
.evidence-trigger { display: none; }
.conversation-scroll { min-height: 0; padding: 26px clamp(20px, 4vw, 54px); overflow-y: auto; scroll-behavior: smooth; }
.chat-empty { min-height: 100%; display: grid; place-content: center; justify-items: center; text-align: center; }
.chat-empty > div { width: 57px; height: 57px; margin-bottom: 19px; display: grid; place-items: center; color: var(--ember); border: 1px solid #ddc9bd; border-radius: 50%; background: white; box-shadow: 0 16px 45px rgba(39,55,49,.08); }
.chat-empty h2 { margin: 8px 0 7px; font-family: "Songti SC", Georgia, serif; font-size: 1.45rem; font-weight: 600; }
.chat-empty > span { max-width: 360px; color: #7e8a85; font-size: .75rem; line-height: 1.7; }
.message-list, .streaming-turn { display: grid; gap: 21px; }
.streaming-turn { margin-top: 21px; }
.message { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 10px; align-items: start; animation: page-enter .25s ease both; }
.message--user { margin-left: clamp(20px, 15%, 110px); grid-template-columns: minmax(0, 1fr); }
.message--user .message-body { justify-self: end; max-width: 82%; padding: 10px 13px; border-radius: 12px 12px 3px 12px; background: #e2ebe7; }
.message--user .message-avatar { display: none; }
.message-avatar { width: 28px; height: 28px; display: grid; place-items: center; color: white; border-radius: 50%; background: var(--ember); box-shadow: 0 5px 14px rgba(172,86,53,.18); }
.message-body { min-width: 0; color: #374943; }
.message-body header { margin: 2px 0 7px; display: flex; align-items: baseline; gap: 8px; }
.message-body header strong { font-size: .72rem; }
.message-body header time { color: #929c98; font-size: .58rem; }
.message-body p { margin: 0; white-space: pre-wrap; font-size: .82rem; line-height: 1.82; }
.answer-copy { font-family: "Songti SC", Georgia, serif; }
.citation { display: inline-flex; margin: 0 2px; padding: 1px 5px; color: #a75435; border: 1px solid #dfc1af; border-radius: 4px; background: #fff5ef; cursor: pointer; font-family: "Avenir Next", sans-serif; font-size: .62rem; font-weight: 800; vertical-align: .08em; }
.citation--deleted { color: #8d9692; border-color: #d9dddb; background: #f0f1ee; cursor: default; }
.failed-message { display: flex; align-items: center; gap: 7px; color: var(--danger); }
.research-state { display: flex; align-items: center; gap: 8px; color: #73827c; font-family: "Avenir Next", sans-serif; font-size: .72rem !important; }
.typing-cursor { display: inline-block; width: 2px; height: 1em; margin-left: 3px; background: var(--ember); animation: blink .8s step-end infinite; vertical-align: -.12em; }
.pulse { color: var(--ember); animation: pulse 1.2s ease-in-out infinite; }
.chat-composer { position: relative; margin: 0 clamp(20px, 4vw, 54px) 20px; padding: 10px 10px 24px 13px; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 9px; border: 1px solid #cdd7d2; border-radius: 11px; background: white; box-shadow: 0 10px 35px rgba(37,54,47,.08); }
.chat-composer textarea { width: 100%; min-height: 45px; max-height: 140px; padding: 5px 0; resize: none; color: var(--ink); border: 0; outline: 0; background: transparent; font-size: .8rem; line-height: 1.55; }
.chat-composer textarea::placeholder { color: #9aa4a0; }
.chat-composer small { position: absolute; bottom: 7px; left: 13px; color: #a0aaa6; font-size: .54rem; }
.evidence-desktop { min-width: 0; border-left: 1px solid var(--line); background: #f0f3f1; }
.evidence-panel { height: 100vh; padding: 22px 17px 16px; display: flex; flex-direction: column; overflow: hidden; }
.evidence-header { min-height: 47px; display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: start; gap: 7px; }
.evidence-header h2 { margin: 5px 0 0; font-family: "Songti SC", Georgia, serif; font-size: 1.15rem; font-weight: 600; }
.evidence-header > span { margin-top: 7px; color: #82908a; font-size: .62rem; }
.evidence-empty { flex: 1; display: grid; place-content: center; justify-items: center; gap: 7px; color: #85918c; text-align: center; }
.evidence-empty svg { margin-bottom: 4px; color: var(--ember); }
.evidence-empty strong { color: var(--ink); font-family: "Songti SC", Georgia, serif; }
.evidence-empty span { max-width: 220px; font-size: .68rem; line-height: 1.6; }
.source-list { max-height: 42%; margin: 16px 0 11px; display: grid; align-content: start; gap: 7px; overflow-y: auto; }
.source-card { width: 100%; padding: 10px; display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 7px; color: #52625c; border: 1px solid #d8dfdb; border-radius: 8px; background: rgba(255,255,255,.64); cursor: pointer; text-align: left; }
.source-card > svg { margin-top: 1px; color: var(--ember); }
.source-card strong, .source-card small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-card strong { color: #354a42; font-size: .68rem; }
.source-card small { margin-top: 4px; color: #89948f; font-size: .58rem; }
.source-card--active { border-color: #d2a78e; background: white; box-shadow: inset 3px 0 var(--ember), 0 6px 20px rgba(41,58,51,.05); }
.source-detail { min-height: 0; flex: 1; padding: 14px; overflow-y: auto; color: #e7efeb; border-radius: 10px; background: var(--forest); }
.source-detail header { display: flex; justify-content: space-between; gap: 10px; }
.source-detail header strong { font-size: .68rem; }
.source-detail header span { color: #9fb1aa; font-size: .57rem; }
.source-detail p { margin: 12px 0 0; white-space: pre-wrap; color: #d8e2de; font-family: "Songti SC", Georgia, serif; font-size: .72rem; line-height: 1.85; }

@keyframes blink { 50% { opacity: 0; } }
@keyframes pulse { 50% { opacity: .45; transform: scale(.92); } }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes drawer-in { from { transform: translateX(100%); } }

@keyframes page-enter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes slide-in { from { transform: translateX(-100%); } }

@media (max-width: 767px) {
  .app-shell { display: block; padding-top: 58px; }
  .sidebar { display: none; }
  .mobile-header { position: fixed; inset: 0 0 auto; z-index: 40; height: 58px; padding: 0 14px; display: flex; align-items: center; gap: 9px; color: #edf3ef; background: var(--forest); box-shadow: 0 4px 20px rgba(25,45,37,.18); }
  .mobile-header .brand-lockup__mark { width: 29px; height: 29px; }
  .mobile-header strong { font-size: .7rem; letter-spacing: .1em; }
  .mobile-header > :last-child { margin-left: auto; }
  .route-canvas { min-height: calc(100vh - 58px); }
}

@media (max-width: 1099px) {
  .documents-workspace { display: block; }
  .documents-detail-desktop { display: none; }
  .detail-trigger { display: inline-flex; }
  .chat-workspace { display: block; }
  .evidence-desktop { display: none; }
  .evidence-trigger { display: inline-flex; }
}

@media (max-width: 640px) {
  .documents-main { padding: 24px 16px; }
  .page-header { display: grid; }
  .metric-strip { grid-template-columns: 1fr 1fr; gap: 7px; }
  .metric-strip > div { border: 0; padding: 5px; }
  .document-toolbar { align-items: flex-start; }
  .filter-tabs { max-width: 100%; overflow-x: auto; }
  .document-row { grid-template-columns: 40px minmax(0, 1fr); padding-right: 38px; }
  .document-row .status { grid-column: 2; justify-self: start; }
  .row-actions { grid-column: 2; }
  .chat-main { height: calc(100vh - 58px); }
  .chat-header { padding: 14px 16px; }
  .conversation-scroll { padding: 20px 16px; }
  .chat-composer { margin: 0 12px 12px; }
  .message--user { margin-left: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
