/* Harvey Agents: Marketer's palette and kit (graphite on paper, cobalt
   actions, rust brand accent), hand-written instead of Tailwind. */
:root {
  --graphite: #1a1d21;
  --paper: #fafaf7;
  --cobalt: #2b5ce6;
  --success: #1e8e5a;
  --danger: #c0392b;
  --rust: #b08230;
  --g-04: rgba(26, 29, 33, .04);
  --g-10: rgba(26, 29, 33, .10);
  --g-20: rgba(26, 29, 33, .20);
  --g-40: rgba(26, 29, 33, .40);
  --g-60: rgba(26, 29, 33, .60);
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--paper); color: var(--graphite);
  font: 14px/1.5 ui-sans-serif, -apple-system, Inter, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--cobalt); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { color: var(--graphite); letter-spacing: -.01em; }

/* ---- kit: button, input, card, badge */
button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-size: 14px; font-weight: 500; line-height: 20px;
  padding: 8px 16px; border-radius: 6px; cursor: pointer; transition: background-color .15s, border-color .15s, color .15s;
  background: #fff; color: var(--graphite); border: 1px solid var(--g-20);
}
button:hover { border-color: var(--g-40); }
button.primary { background: var(--cobalt); color: #fff; border-color: transparent; }
button.primary:hover { background: rgba(43, 92, 230, .9); }
button.ghost { background: transparent; border-color: transparent; color: var(--g-60); }
button.ghost:hover { color: var(--graphite); }
button.danger { color: var(--danger); }
button:disabled { opacity: .5; cursor: not-allowed; }
button:focus-visible, a:focus-visible { outline: 2px solid rgba(43, 92, 230, .4); outline-offset: 2px; }

input, select {
  width: 100%; font: inherit; font-size: 14px; color: var(--graphite);
  background: #fff; border: 1px solid var(--g-20); border-radius: 6px; padding: 8px 12px;
}
input::placeholder { color: var(--g-40); }
input:focus, select:focus { outline: none; border-color: var(--cobalt); box-shadow: 0 0 0 3px rgba(43, 92, 230, .3); }
label { display: block; font-size: 14px; font-weight: 500; margin-bottom: 4px; }

.card { background: #fff; border: 1px solid var(--g-10); border-radius: 8px; padding: 16px; margin-bottom: 16px; box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.card h3 { margin: 0 0 12px; font-size: 15px; font-weight: 600; }
.badge { display: inline-flex; align-items: center; border-radius: 99px; padding: 2px 10px; font-size: 12px; font-weight: 500; background: rgba(43, 92, 230, .1); color: var(--cobalt); }
.muted { color: var(--g-60); }
.error { color: var(--danger); font-size: 14px; min-height: 0; }
.error:empty { display: none; }
.small { font-size: 13px; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }

/* ---- login (Marketer's auth layout) */
.auth { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 48px 16px; }
.auth-inner { width: 100%; max-width: 384px; }
.auth-brand { text-align: center; margin-bottom: 32px; }
.auth-brand .word { font-size: 24px; font-weight: 600; letter-spacing: -.02em; }
.auth-brand p { margin: 8px 0 0; font-size: 14px; color: var(--g-60); }
.auth .card { padding: 24px; margin: 0; }
.auth h1 { margin: 0 0 16px; font-size: 18px; font-weight: 600; }
.auth form { display: grid; gap: 16px; }
.auth form button { width: 100%; }
.auth .hint { margin: -8px 0 16px; font-size: 14px; color: var(--g-60); }
.code-input { font-size: 24px; letter-spacing: 10px; text-align: center; font-variant-numeric: tabular-nums; padding: 10px 12px; }
.auth .links { display: flex; justify-content: space-between; font-size: 13px; }
.auth .links button { padding: 0; border: 0; background: none; color: var(--cobalt); font-size: 13px; }
.auth .links button:hover { text-decoration: underline; }
.auth-foot { margin-top: 32px; text-align: center; font-size: 12px; color: var(--g-40); }
.auth-foot a { color: var(--g-40); }

/* ---- app shell: graphite sidebar, paper main */
.shell { display: flex; height: 100%; }
.side { width: 224px; flex-shrink: 0; background: var(--graphite); color: #fff; padding: 16px; display: flex; flex-direction: column; overflow-y: auto; }
.brand { padding: 0 12px; margin-bottom: 32px; }
.brand .word { display: block; font-size: 18px; font-weight: 600; letter-spacing: -.01em; color: #fff; }
.brand .by { display: flex; align-items: center; gap: 6px; margin-top: 2px; font-size: 11px; color: rgba(255,255,255,.4); }
.brand .by img { height: 14px; width: auto; filter: invert(1); opacity: .8; }
.brand .by b { font-weight: 500; color: var(--rust); }
.side nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.side .group { padding: 12px 12px 4px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: rgba(255,255,255,.4); }
.side a.item { display: block; padding: 8px 12px; border-radius: 6px; font-size: 14px; font-weight: 500; color: rgba(255,255,255,.6); text-decoration: none; transition: background-color .15s, color .15s; }
.side a.item:hover { background: rgba(255,255,255,.05); color: #fff; }
.side a.item.active { background: rgba(255,255,255,.1); color: #fff; }
.side .empty { color: rgba(255,255,255,.4); padding: 8px 12px; text-align: left; }
.side footer { margin-top: 24px; padding: 12px 12px 0; border-top: 1px solid rgba(255,255,255,.1); display: grid; gap: 6px; }
.side footer .who { font-size: 12px; font-weight: 500; color: rgba(255,255,255,.8); overflow: hidden; text-overflow: ellipsis; }
.side footer .badge { background: rgba(176, 130, 48, .2); color: var(--rust); font-size: 11px; padding: 1px 8px; }
.side footer button { justify-self: start; padding: 0; border: 0; background: none; font-size: 12px; color: rgba(255,255,255,.5); }
.side footer button:hover { color: #fff; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 0; }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 0 24px; border-bottom: 1px solid var(--g-10); background: var(--paper); flex-wrap: wrap; }
.topbar h2 { margin: 0; font-size: 14px; font-weight: 500; }
.menu-btn { display: none; padding: 6px 10px; }
.tabs { display: flex; gap: 4px; margin-left: auto; }
.tabs button { background: transparent; border-color: transparent; color: var(--g-60); padding: 6px 12px; }
.tabs button:hover { color: var(--graphite); background: var(--g-04); }
.tabs button.on { background: #fff; border-color: var(--g-10); color: var(--graphite); box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.content { flex: 1; min-height: 0; overflow: auto; padding: 24px; }
.content.term-mode { padding: 0; overflow: hidden; display: flex; flex-direction: column; }

/* ---- terminal: Marketer's light surface (white panel on paper) */
.sessions { display: flex; gap: 6px; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--g-10); background: var(--paper); flex-wrap: wrap; }
.chip { padding: 4px 12px; border-radius: 99px; font-size: 13px; border: 1px solid var(--g-20); background: #fff; color: var(--graphite); }
.chip.on { border-color: var(--cobalt); color: var(--cobalt); background: rgba(43, 92, 230, .06); }
.chip.danger { color: var(--danger); }
.chip .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--g-20); margin-right: 6px; }
.chip .dot.live { background: var(--success); }
.watch { margin-left: auto; display: flex; gap: 10px; align-items: center; font-size: 13px; }
.watch button { padding: 4px 12px; font-size: 13px; }
#term { flex: 1; min-height: 0; padding: 10px 0 0 14px; background: #fff; }
.notice { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin: 12px 16px 0; padding: 10px 14px; border-radius: 8px; border: 1px solid rgba(176,130,48,.35); background: rgba(176,130,48,.08); font-size: 13px; }
.notice b { font-weight: 600; }
.keybar { display: flex; gap: 6px; padding: 10px 16px; border-top: 1px solid var(--g-10); background: var(--paper); overflow-x: auto; }
.keybar button { padding: 5px 10px; font-size: 13px; white-space: nowrap; }
.sendbar { display: flex; gap: 8px; padding: 0 16px 10px; background: var(--paper); }
.sendbar input { flex: 1; min-width: 0; }
.status-line { padding: 6px 16px; font-size: 12px; color: var(--g-60); border-top: 1px solid var(--g-10); background: var(--paper); }

/* ---- lists */
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row input { flex: 1; min-width: 160px; width: auto; }
.row select { width: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
td, th { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--g-10); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
th { color: var(--g-40); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.empty { color: var(--g-60); padding: 24px; text-align: center; }

/* ---- transcripts */
.tx-list button { display: flex; justify-content: space-between; width: 100%; margin-bottom: 6px; }
.msg { border-left: 3px solid var(--g-10); padding: 6px 12px; margin: 10px 0; white-space: pre-wrap; word-break: break-word; }
.msg.user { border-color: var(--cobalt); }
.msg.assistant { border-color: var(--rust); }
.msg.tool, .msg.result { color: var(--g-60); font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.msg.error { border-color: var(--danger); font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.msg .who { display: block; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--g-40); font-family: ui-sans-serif, -apple-system, Inter, sans-serif; }

@media (max-width: 767px) {
  .side { position: fixed; inset: 0 auto 0 0; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: 0 0 0 100vmax rgba(26, 29, 33, .5); }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 8px 16px; }
  .tabs { margin-left: 0; width: 100%; overflow-x: auto; }
  .content { padding: 16px; }
}

/* ---- chat view */
.chat-log { flex: 1; min-height: 0; overflow-y: auto; padding: 20px 24px; display: flex; flex-direction: column; gap: 10px; background: var(--paper); }
.bubble { max-width: min(720px, 88%); padding: 10px 14px; border-radius: 12px; font-size: 14px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.bubble.user { align-self: flex-end; background: rgba(43, 92, 230, .1); color: var(--graphite); border-bottom-right-radius: 4px; }
.bubble.agent { align-self: flex-start; background: #fff; border: 1px solid var(--g-10); box-shadow: 0 1px 2px rgba(0,0,0,.05); border-bottom-left-radius: 4px; white-space: normal; }
.bubble.agent pre, .action-detail pre { margin: 8px 0; padding: 10px 12px; background: var(--paper); border: 1px solid var(--g-10); border-radius: 6px; font: 12px/1.5 ui-monospace, Menlo, monospace; white-space: pre-wrap; word-break: break-word; max-height: 320px; overflow: auto; }
.bubble.agent code { background: var(--g-04); padding: 1px 5px; border-radius: 4px; }
.sys { align-self: center; font-size: 12px; color: var(--g-40); }
.action-wrap { align-self: flex-start; max-width: min(720px, 88%); }
.action { display: flex; align-items: center; gap: 8px; padding: 2px 4px; border: 0; background: none; color: var(--g-60); font-size: 13px; font-weight: 400; text-align: left; justify-content: flex-start; }
.action:hover { color: var(--graphite); }
.action .mark { width: 14px; height: 14px; flex-shrink: 0; border-radius: 50%; background: var(--success); -webkit-mask: radial-gradient(circle, #000 35%, transparent 37%); mask: radial-gradient(circle, #000 35%, transparent 37%); }
.action:not(.pending):not(.failed) .mark { -webkit-mask: none; mask: none; background: rgba(30, 142, 90, .15); position: relative; }
.action:not(.pending):not(.failed) .mark::after { content: "✓"; position: absolute; inset: 0; display: grid; place-items: center; font-size: 10px; color: var(--success); }
.action.pending .mark { background: var(--cobalt); animation: pulse 1.2s ease-in-out infinite; }
.action.failed .mark { -webkit-mask: none; mask: none; background: rgba(192, 57, 43, .15); position: relative; }
.action.failed .mark::after { content: "!"; position: absolute; inset: 0; display: grid; place-items: center; font-size: 10px; font-weight: 700; color: var(--danger); }
.action-detail { margin: 4px 0 6px 22px; }
.detail-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--g-40); margin-top: 6px; }
.ask { margin: 6px 0 4px 22px; padding: 12px 14px; background: #fff; border: 1px solid var(--g-10); border-radius: 8px; box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.ask-q { font-weight: 500; margin-bottom: 10px; }
.chat-state { display: flex; align-items: center; gap: 10px; padding: 8px 24px; border-top: 1px solid var(--g-10); background: #fff; font-size: 13px; color: var(--g-60); }
.chat-state button { margin-left: auto; padding: 4px 12px; font-size: 13px; }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--g-20); border-top-color: var(--rust); animation: spin .8s linear infinite; }
.composer { display: flex; gap: 8px; align-items: flex-end; padding: 12px 24px; border-top: 1px solid var(--g-10); background: var(--paper); }
.composer textarea { flex: 1; min-width: 0; resize: none; font: inherit; font-size: 14px; color: var(--graphite); background: #fff; border: 1px solid var(--g-20); border-radius: 6px; padding: 9px 12px; max-height: 200px; }
.composer textarea:focus { outline: none; border-color: var(--cobalt); box-shadow: 0 0 0 3px rgba(43, 92, 230, .3); }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: .35; } }
@media (max-width: 767px) { .chat-log { padding: 14px 12px; } .composer, .chat-state { padding-left: 12px; padding-right: 12px; } .bubble, .action-wrap { max-width: 94%; } }

/* ---- screen view */
.screen { flex: 1; min-height: 0; background: var(--paper); overflow: hidden; }
.screen > div { background: var(--paper) !important; }
