:root,
:root[data-theme="light"] {
  --bg: #f5f4ef;
  --bg-2: #ece9e1;
  --surface: rgba(255, 255, 255, 0.82);
  --surface-2: rgba(252, 250, 244, 0.75);
  --line: rgba(35, 35, 35, 0.12);
  --line-strong: rgba(35, 35, 35, 0.22);
  --text: #111216;
  --muted: #5f6269;
  --accent: #0f56ff;
  --accent-2: #00a59b;
  --radius: 18px;
  --shadow: 0 18px 48px rgba(14, 24, 36, 0.09);
}

:root[data-theme="dark"] {
  --bg: #0b0d11;
  --bg-2: #11141a;
  --surface: rgba(24, 29, 38, 0.78);
  --surface-2: rgba(16, 20, 28, 0.8);
  --line: rgba(213, 225, 255, 0.16);
  --line-strong: rgba(213, 225, 255, 0.28);
  --text: #f3f7ff;
  --muted: #afb9cd;
  --accent: #8aaeff;
  --accent-2: #5edbcc;
  --shadow: 0 22px 56px rgba(0, 0, 0, 0.42);
}

:root[data-theme="glass"] {
  --bg: #090d15;
  --bg-2: #101b2e;
  --surface: rgba(255, 255, 255, 0.11);
  --surface-2: rgba(255, 255, 255, 0.08);
  --line: rgba(255, 255, 255, 0.2);
  --line-strong: rgba(255, 255, 255, 0.34);
  --text: #f4f8ff;
  --muted: #ccd7eb;
  --accent: #9ebdff;
  --accent-2: #7cf0e0;
  --shadow: 0 28px 64px rgba(0, 0, 0, 0.44);
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  font-family: "Space Grotesk", system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(
      110vw 75vh at 0% 0%,
      rgba(15, 86, 255, 0.13),
      transparent 64%
    ),
    radial-gradient(
      85vw 70vh at 100% 100%,
      rgba(0, 165, 155, 0.14),
      transparent 66%
    ),
    linear-gradient(150deg, var(--bg), var(--bg-2));
}

.app-shell {
  max-width: 1120px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 18px 16px 108px;
}

.preloader {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  gap: 10px;
  background: #0d1322;
  z-index: 999;
  transition:
    opacity 0.35s ease,
    visibility 0.35s ease;
}
.preloader.done {
  opacity: 0;
  visibility: hidden;
}
.preloader-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.preloader-bar {
  width: 220px;
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
  overflow: hidden;
}
.preloader-bar span {
  display: block;
  width: 62%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  animation: slide 1s ease-in-out infinite;
}

.topbar,
.command-panel,
.panel,
.hero-card,
.stats article,
.now-block,
.item-card,
.quick-actions button,
.grid-links a,
.tabbar {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px) saturate(125%);
}

.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 12px;
}

.identity {
  display: flex;
  align-items: center;
  gap: 10px;
}
.pulse {
  width: 11px;
  height: 11px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 6px color-mix(in oklab, var(--accent) 18%, transparent);
}
.tiny {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.topbar h1 {
  margin: 2px 0 0;
  font-size: 22px;
  font-family: "Fraunces", serif;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.mode-switches {
  display: flex;
  gap: 8px;
  justify-self: center;
  flex-wrap: wrap;
}
.chip-link {
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 13px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--text);
  background: var(--surface-2);
}
.chip-link.subtle {
  opacity: 0.92;
}

.net-status {
  margin: 8px 0 0;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-2);
}
.net-status.offline {
  color: #ff6363;
}

.command-panel {
  margin-top: 10px;
  padding: 10px;
}
.command-row {
  margin-top: 8px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}
.command-inputs {
  display: grid;
  grid-template-columns: 1fr 44px;
  gap: 8px;
}
.command-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.command-row input,
.command-row button,
.story-controls button,
.cal-tab,
.pill-btn,
.share-form select,
.share-form button {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
}
.command-row input::placeholder {
  color: color-mix(in oklab, var(--muted) 78%, transparent);
}
.command-row button,
.story-controls button,
.cal-tab,
.pill-btn,
.share-form button {
  cursor: pointer;
  font-weight: 700;
}

