:root {
  color-scheme: dark;
  --bg: #07101d;
  --bg-deep: #040a13;
  --surface: rgba(17, 29, 48, .78);
  --surface-solid: #101d30;
  --surface-soft: rgba(255, 255, 255, .035);
  --text: #f7f4ed;
  --muted: #9aa7ba;
  --muted-strong: #bdc7d5;
  --border: rgba(181, 196, 218, .14);
  --border-strong: rgba(181, 196, 218, .24);
  --accent: #d8ad5d;
  --accent-bright: #f1ca7c;
  --accent-soft: rgba(216, 173, 93, .10);
  --success: #8cd7ad;
  --danger: #f19a9a;
  --shadow: 0 20px 60px rgba(0, 0, 0, .28);
  --serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  font-family: var(--sans);
  background:
    linear-gradient(180deg, rgba(255,255,255,.012), transparent 22%),
    var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, textarea { font: inherit; }
button { cursor: pointer; }

.ambient {
  position: fixed;
  pointer-events: none;
  border-radius: 999px;
  filter: blur(72px);
  opacity: .18;
  z-index: -1;
}
.ambient-one {
  width: 280px;
  height: 280px;
  top: -120px;
  right: -120px;
  background: #37547b;
}
.ambient-two {
  width: 220px;
  height: 220px;
  left: -150px;
  top: 36vh;
  background: #8b672b;
  opacity: .10;
}

.app-shell {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: calc(20px + env(safe-area-inset-top)) 20px calc(112px + env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 42px;
}
.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid rgba(216, 173, 93, .38);
  border-radius: 14px;
  background: linear-gradient(145deg, rgba(216, 173, 93, .12), rgba(255,255,255,.025));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
}
.brand-mark svg { width: 30px; height: 30px; }
.brand-mark .beam { fill: rgba(241, 202, 124, .36); }
.brand-mark .tower,
.brand-mark .base { fill: var(--accent-bright); }
.brand-mark .window { fill: var(--bg-deep); }
.brand-name {
  margin: 0;
  color: var(--accent-bright);
  font-size: .77rem;
  letter-spacing: .22em;
  font-weight: 800;
}
.brand-subtitle {
  margin: 3px 0 0;
  color: var(--muted);
  font-family: var(--serif);
  font-style: italic;
  font-size: .78rem;
}
.date-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted-strong);
  background: rgba(9, 18, 31, .58);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  font-size: .74rem;
  white-space: nowrap;
}
.date-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(216, 173, 93, .08);
}

h1, h2, h3, p { margin-top: 0; }
h1, h2 {
  font-family: var(--serif);
  font-weight: 500;
  letter-spacing: -.025em;
}
h1 {
  margin-bottom: 12px;
  font-size: clamp(2.25rem, 9.2vw, 4rem);
  line-height: 1.02;
}
h2 {
  margin-bottom: 7px;
  font-size: clamp(1.45rem, 5.6vw, 2rem);
  line-height: 1.15;
}
p { line-height: 1.65; }
.overline,
.section-kicker {
  margin: 0 0 10px;
  color: var(--accent);
  font-family: var(--sans);
  font-size: .66rem;
  letter-spacing: .18em;
  font-weight: 850;
}
.muted { color: var(--muted); }
.hidden { display: none !important; }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: panel-in .32s ease both; }

.empty-state {
  min-height: 62vh;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  padding: 16px 0 36px;
}
.empty-orbit {
  width: 74px;
  height: 74px;
  margin-bottom: 28px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(216, 173, 93, .3);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(216,173,93,.12), transparent 68%);
  color: var(--accent-bright);
  font-size: 1.5rem;
  box-shadow: 0 0 0 14px rgba(216, 173, 93, .025);
}
.empty-state h1 { max-width: 560px; }
.empty-state > p:not(.overline) {
  max-width: 520px;
  margin-bottom: 26px;
  color: var(--muted-strong);
  font-size: 1rem;
}

