/* --- Theme tokens --- */
:root {
  --bg: #faf7f2;
  --surface: #ffffff;
  --surface-2: #f3efe8;
  --text: #1d1b18;
  --text-muted: #6e655a;
  --accent: #a01717;
  --accent-soft: #f5e3e3;
  --border: #e2dccf;
  --shadow: 0 1px 2px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.03);
  --radius: 14px;
  --radius-sm: 8px;
  --safe-top: env(safe-area-inset-top);
  --safe-bottom: env(safe-area-inset-bottom);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16140f;
    --surface: #1f1c16;
    --surface-2: #28241c;
    --text: #f1ebde;
    --text-muted: #aaa192;
    --accent: #ff6868;
    --accent-soft: #3a1a1a;
    --border: #322d23;
    --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 4px 12px rgba(0,0,0,0.2);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI",
    Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  min-height: 100dvh;
}

/* --- Top bar --- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding-top: var(--safe-top);
  backdrop-filter: saturate(140%) blur(8px);
}
.topbar-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.title h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--accent);
}
.meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
.actions {
  display: flex;
  gap: 4px;
}
.icon-btn {
  background: transparent;
  border: none;
  color: var(--text);
  padding: 8px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn:active { transform: scale(0.95); }

/* --- Main + status --- */
main {
  max-width: 720px;
  margin: 0 auto;
  padding: 18px 18px calc(18px + var(--safe-bottom));
}
.status {
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  padding: 60px 20px;
}
.status.error { color: var(--accent); }

/* --- Story cards --- */
.stories {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.story {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.08s ease, border-color 0.15s ease;
}
.story:hover { border-color: var(--text-muted); }
.story:active { transform: scale(0.995); }

.story-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}
.story-headline {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.32;
  margin: 0;
  color: var(--text);
  flex: 1;
}
.badge {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  white-space: nowrap;
}
.story-summary {
  font-size: 14.5px;
  color: var(--text-muted);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.story-foot {
  margin-top: 8px;
  font-size: 11.5px;
  color: var(--text-muted);
  display: flex;
  gap: 10px;
}

/* --- Dialog (story detail) --- */
.story-dialog {
  border: none;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  max-width: 560px;
  width: calc(100% - 24px);
  max-height: 85vh;
  padding: 24px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.25);
}
.story-dialog::backdrop {
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
}
.dialog-close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: transparent;
  border: none;
  font-size: 28px;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
}
.dialog-headline-en {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.3;
  margin: 0 0 6px 0;
}
.dialog-headline-hi {
  font-size: 16px;
  color: var(--text-muted);
  margin: 0 0 14px 0;
  line-height: 1.4;
}
.dialog-summary {
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  margin: 0 0 14px 0;
}
.dialog-meta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  gap: 12px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

/* --- Settings dialog --- */
.story-dialog h2 {
  margin: 0 0 12px 0;
  font-size: 18px;
}
.notif-status {
  font-size: 14px;
  color: var(--text-muted);
  margin: 0 0 16px 0;
}
.notif-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.primary-btn, .secondary-btn {
  font-size: 14px;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-family: inherit;
}
.primary-btn {
  background: var(--accent);
  color: #fff;
}
.primary-btn:hover { opacity: 0.92; }
.primary-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.secondary-btn {
  background: var(--surface-2);
  color: var(--text);
}
.notif-hint {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0;
}
