/* Wrap, V6 "nocturnă" (HANDOVER §7; mockups in design/). */

:root {
  --bg: #080c24;
  --card: #12183d;
  --card-border: #232b5c;
  --rule: #1e2658;
  --art-bg: #1a2258;
  --art-line: #36418a;
  --text: #ffffff;
  --text-2: #a9b0d6;
  --label: #7fa6ff;
  --accent: #2f6bff;
  --hi: #ffd400;
  --on-accent: #ffffff;
  --on-hi: #080c24;

  --cond: "Barlow Condensed", "Arial Narrow", sans-serif;
  --body: "Barlow", system-ui, sans-serif;
  --app-w: min(100vw, 480px);
  --nav-h: 72px;
  color-scheme: dark;
}

/* Light: when the phone is light and the reader kept "Automat", or chose "Luminos".
   The two blocks hold the same values. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f4f5fa;
    --card: #ffffff;
    --card-border: #dce0ee;
    --rule: #e2e5f0;
    --art-bg: #e3e9fa;
    --art-line: #a9b7e8;
    --text: #0b1030;
    --text-2: #4a5278;
    --label: #2a55d6;
    color-scheme: light;
  }
}

:root[data-theme="light"] {
  --bg: #f4f5fa;
  --card: #ffffff;
  --card-border: #dce0ee;
  --rule: #e2e5f0;
  --art-bg: #e3e9fa;
  --art-line: #a9b7e8;
  --text: #0b1030;
  --text-2: #4a5278;
  --label: #2a55d6;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--body);
  -webkit-text-size-adjust: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--label);
  outline-offset: 2px;
}

.app {
  max-width: 480px;
  min-height: 100dvh;
  margin: 0 auto;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
}

main:focus {
  outline: none;
}

.notice {
  margin: 0;
  padding: 48px 24px;
  text-align: center;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text-2);
}

.retry {
  margin-top: 16px;
  min-height: 44px;
  padding: 0 20px;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  background: var(--card);
  cursor: pointer;
}

/* ---------- header ---------- */

.logo-bar {
  height: calc(64px + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border-bottom: 1px solid var(--rule);
}

.logo-mark {
  width: 14px;
  height: 26px;
  background: var(--accent);
  transform: skewX(-16deg);
}

.logo-word {
  margin: 0;
  font-family: var(--cond);
  font-style: italic;
  font-weight: 800;
  font-size: 32px;
  letter-spacing: 0.06em;
}

/* ---------- edition ---------- */

.edition-head {
  padding: 20px 20px 14px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.edition-date {
  margin: 0;
  font-family: var(--cond);
  font-style: italic;
  font-weight: 700;
  font-size: 28px;
  line-height: 1.1;
}

.edition-sub {
  margin: 2px 0 0;
  font-family: var(--cond);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-2);
}

.counter {
  font-family: var(--cond);
  font-style: italic;
  font-weight: 800;
  font-size: 22px;
  white-space: nowrap;
}

.carousel {
  display: flex;
  gap: 14px;
  padding: 0 20px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-padding-left: 20px;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
}

.carousel::-webkit-scrollbar {
  display: none;
}

.card,
.final {
  flex: 0 0 auto;
  width: calc(var(--app-w) - 72px);
  height: 590px;
  border-radius: 10px;
  scroll-snap-align: start;
}

.carousel-end {
  flex: 0 0 6px;
}

.card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--card);
  border: 1px solid var(--card-border);
}

.card-link {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.media {
  position: relative;
  flex-shrink: 0;
  height: 200px;
  overflow: hidden;
  background: var(--art-bg);
}

.media img,
.art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.art {
  stroke: var(--art-line);
}

.art .art-ball {
  fill: var(--hi);
  stroke: none;
}

.art .art-mark {
  stroke: var(--text);
}

.corner {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 72px;
  height: 72px;
  background: var(--accent);
  clip-path: polygon(100% 0, 100% 100%, 0 100%);
}

.num {
  position: absolute;
  left: 22px;
  top: 178px;
  height: 44px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  background: var(--hi);
  transform: skewX(-12deg);
}

.num span {
  transform: skewX(12deg);
  color: var(--on-hi);
  font-family: var(--cond);
  font-style: italic;
  font-weight: 800;
  font-size: 30px;
}

.card-text {
  min-height: 0;
  padding: 38px 20px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.label {
  margin: 0;
  font-family: var(--cond);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--label);
}

.card-title,
.card-desc {
  margin: 0;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  line-clamp: 4;
  overflow: hidden;
}

.card-title {
  font-family: var(--cond);
  font-style: italic;
  font-weight: 700;
  font-size: 30px;
  line-height: 1.02;
}

.card-desc {
  font-size: 15px;
  line-height: 1.45;
  color: var(--text-2);
}

.card-foot {
  padding: 0 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.status {
  height: 30px;
  display: flex;
  align-items: center;
}

.read-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--cond);
  font-weight: 800;
  font-size: 16px;
  letter-spacing: 0.1em;
}

.tick {
  width: 24px;
  height: 24px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
}

.meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 6px;
  border-top: 1px solid var(--card-border);
}

.meta {
  margin: 0;
  font-family: var(--cond);
  font-style: italic;
  font-weight: 700;
  font-size: 19px;
}

