/* ---------- tokens ---------- */
:root,
:root[data-theme="dark"] {
  --bg: #0a0c10;
  --panel: #12151c;
  --panel-2: #171b24;
  --line: #232936;
  --text: #e6edf3;
  --muted: #8b97a8;
  --dim: #626e80;
  --accent: #f0a05a;
  --accent-soft: rgba(240, 160, 90, 0.12);
  --ok: #6ee7a0;
  --user-bg: #1b2130;
  --focus: #f0a05a;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.02) inset;
}

:root[data-theme="light"] {
  --bg: #f7f7f5;
  --panel: #ffffff;
  --panel-2: #f1f1ee;
  --line: #dedbd4;
  --text: #1d1c1a;
  --muted: #5f5c56;
  --dim: #86827a;
  --accent: #b45309;
  --accent-soft: rgba(180, 83, 9, 0.09);
  --ok: #0f7a4a;
  --user-bg: #eceae4;
  --focus: #b45309;
  --shadow: none;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-monospace, "SF Mono", SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; border-bottom: 1px solid var(--accent-soft); }
a:hover { border-bottom-color: currentColor; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

.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;
}

.skip-link {
  position: absolute; left: 8px; top: -60px; z-index: 20;
  background: var(--panel); border: 1px solid var(--line);
  padding: 8px 14px; border-radius: 8px; transition: top .15s;
}
.skip-link:focus { top: 8px; }

/* ---------- shell ---------- */
.app {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100dvh;
  max-width: 860px;
  margin: 0 auto;
  border-inline: 1px solid var(--line);
}

@media (max-width: 900px) { .app { border-inline: 0; } }

/* ---------- topbar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(8px);
}

.identity { display: flex; align-items: center; gap: 10px; min-width: 0; }

.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  object-fit: cover; border: 1px solid var(--line);
}

.identity-text { display: flex; flex-direction: column; min-width: 0; }
.identity-name { font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }
.identity-status {
  font-size: 11.5px; color: var(--dim);
  display: flex; align-items: center; gap: 6px;
}
.dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ok); box-shadow: 0 0 8px var(--ok);
}

.topbar-actions { display: flex; gap: 4px; }

.icon-btn {
  display: grid; place-items: center;
  width: 34px; height: 34px;
  border: 1px solid transparent; border-radius: 8px;
  background: none; color: var(--muted);
  font-size: 15px; cursor: pointer;
}
.icon-btn:hover { color: var(--text); background: var(--panel-2); border-color: var(--line); }

/* ---------- transcript ---------- */
.chat { overflow: hidden; }

.transcript {
  height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 24px 16px 8px;
  display: flex; flex-direction: column; gap: 18px;
}

.transcript > * { flex: 0 0 auto; }

.msg { display: flex; gap: 12px; max-width: 100%; }

.msg-agent .gutter {
  flex: 0 0 auto; width: 16px; color: var(--accent);
  font-size: 11px; line-height: 1.9;
}

.msg-body { min-width: 0; flex: 1; overflow-wrap: anywhere; }

.msg-user {
  justify-content: flex-end;
}
.msg-user .msg-body {
  flex: 0 1 auto;
  background: var(--user-bg);
  border: 1px solid var(--line);
  border-radius: 12px 12px 2px 12px;
  padding: 8px 14px;
  color: var(--text);
}

.msg-body > *:first-child { margin-top: 0; }
.msg-body > *:last-child { margin-bottom: 0; }
.msg-body p { margin: 0 0 10px; }

.msg-body h3 {
  margin: 18px 0 2px; font-size: 14px; font-weight: 600;
  letter-spacing: -0.01em;
}
.msg-body .meta { color: var(--dim); font-size: 12.5px; margin: 0 0 6px; }
.msg-body ul { margin: 0 0 10px; padding-left: 18px; }
.msg-body li { margin-bottom: 4px; }
.msg-body li::marker { color: var(--dim); }
.msg-body strong { color: var(--text); font-weight: 600; }

.tag-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 12px; }
.tag {
  font-size: 12px; color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 2px 10px; background: var(--panel);
}

.linkline { font-size: 13px; margin: 6px 0 0; color: var(--dim); }


