:root {
  color-scheme: light;
  --bg: #faf8f4;
  --ink: #1d1b17;
  --muted: #8d867a;
  --accent: #a2482c;
  --hairline: rgba(29, 27, 23, 0.14);
  --fill: rgba(29, 27, 23, 0.06);
  --sheet: #ffffff;
  --serif: "New York", ui-serif, "Iowan Old Style", Charter, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #101010;
    --ink: #ece9e3;
    --muted: #97907f;
    --accent: #d08a63;
    --hairline: rgba(236, 233, 227, 0.16);
    --fill: rgba(236, 233, 227, 0.08);
    --sheet: #1c1c1c;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

.page {
  max-width: 620px;
  margin: 0 auto;
  padding: 0 24px calc(96px + env(safe-area-inset-bottom));
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ── Шапка ─────────────────────────────────────────────── */

.masthead {
  text-align: center;
  padding: 40px 0 28px;
  border-bottom: 1px solid var(--hairline);
}

.date-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.nav-button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  cursor: pointer;
}

.nav-button svg { width: 18px; height: 18px; }

.nav-button:disabled { opacity: 0.25; cursor: default; }

.today-link {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
  padding: 2px 0 0;
}

.kicker {
  margin: 0 0 10px;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.date-nav .kicker { margin: 0; }

.wordmark {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: 2rem;
  letter-spacing: 0.01em;
}

/* ── Стихотворение ─────────────────────────────────────── */

.poem {
  flex: 1;
  padding: 36px 0 24px;
  animation: rise 0.7s ease both;
}

.byline {
  margin: 0 0 6px;
  font-size: 0.85rem;
  color: var(--accent);
  animation: rise 0.7s 0.08s ease both;
}

.poem-title {
  margin: 0 0 28px;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(1.4rem, 1rem + 2vw, 1.7rem);
  line-height: 1.25;
  animation: rise 0.7s 0.16s ease both;
}

.poem-text {
  font-family: var(--serif);
  font-size: clamp(1.06rem, 0.95rem + 0.8vw, 1.2rem);
  line-height: 1.7;
  white-space: pre-line;
  animation: rise 0.7s 0.26s ease both;
}

.poem.loading .byline,
.poem.loading .poem-title { color: transparent; }
.poem.loading .poem-text { color: var(--muted); font-style: italic; }

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .poem, .byline, .poem-title, .poem-text { animation: none; }
}

/* ── Панель действий ───────────────────────────────────── */

.toolbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  border-top: 1px solid var(--hairline);
}

.toolbar-buttons { display: flex; align-items: center; gap: 4px; }

.segmented {
  display: flex;
  background: var(--fill);
  border-radius: 9px;
  padding: 2px;
}

.segmented button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.82rem;
  padding: 5px 14px;
  border-radius: 7px;
  cursor: pointer;
}

.segmented button.active {
  background: var(--sheet);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
}

.text-button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: 0.92rem;
  padding: 8px 10px;
  cursor: pointer;
}

.text-button.muted { color: var(--muted); }

.icon-button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink);
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  cursor: pointer;
}

.icon-button svg { width: 21px; height: 21px; }

.icon-button.on { color: var(--accent); }

.icon-button:disabled { opacity: 0.3; cursor: default; }

.text-button:active, .icon-button:active:not(:disabled), .segmented button:active { opacity: 0.55; }

/* ── Лист «Ещё действия» ──────────────────────────────── */

.sheet-rows {
  display: flex;
  flex-direction: column;
  margin-bottom: 18px;
}

.sheet-row {
  appearance: none;
  border: 0;
  border-bottom: 1px solid var(--hairline);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.95rem;
  text-align: left;
  padding: 13px 2px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.sheet-row:last-child { border-bottom: 0; }

.row-detail { color: var(--muted); font-size: 0.82rem; }

.sheet-subhead {
  margin: 6px 0 4px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
}

.sheet-history {
  max-height: 40vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.history-row {
  appearance: none;
  border: 0;
  border-bottom: 1px solid var(--hairline);
  background: transparent;
  font: inherit;
  text-align: left;
  width: 100%;
  padding: 10px 2px;
  cursor: pointer;
  display: block;
}

.history-title {
  display: block;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-author {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
}

.custom-time {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: -6px 0 20px;
  font-size: 0.9rem;
  color: var(--muted);
}

.custom-time input {
  font: inherit;
  color: var(--ink);
  background: var(--fill);
  border: 0;
  border-radius: 8px;
  padding: 7px 12px;
}

/* ── Лист настроек уведомлений ─────────────────────────── */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(0, 0, 0, 0.32);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet-backdrop[hidden] { display: none; }

.sheet {
  width: 100%;
  max-width: 480px;
  background: var(--sheet);
  border-radius: 16px 16px 0 0;
  padding: 22px 24px calc(20px + env(safe-area-inset-bottom));
  animation: sheet-up 0.28s ease both;
}

@keyframes sheet-up {
  from { transform: translateY(24px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.sheet h3 {
  margin: 0 0 8px;
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.2rem;
}

.sheet-note {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.sheet-times {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.sheet-times button {
  flex: 1;
  appearance: none;
  border: 1px solid var(--hairline);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.95rem;
  padding: 10px 0;
  border-radius: 10px;
  cursor: pointer;
}

.sheet-times button.active {
  border-color: var(--accent);
  color: var(--accent);
}

.sheet-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

@media (min-width: 600px) {
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: 16px; }
}
