:root {
  --bg: #0e1116;
  --bg-2: #151922;
  --paper: #171c26;
  --ink: #e8eaed;
  --muted: #9aa3b2;
  --line: #2a3140;
  --navy: #0b0e13;
  --navy-2: #151a24;
  --gold: #d4b46a;
  --gold-2: #e8c547;
  --ok: #7dcea0;
  --ok-bg: #1e3a2a;
  --maybe: #e8c547;
  --maybe-bg: #3a3218;
  --ng: #e07a6a;
  --ng-bg: #3a1e1c;
  --heat-0: #252830;
  --heat-1: #3d3420;
  --heat-2: #6b5420;
  --heat-3: #b8892e;
  --heat-4: #e8c547;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
  --radius: 20px;
  --sidebar: 228px;
  --font: "Noto Sans JP", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Yu Gothic", sans-serif;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body,
#root,
#app {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--font);
  background:
    radial-gradient(1100px 480px at 8% -8%, #243018 0%, transparent 55%),
    radial-gradient(900px 420px at 100% 0%, #1a2430 0%, transparent 50%),
    var(--bg);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

h1,
h2,
h3,
h4 {
  font-family: var(--font);
  font-weight: 800;
  letter-spacing: 0.02em;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar) 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--navy);
  color: #f7f1e4;
  padding: 28px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  padding: 0 10px;
}

.brand-kicker {
  margin: 0 0 6px;
  color: var(--gold);
  font-size: 11px;
  letter-spacing: 0.18em;
  font-weight: 700;
}

.brand h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.15;
}

.brand p {
  margin: 8px 0 0;
  color: #c9d0da;
  font-size: 12px;
  line-height: 1.6;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-btn,
.icon-btn,
.ghost-btn,
.primary-btn,
.result-btn,
.chip,
.book-tab {
  border: 0;
  background: transparent;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #d7dde6;
  text-align: left;
  padding: 11px 12px;
  border-radius: 12px;
}

.nav-btn.active,
.nav-btn:hover {
  background: rgba(196, 163, 90, 0.16);
  color: #fff;
}

.nav-ico {
  width: 18px;
  text-align: center;
}

.sidebar-foot {
  margin-top: auto;
  padding: 12px;
  border-radius: 14px;
  background: var(--navy-2);
  color: #d7dde6;
  font-size: 12px;
  line-height: 1.6;
}

.main {
  padding: 28px 32px 120px;
  min-width: 0;
}

.page-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-end;
  margin-bottom: 22px;
}

.page-head h2 {
  margin: 0;
  font-size: 34px;
}

.page-head p {
  margin: 6px 0 0;
  color: var(--muted);
}

.grid-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.stat-card .label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.stat-card .value {
  font-family: var(--font);
  font-weight: 800;
  font-size: 34px;
  margin-top: 8px;
  line-height: 1;
}

.stat-card .hint {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.panel-grid {
  display: grid;
  grid-template-columns: 1.4fr 0.9fr;
  gap: 14px;
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 14px;
}

.section-title h3 {
  margin: 0;
  font-size: 20px;
}

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

.week-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}

.week-cell {
  background: #1f2530;
  border-radius: 14px;
  padding: 10px 8px;
  text-align: center;
}

.week-cell.today {
  outline: 2px solid var(--gold);
}

.week-cell .wd {
  font-size: 11px;
  color: var(--muted);
  font-weight: 700;
}

.week-cell .num {
  font-family: var(--font);
  font-weight: 800;
  font-size: 22px;
  margin: 4px 0;
}

.week-bar {
  height: 6px;
  border-radius: 99px;
  background: #2a3140;
  overflow: hidden;
}

.week-bar > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #6b5420, #e8c547);
}

.goal-track {
  height: 10px;
  background: #2a3140;
  border-radius: 99px;
  overflow: hidden;
  margin-top: 10px;
}

.goal-track > span {
  display: block;
  height: 100%;
  background: #3d8f62;
}

.activity {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.activity-months {
  display: flex;
  gap: 3px;
  margin: 0 0 6px 22px;
  font-size: 11px;
  color: var(--muted);
}

.activity-grid {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(7, 12px);
  gap: 3px;
}

.activity-cell {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: var(--heat-0);
}

.activity-cell.lv1 { background: var(--heat-1); }
.activity-cell.lv2 { background: var(--heat-2); }
.activity-cell.lv3 { background: var(--heat-3); }
.activity-cell.lv4 { background: var(--heat-4); }

.wd-col {
  display: grid;
  grid-template-rows: repeat(7, 12px);
  gap: 3px;
  color: var(--muted);
  font-size: 10px;
  align-items: center;
}

.legend {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}

.book-progress {
  display: grid;
  gap: 12px;
}

.progress-row {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 10px;
  align-items: center;
}

.progress-bar {
  height: 10px;
  background: #2a3140;
  border-radius: 99px;
  overflow: hidden;
}

.progress-bar > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #6b5420, #e8c547);
}

.list {
  display: grid;
  gap: 8px;
}

.list-item,
.history-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border-radius: 14px;
  background: #1f2530;
  border: 0;
  width: 100%;
  text-align: left;
  color: inherit;
}

.mark {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 800;
  flex: none;
}

