:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --ink: #1f2933;
  --muted: #7b8794;
  --line: #e4e7eb;
  --accent: #2f6fed;
  --ok: #2f9e6f;
  --warn: #c98a00;
  --err: #d64545;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, "Segoe UI", "Malgun Gothic", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}
.app {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 16px calc(76px + env(safe-area-inset-bottom));
}
.muted { color: var(--muted); }
.error, .save-status.err { color: var(--err); }

/* ---- login ---- */
.login { text-align: center; padding-top: 18vh; }
.login h1 { font-size: 1.4rem; margin: 0 0 4px; }
.login form { display: flex; flex-direction: column; gap: 12px; margin-top: 28px; }
.login input, .login button, .field input {
  font-size: 16px; padding: 14px; border-radius: var(--radius);
  border: 1px solid var(--line);
}
.login button, form button[type="submit"] {
  background: var(--accent); color: #fff; border: none; font-weight: 600;
}
.error { min-height: 1.2em; margin-top: 12px; }
.consent-list { text-align: left; max-width: 320px; margin: 16px auto 0; padding-left: 1.2em; line-height: 1.7; }
.mcp-url { display: block; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  font-size: .85rem; word-break: break-all; user-select: all; }
.ai-conn-list { list-style: none; padding: 0; margin: 12px 0 0; }
.ai-conn-list li { padding: 8px 0; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; }

/* ---- today header ---- */
.today-head { margin-bottom: 14px; }
.today-head .row { display: flex; justify-content: space-between; align-items: flex-start; }
.date { font-size: 1.25rem; font-weight: 700; }
.badge {
  display: inline-block; margin-top: 4px; padding: 2px 10px;
  background: var(--ink); color: #fff; border-radius: 999px; font-size: .8rem;
}
.pace { margin: 10px 0 0; color: var(--muted); font-size: .92rem; line-height: 1.4; }
.warn {
  margin-top: 10px; padding: 8px 12px; border-radius: 10px;
  background: #fff7e6; color: var(--warn); font-size: .88rem;
}
.link { background: none; border: none; color: var(--muted); font-size: .85rem; cursor: pointer; }

