:root {
  color-scheme: dark;
  --bg: #0f1115;
  --bg-soft: #171a21;
  --line: #262b36;
  --text: #e6e8ee;
  --muted: #9aa3b2;
  --green: #2ea44f;
  --green-line: #3fbf66;
  --red: #b3453f;
  --red-line: #d9615a;
  --radius: 16px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

.main {
  max-width: 640px;
  margin: 0 auto;
  padding: 20px 16px 16px;
  padding-top: calc(20px + env(safe-area-inset-top));
  padding-left: calc(16px + env(safe-area-inset-left));
  padding-right: calc(16px + env(safe-area-inset-right));
  padding-bottom: calc(88px + env(safe-area-inset-bottom));
}

.title {
  font-size: 22px;
  margin: 0 0 12px;
}

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

.notice {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 16px;
  text-align: center;
}

.notice-title { font-size: 18px; margin: 0 0 8px; }
.notice-text { color: var(--muted); margin: 0; }

.message {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin: 0;
}

.message-error { border-color: var(--red-line); }

.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.btn-retry {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 6px 14px;
  font-size: 14px;
}

.capsules {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.capsule {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 14px 12px;
}

.capsule-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

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

.capsule-title {
  font-size: 17px;
  font-weight: 600;
  overflow-wrap: break-word;
}

.capsule-time {
  color: var(--muted);
  font-size: 13px;
  margin-left: 8px;
  white-space: nowrap;
}

.streak {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.done-at {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.grid-wrap { margin-top: 12px; }

.grid {
  display: flex;
  flex-wrap: nowrap;
  gap: 5px;
}

.cell {
  flex: 1 1 0;
  min-width: 0;
  height: 30px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: transparent;
}

.cell-on {
  background: var(--green);
  border-color: var(--green-line);
}

.cell-today {
  outline: 2px solid var(--muted);
  outline-offset: 1px;
}

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

.legend-key {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  border: 1px solid var(--line);
}

.legend-key-on { background: var(--green); border-color: var(--green-line); }

.legend-text { margin-right: 6px; }

.actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.btn {
  flex: 1 1 0;
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #1e2430;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  padding: 12px 10px;
  min-height: 46px;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.12s ease;
  touch-action: manipulation;
}

.btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.btn-done {
  background: var(--green);
  border-color: var(--green-line);
  color: #ffffff;
}

.btn-undo {
  background: var(--red);
  border-color: var(--red-line);
  color: #ffffff;
}

.btn:active:not(:disabled) { transform: scale(0.98); }

.tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px;
  padding-left: calc(12px + env(safe-area-inset-left));
  padding-right: calc(12px + env(safe-area-inset-right));
  padding-bottom: calc(8px + env(safe-area-inset-bottom));
  background: rgba(15, 17, 21, 0.96);
  border-top: 1px solid var(--line);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  padding: 10px 16px;
  min-height: 44px;
  border-radius: 12px;
  cursor: pointer;
}

.tab-active {
  color: var(--text);
  background: var(--bg-soft);
  border: 1px solid var(--line);
}

@media (prefers-reduced-motion: reduce) {
  .btn { transition: none; }
  .btn:active:not(:disabled) { transform: none; }
}