.search-results {
  margin-top: 8px;
  max-height: 240px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  display: none;
  background: var(--surface);
}
.search-results.open {
  display: block;
}
.search-results .result {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 10px 12px;
}
.search-results .result:hover {
  background: color-mix(in oklab, var(--accent) 11%, transparent);
}

.quick-actions {
  margin: 10px 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.quick-actions button {
  padding: 12px;
  font-weight: 700;
}

.viewport {
  margin-top: 10px;
  display: grid;
  gap: 10px;
}
.screen {
  display: none;
  gap: 10px;
}
.screen.active {
  display: grid;
  animation: rise 0.25s ease-out;
}
.screen.swipe-left {
  animation: swipe-left 0.25s ease;
}
.screen.swipe-right {
  animation: swipe-right 0.25s ease;
}

.hero-card {
  display: grid;
  grid-template-columns: 206px 1fr;
  gap: 16px;
  padding: 14px;
  background: linear-gradient(
    150deg,
    color-mix(in oklab, var(--surface) 88%, white 12%),
    var(--surface)
  );
}
.hero-card img {
  width: 100%;
  height: 222px;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid var(--line);
  filter: saturate(1.04) contrast(1.02);
}
.hero-card h2 {
  margin: 8px 0;
  line-height: 1.18;
  font-size: clamp(27px, 3vw, 40px);
  font-family: "Fraunces", serif;
  font-weight: 600;
  letter-spacing: -0.03em;
}
.hero-ctas {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.hero-ctas a,
.links-row a,
.feed-card a,
#share-download,
.ledger-links a {
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 11px;
  color: var(--text);
  background: var(--surface-2);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.02em;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.stats article {
  padding: 12px;
}
.stats h3 {
  margin: 4px 0 2px;
  font-size: 25px;
  font-family: "Fraunces", serif;
}

.panel {
  padding: 12px;
}
.panel-head h3 {
  margin: 0;
  font-size: clamp(20px, 2.05vw, 29px);
  font-family: "Fraunces", serif;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.muted {
  color: var(--muted);
}

.more-section {
  padding: 10px 12px;
  border-style: dashed;
}
.more-section > summary {
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  font-weight: 700;
  gap: 8px;
}
.more-section > summary::-webkit-details-marker {
  display: none;
}
.more-section > summary::after {
  content: "+";
  font-size: 17px;
  color: var(--muted);
}
.more-section[open] > summary::after {
  content: "-";
}
.more-section[open] {
  padding-bottom: 12px;
}
.panel-nested {
  margin-top: 10px;
}

.split-grid,
.now-grid,
.badge-grid,
.analytics-grid,
.ledger-grid,
.card-list,
.events-list,
.timeline-rail,
.feed {
  display: grid;
  gap: 8px;
}

.split-grid,
.now-grid,
.badge-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.now-block,
.item-card,
.analytic,
.event-card,
.timeline-item,
.feed-card,
.ledger-card {
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 11px;
  background: var(--surface-2);
}

.bullet-list {
  margin-top: 8px;
  display: grid;
  gap: 6px;
}
.bullet-list p {
  margin: 0;
  padding-left: 10px;
  border-left: 2px solid color-mix(in oklab, var(--accent) 48%, var(--line));
}

.badge-grid span {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  background: var(--surface);
}

.live-track {
  margin-top: 8px;
  height: 5px;
  border-radius: 999px;
  background: color-mix(in oklab, var(--line) 84%, transparent);
  overflow: hidden;
}
.live-track span {
  display: block;
  height: 100%;
  width: 20%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}
.live-items {
  margin-top: 8px;
  display: grid;
  gap: 6px;
}
.live-item {
  margin: 0;
  color: var(--muted);
  padding-left: 8px;
  border-left: 2px solid var(--line);
}
.live-item.is-live {
  color: var(--text);
  border-left-color: var(--accent);
}

.story-controls {
  margin: 8px 0;
  display: grid;
  grid-template-columns: repeat(3, auto) 1fr;
  gap: 8px;
  align-items: center;
}
.timeline-item.active {
  border-color: color-mix(in oklab, var(--accent) 45%, var(--line));
  transform: translateY(-2px);
  box-shadow: 0 12px 28px color-mix(in oklab, var(--accent) 18%, transparent);
}
.timeline-item .dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
  margin-right: 8px;
  background: var(--accent-2);
}

.links-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.grid-links {
  margin-top: 8px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.grid-links a {
  padding: 10px 12px;
}

.share-form {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
}
.share-canvas {
  margin-top: 10px;
  width: 100%;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  background: var(--surface);
}
.hidden {
  display: none !important;
}

.calendar-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}
.cal-tab.active {
  background: color-mix(in oklab, var(--accent) 14%, var(--surface));
  border-color: color-mix(in oklab, var(--accent) 52%, var(--line));
}
.calendar-shell {
  position: relative;
  min-height: 420px;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface);
}
.calendar-glow {
  position: absolute;
  inset: -30%;
  pointer-events: none;
  background:
    radial-gradient(
      circle at 15% 20%,
      color-mix(in oklab, var(--accent) 22%, transparent),
      transparent 45%
    ),
    radial-gradient(
      circle at 90% 0%,
      color-mix(in oklab, var(--accent-2) 16%, transparent),
      transparent 40%
    );
}
.calendar-view iframe {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 420px;
  border: 0;
}

.radar-wrap {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 10px;
  align-items: center;
}
#impact-radar {
  width: 100%;
  max-width: 260px;
}
.radar-controls {
  display: grid;
  gap: 8px;
}
.radar-row {
  display: grid;
  grid-template-columns: 100px 1fr 45px;
  gap: 8px;
  align-items: center;
}

.tabbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 10px;
  width: min(96vw, 940px);
  padding: 7px;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
}
.tab {
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  color: var(--muted);
  padding: 10px 6px;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.02em;
  cursor: pointer;
}
.tab.active {
  color: var(--text);
  background: color-mix(in oklab, var(--accent) 15%, transparent);
  border-color: color-mix(in oklab, var(--accent) 45%, var(--line));
}