.save {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  margin-right: -10px;
  padding: 0;
  border: 0;
  background: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.save path {
  fill: none;
}

.save[aria-pressed="true"] path {
  fill: var(--text);
}

.final {
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 12px;
  background: var(--accent);
  color: var(--on-accent);
}

.final-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.final-kicker {
  margin: 0;
  font-family: var(--cond);
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.12em;
}

.final-title {
  margin: 0;
  font-family: var(--cond);
  font-style: italic;
  font-weight: 800;
  font-size: 52px;
  line-height: 0.95;
}

.final-next {
  margin: 0;
  font-size: 16px;
  line-height: 1.45;
}

/* ---------- bottom navigation ---------- */

.tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  max-width: 480px;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  margin: 0 auto;
  padding-bottom: env(safe-area-inset-bottom);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 1px solid var(--rule);
  background: var(--bg);
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 12px;
  font-weight: 500;
}

.tab[aria-current="page"] {
  color: var(--label);
  font-weight: 600;
}

body[data-screen="story"] .tabs {
  display: none;
}

body[data-screen="story"] .app {
  padding-bottom: 0;
}

/* ---------- story preview ---------- */

.bar {
  position: sticky;
  top: 0;
  z-index: 2;
  height: calc(64px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 8px 0 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--rule);
  background: var(--bg);
}

.back {
  height: 44px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 15px;
  font-weight: 600;
}

.bar .save {
  margin-right: 0;
}

.story-media {
  position: relative;
}

.story-media .media {
  height: 210px;
}

.story-media .corner {
  width: 90px;
  height: 90px;
}

.story-media .num {
  left: 24px;
  top: 188px;
}

.story-body {
  padding: 40px 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.story-head {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.story-title {
  margin: 0;
  font-family: var(--cond);
  font-style: italic;
  font-weight: 800;
  font-size: 38px;
  line-height: 1;
}

.story-desc {
  margin: 0;
  font-size: 17px;
  line-height: 1.45;
  color: var(--text-2);
}

.primary {
  min-height: 56px;
  padding: 0 20px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 16px;
  font-weight: 600;
}

.section-label {
  margin: 0;
  padding-bottom: 6px;
  font-family: var(--cond);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-2);
}

.also {
  margin: 0;
  padding: 0;
  list-style: none;
}

.also a {
  min-height: 56px;
  padding: 8px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--card-border);
}

.also li:last-child a {
  border-bottom: 1px solid var(--card-border);
}

.also-source {
  display: block;
  font-size: 15px;
  font-weight: 600;
}

.also-title {
  display: block;
  margin-top: 2px;
  font-size: 13px;
  line-height: 1.35;
  color: var(--text-2);
}

.out {
  flex-shrink: 0;
  stroke: var(--label);
}

.primary .out {
  stroke: currentColor;
}

.next-bar {
  position: sticky;
  bottom: 0;
  padding: 12px 20px calc(20px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--rule);
  background: var(--bg);
}

.next {
  min-height: 56px;
  padding: 0 20px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--card-border);
}

.next-text {
  min-width: 0;
}

.next-kicker {
  display: block;
  font-family: var(--cond);
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.12em;
}

.next-title {
  display: block;
  overflow: hidden;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* ---------- archive, saved and about ---------- */

.page {
  padding: 20px 20px 32px;
}

.page-title {
  margin: 0 0 16px;
  font-family: var(--cond);
  font-style: italic;
  font-weight: 800;
  font-size: 34px;
  line-height: 1;
}

.page h2 {
  margin: 28px 0 8px;
  font-family: var(--cond);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--label);
}

.page p,
.page ol li {
  font-size: 16px;
  line-height: 1.5;
  color: var(--text-2);
}

.page p {
  margin: 0 0 12px;
}

.page ol {
  margin: 0;
  padding-left: 22px;
}

.page .link {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.sources {
  margin: 0;
  padding: 0;
  list-style: none;
}

.sources a {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--card-border);
  color: var(--text);
  font-weight: 600;
}

.sources li:last-child a {
  border-bottom: 1px solid var(--card-border);
}

.saved-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.saved-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 14px 0;
  border-top: 1px solid var(--card-border);
}

.saved-item:last-child {
  border-bottom: 1px solid var(--card-border);
}

.saved-link {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.saved-title {
  font-family: var(--cond);
  font-style: italic;
  font-weight: 700;
  font-size: 22px;
  line-height: 1.05;
}

.saved-meta {
  font-size: 13px;
  color: var(--text-2);
}

.saved-item .save {
  margin-right: -10px;
}

.archive-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.archive-item {
  min-height: 56px;
  padding: 14px 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-top: 1px solid var(--card-border);
}

.archive-list li:last-child .archive-item {
  border-bottom: 1px solid var(--card-border);
}

.archive-date {
  font-family: var(--cond);
  font-style: italic;
  font-weight: 700;
  font-size: 22px;
  line-height: 1.05;
}

.archive-meta {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  font-size: 13px;
  line-height: 1.35;
  color: var(--text-2);
}

.theme-switch {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  background: var(--card);
}

.theme-option {
  min-height: 44px;
  border: 0;
  border-radius: 7px;
  background: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.theme-option[aria-checked="true"] {
  background: var(--accent);
  color: var(--on-accent);
}

.page .hint {
  margin: 8px 0 0;
  font-size: 14px;
}
