:root {
  --bg: #f6f3ee;
  --panel: #fffdf9;
  --panel-strong: #172230;
  --text: #18202a;
  --muted: #6b7280;
  --line: #ded8ce;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --danger: #b42318;
  --warning: #b7791f;
  --ok: #15803d;
  --shadow: 0 16px 40px rgba(30, 41, 59, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(100%, 560px);
  min-height: 100vh;
  margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top)) 14px calc(24px + env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.08;
}

.clock {
  min-width: 58px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.hero {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  padding: 18px;
  border-radius: 8px;
  background: var(--panel-strong);
  color: #f8fafc;
  box-shadow: var(--shadow);
}

.hero-main {
  display: grid;
  gap: 8px;
}

.muted,
.hero-subtitle {
  color: rgba(248, 250, 252, 0.74);
}

.hero h2 {
  font-size: 24px;
  line-height: 1.16;
}

.hero-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.primary-action,
.ghost-action,
.secondary-action {
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  font-weight: 800;
}

.primary-action {
  background: #34d399;
  color: #06281e;
}

.primary-action:disabled {
  background: #94a3b8;
  color: #f8fafc;
  cursor: default;
}

.ghost-action {
  border: 1px solid rgba(248, 250, 252, 0.26);
  background: rgba(248, 250, 252, 0.08);
  color: #f8fafc;
}

.ghost-action:disabled {
  opacity: 0.5;
  cursor: default;
}

.secondary-action {
  width: 100%;
  background: var(--accent);
  color: white;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  margin: 18px 0 12px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 249, 0.7);
}

.tab {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.tab.is-active {
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
}

.tab-panel {
  display: none;
}

.tab-panel.is-active {
  display: block;
}

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

.day-row {
  display: grid;
  grid-template-columns: 54px 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  cursor: pointer;
}

.day-date {
  display: grid;
  gap: 2px;
  color: var(--muted);
  font-size: 12px;
}

.day-date strong {
  color: var(--text);
  font-size: 15px;
}

.day-info {
  min-width: 0;
}

.day-info strong,
.day-info span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.day-info span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}

.badge {
  min-width: 74px;
  padding: 7px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.badge.taken {
  background: rgba(21, 128, 61, 0.12);
  color: var(--ok);
}

.badge.today {
  background: rgba(15, 118, 110, 0.12);
  color: var(--accent-strong);
}

.badge.missed {
  background: rgba(180, 35, 24, 0.1);
  color: var(--danger);
}

.badge.future,
.badge.not_started {
  background: rgba(107, 114, 128, 0.12);
  color: var(--muted);
}

.settings-form {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  padding: 0 12px;
}

.system-list {
  display: grid;
  gap: 8px;
  margin: 0;
}

.system-list div {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

dt {
  color: var(--muted);
  font-weight: 700;
}

dd {
  margin: 0;
  font-weight: 800;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(18px);
  min-width: min(320px, calc(100vw - 28px));
  padding: 12px 14px;
  border-radius: 8px;
  background: #111827;
  color: white;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
  text-align: center;
  font-weight: 700;
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.day-editor {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
}

.day-editor.is-open {
  display: block;
}

.day-editor__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, 0.58);
}

.day-editor__panel {
  position: absolute;
  left: 50%;
  right: auto;
  bottom: 0;
  width: min(100%, 560px);
  transform: translateX(-50%);
  display: grid;
  gap: 14px;
  padding: 16px 14px calc(18px + env(safe-area-inset-bottom));
  border-radius: 12px 12px 0 0;
  background: var(--panel);
  box-shadow: 0 -18px 44px rgba(15, 23, 42, 0.24);
}

.editor-head {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: flex-start;
  gap: 12px;
}

.editor-head h2 {
  color: var(--text);
  font-size: 22px;
}

.editor-subtitle {
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.35;
}

.icon-button {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 26px;
  line-height: 1;
}

.editor-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.danger-action {
  min-height: 48px;
  border: 1px solid rgba(180, 35, 24, 0.28);
  border-radius: 8px;
  background: rgba(180, 35, 24, 0.1);
  color: var(--danger);
  font-weight: 800;
}

.danger-action:disabled {
  opacity: 0.45;
  cursor: default;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141a;
    --panel: #151d26;
    --panel-strong: #1b2a36;
    --text: #f8fafc;
    --muted: #9aa7b6;
    --line: #283442;
    --shadow: none;
  }
}