/* ---- cards ---- */
.card {
  background: var(--card); border-radius: var(--radius); padding: 14px;
  margin-bottom: 14px; box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.card-head {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: .9rem; color: var(--muted); margin-bottom: 10px;
}
.total { font-weight: 700; color: var(--ink); }

.subjects { list-style: none; margin: 0; padding: 0; }
.subject { padding: 12px 0; border-top: 1px solid var(--line); }
.subject:first-child { border-top: none; }
.subject-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.name { font-weight: 600; }
.figures { font-size: .85rem; color: var(--muted); white-space: nowrap; }
.figures .actual { color: var(--ink); font-size: 1rem; }
.remaining { color: var(--accent); }
.remaining.over, #week-dev.over { color: var(--ok); font-weight: 700; }

.bar { height: 6px; background: var(--line); border-radius: 999px; margin: 8px 0 10px; overflow: hidden; }
.fill { height: 100%; background: var(--ok); border-radius: 999px; transition: width .2s ease; }

.stepper { display: flex; align-items: center; gap: 12px; }
.stepper-label { font-size: .82rem; color: var(--muted); margin-right: auto; }
.stepper button {
  width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line);
  background: #f7f8fa; font-size: 1.4rem; line-height: 1; color: var(--ink); cursor: pointer;
}
.stepper button:active { background: #eceef1; }
.today-val { min-width: 2.5ch; text-align: center; font-size: 1.15rem; font-weight: 700; }
.unit { color: var(--muted); font-size: .85rem; }

/* ---- memo fields ---- */
.field { display: block; margin-bottom: 12px; }
.field span { display: block; font-size: .82rem; color: var(--muted); margin-bottom: 6px; }
.field input { width: 100%; }
.save-status { min-height: 1.1em; font-size: .82rem; color: var(--ok); margin: 0; }

.small { font-size: .8rem; }
.btn {
  margin-top: 12px; width: 100%; padding: 13px; border: none; border-radius: 12px;
  background: var(--accent); color: #fff; font-weight: 600; font-size: 15px; cursor: pointer;
}
.neg { color: var(--err); font-weight: 700; }
.pos { color: var(--ok); font-weight: 700; }

/* ---- week nav ---- */
.weeknav { display: flex; align-items: center; gap: 10px; }
.weeknav-mid { flex: 1; text-align: center; }
.navbtn {
  width: 44px; height: 44px; display: flex; align-items: center; justify-content: center;
  border-radius: 12px; background: #fff; border: 1px solid var(--line);
  text-decoration: none; color: var(--ink); font-size: 1.1rem;
}
.navbtn.disabled { opacity: .3; }

/* ---- editable grid table (week / settings) ---- */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.grid { border-collapse: collapse; width: 100%; font-size: .85rem; }
table.grid th, table.grid td { border: 1px solid var(--line); padding: 4px; text-align: center; }
table.grid thead th { background: #f7f8fa; font-weight: 600; white-space: nowrap; }
table.grid th.sticky { position: sticky; left: 0; background: #f7f8fa; z-index: 1; white-space: nowrap; }
table.grid th.day small { display: block; color: var(--muted); font-weight: 400; }
table.grid tfoot td, table.grid .day-total { background: #fbfbfc; font-weight: 700; }
.cell {
  width: 52px; padding: 8px 4px; text-align: center; font-size: 15px;
  border: 1px solid var(--line); border-radius: 8px;
}
.grand { background: var(--ink) !important; color: #fff; }

/* ---- notes list ---- */
.notes, .pace-list { list-style: none; margin: 0; padding: 0; }
.note-row, .pace-item { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.note-day, .pace-week { flex: 0 0 84px; font-size: .82rem; color: var(--muted); }
.note-input, .pace-input {
  flex: 1; padding: 10px; border: 1px solid var(--line); border-radius: 10px; font-size: 15px;
}
.adjust-text {
  width: 100%; min-height: 120px; padding: 12px; border: 1px solid var(--line);
  border-radius: 12px; font-size: 14px; line-height: 1.5; resize: vertical;
  font-family: "Malgun Gothic", -apple-system, system-ui, monospace;
}
@keyframes flashbg { 0% { background-color: #ffe066; } 100% { background-color: transparent; } }
.flash-updated { animation: flashbg 1.8s ease; }

.coach-list { list-style: none; margin: 0; padding: 0; }
.coach-list li { display: flex; align-items: baseline; gap: 8px; padding: 7px 0; border-top: 1px solid var(--line); }
.coach-list li:first-child { border-top: none; }
.coach-list li.on { background: #f7f8fa; margin: 0 -8px; padding: 7px 8px; border-radius: 8px; border-top: none; }
.coach-week { flex: 0 0 auto; font-weight: 700; color: var(--accent); text-decoration: none; }
.coach-date { flex: 0 0 auto; }
.coach-prev { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- dashboard ---- */
.pace-lines { list-style: none; margin: 0; padding: 0; }
.pace-lines li { padding: 4px 0; font-size: .95rem; line-height: 1.45; }
.pace-lines b { font-size: 1.05rem; }
.pill { font-size: .74rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; }
.pill.ok { background: #e3f6ec; color: var(--ok); }
.pill.warn { background: #fff7e6; color: var(--warn); }
.warn-txt { color: var(--warn); font-weight: 600; }
.ok-txt { color: var(--ok); font-weight: 600; }

.kpis { display: flex; gap: 8px; }
.kpi { flex: 1; text-align: center; }
.kpi-num { display: block; font-size: 1.5rem; font-weight: 800; }
.kpi-lab { font-size: .72rem; color: var(--muted); line-height: 1.3; }
.chart-wrap { width: 100%; }
.linechart { width: 100%; height: auto; }
.linechart .grid { stroke: var(--line); stroke-width: 1; }
.linechart .plan { fill: none; stroke: #9aa5b1; stroke-width: 2; stroke-dasharray: 4 3; }
.linechart .actual { fill: none; stroke: var(--accent); stroke-width: 2.5; }
.linechart .dot { fill: var(--accent); }
.linechart .ylab { fill: var(--muted); font-size: 10px; text-anchor: end; }
.linechart .xlab, .linechart .xunit { fill: var(--muted); font-size: 10px; text-anchor: middle; }
.legend { display: flex; gap: 16px; margin-top: 8px; font-size: .8rem; color: var(--muted); }
.lg { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 16px; height: 3px; display: inline-block; border-radius: 2px; }
.sw.plan { background: #9aa5b1; }
.sw.actual { background: var(--accent); }

/* ---- phase timeline ---- */
.timeline { list-style: none; margin: 0; padding: 0; }
.tl { display: flex; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.tl:first-child { border-top: none; }
.tl-badge {
  flex: 0 0 34px; height: 34px; border-radius: 8px; background: #eceef1;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem;
}
.tl.now .tl-badge { background: var(--accent); color: #fff; }
.tl.now .tl-title em { color: var(--accent); font-style: normal; font-weight: 700; }
.tl-title { font-weight: 600; }

/* ---- checkpoints ---- */
.checkpoints { list-style: none; margin: 0; padding: 0; }
.cp { padding: 10px 0; border-top: 1px solid var(--line); }
.cp:first-child { border-top: none; }
.cp-top { display: flex; align-items: center; gap: 8px; }
.cp-status {
  flex: 0 0 auto; font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  background: #eceef1; color: var(--muted);
}
.status-pass .cp-status { background: #e3f6ec; color: var(--ok); }
.status-redo .cp-status { background: #fdecec; color: var(--err); }
.cp-title { font-weight: 600; font-size: .92rem; }
.cp-input { margin-top: 6px; }
.cp-input label { font-size: .82rem; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.cp-actual { width: 110px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; font-size: 15px; }

/* ---- weekly dashboard ---- */
.bar.big { height: 10px; margin: 4px 0 2px; }
.wk-figure { font-size: 1.5rem; font-weight: 800; margin: 2px 0 6px; }
.wk-figure #wk-pct { font-weight: 600; margin-left: 6px; }

.daychart { display: flex; align-items: flex-end; gap: 6px; height: 130px; padding-top: 6px; }
.daycol { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; }
.dval { font-size: .72rem; color: var(--muted); margin-bottom: 2px; }
.dbar-wrap { flex: 1; width: 100%; display: flex; align-items: flex-end;
  background: linear-gradient(var(--line), var(--line)) center / 100% 1px no-repeat; }
.dbar { width: 70%; margin: 0 auto; min-height: 2px; background: var(--ok);
  border-radius: 4px 4px 0 0; transition: height .2s ease; }
.ddow { font-size: .78rem; color: var(--muted); margin-top: 4px; }

.edit-block > summary {
  cursor: pointer; font-weight: 600; color: var(--accent); padding: 4px 0;
  list-style: none;
}
.edit-block > summary::-webkit-details-marker { display: none; }
.edit-block[open] > summary { margin-bottom: 10px; border-bottom: 1px solid var(--line); }

/* ---- report ---- */
.report-pre {
  white-space: pre-wrap; word-break: break-word; margin: 0 0 12px;
  background: #f7f8fa; border: 1px solid var(--line); border-radius: 12px;
  padding: 14px; font-size: .9rem; line-height: 1.55;
  font-family: "Malgun Gothic", -apple-system, system-ui, monospace;
}
.btn.ghost {
  background: #fff; color: var(--accent); border: 1px solid var(--accent);
  display: block; text-align: center; text-decoration: none; margin-top: 8px;
}

/* ---- bottom tab bar ---- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  flex: 1; text-align: center; padding: 12px 0; text-decoration: none;
  color: var(--muted); font-size: .78rem;
}
.tabbar a.on { color: var(--accent); font-weight: 700; }
