@import url("https://fonts.googleapis.com/css2?family=Caveat:wght@600&family=Fraunces:opsz,wght@9..144,600&family=Nunito:wght@400;600;700;800&display=swap");

:root {
  --leaf: #52AE2B;
  --leaf-deep: #3A8A1A;
  --leaf-soft: #E6F3DC;
  --sky: #A1CCFC;
  --sky-soft: #E8F2FE;
  --ink: #173E59;
  --ink-2: #4A6478;
  --ink-3: #8497A6;
  --paper: #FBF8F1;
  --card: #FFFFFF;
  --line: #E7E1D3;
  --amber: #E8A317;
  --amber-soft: #FDF3DC;
  --red: #D2553F;
  --red-soft: #FBE7E2;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(23, 62, 89, .06), 0 6px 20px rgba(23, 62, 89, .06);
  --sans: "Nunito", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --serif: "Fraunces", "Noto Serif SC", Georgia, serif;
  --hand: "Caveat", "Nunito", cursive;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--leaf-deep); }
.hidden { display: none !important; }

/* ---------- brand mark */
.mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--leaf-deep); color: #fff;
  display: grid; place-items: center;
  font-family: "Dela Gothic One", var(--sans); font-weight: 800; font-size: 15px; letter-spacing: -.5px;
  flex: none;
}
.mark.big { width: 56px; height: 56px; border-radius: 16px; font-size: 24px; }

