:root {
  color-scheme: dark;
  --bg: #110818;
  --card: #1c122c;
  --text: #f6f3ff;
  --soft: #e6dff5;
  --line: rgba(255, 255, 255, 0.1);
  --done: #3ddc84;
  --miss: #ff8b9a;
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", Inter, system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.35;
}

body { min-height: 100dvh; }

body.sheet-open { overflow: hidden; }

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

button {
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, p { margin: 0; }

.sky {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(1.4px 1.4px at 8% 12%, rgba(255, 255, 255, 0.9), transparent 60%),
    radial-gradient(1px 1px at 18% 28%, rgba(255, 255, 255, 0.55), transparent 60%),
    radial-gradient(1.6px 1.6px at 27% 8%, rgba(230, 220, 255, 0.85), transparent 60%),
    radial-gradient(1px 1px at 36% 42%, rgba(255, 255, 255, 0.4), transparent 60%),
    radial-gradient(1.2px 1.2px at 48% 18%, rgba(255, 255, 255, 0.7), transparent 60%),
    radial-gradient(1px 1px at 58% 33%, rgba(255, 255, 255, 0.45), transparent 60%),
    radial-gradient(1.8px 1.8px at 70% 10%, rgba(255, 244, 214, 0.9), transparent 60%),
    radial-gradient(1px 1px at 78% 26%, rgba(255, 255, 255, 0.5), transparent 60%),
    radial-gradient(1.3px 1.3px at 88% 14%, rgba(220, 210, 255, 0.8), transparent 60%),
    radial-gradient(1px 1px at 94% 38%, rgba(255, 255, 255, 0.4), transparent 60%),
    radial-gradient(1.2px 1.2px at 12% 62%, rgba(255, 255, 255, 0.55), transparent 60%),
    radial-gradient(1px 1px at 22% 78%, rgba(255, 255, 255, 0.35), transparent 60%),
    radial-gradient(1.5px 1.5px at 33% 68%, rgba(255, 255, 255, 0.65), transparent 60%),
    radial-gradient(1px 1px at 44% 86%, rgba(255, 255, 255, 0.4), transparent 60%),
    radial-gradient(1.2px 1.2px at 55% 58%, rgba(230, 220, 255, 0.7), transparent 60%),
    radial-gradient(1px 1px at 66% 74%, rgba(255, 255, 255, 0.45), transparent 60%),
    radial-gradient(1.7px 1.7px at 76% 64%, rgba(255, 236, 196, 0.75), transparent 60%),
    radial-gradient(1px 1px at 86% 82%, rgba(255, 255, 255, 0.4), transparent 60%),
    linear-gradient(118deg, transparent 38%, rgba(150, 80, 255, 0.1) 46%, transparent 54%),
    linear-gradient(102deg, transparent 58%, rgba(80, 140, 255, 0.07) 66%, transparent 74%),
    radial-gradient(ellipse 90% 48% at 50% 118%, rgba(120, 40, 200, 0.42), transparent 58%),
    radial-gradient(ellipse 70% 40% at 100% -8%, rgba(80, 40, 160, 0.38), transparent 52%),
    var(--bg);
}

.wrap {
  position: relative;
  z-index: 1;
  width: min(480px, 100%);
  margin: 0 auto;
  padding: calc(12px + env(safe-area-inset-top)) 16px calc(112px + env(safe-area-inset-bottom));
}

h1 {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.045em;
  line-height: 1;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  margin-bottom: 8px;
}

.hit, .tab, .btn, .daycard-toggle {
  border: 0;
  background: transparent;
}

.hit {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  color: var(--text);
  flex: none;
}

.hit svg, .tab svg, .qedit svg {
  width: 26px;
  height: 26px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.plain {
  font-size: 17px;
  line-height: 1.4;
  color: var(--text);
}

.section-title {
  margin: 28px 0 8px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.panel-title {
  margin: 6px 0 2px;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.count-line, .week-range {
  font-size: 18px;
  font-weight: 600;
  color: var(--soft);
}

.count-line { margin: 0 0 12px; }

.week-range { margin: 0 0 14px; }

.stack { display: grid; gap: 12px; }

.date-nav {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  align-items: center;
  margin: 4px 0 6px;
}

.date-mid { text-align: center; }

.date-label {
  font-size: 18px;
  font-weight: 600;
}

.jump-back {
  margin-top: 2px;
  min-height: 44px;
  padding: 0 8px;
  border: 0;
  background: transparent;
  color: var(--soft);
  font-size: 17px;
  font-weight: 600;
}

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 12px 0 22px;
}

.ring {
  position: relative;
  width: 196px;
  height: 196px;
}

.ring svg { width: 100%; height: 100%; display: block; }

.ring-copy {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ring-pct {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.ring-of {
  margin-top: 10px;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
  text-align: center;
}

.hcard {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  min-height: 88px;
  padding: 14px 14px 14px 16px;
  border-radius: 20px;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.hcard.session { grid-template-columns: 44px minmax(0, 1fr); }

.hcard[data-kind="completed"] { background: #161022; }

.hcard[data-kind="completed"] .hab-icon { opacity: 0.8; }

.hab-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--ico) 20%, transparent);
  color: var(--ico);
}

.hab-icon svg {
  width: 22px;
  height: 22px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.hname {
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.hsub {
  margin-top: 2px;
  font-size: 17px;
  line-height: 1.3;
  color: var(--soft);
}

.hdetail {
  margin-top: 6px;
  font-size: 17px;
  line-height: 1.4;
  color: var(--soft);
}

.status {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.status-word {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.1;
}

.status-word.miss { color: #ffd5dc; }

.quota-count {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  white-space: nowrap;
}

.quota-bar {
  display: block;
  height: 6px;
  margin-top: 8px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.quota-bar > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #f4f0ff;
}

.quota-bar.is-full > span { background: var(--done); }

.dayline .quota-count { font-size: 20px; }

.dayline .quota-bar { margin-top: 6px; }

.mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  flex: none;
}

.mark svg {
  width: 20px;
  height: 20px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mark-done {
  border-radius: 50%;
  background: var(--done);
  color: #062214;
}

.mark-open {
  border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, 0.78);
}

.mark-skip {
  border-radius: 12px;
  border: 2px dashed rgba(255, 255, 255, 0.82);
}

.mark-skip::after {
  content: "";
  width: 14px;
  height: 3px;
  border-radius: 2px;
  background: #fff;
}

.mark-missed {
  border-radius: 50%;
  border: 2.5px solid var(--miss);
  color: var(--miss);
}

.daycard {
  border-radius: 20px;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.daycard.is-today { border-color: rgba(255, 255, 255, 0.32); }

.daycard-toggle {
  width: 100%;
  display: grid;
  gap: 10px;
  padding: 16px;
  text-align: left;
  color: inherit;
  min-height: 76px;
}

.daycard-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.daycard-name {
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.daycard-end {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

.daycard-score {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.daycard-note {
  font-size: 17px;
  font-weight: 600;
  color: var(--soft);
}

.chev {
  width: 22px;
  height: 22px;
  color: var(--soft);
  transition: transform 0.15s ease;
}

.daycard.is-open .chev { transform: rotate(180deg); }

.mini-bar {
  display: block;
  height: 10px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.mini-bar > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #f4f0ff;
}

.mini-bar.is-full > span { background: var(--done); }

.daycard-body {
  border-top: 1px solid var(--line);
  padding: 6px 16px 12px;
  display: grid;
  gap: 2px;
}

.dayline {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 48px;
}

.dayline-name {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.25;
}

.qlist { display: grid; gap: 12px; padding-top: 8px; }

.qcard {
  --q: #f4f0ff;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 124px;
  padding: 16px 16px 14px;
  border-radius: 18px;
  border: 2px solid var(--q);
  background: #160d22;
  box-shadow: var(--shadow);
}

.qlabel {
  max-width: calc(100% - 40px);
  color: var(--q);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.qedit {
  position: absolute;
  top: 6px;
  right: 6px;
  color: var(--q);
}

.qmid { text-align: center; padding: 4px 0 2px; }

.qtime {
  color: var(--q);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.qsince {
  margin-top: 2px;
  font-size: 17px;
  line-height: 1.2;
  color: var(--soft);
}

.tabbar {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(480px, 100%);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 6px 8px calc(8px + env(safe-area-inset-bottom));
  background: rgba(17, 8, 24, 0.92);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(16px);
}

.tab {
  min-height: 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border-radius: 14px;
  color: #ddd6ee;
  font-size: 17px;
  font-weight: 600;
}

.tab[aria-selected="true"] { color: #fff; }

.sheet {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  align-items: end;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  padding: 0;
  background: rgba(0, 0, 0, 0.58);
}

.sheet-panel {
  position: relative;
  width: min(480px, 100%);
  margin: 0 auto;
  max-height: min(88dvh, 720px);
  overflow: auto;
  padding: 10px 18px calc(18px + env(safe-area-inset-bottom));
  border-radius: 22px 22px 0 0;
  background: #1b1030;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-bottom: 0;
}

.sheet-grab {
  width: 40px;
  height: 5px;
  margin: 4px auto 14px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.28);
}

#editor-title, #about-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.editor-elapsed {
  margin-top: 8px;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.editor-since { margin-top: 4px; font-size: 17px; color: var(--soft); }

#editor-source { margin-top: 8px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 17px;
  font-weight: 600;
}

.btn-primary {
  width: 100%;
  margin-top: 16px;
  border: 0;
  background: #f4f0ff;
  color: #1a1028;
}

.btn-secondary {
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: transparent;
  color: var(--text);
}

.field {
  display: grid;
  gap: 8px;
  margin-top: 16px;
  font-size: 17px;
  color: var(--soft);
}

input[type="datetime-local"] {
  width: 100%;
  min-height: 48px;
  color-scheme: dark;
  background: #110818;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  padding: 8px 10px;
  font-size: 17px;
}

.edit-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.edit-actions .btn { flex: 1 1 8rem; }

.editor-note { margin-top: 14px; color: var(--soft); }

.form-error { margin-top: 8px; font-size: 17px; color: #ffd0d6; }

#about-body { display: grid; gap: 12px; margin-top: 12px; }

#about-body h3 {
  font-size: 18px;
  font-weight: 700;
}

.about-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 6px;
}

.about-list li { font-size: 17px; line-height: 1.35; }

.about-close { width: 100%; margin-top: 16px; }

#about-body .btn { width: 100%; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

:focus-visible {
  outline: 2px solid #f6f3ff;
  outline-offset: 3px;
}

@media (hover: hover) {
  .hit:hover, .tab:hover, .jump-back:hover, .btn-secondary:hover {
    background: rgba(255, 255, 255, 0.06);
  }
}

@media (prefers-reduced-motion: reduce) {
  .chev { transition: none; }
}

@media (min-width: 700px) {
  .sheet { align-items: center; padding: 24px; }
  .sheet-panel {
    border-radius: 22px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  }
}

html[data-tab="today"] #panel-week,
html[data-tab="today"] #panel-quit,
html[data-tab="week"] #panel-today,
html[data-tab="week"] #panel-quit,
html[data-tab="quit"] #panel-today,
html[data-tab="quit"] #panel-week {
  display: none;
}