.edition-header {
  position: relative;
  padding: 4px 0 30px;
  margin-bottom: 22px;
}
.edition-header::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 54px;
  height: 1px;
  background: var(--accent);
  box-shadow: 64px 0 0 rgba(181,196,218,.15), 128px 0 0 rgba(181,196,218,.08);
}
.edition-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
  font-size: .78rem;
}
.edition-meta .overline { margin: 0; }
.meta-separator {
  width: 18px;
  height: 1px;
  background: var(--border-strong);
}
.edition-deck {
  margin: 0;
  color: var(--muted-strong);
  font-family: var(--serif);
  font-size: 1.04rem;
  font-style: italic;
}

.focus-card {
  position: relative;
  display: grid;
  grid-template-columns: 3px 1fr;
  gap: 20px;
  margin: 28px 0 40px;
  padding: 22px 22px 20px;
  overflow: hidden;
  border: 1px solid rgba(216, 173, 93, .23);
  border-radius: 22px;
  background:
    linear-gradient(135deg, rgba(216,173,93,.085), rgba(255,255,255,.018) 58%),
    rgba(12, 23, 39, .78);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04), var(--shadow);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
.focus-accent {
  width: 3px;
  min-height: 100%;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--accent-bright), rgba(216,173,93,.22));
}
.focus-content { min-width: 0; }
.focus-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.section-kicker { margin-bottom: 13px; }
.focus-badge {
  align-self: flex-start;
  padding: 5px 8px;
  border: 1px solid rgba(216,173,93,.2);
  border-radius: 999px;
  color: var(--muted-strong);
  font-size: .7rem;
  white-space: nowrap;
}
#dailyFocusText {
  color: var(--text);
  font-family: var(--serif);
  font-size: 1.16rem;
  line-height: 1.55;
}
#dailyFocusText p:last-child { margin-bottom: 0; }
.action-check {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 20px;
  color: var(--muted);
  font-size: .86rem;
  cursor: pointer;
}
.action-check input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}
.custom-check {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: rgba(255,255,255,.025);
  transition: .2s ease;
}
.action-check input:checked + .custom-check {
  border-color: var(--accent);
  background: var(--accent);
}
.action-check input:checked + .custom-check::after {
  content: "✓";
  color: #1c1407;
  font-size: .8rem;
  font-weight: 900;
}
.action-check input:focus-visible + .custom-check {
  outline: 2px solid var(--accent-bright);
  outline-offset: 3px;
}

.content-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 16px;
}
.content-heading .overline { margin-bottom: 8px; }
.content-heading h2 { margin-bottom: 0; }
.content-heading > p,
.page-heading > p:not(.overline) {
  margin-bottom: 2px;
  color: var(--muted);
  font-size: .86rem;
  text-align: right;
}

.sections-list {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}
.briefing-row {
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: 16px;
  transition: background .2s ease, border-color .2s ease, transform .2s ease;
}
.briefing-row:has(.row-toggle[aria-expanded="true"]) {
  border-color: var(--border);
  background: rgba(255,255,255,.026);
}
.row-toggle {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 17px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  text-align: left;
}
.row-leading {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 14px;
}
.row-index {
  min-width: 27px;
  color: var(--accent);
  font-family: var(--serif);
  font-size: .78rem;
  font-style: italic;
}
.row-title {
  color: var(--muted-strong);
  font-size: .96rem;
  line-height: 1.35;
  font-weight: 650;
  transition: color .2s ease;
}
.row-toggle[aria-expanded="true"] .row-title { color: var(--text); }
.chevron {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 1.2rem;
  font-weight: 300;
  transition: transform .22s ease, color .22s ease;
}
.row-toggle[aria-expanded="true"] .chevron {
  color: var(--accent);
  transform: rotate(45deg);
}
.row-body {
  display: none;
  padding: 0 18px 22px 55px;
  color: #d8e0ea;
  font-size: .94rem;
  line-height: 1.75;
  white-space: pre-wrap;
}
.row-body.open { display: block; animation: reveal .24s ease both; }
.row-body a {
  color: var(--accent-bright);
  text-decoration-color: rgba(241,202,124,.38);
  text-underline-offset: 3px;
}
.row-body strong { color: var(--text); }
.row-body blockquote {
  margin: 16px 0;
  padding: 14px 0 14px 17px;
  border-left: 1px solid var(--accent);
  color: var(--text);
  font-family: var(--serif);
  font-size: 1.04rem;
  font-style: italic;
}