/* ---------- login */
.login-wrap { min-height: 100%; display: grid; place-items: center; padding: 24px; position: relative; overflow: hidden; }
.login-wrap::before {
  content: ""; position: absolute; inset: auto -10% -30% -10%; height: 55%;
  background: radial-gradient(60% 80% at 50% 100%, var(--leaf-soft), transparent 70%);
  z-index: 0;
}
.login-card {
  position: relative; z-index: 1;
  width: min(420px, 100%); background: var(--card); border-radius: 22px; padding: 32px 28px 26px;
  box-shadow: var(--shadow); border: 1px solid var(--line);
}
.login-card h1 { font-family: var(--serif); font-size: 26px; margin: 14px 0 2px; letter-spacing: -.3px; }
.login-card .sub { color: var(--ink-2); margin: 0 0 22px; }
.hand { font-family: var(--hand); color: var(--leaf-deep); font-size: 21px; line-height: 1.1; }
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 700; font-size: 13px; color: var(--ink-2); margin-bottom: 6px; }
.names { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1.5px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 14px;
  font-weight: 700; font-size: 14px; color: var(--ink-2); transition: .15s;
}
.chip:hover { border-color: var(--leaf); }
.chip.on { background: var(--leaf-soft); border-color: var(--leaf); color: var(--leaf-deep); }
.input {
  width: 100%; border: 1.5px solid var(--line); border-radius: 12px; padding: 11px 14px; background: #fff;
  outline: none; transition: border-color .15s;
}
.input:focus { border-color: var(--leaf); }
.btn {
  border: 0; border-radius: 12px; padding: 11px 18px; font-weight: 800;
  background: var(--leaf-deep); color: #fff; transition: transform .1s, background .15s;
}
.btn:hover { background: #2F7614; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; color: var(--ink-2); border: 1.5px solid var(--line); }
.btn.ghost:hover { border-color: var(--ink-3); background: #fff; }
.err { color: var(--red); font-size: 13.5px; min-height: 20px; margin: 4px 0 8px; }
.fine { color: var(--ink-3); font-size: 12.5px; margin-top: 16px; line-height: 1.5; }

/* ---------- app layout */
.app { display: grid; grid-template-columns: 280px 1fr; height: 100%; }
.side {
  background: #F4EFE3; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0;
}
.side-top { padding: 18px 16px 12px; display: flex; align-items: center; gap: 10px; }
.side-top .t { font-weight: 800; line-height: 1.15; }
.side-top .t small { display: block; font-weight: 600; color: var(--ink-3); font-size: 12px; }
.new-btn {
  margin: 4px 14px 12px; display: flex; align-items: center; gap: 8px; justify-content: center;
  border: 1.5px dashed #C9C0AB; background: transparent; border-radius: 12px; padding: 10px; font-weight: 800; color: var(--ink);
}
.new-btn:hover { border-color: var(--leaf); color: var(--leaf-deep); background: #fff; }
.conv-list { flex: 1; overflow-y: auto; padding: 0 8px 8px; }
.conv-group { font-size: 11.5px; font-weight: 800; color: var(--ink-3); text-transform: uppercase; letter-spacing: .6px; padding: 12px 10px 4px; }
.conv {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; border: 0; background: transparent;
  padding: 9px 10px; border-radius: 10px; color: var(--ink); font-size: 14px;
}
.conv:hover { background: rgba(255,255,255,.7); }
.conv.on { background: #fff; box-shadow: 0 1px 3px rgba(23,62,89,.08); }
.conv .ttl { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: transparent; }
.dot.PASS { background: var(--leaf); }
.dot.MINOR { background: var(--amber); }
.dot.REDO { background: var(--red); }
.badge-new { background: var(--sky); color: var(--ink); font-size: 10.5px; font-weight: 800; padding: 1px 6px; border-radius: 6px; }
.side-foot { border-top: 1px solid var(--line); padding: 12px 16px; display: flex; align-items: center; gap: 10px; font-size: 14px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--sky); display: grid; place-items: center; font-weight: 800; font-size: 13px; flex: none; }
.side-foot .who { flex: 1; font-weight: 700; }
.side-foot a, .side-foot button.link { font-size: 13px; color: var(--ink-3); background: none; border: 0; padding: 0; text-decoration: none; }
.side-foot a:hover, .side-foot button.link:hover { color: var(--ink); }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar { display: none; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--paper); }
.icon-btn { border: 0; background: transparent; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; }
.icon-btn:hover { background: #fff; }

.thread { flex: 1; overflow-y: auto; padding: 28px 24px 12px; }
.thread-inner { max-width: 760px; margin: 0 auto; }

/* ---------- empty state */
.hello { padding: 34px 0 10px; }
.hello h2 { font-family: var(--serif); font-size: 30px; margin: 4px 0 6px; letter-spacing: -.4px; }
.hello p { color: var(--ink-2); margin: 0 0 22px; max-width: 560px; }
.starters { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.starter {
  text-align: left; background: var(--card); border: 1.5px solid var(--line); border-radius: var(--radius);
  padding: 16px 16px 14px; transition: .15s; position: relative; overflow: hidden;
}
.starter:hover { border-color: var(--leaf); transform: translateY(-1px); box-shadow: var(--shadow); }
.starter .ic { font-size: 22px; line-height: 1; }
.starter b { display: block; margin: 8px 0 2px; font-size: 15.5px; }
.starter span { color: var(--ink-2); font-size: 13.5px; }
.starter::after {
  content: ""; position: absolute; right: -18px; bottom: -18px; width: 64px; height: 64px; border-radius: 50%;
  background: var(--leaf-soft); opacity: .7;
}
.starter.sky::after { background: var(--sky-soft); }
.starter.amber::after { background: var(--amber-soft); }
.tips { margin-top: 18px; color: var(--ink-3); font-size: 13px; }

/* ---------- messages */
.msg { display: flex; gap: 12px; margin: 0 0 22px; }
.msg.user { justify-content: flex-end; }
.msg .bubble { max-width: 86%; }
.msg.user .bubble {
  background: var(--ink); color: #fff; border-radius: 18px 18px 4px 18px; padding: 10px 15px; white-space: pre-wrap; word-wrap: break-word;
}
.msg.user .meta-tag { display: inline-block; font-size: 11.5px; font-weight: 800; background: rgba(255,255,255,.15); border-radius: 6px; padding: 1px 7px; margin-bottom: 6px; }
.msg.user .imgs { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; margin-bottom: 6px; }
.msg.user .imgs img { width: 120px; height: 120px; object-fit: cover; border-radius: 12px; cursor: zoom-in; border: 2px solid #fff; box-shadow: var(--shadow); }
.msg.ai .mark { margin-top: 2px; }
.msg.ai .bubble { flex: 1; min-width: 0; }
.msg.ai .body { word-wrap: break-word; }
.msg.admin .avatar { background: #FFD9A8; }
.from-chloe { font-family: var(--hand); font-size: 20px; color: #B86A00; line-height: 1; margin-bottom: 4px; }
.msg.admin .body { background: #FFF6E8; border: 1px solid #F3DDB8; border-radius: 4px 16px 16px 16px; padding: 10px 14px; }

.verdict {
  display: inline-flex; align-items: center; gap: 8px; font-weight: 800; border-radius: 12px; padding: 7px 13px; margin: 2px 0 10px; font-size: 14.5px;
}
.verdict.PASS { background: var(--leaf-soft); color: var(--leaf-deep); }
.verdict.MINOR { background: var(--amber-soft); color: #9A6A00; }
.verdict.REDO { background: var(--red-soft); color: #A63A27; }
.verdict small { font-weight: 600; opacity: .8; }
.asked {
  margin-top: 10px; display: flex; gap: 10px; align-items: flex-start; background: var(--sky-soft); border-radius: 12px; padding: 10px 13px; font-size: 13.5px; color: var(--ink-2);
}
.asked b { color: var(--ink); }

.body h1, .body h2, .body h3, .body h4 { font-size: 15.5px; margin: 16px 0 6px; font-weight: 800; }
.body p { margin: 0 0 10px; }
.body ul, .body ol { margin: 0 0 10px; padding-left: 22px; }
.body li { margin: 3px 0; }
.body blockquote { margin: 8px 0 12px; padding: 8px 14px; border-left: 3px solid var(--leaf); background: #fff; border-radius: 0 10px 10px 0; color: var(--ink); }
.body code { background: #EFEADD; padding: 1px 5px; border-radius: 5px; font-size: 13px; }
.body pre { background: #fff; border: 1px solid var(--line); padding: 10px 12px; border-radius: 10px; overflow-x: auto; white-space: pre-wrap; }
.body hr { border: 0; border-top: 1px dashed var(--line); margin: 14px 0; }
.body > *:last-child { margin-bottom: 0; }
.copy-row { margin-top: 8px; display: flex; gap: 8px; }
.mini { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 3px 10px; font-size: 12.5px; color: var(--ink-2); font-weight: 700; }
.mini:hover { border-color: var(--ink-3); color: var(--ink); }
.typing span { display: inline-block; width: 7px; height: 7px; margin-right: 4px; border-radius: 50%; background: var(--leaf); animation: b 1s infinite ease-in-out; }
.typing span:nth-child(2) { animation-delay: .15s; } .typing span:nth-child(3) { animation-delay: .3s; }
@keyframes b { 0%, 80%, 100% { transform: scale(.6); opacity: .4; } 40% { transform: scale(1); opacity: 1; } }
.err-box { background: var(--red-soft); color: #A63A27; border-radius: 12px; padding: 10px 14px; font-size: 14px; }

/* ---------- composer */
.composer-wrap { padding: 8px 24px 18px; }
.composer {
  max-width: 760px; margin: 0 auto; background: var(--card); border: 1.5px solid var(--line); border-radius: 20px;
  box-shadow: var(--shadow); padding: 10px 12px 10px; transition: border-color .15s;
}
.composer.drag { border-color: var(--leaf); background: var(--leaf-soft); }
.composer:focus-within { border-color: #BFD9AE; }
.ctx { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 0 2px 8px; }
.ctx .lab { font-size: 12px; font-weight: 800; color: var(--ink-3); margin-right: 2px; }
.ctx .chip { padding: 3px 11px; font-size: 13px; }
.ctx .x { border: 0; background: none; color: var(--ink-3); font-size: 13px; padding: 0 4px; }
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; padding: 2px 2px 8px; }
.thumb { position: relative; width: 64px; height: 64px; }
.thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.thumb .rm { position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; border-radius: 50%; border: 0; background: var(--ink); color: #fff; font-size: 12px; line-height: 20px; padding: 0; }
.thumb.loading img { opacity: .4; }
.row { display: flex; align-items: flex-end; gap: 8px; }
.row textarea {
  flex: 1; border: 0; outline: none; resize: none; min-height: 26px; max-height: 220px; padding: 6px 4px; background: transparent; line-height: 1.5;
}
.attach { border: 0; background: var(--sky-soft); width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; color: var(--ink); flex: none; }
.attach:hover { background: var(--sky); }
.send { width: 38px; height: 38px; padding: 0; border-radius: 12px; display: grid; place-items: center; flex: none; }
.foot-note { max-width: 760px; margin: 8px auto 0; font-size: 12px; color: var(--ink-3); text-align: center; }

/* ---------- lightbox */
.lightbox { position: fixed; inset: 0; background: rgba(15, 30, 40, .82); display: grid; place-items: center; z-index: 50; padding: 20px; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 10px; }

/* ---------- mobile */
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 25% 0 0; z-index: 40; transform: translateX(-102%); transition: transform .2s; box-shadow: 8px 0 30px rgba(0,0,0,.12); }
  .side.open { transform: none; }
  .scrim { position: fixed; inset: 0; background: rgba(23,62,89,.25); z-index: 30; }
  .topbar { display: flex; }
  .thread { padding: 18px 14px 8px; }
  .composer-wrap { padding: 6px 10px 12px; }
  .starters { grid-template-columns: 1fr; }
  .ctx { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .ctx::-webkit-scrollbar { display: none; }
  .ctx .chip, .ctx .lab { flex: none; }
  .hello { padding-top: 10px; }
  .hello h2 { font-size: 25px; }
  .msg .bubble { max-width: 92%; }
}

/* ---------- admin */
.admin { max-width: 1040px; margin: 0 auto; padding: 22px 22px 60px; }
.admin-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.admin-head h1 { font-family: var(--serif); font-size: 24px; margin: 0; flex: 1; }
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tab { border: 0; background: none; padding: 10px 14px; font-weight: 800; color: var(--ink-3); border-bottom: 3px solid transparent; white-space: nowrap; }
.tab.on { color: var(--ink); border-color: var(--leaf); }
.tab .n { background: var(--red); color: #fff; border-radius: 999px; font-size: 11px; padding: 1px 7px; margin-left: 4px; }
.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat .k { font-size: 12.5px; color: var(--ink-3); font-weight: 800; }
.stat .v { font-size: 26px; font-weight: 800; margin-top: 2px; font-family: var(--serif); }
.stat .v small { font-size: 14px; color: var(--ink-3); font-family: var(--sans); }
.meter { height: 8px; border-radius: 6px; background: #EFEADD; margin-top: 8px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--leaf); border-radius: 6px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 14px; }
.panel h3 { margin: 0 0 10px; font-size: 15px; }
.list-row { display: flex; gap: 12px; align-items: center; padding: 9px 0; border-top: 1px solid #F1ECE0; font-size: 14px; }
.list-row:first-of-type { border-top: 0; }
.list-row .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.muted { color: var(--ink-3); font-size: 13px; }
.pill { font-size: 12px; font-weight: 800; border-radius: 8px; padding: 2px 8px; white-space: nowrap; }
.pill.PASS { background: var(--leaf-soft); color: var(--leaf-deep); }
.pill.MINOR { background: var(--amber-soft); color: #9A6A00; }
.pill.REDO { background: var(--red-soft); color: #A63A27; }
.pill.open { background: var(--sky-soft); color: var(--ink); }
.pill.answered { background: var(--leaf-soft); color: var(--leaf-deep); }
.pill.dismissed { background: #EFEADD; color: var(--ink-3); }
.q { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px; }
.q .top { display: flex; gap: 10px; align-items: center; margin-bottom: 6px; }
.q .qt { font-weight: 800; font-size: 15.5px; margin-bottom: 4px; }
.q .orig { color: var(--ink-2); font-size: 13.5px; background: #FAF7EF; border-radius: 10px; padding: 8px 10px; margin: 6px 0 10px; white-space: pre-wrap; max-height: 120px; overflow: auto; }
.q textarea { width: 100%; min-height: 74px; border: 1.5px solid var(--line); border-radius: 12px; padding: 9px 12px; outline: none; resize: vertical; }
.q textarea:focus { border-color: var(--leaf); }
.q .acts { display: flex; gap: 10px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.q label.ck { font-size: 13.5px; color: var(--ink-2); display: flex; gap: 6px; align-items: center; flex: 1; }
.kb-area { width: 100%; min-height: 62vh; border: 1.5px solid var(--line); border-radius: 14px; padding: 14px 16px; font-family: ui-monospace, "SF Mono", Menlo, "Noto Sans SC", monospace; font-size: 13.5px; line-height: 1.6; outline: none; resize: vertical; background: #fff; }
.kb-area:focus { border-color: var(--leaf); }
.kb-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.kb-bar .grow { flex: 1; }
.todo-hint { background: var(--amber-soft); border-radius: 12px; padding: 10px 14px; font-size: 13.5px; margin-bottom: 10px; }
.viewer { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
@media (max-width: 820px) { .cards { grid-template-columns: repeat(2, 1fr); } }
