*, *::before, *::after {
  box-sizing: border-box;
}

:root {
  --bg: #e9e1d6;
  --surface: rgba(255, 252, 247, 0.64);
  --surface-strong: rgba(255, 251, 245, 0.88);
  --line: rgba(55, 40, 26, 0.2);
  --text: #1b1611;
  --muted: #49382b;
  --accent: #c25a21;
  --cyan: #2fc9c2;
  --ink: #25373a;
  --shadow: 0 24px 60px rgba(35, 25, 16, 0.16);
  --radius-lg: 24px;
  --radius-md: 14px;
  --font: Georgia, "Times New Roman", "Songti SC", serif;
  --font-mono: "SF Mono", "Fira Code", "Courier New", monospace;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  color: var(--text);
  background:
    linear-gradient(rgba(245, 238, 229, 0.74), rgba(232, 223, 212, 0.78)),
    linear-gradient(180deg, #f4ede4 0%, #e6ddcf 100%);
  font-family: var(--font);
  line-height: 1.6;
  font-weight: 500;
  overflow-x: hidden;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.86' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 220px 220px;
  z-index: 2;
}

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

button,
input {
  font: inherit;
}

.page-border {
  position: fixed;
  inset: 8px;
  border: 1px solid var(--line);
  pointer-events: none;
  z-index: 4;
}

.page-border::before {
  content: "";
  position: absolute;
  inset: 4px;
  border: 1px solid rgba(55, 40, 26, 0.12);
}

.home-page {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  padding: 14px;
  display: grid;
  grid-template-columns: minmax(280px, 1.2fr) minmax(360px, 1.55fr) minmax(260px, 0.9fr);
  grid-template-rows: 58px minmax(260px, 1fr) minmax(180px, 0.72fr);
  gap: 12px;
}

.glass {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px) saturate(140%);
}

.glass::before {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: calc(var(--radius-lg) - 6px);
  pointer-events: none;
  opacity: .48;
  z-index: 1;
}

.top-strip {
  grid-column: 1 / 4;
  grid-row: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 10px;
}

.kicker {
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
}

.top-strip h1,
.panel-title h2,
.focus-copy h2 {
  margin: 0;
  line-height: 1;
}

.top-strip h1 {
  font-size: clamp(26px, 2.4vw, 38px);
}

