/* ===== Design tokens ===== */
:root {
  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-2: #f7f8fb;
  --text: #1c2333;
  --text-2: #4a5468;
  --muted: #7a8396;
  --line: #e2e6ee;
  --line-strong: #cfd5e1;
  --accent: #2f6bed;
  --accent-strong: #1f56c9;
  --accent-soft: #eaf1ff;
  --danger: #cf3b3b;
  --shadow: 0 1px 2px rgba(20, 30, 60, .06), 0 2px 8px rgba(20, 30, 60, .05);
  --shadow-hover: 0 2px 4px rgba(20, 30, 60, .08), 0 6px 16px rgba(20, 30, 60, .08);
  --radius: 12px;
  --col: 320px;

  /* Status tones: background / text */
  --t-gray-bg: #eef0f4;   --t-gray: #4f5868;
  --t-blue-bg: #e4eeff;   --t-blue: #1f56c9;
  --t-amber-bg: #fff3d6;  --t-amber: #8a5a00;
  --t-orange-bg: #ffe8dc; --t-orange: #b2470f;
  --t-purple-bg: #f0e8ff; --t-purple: #6a3fc4;
  --t-teal-bg: #dcf5f1;   --t-teal: #0e6f63;
  --t-green-bg: #e1f5e6;  --t-green: #1d7a3a;

  /* Slot colors (P / D / 担当): dark enough for white text in both light and dark mode */
  --s-producer: #7a3fd1;
  --s-director: #1f5fd6;
  --s-assignee: #17804f;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1218;
    --surface: #181c24;
    --surface-2: #1f242e;
    --text: #e8ebf1;
    --text-2: #c1c7d3;
    --muted: #8b93a3;
    --line: #2b313d;
    --line-strong: #3a4250;
    --accent: #6f9bff;
    --accent-strong: #8db0ff;
    --accent-soft: #1d2a45;
    --danger: #ff7f7f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-hover: 0 4px 14px rgba(0, 0, 0, .4);

    --t-gray-bg: #272c36;   --t-gray: #b7bfcc;
    --t-blue-bg: #1b2c4f;   --t-blue: #9dbcff;
    --t-amber-bg: #3a2f12;  --t-amber: #f2c75c;
    --t-orange-bg: #3f2517; --t-orange: #ffad7f;
    --t-purple-bg: #2e2347; --t-purple: #c9aefc;
    --t-teal-bg: #133632;   --t-teal: #7fdccd;
    --t-green-bg: #163522;  --t-green: #7fdc98;

  }
}

/* ===== Base ===== */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", "Meiryo", sans-serif;
  font-size: 15px;
  line-height: 1.65;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.loading { padding: 64px; text-align: center; color: var(--muted); }
.muted { color: var(--muted); font-size: 0.88rem; }
.prewrap { white-space: pre-wrap; word-break: break-word; }
.error { color: var(--danger); }
.spacer { flex: 1; }

/* ===== Header ===== */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 20px;
  height: 56px; padding: 0 20px; padding-top: env(safe-area-inset-top);
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.02rem; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand img { width: 26px; height: 26px; border-radius: 7px; }
.topbar nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.topbar nav::-webkit-scrollbar { display: none; }
.topbar nav a { padding: 7px 14px; border-radius: 8px; color: var(--text-2); white-space: nowrap; font-weight: 500; }
.topbar nav a:hover { background: var(--surface-2); text-decoration: none; }
.topbar nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.me { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 0.88rem; white-space: nowrap; }
.avatar {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 0.85rem;
}
.banner { background: var(--accent-soft); color: var(--text); padding: 10px 20px; font-size: 0.9rem; }

main { padding: 24px; }
.page { max-width: 860px; margin: 0 auto; }
h1 { font-size: 1.4rem; line-height: 1.35; margin: 0 0 18px; letter-spacing: .01em; }
h2 { font-size: 1.02rem; margin: 0 0 14px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 22px; margin-bottom: 18px; box-shadow: var(--shadow);
}
.crumbs { font-size: 0.88rem; margin-bottom: 10px; color: var(--muted); }