.search-hidden {
  display: none !important;
}
.pulse-highlight {
  animation: flash 0.85s ease;
}

a,
button,
.tab,
.item-card,
.panel {
  transition:
    transform 0.16s ease,
    background-color 0.22s ease,
    border-color 0.2s ease,
    box-shadow 0.24s ease;
}
a:hover,
button:hover,
.tab:hover,
.item-card:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
}
a:active,
button:active,
.tab:active {
  transform: scale(0.985);
}
:where(a, button, input, select, .tab):focus-visible {
  outline: 2px solid color-mix(in oklab, var(--accent) 65%, white);
  outline-offset: 2px;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@keyframes swipe-left {
  from {
    opacity: 0.34;
    transform: translateX(-28px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}
@keyframes swipe-right {
  from {
    opacity: 0.34;
    transform: translateX(28px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}
@keyframes slide {
  0% {
    transform: translateX(-62%);
  }
  50% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(62%);
  }
}
@keyframes flash {
  0% {
    box-shadow: 0 0 0 0 color-mix(in oklab, var(--accent) 36%, transparent);
  }
  100% {
    box-shadow: 0 0 0 14px transparent;
  }
}

@media (max-width: 980px) {
  .topbar {
    grid-template-columns: 1fr;
  }
  .mode-switches {
    justify-self: start;
  }
  .hero-card {
    grid-template-columns: 1fr;
  }
  .hero-card img {
    height: 272px;
  }
  .stats,
  .quick-actions,
  .split-grid,
  .now-grid,
  .badge-grid,
  .grid-links {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .tabbar {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .radar-wrap {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 14px 12px 108px;
  }
  .command-row {
    grid-template-columns: 1fr;
  }
  .share-form {
    grid-template-columns: 1fr;
  }
  .stats,
  .quick-actions,
  .split-grid,
  .now-grid,
  .badge-grid,
  .grid-links {
    grid-template-columns: 1fr;
  }
  .calendar-shell,
  .calendar-view iframe {
    min-height: 520px;
    height: 520px;
  }
}
