:root {
  color-scheme: dark;
  --bg: #0e1014;
  --panel: #181b21;
  --panel-2: #20242c;
  --line: #2b303a;
  --text: #f5f6f8;
  --muted: #989faa;
  --accent: #8fb3ff;
  --accent-strong: #5f8ff7;
  --green: #68d391;
  --danger: #ff8585;
  --radius: 22px;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top right, #1b2540 0, var(--bg) 34rem);
  color: var(--text);
  padding: env(safe-area-inset-top) 0 calc(28px + env(safe-area-inset-bottom));
}

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

.topbar, main {
  width: min(720px, calc(100% - 32px));
  margin-inline: auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 26px 2px 18px;
}

h1, h2, p { margin: 0; }
h1 { margin-top: 4px; font-size: 30px; letter-spacing: -0.04em; }
h2 { font-size: 20px; letter-spacing: -0.025em; }

.eyebrow {
  color: var(--accent);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.13em;
}

.icon-button, .date-arrow {
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 88%, transparent);
}

.icon-button {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  font-weight: 800;
}

.date-card {
  display: grid;
  grid-template-columns: 46px 1fr 46px;
  align-items: center;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--panel) 90%, transparent);
  overflow: hidden;
}

.date-card label {
  display: grid;
  justify-items: center;
  gap: 3px;
  padding: 15px 6px 13px;
  font-weight: 700;
}

.date-card input {
  width: 136px;
  border: 0;
  background: transparent;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}

.date-arrow { height: 100%; border-width: 0; background: transparent; font-size: 32px; color: var(--muted); }

.panel, .history-section {
  margin-top: 14px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--panel) 94%, transparent);
  box-shadow: 0 18px 44px rgb(0 0 0 / 0.18);
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 16px;
}

.pill {
  padding: 5px 10px;
  border-radius: 999px;
  background: #263653;
  color: #bcd0ff;
  font-size: 12px;
  font-weight: 700;
}

.section-help { color: var(--muted); font-size: 12px; }
.habit-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }

.habit-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel-2);
  font-weight: 700;
}

.habit-button::after {
  content: "";
  width: 17px;
  height: 17px;
  border: 2px solid #555d69;
  border-radius: 50%;
}

.habit-button.active { border-color: #426cc9; background: #1d3158; }
.habit-button.active::after { border-color: var(--accent); background: var(--accent); box-shadow: inset 0 0 0 4px #1d3158; }

.exercise-list { display: grid; gap: 11px; }
.exercise-row { display: grid; grid-template-columns: minmax(88px, 1fr) 90px 92px; gap: 9px; align-items: center; }
.exercise-row strong { font-size: 15px; }

.exercise-row input, textarea, .token-label input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #101318;
  color: var(--text);
  outline: none;
}

.exercise-row input { padding: 11px 10px; text-align: right; }
.exercise-row input:focus, textarea:focus, .token-label input:focus { border-color: var(--accent-strong); }

.note-label, .token-label { display: grid; gap: 9px; font-weight: 700; }
textarea { margin-top: 10px; resize: vertical; padding: 14px; line-height: 1.55; }

.save-button {
  width: 100%;
  margin-top: 16px;
  padding: 16px;
  border: 0;
  border-radius: 17px;
  background: linear-gradient(135deg, #79a3ff, #557fe1);
  color: #07101f;
  font-weight: 850;
  box-shadow: 0 12px 28px rgb(69 111 208 / 0.28);
}

.save-button:disabled { opacity: 0.55; }
.status { min-height: 21px; padding-top: 10px; text-align: center; color: var(--muted); font-size: 13px; }
.status.error { color: var(--danger); }
.status.success { color: var(--green); }

.history-section { margin-top: 8px; }
.history-list { display: grid; gap: 8px; }
.history-row {
  display: grid;
  grid-template-columns: 78px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}
.history-row:last-child { border-bottom: 0; }
.history-row span { color: var(--muted); font-size: 13px; }
.history-row strong { font-size: 14px; }
.empty { color: var(--muted); font-size: 14px; line-height: 1.6; }

dialog {
  width: min(420px, calc(100% - 34px));
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: #181b21;
  color: var(--text);
}
dialog::backdrop { background: rgb(0 0 0 / 0.65); backdrop-filter: blur(5px); }
.dialog-copy { margin: 10px 0 18px; color: var(--muted); font-size: 14px; line-height: 1.55; }
.token-label input { margin-top: 8px; padding: 13px; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 20px; }
.dialog-actions button { padding: 12px; border-radius: 13px; font-weight: 750; }
.secondary-button { border: 1px solid var(--line); background: var(--panel-2); }
.primary-button { border: 0; background: var(--accent-strong); color: white; }

@media (max-width: 480px) {
  .exercise-row { grid-template-columns: 1fr 78px 82px; }
  .panel, .history-section { padding: 18px 16px; }
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #f1f3f7;
    --panel: #ffffff;
    --panel-2: #f4f6fa;
    --line: #dde1e8;
    --text: #171a20;
    --muted: #69717d;
  }
  body { background: radial-gradient(circle at top right, #dde8ff 0, var(--bg) 34rem); }
  .exercise-row input, textarea, .token-label input { background: #fff; }
  dialog { background: #fff; }
}