/* ===== Forms ===== */
label { display: block; font-weight: 600; font-size: 0.88rem; color: var(--text-2); margin: 16px 0 6px; }
label.first { margin-top: 0; }
input[type=text], input[type=email], input[type=password], select, textarea {
  width: 100%; font: inherit; color: var(--text);
  padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 100px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.checks label {
  display: inline-flex; align-items: center; gap: 6px; margin: 0;
  padding: 6px 12px; border: 1px solid var(--line-strong); border-radius: 999px;
  font-weight: 500; color: var(--text); cursor: pointer; background: var(--surface);
}
.checks label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.checks input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.hint { font-size: 0.84rem; color: var(--muted); margin-top: 6px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; align-items: center; }
button {
  font: inherit; font-weight: 600; cursor: pointer;
  min-height: 42px; padding: 8px 18px; border-radius: 9px;
  border: 1px solid var(--accent); background: var(--accent); color: #fff;
  transition: background .15s, box-shadow .15s;
}
button:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
button.secondary { background: var(--surface); color: var(--accent); border-color: var(--line-strong); }
button.secondary:hover { background: var(--accent-soft); border-color: var(--accent); }
button.danger { background: var(--surface); color: var(--danger); border-color: var(--line-strong); }
button.danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
button.link { background: none; border: none; color: var(--accent); padding: 4px 6px; min-height: 0; font-weight: 600; }
button.link:hover { text-decoration: underline; background: none; }
button:disabled { opacity: .5; cursor: default; }

.auth { max-width: 420px; margin: 56px auto; padding: 32px; }
.auth h1 { text-align: center; margin-bottom: 8px; }
.auth .auth-logo { display: block; width: 52px; height: 52px; margin: 0 auto 14px; border-radius: 14px; }

/* ===== Board ===== */
.board-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.board-head h1 { margin: 0; }
.board {
  display: flex; gap: 16px; align-items: flex-start;
  overflow-x: auto; padding: 2px 2px 20px;
  scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch;
}
.column {
  flex: 0 0 var(--col); max-width: 88vw;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius);
  scroll-snap-align: start; display: flex; flex-direction: column;
}
.column-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px 10px;
}
.column-head a { font-weight: 700; font-size: 1rem; color: var(--text); flex: 1; word-break: break-word; line-height: 1.4; }
.count { min-width: 26px; text-align: center; padding: 1px 8px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); color: var(--text-2); font-size: 0.8rem; font-weight: 600; }
.todo-list { list-style: none; margin: 0; padding: 4px 10px 10px; display: flex; flex-direction: column; gap: 8px; }
.todo {
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 12px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 8px;
  transition: box-shadow .15s, border-color .15s;
}
.todo:hover { box-shadow: var(--shadow-hover); border-color: var(--line-strong); }
.todo.mine { border-left: 4px solid var(--accent); padding-left: 9px; }
.todo .title { font-weight: 700; color: var(--text); word-break: break-word; line-height: 1.45; }
.todo .title:hover { color: var(--accent); text-decoration: none; }
/* Card layout is always: [category ........ status] / title / people */
.todo-top { display: flex; align-items: center; gap: 8px; min-height: 26px; }
.todo-top .status { margin-left: auto; flex: 0 0 auto; }
.todo-top .cat { margin: 0; }
.legend { display: inline-flex; align-items: center; gap: 6px; }
.legend::before { content: ""; width: 4px; height: 16px; border-radius: 2px; background: var(--accent); }
.title-row .cat { margin: 0; }
.cat {
  display: inline-block; font-size: 0.72rem; font-weight: 600; color: var(--text-2);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 5px; padding: 0 6px;
  margin-bottom: 4px;
}
.empty { margin: 4px 10px 10px; padding: 14px; color: var(--muted); font-size: 0.86rem; text-align: center; border: 1px dashed var(--line-strong); border-radius: 10px; }
.quick-add { display: flex; gap: 6px; padding: 10px; border-top: 1px solid var(--line); }
.quick-add input { padding: 7px 10px; background: var(--surface); }
.quick-add button { min-height: 36px; padding: 4px 12px; flex: 0 0 auto; white-space: nowrap; }
details.done { border-top: 1px solid var(--line); }
details.done summary { padding: 10px 16px; cursor: pointer; color: var(--muted); font-size: 0.86rem; font-weight: 600; }
details.done .todo { opacity: .75; }
.new-project { flex: 0 0 260px; padding: 16px; background: var(--surface); }

/* People line: P 鈴木 / D 田中 / 担当 佐藤・山本 */
.people { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 0.8rem; color: var(--text-2); }
.people span { display: inline-flex; align-items: baseline; gap: 4px; }
.slot {
  display: inline-block; min-width: 20px; text-align: center;
  font-size: 0.72rem; font-weight: 700; padding: 1px 6px; border-radius: 5px;
  color: #fff; line-height: 1.5; letter-spacing: .02em;
}
.slot-producer { background: var(--s-producer); }
.slot-director { background: var(--s-director); }
.slot-assignee { background: var(--s-assignee); }
.people .none { color: var(--muted); }