.nav-pills,
.focus-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.pill,
.main-action,
.ghost-action {
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(55, 40, 26, 0.17);
  border-radius: 999px;
  background: rgba(255, 252, 247, 0.72);
  box-shadow: 0 10px 24px rgba(35, 25, 16, 0.08);
  padding: 0 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.pill.primary,
.main-action {
  border-color: rgba(194, 90, 33, .46);
  background: rgba(194, 90, 33, .14);
  color: #7b3111;
}

.focus-panel {
  grid-column: 1;
  grid-row: 2 / 4;
}

.panel-inner {
  position: relative;
  z-index: 2;
  height: 100%;
  padding: 22px;
  display: grid;
  grid-template-rows: auto minmax(180px, 1fr) auto;
  gap: 18px;
}

.focus-copy {
  display: grid;
  gap: 10px;
}

.focus-copy h2 {
  max-width: 12ch;
  font-size: clamp(30px, 4.4vw, 58px);
}

.focus-copy p {
  margin: 0;
  max-width: 34ch;
  color: var(--muted);
  font-size: 15px;
}

.cover-stack {
  position: relative;
  min-height: 220px;
  display: grid;
  place-items: center;
}

.cover-sheet {
  position: absolute;
  width: min(68%, 230px);
  aspect-ratio: 0.72;
  border: 1px solid rgba(55, 40, 26, 0.22);
  border-radius: 8px;
  background: linear-gradient(145deg, #fff7eb, #ddcbb4);
  box-shadow: 0 28px 46px rgba(35, 25, 16, 0.2);
}

.cover-sheet.front {
  z-index: 3;
  padding: 22px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transform: rotate(-4deg);
}

.cover-sheet.middle {
  z-index: 2;
  transform: translate(20px, 18px) rotate(7deg);
  background: linear-gradient(145deg, rgba(47, 201, 194, 0.32), rgba(255, 252, 247, 0.76));
}

.cover-sheet.back {
  z-index: 1;
  transform: translate(-18px, 30px) rotate(-12deg);
  background: linear-gradient(145deg, rgba(37, 55, 58, 0.2), rgba(255, 252, 247, 0.72));
}

.cover-sheet span,
.cover-sheet strong {
  font-family: var(--font-mono);
  letter-spacing: 0;
}

.cover-sheet span {
  font-size: 12px;
  color: var(--accent);
}

.cover-sheet strong {
  font-size: 28px;
  color: var(--ink);
  word-break: break-word;
}

.focus-actions {
  justify-content: flex-start;
  flex-wrap: wrap;
}

.route-panel {
  grid-column: 2;
  grid-row: 2;
  padding: 18px;
}

.recent-panel {
  grid-column: 2 / 4;
  grid-row: 3;
  padding: 18px;
}

.status-panel {
  grid-column: 3;
  grid-row: 2;
  padding: 18px;
}

.panel-title {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-title h2 {
  font-size: 24px;
}

.route-grid {
  position: relative;
  z-index: 2;
  height: calc(100% - 48px);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.route-tile {
  min-height: 120px;
  display: grid;
  align-content: space-between;
  gap: 10px;
  border: 1px solid rgba(55, 40, 26, 0.14);
  border-radius: var(--radius-md);
  background: rgba(255, 252, 247, 0.64);
  padding: 14px;
}

.route-tile.active {
  border-color: rgba(47, 201, 194, .45);
  background: rgba(47, 201, 194, .12);
}

.route-tile span,
.route-tile em,
.status-row span,
.recent-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  font-style: normal;
  color: var(--muted);
  font-weight: 700;
}

.route-tile strong {
  font-size: 22px;
  line-height: 1.08;
}

.status-list,
.recent-list {
  position: relative;
  z-index: 2;
  display: grid;
  gap: 10px;
}

.status-row,
.recent-row,
.empty-row {
  border: 1px solid rgba(55, 40, 26, 0.13);
  border-radius: var(--radius-md);
  background: rgba(255, 252, 247, 0.68);
  padding: 13px;
}

.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.status-row strong {
  color: #315c58;
  font-family: var(--font-mono);
  font-size: 12px;
}

.recent-row {
  min-height: 72px;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.recent-format {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(194, 90, 33, .24);
  border-radius: 8px;
  background: rgba(194, 90, 33, .12);
  color: #7b3111;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 800;
}

.recent-copy {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.recent-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 18px;
  font-weight: 800;
}

.recent-open {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(47, 201, 194, .42);
  border-radius: 999px;
  background: rgba(47, 201, 194, .13);
  font-family: var(--font-mono);
  font-weight: 800;
}

.empty-row {
  color: var(--muted);
}

@media (max-width: 980px) {
  .home-page {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
  }

  .top-strip,
  .focus-panel,
  .route-panel,
  .status-panel,
  .recent-panel {
    grid-column: 1;
    grid-row: auto;
  }

  .top-strip {
    align-items: flex-start;
    flex-direction: column;
    padding: 8px 4px;
  }

  .nav-pills {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .focus-copy h2 {
    max-width: 100%;
  }

  .route-grid {
    height: auto;
    grid-template-columns: 1fr;
  }

  .recent-panel {
    padding-bottom: 24px;
  }
}

@media (max-width: 560px) {
  .home-page {
    padding: 10px;
  }

  .panel-inner,
  .route-panel,
  .status-panel,
  .recent-panel {
    padding: 14px;
  }

  .recent-row {
    grid-template-columns: 42px minmax(0, 1fr);
  }

  .recent-open {
    display: none;
  }
}
