@font-face { font-family: Inter; src: url(/fonts/Inter-Regular.ttf) format("truetype"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: Inter; src: url(/fonts/Inter-SemiBold.ttf) format("truetype"); font-weight: 500 700; font-style: normal; font-display: swap; }
@font-face { font-family: Inter; src: url(/fonts/Inter-Italic.ttf) format("truetype"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Space Grotesk"; src: url(/fonts/SpaceGrotesk-SemiBold.ttf) format("truetype"); font-weight: 500 700; font-display: swap; }

:root {
  --bg: #FFFFFF;
  --surface: #F5F7FB;
  --line: #E5E9F2;
  --line-strong: #C9D2E3;
  --ink: #14213D;
  --muted: #4B5675;
  --accent: #2563EB;
  --accent-ink: #1D4ED8;
  --accent-soft: #EEF3FF;
  --warn: #9A3412;
  --warn-soft: #FFF1E6;
  --good: #166534;
  --good-soft: #E8F6EC;
  --bad: #B42318;
  --radius: 14px;
  --head: 'Space Grotesk', system-ui, sans-serif;
  --body: Inter, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --field: #FFFFFF;
  --card: #FFFFFF;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0E1626; --surface: #17223A; --line: #243150; --line-strong: #34446A; --ink: #E8EDF7; --muted: #A3AFC7;
    --accent: #3B82F6; --accent-ink: #93B4F8; --accent-soft: #1A2B4F; --warn: #FDBA8C; --warn-soft: #3A2414;
    --good: #86EFAC; --good-soft: #12301F; --bad: #F87171; --field: #121C30; --card: #121C30; color-scheme: dark;
  }
  a:hover { color: #BFD3FF !important; }
  .save-bar { background: rgba(14,22,38,0.95) !important; }
  .toast { background: #E8EDF7 !important; color: #0E1626 !important; }
  .toast.error { background: #B42318 !important; color: #fff !important; }
  .btn.primary, .btn.primary:hover { color: #fff; }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 15px; line-height: 1.5; }
a { color: var(--accent-ink); }
a:hover { color: #1E3A8A; }
h1, h2, h3 { font-family: var(--head); letter-spacing: -0.01em; margin: 0; }
h1 { font-size: 34px; font-weight: 600; }
h2 { font-size: 20px; font-weight: 600; }
h3 { font-size: 16px; font-weight: 600; }
p { margin: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid #93B4F8; outline-offset: 2px; }

/* Top bar */
.top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 24px; padding: 14px 32px; border-bottom: 1px solid var(--line); background: var(--bg); position: sticky; top: 0; z-index: 10; }
.brand { font-family: var(--head); font-weight: 700; font-size: 22px; letter-spacing: -0.02em; color: var(--ink); text-decoration: none; }
.brand span { color: var(--accent); }
.nav { display: flex; flex-wrap: wrap; gap: 4px; flex: 1 1 auto; }
.nav a { text-decoration: none; padding: 9px 14px; border-radius: 99px; color: var(--muted); font-size: 14px; }
.nav a:hover { background: var(--surface); color: var(--ink); }
.nav a.on { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }

.main { max-width: 1200px; margin: 0 auto; padding: 32px; display: flex; flex-direction: column; gap: 24px; outline: none; }
.narrow { max-width: 760px; }

/* Buttons and fields */
.btn { font: inherit; font-size: 14px; font-weight: 500; min-height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--bg); color: var(--ink); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--surface); color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--accent-ink); color: #fff; }
.btn.pill { border-radius: 99px; }
.btn.small { min-height: 32px; padding: 0 10px; font-size: 13px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface); }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: 0.55; cursor: progress; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 12px; }

label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 500; color: var(--muted); }
input, textarea, select { font: inherit; font-size: 15px; color: var(--ink); background: var(--field); border: 1px solid var(--line-strong); border-radius: 10px; padding: 9px 12px; width: 100%; }
textarea { min-height: 90px; resize: vertical; line-height: 1.5; }
textarea.tall { min-height: 320px; }
textarea.code { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 13px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.hint { font-size: 13px; color: var(--muted); }
.check { flex-direction: row; align-items: center; gap: 8px; font-size: 14px; color: var(--ink); }
.check input { width: auto; }

/* Cards */
.card { border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; background: var(--bg); }
.card.soft { background: var(--surface); border-color: transparent; }
.card h2 { margin-bottom: 12px; }
.muted { color: var(--muted); }
.empty { color: var(--muted); font-size: 14px; padding: 8px 0; }

/* Dashboard */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.stats > div { padding: 18px 22px; border-right: 1px solid var(--line); }
.stats > div:last-child { border-right: 0; }
.stats .n { font-family: var(--head); font-size: 34px; font-weight: 600; }
.stats .l { font-size: 13px; color: var(--muted); }
.cols { display: flex; flex-wrap: wrap; gap: 24px; }
.cols > .wide { flex: 2 1 460px; min-width: 0; }
.cols > .side { flex: 1 1 280px; min-width: 0; }
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.list li { border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list a.item { display: flex; justify-content: space-between; gap: 12px; padding: 12px 4px; text-decoration: none; color: var(--ink); }
.list a.item:hover { background: var(--surface); }
.tag { font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 99px; background: var(--surface); color: var(--muted); white-space: nowrap; }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.blue { background: var(--accent-soft); color: var(--accent-ink); }
.tag.good { background: var(--good-soft); color: var(--good); }
.pipe { display: flex; height: 12px; border-radius: 99px; overflow: hidden; background: var(--line); }
.pipe span { display: block; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 13px; color: var(--muted); margin-top: 10px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* Board */
.board-wrap { overflow-x: auto; padding-bottom: 8px; }
.board { display: grid; grid-template-columns: repeat(5, minmax(200px, 1fr)); gap: 12px; min-width: 1040px; }
.col { background: var(--surface); border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 8px; min-height: 360px; }
.col.over { background: var(--accent-soft); outline: 2px dashed var(--accent); }
.col-head { font-size: 13px; font-weight: 600; color: var(--muted); display: flex; justify-content: space-between; padding: 0 2px 4px; }
.kcard { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px; cursor: grab; text-decoration: none; color: var(--ink); display: block; }
.kcard:hover { border-color: var(--line-strong); color: var(--ink); }
.kcard.dragging { opacity: 0.4; }
.kcard .t { font-weight: 600; font-size: 14px; }
.kcard .c { font-size: 13px; color: var(--muted); }
.kcard .m { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

/* Job page */
.job-head { display: flex; flex-wrap: wrap; gap: 16px; justify-content: space-between; align-items: flex-start; }
.job-head .meta { color: var(--muted); font-size: 14px; margin-top: 4px; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--line); }
.tabs button { font: inherit; font-size: 14px; background: none; border: 0; border-bottom: 2px solid transparent; padding: 10px 14px; color: var(--muted); cursor: pointer; margin-bottom: -1px; }
.tabs button.on { color: var(--ink); font-weight: 600; border-bottom-color: var(--accent); }
.score { font-family: var(--head); font-size: 48px; font-weight: 600; line-height: 1; }
.bar { height: 10px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 13px; padding: 4px 10px; border-radius: 99px; background: var(--surface); }
.chip.yes { background: var(--good-soft); color: var(--good); }
.chip.no { background: var(--warn-soft); color: var(--warn); }
ul.plain { margin: 0; padding-left: 18px; line-height: 1.7; }

.doc-layout { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.doc-layout > .doc { flex: 3 1 520px; min-width: 0; }
.doc-layout > .chat { flex: 2 1 300px; min-width: 0; position: sticky; top: 84px; }
.part { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-bottom: 10px; }
.part:hover { border-color: var(--line-strong); }
.part-tools { display: flex; gap: 4px; justify-content: flex-end; margin-top: 6px; }
.suggest { background: var(--accent-soft); border-radius: 10px; padding: 12px; margin-top: 10px; }

.md h1 { font-size: 24px; margin-bottom: 4px; }
.md h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent-ink); border-bottom: 1px solid var(--line); padding-bottom: 4px; margin: 4px 0 8px; }
.md h3 { font-size: 15px; margin: 6px 0 2px; }
.md p { margin: 0 0 8px; }
.md ul { margin: 0 0 8px; padding-left: 20px; }
.md .meta { color: var(--muted); font-size: 13px; font-style: italic; }
.md .contact { color: var(--muted); font-size: 14px; }

.chat-box { border: 1px solid var(--line); border-radius: 14px; display: flex; flex-direction: column; max-height: calc(100vh - 120px); }
.chat-log { padding: 14px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; min-height: 160px; flex: 1 1 auto; }
.bubble { padding: 9px 12px; border-radius: 12px; font-size: 14px; max-width: 90%; white-space: pre-wrap; }
.bubble.user { align-self: flex-end; background: var(--accent); color: #fff; }
.bubble.assistant { align-self: flex-start; background: var(--surface); }
.chat-form { border-top: 1px solid var(--line); padding: 10px; display: flex; gap: 8px; }
.chat-form textarea { min-height: 44px; height: 44px; }

.copyrow { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 10px 0; border-top: 1px solid var(--line); }
.copyrow:first-child { border-top: 0; }
.copyrow .k { font-size: 13px; color: var(--muted); }
.copyrow .v { white-space: pre-wrap; word-break: break-word; }

/* Profile */
.entry { border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.save-bar { position: sticky; bottom: 0; background: rgba(255,255,255,0.95); border-top: 1px solid var(--line); padding: 12px 0; display: flex; gap: 10px; align-items: center; justify-content: flex-end; }

/* Sign in */
.auth { max-width: 400px; width: 100%; margin: 8vh auto 0; display: flex; flex-direction: column; gap: 16px; }
.auth .lead { color: var(--muted); }
.auth .switch { display: flex; gap: 4px; background: var(--surface); padding: 4px; border-radius: 12px; }
.auth .switch button { flex: 1; font: inherit; font-size: 14px; border: 0; background: none; color: var(--muted); padding: 9px; border-radius: 9px; cursor: pointer; }
.auth .switch button.on { background: var(--bg); color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px rgba(20,33,61,.12); }
.auth .fine { font-size: 13px; color: var(--muted); }
.linkbtn { font: inherit; font-size: 13px; background: none; border: 0; color: var(--accent-ink); cursor: pointer; padding: 0; text-decoration: underline; align-self: flex-start; }
.ai-pick { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.ai-pick label { flex-direction: row; gap: 10px; align-items: flex-start; border: 1px solid var(--line-strong); border-radius: 12px; padding: 14px; cursor: pointer; color: var(--ink); font-size: 14px; }
.ai-pick label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.ai-pick input { width: auto; margin-top: 3px; accent-color: var(--accent); }
.ai-pick small { display: block; color: var(--muted); font-weight: 400; margin-top: 2px; }

/* Footer */
.foot { max-width: 1200px; margin: 0 auto; padding: 24px 32px 40px; display: flex; flex-wrap: wrap; gap: 8px 20px; font-size: 13px; color: var(--muted); }
.foot a { color: var(--muted); }
.foot span { margin-right: auto; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: calc(100% - 32px); z-index: 50; }
.toast.show { opacity: 1; }
.toast.error { background: var(--bad); }

.spin { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; display: inline-block; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 640px) {
  .top { padding: 12px 16px; }
  .main { padding: 20px 16px; }
  .foot { padding: 20px 16px 32px; }
  h1 { font-size: 28px; }
  .stats > div { border-right: 0; border-bottom: 1px solid var(--line); }
  .doc-layout > .chat { position: static; }
}