/* Status pill (select or badge) */
.status {
  font: inherit; font-size: 0.8rem; font-weight: 700;
  width: auto; max-width: 170px; min-height: 0;
  padding: 3px 26px 3px 10px; border-radius: 999px; border: 1px solid transparent;
  white-space: nowrap; cursor: pointer;
  field-sizing: content; /* width fits the chosen status (where supported) */
  -webkit-appearance: none; appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: right 12px center, right 8px center;
  background-size: 4px 4px, 4px 4px; background-repeat: no-repeat;
}
.status:focus { box-shadow: 0 0 0 3px var(--accent-soft); }
span.status { cursor: default; padding-right: 10px; background-image: none; display: inline-block; }
.tone-gray { background-color: var(--t-gray-bg); color: var(--t-gray); }
.tone-blue { background-color: var(--t-blue-bg); color: var(--t-blue); }
.tone-amber { background-color: var(--t-amber-bg); color: var(--t-amber); }
.tone-orange { background-color: var(--t-orange-bg); color: var(--t-orange); }
.tone-purple { background-color: var(--t-purple-bg); color: var(--t-purple); }
.tone-teal { background-color: var(--t-teal-bg); color: var(--t-teal); }
.tone-green { background-color: var(--t-green-bg); color: var(--t-green); }
select.status option { background: var(--surface); color: var(--text); font-weight: 500; }

/* ===== Detail ===== */
.title-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.title-row h1 { margin: 0; }
.meta-grid { display: grid; grid-template-columns: 130px 1fr; gap: 12px 16px; align-items: baseline; margin: 0; }
.meta-grid dt { color: var(--muted); font-size: 0.86rem; font-weight: 600; }
.meta-grid dd { margin: 0; }
.chip {
  display: inline-block; padding: 2px 10px; margin: 0 6px 6px 0; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line); font-size: 0.86rem;
}
.chip.inactive { color: var(--muted); text-decoration: line-through; }
.links { margin: 0; padding-left: 18px; }
.links li { margin-bottom: 2px; }
/* Link buttons */
.link-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.link-btn {
  display: inline-flex; align-items: center; gap: 8px; max-width: 100%;
  padding: 7px 14px; border-radius: 9px;
  border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--accent); font-weight: 700; font-size: 0.9rem; box-shadow: var(--shadow);
  transition: background .15s, border-color .15s;
}
.link-btn:hover { text-decoration: none; background: var(--accent-soft); border-color: var(--accent); }
.link-btn.disabled { color: var(--muted); box-shadow: none; }
.link-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-kind { font-size: 0.74rem; font-weight: 500; color: var(--muted); white-space: nowrap; }
.link-arrow { font-size: 0.85rem; opacity: .8; }