.page-heading { margin-bottom: 28px; }
.page-heading .text-button { margin-bottom: 30px; }
.page-heading h1 { font-size: clamp(2.15rem, 8vw, 3.4rem); }
.page-heading > p:not(.overline) {
  max-width: 520px;
  text-align: left;
}
.archive-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.import-panel {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
}
.import-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}
.import-label-row label {
  color: var(--text);
  font-size: .86rem;
  font-weight: 700;
}
.import-label-row span {
  color: var(--muted);
  font-size: .72rem;
}
textarea {
  width: 100%;
  min-height: 46vh;
  resize: vertical;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 0;
  outline: none;
  line-height: 1.6;
}
textarea::placeholder { color: #66758a; }

.button-row {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}
.button {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  border-radius: 14px;
  border: 1px solid transparent;
  padding: 12px 16px;
  font-weight: 760;
  transition: transform .16s ease, opacity .16s ease, border-color .16s ease;
}
.button:active { transform: scale(.985); }
.button.primary {
  background: linear-gradient(135deg, var(--accent-bright), var(--accent));
  color: #1c1407;
  box-shadow: 0 12px 28px rgba(128, 87, 19, .18);
}
.button.secondary {
  background: rgba(255,255,255,.025);
  color: var(--muted-strong);
  border-color: var(--border);
}
.text-button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted-strong);
  font-size: .82rem;
  font-weight: 700;
}
.danger-text { color: var(--danger); }
.feedback {
  min-height: 22px;
  margin: 14px 0 0;
  color: var(--success);
  font-size: .84rem;
}

.archive-list {
  display: grid;
  gap: 10px;
  margin-top: 24px;
}
.archive-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 17px 18px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(255,255,255,.018);
}
.archive-item strong {
  font-family: var(--serif);
  font-size: 1rem;
  font-weight: 500;
}
.archive-item button {
  border: 0;
  background: transparent;
  color: var(--accent-bright);
  font-size: .78rem;
  font-weight: 800;
}
.archive-meta {
  margin-top: 5px;
  color: var(--muted);
  font-size: .76rem;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: calc(12px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(390px, calc(100% - 28px));
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 5px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: rgba(8, 17, 30, .82);
  backdrop-filter: blur(22px) saturate(130%);
  -webkit-backdrop-filter: blur(22px) saturate(130%);
  box-shadow: 0 18px 50px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.045);
  z-index: 10;
}
.tab {
  position: relative;
  min-height: 55px;
  border: 0;
  border-radius: 15px;
  background: transparent;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: .69rem;
  transition: color .2s ease, background .2s ease;
}
.tab-icon {
  color: inherit;
  font-size: 1.03rem;
  line-height: 1;
}
.tab.active {
  color: var(--text);
  background: rgba(255,255,255,.045);
}
.tab.active::after {
  content: "";
  position: absolute;
  bottom: 7px;
  width: 12px;
  height: 1px;
  background: var(--accent);
}

@keyframes panel-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes reveal {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 520px) {
  .app-shell { padding-left: 18px; padding-right: 18px; }
  .topbar { margin-bottom: 34px; }
  .brand-subtitle { display: none; }
  .date-badge { padding: 7px 9px; }
  .content-heading { align-items: flex-start; }
  .content-heading > p { display: none; }
  .focus-card { grid-template-columns: 2px 1fr; gap: 16px; padding: 20px 18px; }
  .row-body { padding-left: 55px; padding-right: 15px; }
  .button-row { flex-direction: column; }
  .button { width: 100%; }
  .archive-heading { align-items: baseline; }
}

