/* Mobile first: base styles are phone width; min-width queries scale up. */
:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --text: #1d1f22;
  --muted: #62666d;
  --line: #e2e0da;
  --accent: #1f5f8b;
  --accent-text: #ffffff;
  --danger: #a3332b;
  --pill-active: #dcebf6;   --pill-active-text: #1f5f8b;
  --pill-todo: #f4ead2;     --pill-todo-text: #7a5a12;
  --pill-good: #dcefdf;     --pill-good-text: #2c6a37;
  --pill-closed: #ebeae6;   --pill-closed-text: #5d6066;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171a;
    --surface: #1e2125;
    --text: #e8e7e3;
    --muted: #9ea2a8;
    --line: #2f3338;
    --accent: #6fb0e0;
    --accent-text: #0e1a24;
    --danger: #ef8a80;
    --pill-active: #1d3446;   --pill-active-text: #9fcdef;
    --pill-todo: #3a3120;     --pill-todo-text: #e8c87e;
    --pill-good: #1f3624;     --pill-good-text: #9ad3a5;
    --pill-closed: #2a2d31;   --pill-closed-text: #a5a8ad;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1, h2 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.25rem; }
h2 { font-size: 1.05rem; }
[hidden] { display: none !important; }

button, input, select {
  font: inherit;
  color: inherit;
}
button {
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
}
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button.small { min-height: 38px; }
button:disabled { opacity: .55; cursor: default; }
input, select {
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
}
label { display: block; font-size: .9rem; color: var(--muted); }
label input, label select { margin-top: 4px; color: var(--text); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: 100%; max-width: 360px; display: grid; gap: 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px;
}
.error { color: var(--danger); margin: 0; min-height: 1.2em; font-size: .9rem; }

/* header */
.top {
  position: sticky; top: 0; z-index: 2;
  background: var(--bg); padding: 12px 16px 8px; border-bottom: 1px solid var(--line);
}
.top-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.summary { margin: 6px 0 8px; color: var(--muted); font-size: .9rem; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; }
.chips button { min-height: 36px; border-radius: 999px; white-space: nowrap; }
.chips button[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }

/* list */
.list { display: grid; gap: 12px; padding: 12px 16px 40px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px;
  min-width: 0;
}
.empty { color: var(--muted); text-align: center; padding: 32px 0; }
.posting .head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.posting .company { margin: 2px 0 0; color: var(--muted); font-size: .92rem; overflow-wrap: anywhere; }
.posting .title { overflow-wrap: anywhere; }
.meta { margin: 8px 0 0; font-size: .88rem; color: var(--muted); overflow-wrap: anywhere; }
.followup { margin: 6px 0 0; font-size: .88rem; }

.pill {
  flex: none; font-size: .78rem; font-weight: 600; padding: 3px 10px; border-radius: 999px;
  background: var(--pill-closed); color: var(--pill-closed-text); text-transform: capitalize;
}
.pill[data-group="active"] { background: var(--pill-active); color: var(--pill-active-text); }
.pill[data-group="todo"] { background: var(--pill-todo); color: var(--pill-todo-text); }
.pill[data-status="offer"], .pill[data-status="interviewing"] { background: var(--pill-good); color: var(--pill-good-text); }

.links { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.link {
  display: flex; align-items: center; justify-content: center; min-height: 44px;
  border: 1px solid var(--line); border-radius: 10px; text-decoration: none; color: var(--accent);
  font-weight: 600; font-size: .92rem;
}
.link.none { color: var(--muted); font-weight: 400; border-style: dashed; opacity: .6; text-decoration: line-through; pointer-events: none; }

details { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
summary { cursor: pointer; font-weight: 600; min-height: 32px; }
.field { margin-top: 10px; }
.hint { font-size: .8rem; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.link-edit { border: 1px dashed var(--line); border-radius: 10px; margin: 14px 0 0; padding: 4px 12px 12px; }
.link-edit legend { color: var(--muted); font-size: .85rem; padding: 0 4px; }
.link-edit button { margin-top: 10px; }

.events { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 8px; font-size: .88rem; }
.events li { border-left: 2px solid var(--line); padding-left: 10px; overflow-wrap: anywhere; }
.events time { color: var(--muted); display: block; font-size: .8rem; }

.add-form { margin: 12px 16px 0; display: grid; gap: 10px; }
.two { display: grid; gap: 10px; }

.toast {
  position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 5;
  background: var(--text); color: var(--bg); padding: 12px 14px; border-radius: 10px; font-size: .92rem;
}
.toast.bad { background: var(--danger); color: #fff; }

@media (min-width: 640px) {
  .top, .list { padding-left: 24px; padding-right: 24px; }
  .add-form { margin: 12px 24px 0; }
  .two { grid-template-columns: 1fr 1fr; }
  .toast { left: auto; max-width: 420px; }
}
@media (min-width: 960px) {
  .list { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; max-width: 1200px; margin: 0 auto; }
  .top { padding-left: max(24px, calc((100% - 1152px) / 2)); padding-right: max(24px, calc((100% - 1152px) / 2)); }
}
