/* Sakiokuri 画面の見た目。色・余白・部品の形は Artifact「Sakiokuri 画面案」に合わせる */

:root {
  --bg: #16181c;        /* 地 */
  --face: #24272e;      /* 面（票・枠） */
  --well: #1e2126;      /* 面より一段沈んだ所（貼る欄・子の行） */
  --line: #2b2f36;      /* 仕切り */
  --edge: #3a3f48;      /* 部品の縁 */
  --chip: #3a3f48;
  --text: #e8e6e1;
  --text-2: #d5d7db;
  --text-3: #b3b6bd;
  --muted: #9a9ea6;
  --dim: #6f7580;
  --amber: #e0a458;     /* 相棒の提案と OK だけ */
  --amber-hi: #f0be7a;
  --amber-well: #2f2a22;
  --red: #e5645a;       /* 危ないだけ */
  --red-hi: #f0a49c;
  --red-well: #2a1f1f;
  --blue: #7fb2d9;      /* 一緒にやると楽 */
  --radius: 12px;
  --radius-s: 8px;
  --top-h: 56px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Zen Kaku Gothic New', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
a { color: var(--amber); }
a:hover { color: var(--amber-hi); }
h1, h2, h3 { margin: 0; font-weight: 700; }
h1 { font-size: 20px; }
h2 { font-size: 16px; }
button { font: inherit; cursor: pointer; color: inherit; }
button:disabled { opacity: 0.45; cursor: default; }
textarea, input, select { font: inherit; color: var(--text); }
[hidden] { display: none !important; }
.grow { flex-grow: 1; }
.muted { color: var(--muted); font-size: 13px; }
.small { font-size: 12px; }
.amber { color: var(--amber-hi); }
.red { color: var(--red-hi); }

/* ---------- 上部 ---------- */
.top {
  height: var(--top-h);
  padding: 0 28px;
  display: flex;
  align-items: center;
  gap: 24px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 20;
}
.brand { font-size: 18px; font-weight: 700; letter-spacing: 0.04em; }
.nav { display: flex; gap: 4px; }
.nav a {
  padding: 8px 14px;
  border-radius: var(--radius-s);
  color: var(--text-3);
  text-decoration: none;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.nav a.active { background: var(--line); color: var(--text); font-weight: 500; }
.nav-count {
  cursor: pointer;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px; background: var(--red); color: var(--bg);
  font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center;
}
.user { border: 0; background: transparent; color: var(--muted); font-size: 13px; padding: 6px 8px; border-radius: 6px; }
.user:hover { background: var(--line); }

/* ---------- 画面の枠 ---------- */
.screen { min-height: calc(100vh - var(--top-h)); }
.page { padding: 20px 28px; display: flex; flex-direction: column; gap: 14px; }
.page-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.page-head .muted { flex: 1 1 200px; }

/* 2 列（貼る口） */
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; padding: 24px 28px; }
.col { display: flex; flex-direction: column; gap: 12px; min-height: 0; }

/* 棚: 左の一覧と右の票 */
.shelf-layout { display: flex; min-height: calc(100vh - var(--top-h)); }
.side {
  width: 220px; flex-shrink: 0;
  padding: 20px 16px;
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 6px;
}
.side-label { font-size: 12px; color: var(--muted); padding: 0 10px 6px; }
.side-item {
  padding: 10px 12px; border-radius: var(--radius-s);
  color: var(--text-2); text-decoration: none; font-size: 14px;
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  border: 0; background: transparent; width: 100%; text-align: left;
}
.side-item:hover { background: var(--well); }
.side-item.active { background: var(--line); color: var(--text); font-weight: 500; }
.side-item .count { color: var(--muted); }
.side-item .count.red { color: var(--red); font-weight: 700; }
.side-add {
  margin-top: 8px; padding: 10px 12px; border-radius: var(--radius-s);
  border: 1px dashed var(--edge); background: transparent; color: var(--muted);
  font-size: 13px; text-align: left; width: 100%;
}
.main { flex-grow: 1; padding: 20px 28px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }

/* ---------- 部品 ---------- */
.btn {
  padding: 8px 14px; border-radius: var(--radius-s);
  border: 1px solid var(--edge); background: transparent; color: var(--text-2);
  font-size: 13px; white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--well); }