@media (min-width: 680px) {
  .app-shell { padding-left: 34px; padding-right: 34px; }
  .focus-card { padding: 26px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* Multimedia y referencias */
.formatted-text > *:last-child { margin-bottom: 0; }
.formatted-text p { margin: 0 0 13px; }
.inline-heading {
  margin: 22px 0 9px;
  color: var(--text);
  font-family: var(--serif);
  font-size: 1.08rem;
  font-weight: 560;
}
.briefing-list {
  display: grid;
  gap: 8px;
  margin: 10px 0 16px;
  padding-left: 18px;
}
.briefing-list li { padding-left: 3px; }
.briefing-list li::marker { color: var(--accent); }

.media-stack {
  display: grid;
  gap: 13px;
  margin-top: 20px;
}
.media-figure {
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(255,255,255,.018);
}
.media-image {
  position: relative;
  display: block;
  min-height: 160px;
  background: linear-gradient(145deg, rgba(216,173,93,.08), rgba(255,255,255,.025));
}
.media-image img {
  display: block;
  width: 100%;
  max-height: 370px;
  object-fit: cover;
}
.media-image-fallback {
  display: none;
  min-height: 160px;
  align-items: center;
  justify-content: center;
  padding: 24px;
  color: var(--muted);
  font-size: .82rem;
  text-align: center;
}
.media-image.media-error img { display: none; }
.media-image.media-error .media-image-fallback { display: flex; }
.media-figure figcaption {
  display: grid;
  gap: 6px;
  padding: 12px 14px 14px;
  color: var(--muted-strong);
  font-size: .76rem;
  line-height: 1.45;
}
.media-figure figcaption a {
  width: fit-content;
  color: var(--accent-bright);
  font-weight: 700;
  text-decoration: none;
}
.video-card,
.source-card {
  position: relative;
  display: grid;
  align-items: center;
  gap: 13px;
  border: 1px solid var(--border);
  border-radius: 17px;
  background: rgba(255,255,255,.022);
  color: var(--text) !important;
  text-decoration: none !important;
  transition: border-color .18s ease, background .18s ease, transform .18s ease;
}
.video-card {
  grid-template-columns: 96px minmax(0, 1fr) auto;
  padding: 9px 13px 9px 9px;
}
.video-card:active,
.source-card:active { transform: scale(.99); }
.video-card:hover,
.source-card:hover {
  border-color: rgba(216,173,93,.3);
  background: rgba(216,173,93,.045);
}
.video-visual {
  position: relative;
  width: 96px;
  aspect-ratio: 16 / 10;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 11px;
  background: linear-gradient(145deg, #172940, #0a1422);
}
.video-visual img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: .78;
}
.video-visual.media-error img { display: none; }
.video-placeholder { color: var(--accent-bright); }
.play-button {
  position: absolute;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  padding-left: 2px;
  border: 1px solid rgba(255,255,255,.24);
  border-radius: 50%;
  background: rgba(4,10,19,.72);
  color: var(--text);
  font-size: .7rem;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.video-copy {
  min-width: 0;
  display: grid;
  gap: 4px;
}
.video-copy strong,
.source-card strong {
  overflow: hidden;
  color: var(--text);
  font-size: .86rem;
  line-height: 1.32;
  text-overflow: ellipsis;
}
.video-copy small { color: var(--muted); }
.media-eyebrow {
  color: var(--accent);
  font-size: .6rem;
  letter-spacing: .14em;
  font-weight: 850;
}
.external-arrow {
  color: var(--accent-bright);
  font-size: .9rem;
}
.source-card {
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 14px 15px;
}
.source-card > span:first-child { display: grid; gap: 4px; }

.format-help {
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: 17px;
  background: rgba(255,255,255,.018);
}
.format-help summary {
  padding: 14px 16px;
  color: var(--muted-strong);
  font-size: .84rem;
  font-weight: 750;
  cursor: pointer;
}
.format-help[open] summary { color: var(--text); }
.format-help-body {
  padding: 0 16px 16px;
  color: var(--muted);
  font-size: .82rem;
}
.format-help-body p { margin-bottom: 12px; }
.format-help-body pre {
  overflow-x: auto;
  margin: 0;
  padding: 14px;
  border: 1px solid rgba(181,196,218,.1);
  border-radius: 13px;
  background: rgba(3,9,17,.55);
  color: #d9e1ec;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .7rem;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}
.format-note { margin: 11px 0 0 !important; font-size: .75rem; }

@media (max-width: 520px) {
  .video-card { grid-template-columns: 82px minmax(0, 1fr) auto; }
  .video-visual { width: 82px; }
}
.row-body { white-space: normal; }