.cursor {
  display: inline-block; width: 0.55em; height: 1em;
  background: var(--accent); vertical-align: -0.15em;
  margin-left: 2px; animation: blink 1.1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* boot lines */
.boot { color: var(--dim); font-size: 13px; margin: 0; }
.boot .ok { color: var(--ok); }
.boot .cmd { color: var(--accent); }

/* ---------- tool call ---------- */
.tool {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  font-size: 12.5px;
  margin: 0 0 12px;
  overflow: hidden;
}
.tool > summary {
  cursor: pointer; list-style: none;
  padding: 7px 12px; color: var(--muted);
  display: flex; align-items: center; gap: 8px;
}
.tool > summary::-webkit-details-marker { display: none; }
.tool > summary::before {
  content: "\25B8"; color: var(--dim); font-size: 10px;
  transition: transform .15s;
}
.tool[open] > summary::before { transform: rotate(90deg); }
.tool .tool-name { color: var(--accent); overflow-wrap: anywhere; min-width: 0; }
.tool .tool-status { margin-left: auto; color: var(--dim); font-size: 11.5px; flex: 0 0 auto; }
.tool .tool-out {
  border-top: 1px solid var(--line);
  padding: 8px 12px; margin: 0;
  color: var(--dim); white-space: pre-wrap; font-size: 12px;
  background: var(--panel-2);
}
.tool.running .tool-name { color: var(--muted); }

/* ---------- composer ---------- */
.composer {
  border-top: 1px solid var(--line);
  padding: 10px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--bg);
}

.composer-form {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--panel); padding: 8px 10px 8px 14px;
}
.composer-form:focus-within { border-color: var(--accent); }

.composer-prompt { color: var(--accent); font-size: 14px; }

#composer-input {
  flex: 1; min-width: 0;
  background: none; border: 0; outline: none;
  color: var(--text); font: inherit; font-size: 14px;
  padding: 2px 0;
}
#composer-input::placeholder { color: var(--dim); }

.send-btn {
  flex: 0 0 auto; width: 32px; height: 32px;
  display: grid; place-items: center; cursor: pointer;
  border: 0; border-radius: 8px;
  background: var(--accent); color: var(--bg); font-size: 13px;
}
.send-btn:disabled { opacity: .35; cursor: default; }

.composer-hint {
  margin: 8px 2px 0; font-size: 11.5px; color: var(--dim); text-align: center;
}
.composer-hint kbd {
  font: inherit; border: 1px solid var(--line); border-radius: 4px;
  padding: 0 4px; background: var(--panel);
}

/* ---------- static CV: hidden when JS runs, shown otherwise ---------- */
#cv-static { display: none; }
.no-js #cv-static { display: block; }
.no-js .app { display: none; }

.cv-static {
  max-width: 780px; margin: 0 auto; padding: 40px 20px 60px;
}
.cv-static h1 { font-size: 24px; margin: 0 0 2px; }
.cv-static .cv-role { margin: 0 0 6px; color: var(--muted); }
.cv-static .cv-contact { margin: 0; font-size: 13px; color: var(--muted); }
.cv-static h2 {
  font-size: 13px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--accent); border-bottom: 1px solid var(--line);
  padding-bottom: 4px; margin: 28px 0 12px;
}
.cv-static h3 { font-size: 14.5px; margin: 0 0 2px; }
.cv-static .cv-meta { margin: 0 0 6px; font-size: 12.5px; color: var(--dim); }
.cv-static .cv-entry { margin-bottom: 16px; break-inside: avoid; }
.cv-static ul { margin: 0; padding-left: 18px; }
.cv-static li { margin-bottom: 3px; }
.cv-skills { list-style: none; padding: 0; }

/* ---------- print = the CV download ---------- */
@media print {
  .app, .skip-link { display: none !important; }
  #cv-static { display: block !important; }
  html, body {
    background: #fff; color: #000;
    font-family: Georgia, "Times New Roman", serif; font-size: 10.5pt; line-height: 1.4;
  }
  a { color: #000; border: 0; text-decoration: none; }
  .cv-static { max-width: none; padding: 0; }
  .cv-static h2 { color: #000; border-bottom: 1px solid #999; }
  .cv-static .cv-meta, .cv-static .cv-contact, .cv-static .cv-role { color: #333; }
  section { break-inside: avoid; }
  @page { margin: 16mm; }
}

/* ---------- motion ---------- */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  .cursor { display: none; }
}