.btn.sm { padding: 6px 10px; font-size: 12px; border-radius: 6px; }
.btn.lg { padding: 12px 22px; font-size: 15px; border-radius: 10px; }
.btn.primary { background: var(--amber); color: var(--bg); border-color: var(--amber); font-weight: 700; }
.btn.primary:hover:not(:disabled) { background: var(--amber-hi); }
.btn.well { background: var(--well); }
.btn.icon { width: 36px; height: 36px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.btn.icon.sm { width: 28px; height: 28px; }
.btn.icon.xs { width: 32px; height: 32px; border-radius: 6px; }
.btn.danger-outline { border-color: var(--red); color: var(--red-hi); }

/* 候補ボタン: 押された物は琥珀の縁 */
.choice {
  padding: 7px 12px; border-radius: var(--radius-s);
  border: 1px solid var(--edge); background: var(--well); color: var(--text-2); font-size: 13px;
}
.choice.on { border-color: var(--amber); background: var(--amber-well); color: var(--amber-hi); }
.choice.red { border-color: var(--red); color: var(--red-hi); }
.choice.red.on { background: var(--red-well); }
.choices { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

.chip {
  font-size: 11px; padding: 3px 8px; border-radius: 999px;
  background: var(--chip); color: var(--text-2); white-space: nowrap;
}
.chip.amber { background: var(--amber-well); color: var(--amber-hi); }
.chip.red { background: var(--red-well); color: var(--red-hi); }

.mark {
  width: 22px; height: 22px; border-radius: 6px; flex-shrink: 0;
  background: var(--red); color: var(--bg); font-size: 12px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}

.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.field > .label { color: var(--muted); font-size: 12px; }
.free-input {
  padding: 7px 12px; border-radius: var(--radius-s); border: 1px solid var(--edge);
  background: var(--well); color: var(--text); font-size: 13px; min-width: 0;
}
.free-input::placeholder { color: var(--dim); }

.paste-area {
  flex-grow: 1; min-height: 260px; resize: none;
  padding: 18px 20px; border-radius: var(--radius); border: 1px solid var(--edge);
  background: var(--well); color: var(--text); font-size: 15px; line-height: 1.7;
}

.stepper { display: flex; align-items: center; gap: 8px; }
.stepper .val { flex-grow: 1; text-align: center; font-size: 16px; font-weight: 700; }
.stepper .val.sm { font-size: 14px; }

/* 相棒の提案 1 行（はい／いいえ） */
.ask {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 12px; border-radius: var(--radius-s); background: var(--well); font-size: 13px;
}
.ask .who { color: var(--amber-hi); }
.ask .say { flex: 1 1 160px; }

/* 相棒の箱（案・理由） */
.buddy-box {
  padding: 14px 16px; border-radius: var(--radius); background: var(--well); border: 1px solid var(--edge);
  display: flex; flex-direction: column; gap: 10px; font-size: 13px; line-height: 1.6;
}

/* 危ない 1 行 */
.alert-line {
  padding: 12px 16px; border-radius: 10px; background: var(--red-well); border: 1px solid var(--red);
  display: flex; align-items: center; gap: 12px; font-size: 13px; flex-wrap: wrap;
}
.alert-line > span:not(.mark) { flex: 1 1 140px; }

/* ---------- 票 ---------- */
.cards { display: flex; flex-direction: column; gap: 8px; }
.card {
  padding: 12px 16px; border-radius: var(--radius);
  background: var(--face); border: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  position: relative;
  touch-action: pan-y;
}
.card.now { border-color: var(--amber); }
.card.alarming { background: var(--red-well); border-color: var(--red); }
.card.blocked .title { color: var(--text-3); }
.card.done { opacity: 0.55; }
.card.done .title { text-decoration: line-through; }
.card .title { font-size: 15px; font-weight: 500; flex: 1 1 160px; min-width: 0; }
.card .meta { font-size: 12px; color: var(--muted); }
.card .meta.red { color: var(--red-hi); }
.card .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.card.parent { flex-direction: column; align-items: stretch; padding: 0; gap: 0; }
.card.parent > .head { padding: 12px 16px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.card.parent > .kids { padding: 0 16px 12px 56px; display: flex; flex-direction: column; gap: 6px; }
.kid {
  padding: 10px 14px; border-radius: var(--radius-s); background: var(--well);
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; border: 1px solid transparent;
  touch-action: pan-y;
}
.kid.now { border-color: var(--edge); }
.kid.done { opacity: 0.55; }
.kid.done .title { text-decoration: line-through; }
.kid .num { font-size: 12px; color: var(--muted); width: 16px; }
.kid .num.on { color: var(--amber-hi); font-weight: 700; }
.kid .title { font-size: 14px; flex: 1 1 140px; min-width: 0; }
.kid.blocked .title { color: var(--text-3); }
.spacer-28 { width: 28px; height: 28px; flex-shrink: 0; }

/* 掴んで動かす */
.grabbable { cursor: grab; }
.dragging { opacity: 0.4; }
.drop-before { box-shadow: 0 -3px 0 0 var(--amber); }
.drop-after { box-shadow: 0 3px 0 0 var(--amber); }
.drag-ghost {
  position: fixed; pointer-events: none; z-index: 100; opacity: 0.85;
  padding: 10px 14px; border-radius: var(--radius-s); background: var(--face); border: 1px solid var(--amber);
  font-size: 14px; max-width: 60vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.grab-armed { outline: 2px solid var(--amber); outline-offset: -2px; }

/* ---------- 矢印の図 ---------- */
.arrows-legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-3); align-items: center; flex-wrap: wrap; }
.arrows-legend span { display: inline-flex; align-items: center; gap: 6px; }
.figure-wrap { position: relative; overflow: auto; flex-grow: 1; margin: 0 28px 20px; }
.figure { position: relative; min-height: 420px; }
.figure svg.lines { position: absolute; left: 0; top: 0; overflow: visible; }
.figure svg.lines path.hit { stroke: transparent; stroke-width: 16; cursor: pointer; fill: none; }
.figure svg.lines path.line { pointer-events: none; }
.figure svg.lines path.line.before { stroke: var(--amber); stroke-width: 2.5; fill: none; }
.figure svg.lines path.line.together { stroke: var(--blue); stroke-width: 2; stroke-dasharray: 5 5; fill: none; }
.figure svg.lines path.line.related { stroke: var(--dim); stroke-width: 2; fill: none; }
.figure svg.lines path.line.proposal { stroke: var(--amber); stroke-width: 2; stroke-dasharray: 3 5; opacity: 0.55; fill: none; }
.figure svg.lines path.line.temp { stroke: var(--amber); stroke-width: 2; stroke-dasharray: 6 4; opacity: 0.8; fill: none; }
.figure svg.lines path.line.cycle { stroke: var(--red); stroke-width: 3; fill: none; filter: drop-shadow(0 0 4px var(--red)); animation: glow 0.9s ease-in-out infinite alternate; }
.figure svg.lines path.line.selected { stroke-width: 3.5; }
@keyframes glow { from { opacity: 0.6; } to { opacity: 1; } }
.node {
  position: absolute; width: 214px;
  padding: 12px 14px; border-radius: 10px; background: var(--face); border: 1px solid var(--line);
  cursor: grab; user-select: none; touch-action: none;
}
.node .t { font-size: 14px; font-weight: 500; }
.node .s { font-size: 11px; color: var(--muted); margin-top: 4px; }
.node.blocked { opacity: 0.7; }
.node.blocked .t { color: var(--text-3); font-weight: 400; }
.node.done { opacity: 0.6; }
.node.done .t { text-decoration: line-through; font-weight: 400; }
.node.now { border-color: var(--amber); }
.node.alarming { background: var(--red-well); border-color: var(--red); }
.node.alarming .s { color: var(--red-hi); }
.node.target { outline: 2px solid var(--amber); outline-offset: 2px; }
.node.cycle { outline: 2px solid var(--red); outline-offset: 2px; }
.group {
  position: absolute; border: 1px dashed var(--dim); border-radius: 14px; padding: 10px 14px;
  font-size: 12px; color: var(--muted); pointer-events: none;
}
.pop {
  position: absolute; z-index: 30;
  padding: 8px 10px; border-radius: 10px; background: var(--well); border: 1px solid var(--edge);
  display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: 12px; max-width: 320px;
}
.pop .muted { padding: 0 4px; font-size: 12px; }

/* ---------- 時間割 ---------- */
.tt-layout { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; padding: 20px 28px; }
.tt-main { grid-column: span 2; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.tt-side { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.tt-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.slot { border-radius: var(--radius); background: var(--face); border: 1px solid var(--line); display: flex; flex-direction: column; }
.slot.now { border-color: var(--amber); }
.slot.past { opacity: 0.7; }
.slot.too-many { border-color: var(--amber); box-shadow: 0 0 0 1px var(--amber) inset; }
.slot > .head { padding: 10px 16px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.slot > .head .name { font-size: 14px; font-weight: 700; }
.slot > .body { padding: 10px 16px; display: flex; flex-direction: column; gap: 8px; min-height: 44px; }
.slot-row { display: flex; gap: 12px; align-items: stretch; }
.slot-row .when { width: 96px; flex-shrink: 0; font-size: 12px; color: var(--muted); padding-top: 10px; }
.slot-row .when.btn-like { cursor: pointer; }
.slot-row .when.btn-like:hover { color: var(--text); }
.slot-item {
  flex-grow: 1; min-width: 0; padding: 10px 14px; border-radius: var(--radius-s); background: var(--well);
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; border: 1px solid transparent;
  touch-action: pan-y;
}
.slot-item.now { border-color: var(--edge); }
.slot-item.done { opacity: 0.55; }
.slot-item.done .title { text-decoration: line-through; }
.slot-item.alarming { background: var(--red-well); border-color: var(--red); }
.slot-item.overdue-slot { border-color: var(--red); }
.slot-item.together { border-left: 3px solid var(--blue); }
.slot-item.proposed { border: 1px dashed var(--amber); background: var(--amber-well); }
.slot-item .title { font-size: 14px; flex: 1 1 140px; min-width: 0; }
.slot-item .title.strong { font-weight: 500; }
.slot-item .meta { font-size: 12px; color: var(--muted); }
.slot-item .meta.red { color: var(--red-hi); }
.slot.drop-target { border-color: var(--amber); }
.day-btn { background: transparent; border: 0; color: var(--text); font-size: 20px; font-weight: 700; padding: 4px 6px; border-radius: 6px; }
.day-btn:hover { background: var(--well); }

/* ---------- 重ね窓 ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55); z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 20px 16px;
  overflow: auto;
}
.modal {
  width: 560px; max-width: 100%; max-height: calc(100vh - 40px); overflow: auto;
  padding: 26px 28px; border-radius: 16px; background: var(--face); border: 1px solid var(--edge);
  display: flex; flex-direction: column; gap: 18px;
}
.modal.wide { width: 720px; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; align-items: center; padding-top: 6px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.modal-foot .muted { flex-grow: 1; }
.alarm-box { padding: 14px 16px; border-radius: 10px; background: var(--well); border: 1px solid var(--edge); display: flex; flex-direction: column; gap: 8px; }
.alarm-box.on { border-color: var(--amber); }
.alarm-box.off { opacity: 0.5; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }

/* カレンダー */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; font-size: 12px; }
.cal .dow { text-align: center; color: var(--muted); padding: 4px 0; }
.cal button { border: 1px solid transparent; background: transparent; color: var(--text-2); padding: 6px 0; border-radius: 6px; }
.cal button:hover { background: var(--well); }
.cal button.on { border-color: var(--amber); color: var(--amber-hi); background: var(--amber-well); }
.cal button.today { text-decoration: underline; }
.cal button.other { color: var(--dim); }
.cal-head { display: flex; align-items: center; gap: 8px; }
.cal-head .val { flex-grow: 1; text-align: center; font-weight: 700; }

/* 知らせ */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  padding: 10px 16px; border-radius: 10px; background: var(--well); border: 1px solid var(--edge);
  font-size: 13px; z-index: 60; max-width: calc(100vw - 32px);
}
.toast.red { background: var(--red-well); border-color: var(--red); }

/* 設定 */
.settings { max-width: 760px; }
.set-section { display: flex; flex-direction: column; gap: 10px; padding: 16px 18px; border-radius: var(--radius); background: var(--face); border: 1px solid var(--line); }
.set-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 10px; border-radius: var(--radius-s); background: var(--well); touch-action: pan-y; }
.set-row .name { flex: 1 1 100px; font-size: 14px; }
.toggle { display: inline-flex; gap: 4px; }

/* 貼る口の案 */
.proposal { padding: 16px 18px; border-radius: var(--radius); background: var(--face); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 12px; }
.proposal.open { border-color: var(--amber); }
.proposal .head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; cursor: pointer; }
.proposal .head .title { font-size: 16px; font-weight: 700; flex: 1 1 160px; }
.proposal.done-card { opacity: 0.55; }
.proposal .fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }

