:root {
  --bg: #fbfaf8;
  --surface: #ffffff;
  --ink: #1d1c1a;
  --ink-soft: #5d5a55;
  --line: #e4e0d9;
  --accent: #7a5c34;
  --attention: #8a5a12;
  --attention-bg: #fdf5e6;
  --radius: 10px;
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand { font-weight: 650; letter-spacing: -0.01em; font-size: 17px; }
.brand-sub { color: var(--ink-soft); font-weight: 400; font-size: 12px; margin-left: 8px; }

.tabs { display: flex; gap: 4px; }
.tab {
  border: 0;
  background: none;
  padding: 7px 13px;
  border-radius: 7px;
  cursor: pointer;
  color: var(--ink-soft);
  font-size: 14px;
}
.tab:hover { background: #f1eee9; }
.tab[aria-current='page'] { background: #efe9e0; color: var(--ink); font-weight: 550; }

main { max-width: 820px; margin: 0 auto; padding: 22px; }
.view { display: flex; flex-direction: column; gap: 14px; }
.hidden { display: none !important; }

.view-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.view-head h2 { margin: 0; font-size: 17px; font-weight: 600; }
.row { display: flex; align-items: center; gap: 12px; }
.check { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-soft); }

.hint { margin: 0; color: var(--ink-soft); font-size: 13px; max-width: 62ch; }

/* Chat */
.transcript { display: flex; flex-direction: column; gap: 12px; min-height: 50vh; }
.msg { padding: 11px 14px; border-radius: var(--radius); max-width: 78%; white-space: pre-wrap; }
.msg.user { align-self: flex-end; background: #ece5da; }
.msg.agent { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); }
.msg.error { align-self: flex-start; background: #fdeeee; border: 1px solid #f0cccc; color: #7a2222; }

/* A run is visible work with a state, not a spinner that blocks the conversation. */
.run {
  align-self: flex-start;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 9px 13px;
  font-size: 13px;
  color: var(--ink-soft);
  background: #fdfcfa;
}
.run .step { display: block; }
.run .step.failed { color: #8a2b2b; }

.composer { display: flex; gap: 8px; position: sticky; bottom: 0; padding: 12px 0; background: var(--bg); }
.composer input[type='text'] { flex: 1; }

input[type='text'], textarea, select {
  font: inherit;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}
textarea { min-height: 320px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }

button {
  font: inherit;
  padding: 9px 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
}
button:hover:not(:disabled) { background: #f4f1ec; }
button:disabled { opacity: 0.55; cursor: default; }
#send, #run-hunt, #save-rules, #save-resume { background: var(--accent); border-color: var(--accent); color: #fff; }
#send:hover:not(:disabled), #run-hunt:hover:not(:disabled), #save-rules:hover:not(:disabled), #save-resume:hover:not(:disabled) { background: #6a4f2c; }

/* Roles */
.list { display: flex; flex-direction: column; gap: 9px; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px 15px;
}
.card.set-aside { background: #faf9f7; }
.card-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.card h3 { margin: 0; font-size: 15px; font-weight: 600; }
.card .company { color: var(--ink-soft); font-size: 13px; }
.card .reason { margin: 7px 0 0; font-size: 13.5px; color: #3f3c38; }
.card .meta { margin-top: 8px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.badge { font-size: 11.5px; padding: 2.5px 8px; border-radius: 99px; border: 1px solid var(--line); color: var(--ink-soft); }
.badge.attention { background: var(--attention-bg); border-color: #e8d3a8; color: var(--attention); }
.badge.success { background: #eef6ee; border-color: #cbe3cb; color: #2f5d33; }
.badge.progress { background: #eef2f8; border-color: #cdd9ea; color: #2f4a70; }
.score { font-size: 12px; color: var(--ink-soft); }
.card a { color: var(--accent); font-size: 13px; }

.empty { color: var(--ink-soft); font-size: 14px; padding: 18px 0; }

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #24221f;
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  z-index: 10;
}

/* The approval block sits below the meta row, separated by a rule: it is a decision about
   this card, not another attribute of it, and it should not read as one more badge. */
.approval { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.approval .reason { margin: 0 0 9px; }

/* Phone-width breakpoint — added for the Vercel move (Phase 1): the webapp is now reachable
   from a real phone browser, not just localhost on a laptop, so the same layout that worked
   fine at any desktop width needs to actually fit a ~375-430px viewport. Nothing here changes
   the desktop layout above; every rule is scoped inside this query. */
@media (max-width: 640px) {
  .topbar {
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 14px;
  }
  .tabs {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .tab { flex: 0 0 auto; padding: 7px 11px; font-size: 13px; }

  main { padding: 14px; }

  .msg { max-width: 92%; }

  /* The composer's input/select/button row is the thing most likely to overflow a phone
     screen at desktop sizing — wrap it onto two lines rather than letting it clip or force
     horizontal scroll. */
  .composer { flex-wrap: wrap; }
  .composer input[type='text'] { flex: 1 1 100%; }
  .composer select { flex: 1 1 auto; }
  .composer button { flex: 1 1 auto; }

  .view-head { flex-wrap: wrap; }
  .card-top { flex-direction: column; align-items: flex-start; gap: 4px; }

  textarea { min-height: 200px; }
}