.mark.ok { background: var(--ok-bg); color: var(--ok); }
.mark.maybe { background: var(--maybe-bg); color: var(--maybe); }
.mark.ng { background: var(--ng-bg); color: var(--ng); }

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

select,
input[type="text"],
input[type="number"],
input[type="datetime-local"],
textarea {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  color: var(--ink);
}

.book-tab,
.chip {
  padding: 8px 12px;
  border-radius: 999px;
  background: #252b36;
  color: var(--ink);
  font-weight: 700;
  font-size: 13px;
}

.book-tab.active,
.chip.active {
  background: var(--gold);
  color: #0e1116;
}

.chapter-block {
  margin-bottom: 22px;
}

.chapter-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
}

.chapter-head h3 {
  margin: 0;
  font-size: 18px;
}

.section-block {
  margin: 12px 0 18px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}

.section-head h4 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
}

.problem-grid {
  display: grid;
  grid-template-columns: repeat(7, 42px);
  gap: 6px;
}

.problem-grid.code {
  grid-template-columns: repeat(7, 56px);
}

.problem-cell {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 0;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  position: relative;
  color: #7d8694;
  background: var(--heat-0);
}

.problem-cell.code {
  width: 56px;
  font-size: 10px;
  letter-spacing: -0.02em;
}

.problem-cell.lv1 { background: var(--heat-1); color: #e8d9a8; }
.problem-cell.lv2 { background: var(--heat-2); color: #f6edd0; }
.problem-cell.lv3 { background: var(--heat-3); color: #1a1408; }
.problem-cell.lv4 { background: var(--heat-4); color: #1a1408; }

.problem-cell.result-ok { background: #2f6b48; color: #d9f5e4; }
.problem-cell.result-maybe { background: #6b5420; color: #f6edd0; }
.problem-cell.result-ng { background: #6b322c; color: #f8d4ce; }

.problem-cell:hover,
.problem-cell:focus-visible {
  transform: translateY(-1px);
  outline: 2px solid var(--gold);
}

.dot {
  position: absolute;
  right: 5px;
  bottom: 5px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.dot.ok { background: var(--ok); }
.dot.maybe { background: var(--maybe); }
.dot.ng { background: var(--ng); }

.quick-log {
  position: sticky;
  bottom: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  background: var(--navy);
  color: #fff;
  padding: 12px;
  border-radius: 18px;
  box-shadow: 0 16px 40px rgba(28, 39, 56, 0.25);
  z-index: 5;
}

.quick-log select,
.quick-log input {
  background: var(--navy-2);
  color: #fff;
  border-color: transparent;
  min-width: 0;
}

.quick-log input {
  width: 108px;
}

.quick-log .muted {
  color: #c5ccd6;
}

.result-btn {
  min-width: 72px;
  border-radius: 12px;
  padding: 10px 12px;
  font-weight: 800;
}

.result-btn.ok { background: var(--ok-bg); color: var(--ok); }
.result-btn.maybe { background: var(--maybe-bg); color: var(--maybe); }
.result-btn.ng { background: var(--ng-bg); color: var(--ng); }
.result-btn.active {
  outline: 2px solid var(--ink);
}

.primary-btn,
.ghost-btn {
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 700;
}

.primary-btn {
  background: var(--gold);
  color: var(--navy);
}

.ghost-btn {
  background: #252b36;
  color: var(--ink);
}

.danger-btn {
  background: var(--ng-bg);
  color: var(--ng);
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 700;
}

.modal-back {
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 14, 0.72);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 20;
}

.modal {
  width: min(520px, 100%);
  background: var(--paper);
  border-radius: 24px;
  padding: 22px;
  box-shadow: var(--shadow);
}

.modal h3 {
  margin: 0 0 4px;
  font-size: 26px;
}

.attempt-mini {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.empty {
  padding: 28px 8px;
  color: var(--muted);
  text-align: center;
  line-height: 1.7;
}

.history-list {
  display: grid;
  gap: 10px;
}

.history-day {
  margin: 18px 0 8px;
  font-weight: 800;
}

.settings-grid {
  display: grid;
  gap: 14px;
  max-width: 720px;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mobile-nav {
  display: none;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }

  .main {
    padding: 20px 16px 108px;
  }

  .grid-stats,
  .panel-grid {
    grid-template-columns: 1fr 1fr;
  }

  .problem-grid {
    grid-template-columns: repeat(7, minmax(0, 1fr));
  }

  .problem-cell {
    width: 100%;
    height: 40px;
  }

  .mobile-nav {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 12px;
    background: var(--navy);
    color: #fff;
    border-radius: 18px;
    padding: 8px;
    z-index: 10;
  }

  .mobile-nav button {
    color: #d7dde6;
    border: 0;
    background: transparent;
    border-radius: 12px;
    padding: 10px 6px;
    font-size: 11px;
    font-weight: 700;
  }

  .mobile-nav button.active {
    background: rgba(196, 163, 90, 0.18);
    color: #fff;
  }

  .quick-log {
    bottom: 76px;
  }
}

@media (max-width: 720px) {
  .grid-stats,
  .panel-grid,
  .week-row {
    grid-template-columns: 1fr;
  }

  .page-head h2 {
    font-size: 28px;
  }
}