/* ---------- スマホ ---------- */
@media (max-width: 720px) {
  .top { padding: 0 12px; gap: 10px; height: 52px; }
  .brand { font-size: 15px; }
  .nav { gap: 0; overflow-x: auto; }
  .nav a { padding: 6px 8px; font-size: 13px; }
  .user { font-size: 12px; padding: 4px 6px; }
  .page, .two-col, .tt-layout { padding: 14px 16px; }
  .two-col { grid-template-columns: 1fr; gap: 16px; }
  .paste-area { min-height: 180px; }
  .proposal .fields { grid-template-columns: 1fr; }
  .shelf-layout { flex-direction: column; }
  .side { width: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 12px 16px; flex-direction: row; flex-wrap: wrap; gap: 4px; }
  .side-label { width: 100%; padding: 0 0 4px; }
  .side-item { width: auto; padding: 8px 10px; }
  .side-add { margin-top: 0; width: auto; padding: 8px 10px; }
  .side .grow { display: none; }
  .main { padding: 14px 16px; }
  .card.parent > .kids { padding-left: 16px; }
  .tt-layout { grid-template-columns: 1fr; }
  .tt-main { grid-column: auto; }
  .slot-row .when { width: 72px; }
  .figure-wrap { margin: 0 0 16px; }
  .node { width: 160px; }
  .modal { padding: 18px 16px; }
  .grid-2 { grid-template-columns: 1fr; }
}