/* Link editor */
.link-rows { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.link-row { display: grid; grid-template-columns: minmax(120px, 1fr) 2fr 40px; gap: 8px; align-items: center; }
.link-remove { min-height: 40px; padding: 0; background: var(--surface); color: var(--muted); border-color: var(--line-strong); font-size: 1.1rem; }
.link-remove:hover { background: var(--surface-2); color: var(--danger); border-color: var(--danger); }
button.small { min-height: 34px; padding: 4px 12px; font-size: 0.88rem; }
@media (max-width: 640px) {
  .link-btn .link-kind { display: none; }
  .msg { max-width: 94%; }
  .composer-hint { display: none; }
  .timeline { max-height: 55vh; }
  .topbar nav a { padding: 7px 10px; }
  .link-row { grid-template-columns: 1fr 40px; }
  .link-row .link-url-input { grid-column: 1; grid-row: 2; }
  .link-row .link-remove { grid-column: 2; grid-row: 1 / 3; height: 100%; }
}
.placeholder { border: 1px dashed var(--line-strong); border-radius: 10px; padding: 20px; color: var(--muted); text-align: center; }
.slot-field { padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; margin-top: 10px; background: var(--surface-2); }
.slot-field .slot-title { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 0.9rem; margin-bottom: 8px; }
.slot-field .hint { margin: 0 0 8px; }

/* ===== Members ===== */
.member { border-bottom: 1px solid var(--line); padding: 14px 0; }
.member:first-of-type { padding-top: 0; }
.member:last-child { border-bottom: 0; padding-bottom: 0; }
.member-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.member-head strong { font-size: 1rem; }
.tag { font-size: 0.74rem; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); color: var(--text-2); }
.tag.warn { color: var(--t-orange); background: var(--t-orange-bg); border-color: transparent; }
.tag.info { color: var(--t-amber); background: var(--t-amber-bg); border-color: transparent; }
.member form { margin-top: 8px; padding: 4px 16px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.secret { margin-bottom: 18px; padding: 18px 20px; border-radius: var(--radius); border: 2px solid var(--t-amber); background: var(--t-amber-bg); }
.secret code { display: inline-block; margin-top: 4px; font-size: 1.35rem; font-weight: 700; letter-spacing: 1.5px; user-select: all; }

/* ===== Display modes (mine / people / overview) ===== */
.nav-short { display: none; }
.view-head { display: flex; align-items: center; gap: 12px 16px; flex-wrap: wrap; margin-bottom: 18px; }
.view-head h1 { margin: 0; }
.chips { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.chip-btn {
  min-height: 34px; padding: 4px 12px; border-radius: 999px; font-size: 0.86rem; font-weight: 600;
  background: var(--surface); color: var(--text-2); border: 1px solid var(--line-strong);
  display: inline-flex; align-items: center; gap: 5px;
}
.chip-btn:hover { background: var(--surface-2); border-color: var(--accent); color: var(--text); }
.chip-btn.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.person-select { width: auto; min-width: 200px; font-weight: 600; }
.person-summary { display: flex; gap: 18px; align-items: baseline; margin-bottom: 14px; }
.person-summary .stat b { font-size: 1.6rem; margin-right: 4px; }
.project-group { margin-bottom: 20px; }
.group-head { display: flex; align-items: center; gap: 10px; margin: 0 2px 8px; }
.group-head a { font-weight: 700; color: var(--text); font-size: 1rem; }
.todo-list.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; padding: 0; }
details.card-like { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 0 12px 4px; }
details.card-like summary { padding: 12px 4px; }
.todo-project { font-size: 0.78rem; color: var(--muted); font-weight: 600; margin-bottom: -4px; }
.focus-name { color: var(--text); text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.person-head .avatar { width: 28px; height: 28px; font-size: 0.82rem; }
.person-roles { padding: 0 16px 6px; font-size: 0.78rem; }
.load-bar { height: 6px; margin: 0 16px 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.load-fill { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 3px; transition: width .3s; }

/* ===== Header badge / callout ===== */
.badge {
  display: inline-block; min-width: 18px; margin-left: 6px; padding: 0 5px;
  border-radius: 999px; background: var(--danger); color: #fff;
  font-size: 0.7rem; font-weight: 700; line-height: 18px; text-align: center; vertical-align: 1px;
}
.badge[hidden] { display: none; }
.callout {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px;
  padding: 14px 18px; margin-bottom: 16px; border-radius: var(--radius);
  background: var(--accent-soft); border: 1px solid var(--accent); font-size: 0.9rem;
}
.callout > div:first-child { flex: 1 1 280px; }
.callout strong { margin-right: 6px; }
.callout-actions { display: flex; gap: 8px; align-items: center; }
.ok-text { color: var(--t-green); font-weight: 700; }

/* ===== Message board ===== */
.timeline {
  display: flex; flex-direction: column; gap: 14px;
  max-height: 60vh; overflow-y: auto; padding: 4px 4px 12px;
  overscroll-behavior: contain;
}
.timeline-empty { padding: 22px; text-align: center; color: var(--muted); font-size: 0.9rem; border: 1px dashed var(--line-strong); border-radius: 10px; }
.msg { display: flex; gap: 10px; align-items: flex-start; max-width: 86%; }
.msg.mine { margin-left: auto; flex-direction: row-reverse; }
.msg .avatar { flex: 0 0 auto; }
.msg-body { min-width: 0; display: flex; flex-direction: column; }
.msg.mine .msg-body { align-items: flex-end; }
.msg-meta { display: flex; gap: 8px; font-size: 0.78rem; color: var(--muted); margin-bottom: 3px; }
.msg-meta strong { color: var(--text-2); }
.bubble {
  padding: 9px 13px; border-radius: 4px 14px 14px 14px;
  background: var(--surface-2); border: 1px solid var(--line);
  white-space: pre-wrap; word-break: break-word; line-height: 1.6;
}
.msg.mine .bubble { border-radius: 14px 4px 14px 14px; background: var(--accent-soft); border-color: transparent; }
.msg.to-me .bubble { border-color: var(--t-amber); box-shadow: 0 0 0 1px var(--t-amber) inset; }
.bubble a { word-break: break-all; }
.mention { color: var(--accent); font-weight: 700; }
.mention.mention-me { background: var(--t-amber-bg); color: var(--t-amber); border-radius: 4px; padding: 0 2px; }
.msg-actions { display: flex; gap: 2px; margin-top: 2px; }
.msg-actions .link { font-size: 0.78rem; color: var(--muted); padding: 2px 4px; }
.msg-actions .danger-link:hover { color: var(--danger); }
.msg-editor { width: min(520px, 70vw); }
.composer { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 14px; }
.composer-box { position: relative; }
.composer-input { min-height: 84px; }
.composer-actions { display: flex; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.composer-hint { margin: 0; }
.mention-list {
  position: absolute; left: 8px; bottom: calc(100% + 4px); z-index: 20;
  list-style: none; margin: 0; padding: 4px; min-width: 240px; max-height: 260px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px; box-shadow: var(--shadow-hover);
}
.mention-list[hidden] { display: none; }
.mention-list li { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 7px; cursor: pointer; }
.mention-list li.active, .mention-list li:hover { background: var(--accent-soft); }
.mention-list .muted { margin-left: auto; font-size: 0.75rem; }
.avatar.small { width: 24px; height: 24px; font-size: 0.75rem; }

/* ===== Notification list ===== */
.notice-list { padding: 6px; }
.notice {
  display: grid; grid-template-columns: 34px 1fr auto; gap: 12px; align-items: start;
  padding: 12px 14px; border-radius: 10px; color: var(--text);
}
.notice + .notice { border-top: 1px solid var(--line); border-radius: 0; }
.notice:hover { background: var(--surface-2); text-decoration: none; }
.notice.unread { background: var(--accent-soft); }
.notice.unread .notice-title { font-weight: 700; }
.notice-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; color: #fff; font-weight: 700; }
.notice-icon.mention { background: var(--s-director); }
.notice-icon.assigned { background: var(--s-assignee); }
.notice-target { font-size: 0.84rem; color: var(--text-2); }
.notice-excerpt { font-size: 0.84rem; color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notice-body { min-width: 0; }
.notice-time { font-size: 0.78rem; color: var(--muted); white-space: nowrap; }

/* ===== Toast ===== */
#toast {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translate(-50%, 8px);
  max-width: 90vw; padding: 11px 18px; border-radius: 10px;
  background: #1c2333; color: #fff; font-size: 0.92rem; box-shadow: 0 6px 20px rgba(0, 0, 0, .2);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 100;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.error { background: var(--danger); }

/* ===== Phone ===== */
@media (max-width: 640px) {
  /* Main menu becomes a bottom tab bar that is easy to reach with a thumb */
  .main-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    display: flex; justify-content: space-around; gap: 0;
    padding: 4px 4px max(4px, env(safe-area-inset-bottom));
    background: var(--surface); border-top: 1px solid var(--line);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, .08);
  }
  .main-nav a {
    flex: 1 1 0; min-width: 0; text-align: center; position: relative;
    padding: 9px 2px; border-radius: 8px; font-size: 0.78rem;
  }
  .main-nav .nav-full { display: none; }
  .main-nav .nav-short { display: inline; }
  .main-nav .badge { position: absolute; top: 2px; right: 50%; margin-right: -26px; margin-left: 0; }
  body { padding-bottom: calc(58px + env(safe-area-inset-bottom)); }
  #toast { bottom: calc(70px + env(safe-area-inset-bottom)); }
  .topbar { justify-content: space-between; }
  .person-select { min-width: 0; flex: 1 1 100%; }
  .todo-list.grid { grid-template-columns: 1fr; }
  main { padding: 14px; }
  .topbar { gap: 10px; padding: 0 12px; }
  .brand span { display: none; }
  .me .who-text { display: none; }
  h1 { font-size: 1.2rem; }
  .card { padding: 16px; }
  .meta-grid { grid-template-columns: 1fr; gap: 2px; }
  .meta-grid dd { margin-bottom: 10px; }
  .board-head .muted { font-size: 0.8rem; }
  .status { font-size: 0.82rem; padding-top: 6px; padding-bottom: 6px; }
}
