:root {
  --navy: #0c1e3c;
  --navy-2: #13294f;
  --primary: #1d5fd6;
  --primary-dark: #1546a3;
  --primary-soft: #e9f1fe;
  --accent: #0ea5c6;
  --bg: #f3f6fb;
  --surface: #ffffff;
  --ink: #0f1b2d;
  --ink-soft: #5a6b82;
  --line: #dde5f0;
  --warn-bg: #fff7e6;
  --warn-line: #f3d79a;
  --warn-ink: #8a5a00;
  --danger: #d64545;

  --c-deep: #1d5fd6;
  --c-creative: #6a5ae0;
  --c-communication: #0ea5c6;
  --c-admin: #5f7291;
  --c-light: #17a08a;
  --c-habit: #2f9e5b;
  --c-fixed: #0c1e3c;

  --radius: 14px;
  --shadow: 0 1px 2px rgba(12, 30, 60, 0.05), 0 6px 20px rgba(12, 30, 60, 0.06);
  --font: "Inter", "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.65;
  color: var(--ink);
  background: var(--bg);
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); }
[hidden] { display: none !important; }

.muted { color: var(--ink-soft); }
.small { font-size: 13px; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: linear-gradient(90deg, var(--navy), var(--navy-2));
  color: #fff;
  padding-top: env(safe-area-inset-top);
}
.topbar-inner {
  max-width: 1200px; margin: 0 auto; height: 60px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 24px;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 8px;
  background: linear-gradient(135deg, #4c8dff, var(--accent));
  position: relative;
}
.brand-mark::after {
  content: ""; position: absolute; inset: 7px 6px 7px 6px;
  border-left: 2px solid #fff; border-bottom: 2px solid #fff;
  transform: skewX(-12deg);
}
.brand-name { font-weight: 700; font-size: 18px; letter-spacing: 0.04em; }
.tabs { display: flex; gap: 4px; background: rgba(255, 255, 255, 0.08); padding: 4px; border-radius: 10px; }
.tab {
  color: rgba(255, 255, 255, 0.75); text-decoration: none; font-size: 14px; font-weight: 600;
  padding: 6px 14px; border-radius: 7px; white-space: nowrap;
}
.tab:hover { color: #fff; }
.tab.active { background: #fff; color: var(--navy); }

/* ---------- Layout ---------- */
.view { max-width: 1200px; margin: 0 auto; padding: 24px; }
.today-grid { display: grid; grid-template-columns: 400px minmax(0, 1fr); gap: 24px; align-items: start; }
.col-input { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 84px; }
.col-result { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
#result-body { display: flex; flex-direction: column; gap: 16px; }
.mypage-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
.mypage-wide { grid-column: 1 / -1; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px;
}
.card-title { font-size: 16px; font-weight: 700; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.card-head .card-title { margin-bottom: 8px; }
.head-actions { display: flex; gap: 6px; }
.sub-title { font-size: 14px; margin: 0 0 10px; color: var(--primary-dark); }
.count {
  font-size: 12px; font-weight: 700; color: var(--primary); background: var(--primary-soft);
  border-radius: 999px; padding: 0 8px; min-width: 22px; text-align: center;
}

/* ---------- Forms ---------- */
.input {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px;
  background: #fff; font-size: 15px; min-height: 42px;
}
.input:focus { outline: 3px solid rgba(29, 95, 214, 0.18); border-color: var(--primary); }
.input-lg { font-size: 16px; padding: 11px 14px; margin-bottom: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--ink-soft); border: none; padding: 0; margin: 0 0 12px; min-width: 0; }
.form-grid .field { margin-bottom: 0; }
.field legend { padding: 0; margin-bottom: 4px; }
.segmented { display: flex; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.segmented label { flex: 1; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span {
  display: block; text-align: center; padding: 7px 8px; border-radius: 7px; cursor: pointer;
  font-size: 14px; font-weight: 600; color: var(--ink-soft);
}
.segmented input:checked + span { background: #fff; color: var(--primary); box-shadow: 0 1px 3px rgba(12, 30, 60, 0.12); }
.segmented input:focus-visible + span { outline: 2px solid var(--primary); }
.more { margin-bottom: 12px; }
.more summary { cursor: pointer; font-size: 13px; color: var(--primary); font-weight: 600; margin-bottom: 10px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-soft); cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }
.days { display: flex; gap: 6px; flex-wrap: wrap; }
.days input { position: absolute; opacity: 0; pointer-events: none; }
.days span {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--line); cursor: pointer; font-weight: 600; font-size: 14px; color: var(--ink-soft);
}
.days input:checked + span { background: var(--primary); border-color: var(--primary); color: #fff; }
.days input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }
.form-actions { display: flex; gap: 8px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 9px 16px;
  font-size: 14px; font-weight: 600; cursor: pointer; min-height: 40px;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-secondary { background: var(--primary-soft); border-color: transparent; color: var(--primary-dark); }
.btn-secondary:hover { background: #dbe7fd; }
.btn-ghost { background: transparent; color: var(--primary-dark); }
.btn-ghost:hover { background: var(--primary-soft); border-color: #c9d9f7; }
.btn-danger { background: transparent; border-color: #f0c7c7; color: var(--danger); }
.btn-danger:hover { background: #fdeeee; }
.btn-sm { padding: 5px 12px; min-height: 32px; font-size: 13px; }
.btn-lg { min-height: 48px; font-size: 16px; }
.btn-block { width: 100%; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: #fff;
  font-size: 20px; line-height: 1; cursor: pointer; color: var(--ink-soft); flex-shrink: 0;
}
.icon-btn:hover { border-color: var(--primary); color: var(--primary); }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* ---------- Date row ---------- */
.date-row { display: flex; align-items: center; gap: 8px; }
.date-label { position: relative; flex: 1; text-align: center; cursor: pointer; }
.date-label input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
#date-text { font-size: 17px; font-weight: 700; }

/* ---------- Task list ---------- */
.task-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.task-item {
  display: grid; grid-template-columns: 22px 1fr auto; gap: 10px; align-items: start;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; border-left: 4px solid var(--c-admin);
}
.task-item.done .task-title { text-decoration: line-through; color: var(--ink-soft); }
.task-item input[type=checkbox] { width: 18px; height: 18px; margin-top: 3px; accent-color: var(--primary); }
.task-title { font-weight: 600; word-break: break-word; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.chip { font-size: 11.5px; padding: 1px 8px; border-radius: 999px; background: var(--bg); color: var(--ink-soft); font-weight: 600; }
.chip.imp-3 { background: #fde9e9; color: #b23a3a; }
.chip.imp-2 { background: var(--primary-soft); color: var(--primary-dark); }
.del-btn { border: none; background: none; color: #9aa8bc; cursor: pointer; font-size: 18px; padding: 0 4px; line-height: 1; }
.del-btn:hover { color: var(--danger); }
.empty { color: var(--ink-soft); font-size: 14px; text-align: center; padding: 12px 0; margin: 0; }
.generate { margin-top: 16px; display: flex; flex-direction: column; gap: 10px; }

.t-deep { border-left-color: var(--c-deep); }
.t-creative { border-left-color: var(--c-creative); }
.t-communication { border-left-color: var(--c-communication); }
.t-admin { border-left-color: var(--c-admin); }
.t-light { border-left-color: var(--c-light); }
.t-habit { border-left-color: var(--c-habit); }
.t-fixed { border-left-color: var(--c-fixed); }

/* ---------- Result ---------- */
.result-empty { text-align: center; padding: 48px 32px; }
.result-empty h2 { margin: 16px 0 8px; font-size: 20px; }
.result-empty p { max-width: 520px; margin: 0 auto 8px; color: var(--ink-soft); }
.result-empty-icon {
  width: 64px; height: 64px; margin: 0 auto; border-radius: 18px;
  background: linear-gradient(135deg, var(--primary-soft), #dff6fb);
  position: relative;
}
.result-empty-icon::before, .result-empty-icon::after {
  content: ""; position: absolute; left: 16px; right: 16px; height: 6px; border-radius: 3px; background: var(--primary);
}
.result-empty-icon::before { top: 22px; right: 26px; }
.result-empty-icon::after { top: 36px; background: var(--accent); }

.stale { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; background: var(--primary-soft); border-color: #c9d9f7; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat-label { display: block; font-size: 12px; color: var(--ink-soft); font-weight: 600; }
.stat-value { display: block; font-size: 22px; font-weight: 700; color: var(--navy); font-variant-numeric: tabular-nums; }
.stat-value-sm { font-size: 15px; padding-top: 6px; }

.warning { background: var(--warn-bg); border: 1px solid var(--warn-line); color: var(--warn-ink); border-radius: 10px; padding: 10px 14px; font-size: 14px; }
#warnings { display: flex; flex-direction: column; gap: 8px; }
#warnings:empty { display: none; }

.rank-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.rank-item { display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: center; padding: 8px 4px; border-bottom: 1px solid var(--line); }
.rank-item:last-child { border-bottom: none; }
.rank-no { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; background: var(--bg); color: var(--ink-soft); }
.rank-item.q-A .rank-no { background: var(--primary); color: #fff; }
.rank-item.q-B .rank-no { background: var(--primary-soft); color: var(--primary-dark); }
.rank-title { font-weight: 600; min-width: 0; word-break: break-word; }
.q-badge { font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 6px; white-space: nowrap; }
.q-badge.q-A { background: var(--primary); color: #fff; }
.q-badge.q-B { background: var(--primary-soft); color: var(--primary-dark); }
.q-badge.q-C { background: #e3f6fa; color: #0b7d96; }
.q-badge.q-D { background: var(--bg); color: var(--ink-soft); }
.rank-overflow .rank-title { color: var(--ink-soft); }

.progress { height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; margin: 4px 0 6px; }
.progress-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--primary), var(--accent)); transition: width .3s; }

/* ---------- Timeline ---------- */
.timeline { list-style: none; margin: 8px 0 0; padding: 0; position: relative; }
.tl-item { display: grid; grid-template-columns: 64px 1fr; gap: 14px; position: relative; padding-bottom: 8px; }
.tl-time { font-size: 13px; font-weight: 700; color: var(--navy); font-variant-numeric: tabular-nums; padding-top: 10px; text-align: right; }
.tl-time small { display: block; font-weight: 500; color: var(--ink-soft); font-size: 11.5px; }
.tl-card {
  border: 1px solid var(--line); border-left: 4px solid var(--c-admin); border-radius: 10px;
  padding: 10px 12px; background: #fff; display: grid; grid-template-columns: 1fr auto; gap: 4px 10px;
}
.tl-title { font-weight: 700; word-break: break-word; }
.tl-reason { grid-column: 1 / -1; font-size: 12.5px; color: var(--ink-soft); }
.tl-meta { display: flex; flex-wrap: wrap; gap: 4px; grid-column: 1 / -1; }
.tl-check { width: 20px; height: 20px; accent-color: var(--primary); margin-top: 2px; }
.tl-item.done .tl-card { opacity: 0.55; }
.tl-item.done .tl-title { text-decoration: line-through; }
.tl-item.now .tl-card { box-shadow: 0 0 0 2px var(--primary); }
.tl-item.now .tl-time { color: var(--primary); }
.tl-break .tl-card { background: var(--bg); border-left-color: #b9c6d8; padding: 6px 12px; }
.tl-break .tl-title { font-weight: 600; font-size: 13px; color: var(--ink-soft); }
.tl-free .tl-card { background: transparent; border-style: dashed; border-left-style: solid; border-left-color: #c9d3e1; padding: 6px 12px; }
.tl-free .tl-title { font-weight: 600; font-size: 13px; color: var(--ink-soft); }
.tl-break .tl-reason, .tl-free .tl-reason { display: none; }
.energy { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; }
.energy-3 { background: #e6efff; color: var(--primary-dark); }
.energy-2 { background: #e6f7fa; color: #0b7d96; }
.energy-1 { background: #f1f3f7; color: #5f7291; }
.energy-0 { background: #f3effb; color: #6a5ae0; }

/* ---------- MyPage ---------- */
.settings .btn { margin-top: 4px; }
.routine-list { list-style: none; margin: 0 0 16px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.routine-item {
  display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center;
  padding: 10px 12px; border: 1px solid var(--line); border-left: 4px solid var(--c-habit); border-radius: 10px;
}
.routine-item.t-fixed { border-left-color: var(--c-fixed); }
.routine-actions { display: flex; gap: 4px; }
.routine-form { border-top: 1px solid var(--line); padding-top: 16px; }
.routine-form > .input { margin-bottom: 12px; }
.method { margin: 0 0 12px; padding-left: 20px; }
.method li { margin-bottom: 6px; }
.danger-zone { display: flex; flex-wrap: wrap; gap: 8px; border-top: 1px solid var(--line); padding-top: 16px; margin-top: 16px; }

.footer { text-align: center; color: var(--ink-soft); font-size: 12px; padding: 8px 16px calc(24px + env(safe-area-inset-bottom)); }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px); background: var(--navy); color: #fff;
  padding: 10px 18px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; z-index: 50; max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .today-grid { grid-template-columns: 1fr; }
  .col-input { position: static; }
  .mypage-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  body { font-size: 14.5px; }
  .topbar-inner { padding: 0 16px; height: 56px; }
  .brand-name { font-size: 16px; }
  .tab { padding: 6px 10px; font-size: 13px; }
  .view { padding: 16px; }
  .today-grid, .mypage-grid { gap: 16px; }
  .card { padding: 16px; }
  .stats { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat-value { font-size: 19px; }
  .tl-item { grid-template-columns: 50px 1fr; gap: 10px; }
  .tl-time { font-size: 12px; }
  .card-head { flex-wrap: wrap; }
  .input { font-size: 16px; } /* iOS の自動ズーム防止 */
}
