:root {
  --bg: #040407;
  --panel: #0b0d15;
  --panel-2: #111425;
  --ink: #f7eed6;
  --muted: #a9acc8;
  --line: #3a4169;
  --orange: #ff9f1c;
  --gold: #ffe39d;
  --magenta: #f187d5;
  --violet: #9da0ff;
  --blue: #6f8cc9;
  --mint: #71d1b3;
  --danger: #ff6b8a;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.starfield {
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(circle at 12% 18%, rgba(255, 227, 157, 0.14), transparent 18%),
    radial-gradient(circle at 82% 14%, rgba(157, 160, 255, 0.15), transparent 20%),
    radial-gradient(circle at 70% 78%, rgba(241, 135, 213, 0.12), transparent 24%),
    linear-gradient(135deg, #030305 0%, #080813 48%, #030305 100%);
}

.starfield::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.34;
  background-image:
    radial-gradient(circle, rgba(255, 255, 255, 0.72) 0 1px, transparent 1px),
    radial-gradient(circle, rgba(255, 255, 255, 0.42) 0 1px, transparent 1px);
  background-position: 0 0, 38px 54px;
  background-size: 140px 120px, 180px 160px;
}

.app-shell {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 100svh;
  padding: 12px;
}

body[data-auth="locked"] .app-shell,
body[data-auth="open"] .access-screen {
  display: none;
}

.access-screen {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.access-frame {
  width: min(1120px, 100%);
  min-height: 680px;
  display: grid;
  grid-template-columns: minmax(320px, 1.15fr) minmax(320px, 0.85fr);
  grid-template-rows: auto 1fr auto;
  gap: 12px;
  padding: 16px;
  border: 1px solid rgba(157, 160, 255, 0.42);
  border-radius: 8px;
  background: rgba(5, 5, 9, 0.92);
  box-shadow: var(--shadow);
}

.access-rail {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1.2fr 0.34fr 0.9fr;
  gap: 8px;
  min-height: 48px;
}

.rail-block,
.rail-segment {
  display: block;
  border-radius: 8px;
  background: var(--orange);
}

.rail-a {
  border-radius: 28px 0 0 28px;
  background: linear-gradient(90deg, var(--gold), var(--magenta));
}

.rail-b {
  background: var(--violet);
}

.rail-c {
  border-radius: 0 28px 28px 0;
  background: linear-gradient(90deg, var(--orange), var(--gold));
}

.access-brand {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(260px, 0.9fr);
  gap: 22px;
  align-items: center;
  padding: 18px;
  border: 1px solid rgba(255, 227, 157, 0.42);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(17, 20, 37, 0.84), rgba(6, 7, 13, 0.96));
}

.sector-map {
  width: 100%;
  min-width: 0;
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.eyebrow,
.subtitle,
.profile-panel p,
.stat-grid span,
.stat-primary span,
.system-line span,
.system-meter span,
label,
.timeline-meta,
.timeline-weight small,
.access-status {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.access-brand h1,
.brand-lockup h1 {
  margin: 0;
  color: var(--orange);
  font-size: 54px;
  line-height: 0.95;
  text-transform: uppercase;
}

.access-brand .eyebrow,
.access-brand .subtitle {
  margin: 0 0 10px;
}

.access-panel,
.access-systems,
.panel {
  border: 1px solid rgba(157, 160, 255, 0.44);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(17, 20, 37, 0.94), rgba(4, 5, 9, 0.94));
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.26);
  overflow: hidden;
}

.access-panel {
  display: grid;
  align-content: start;
  gap: 16px;
  padding: 0 18px 18px;
}

.access-panel label,
.entry-form label,
.settings-panel label,
.weight-form label {
  display: grid;
  gap: 7px;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  color: var(--ink);
  border: 1px solid rgba(169, 172, 200, 0.44);
  border-radius: 6px;
  background: rgba(2, 3, 7, 0.84);
  outline: none;
}

input,
select {
  min-height: 42px;
  padding: 9px 12px;
}

textarea {
  resize: vertical;
  min-height: 130px;
  padding: 14px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(255, 227, 157, 0.16);
}

.access-options {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}

.check-row {
  display: flex !important;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px !important;
}

.check-row input {
  width: 18px;
  min-height: 18px;
}

.text-link {
  color: var(--violet);
  border: 0;
  background: transparent;
  font-weight: 800;
  text-transform: uppercase;
}

.access-status {
  margin: 0;
  color: var(--mint);
}

.access-systems {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  padding: 10px;
}

.system-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 16px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
}

.system-line strong {
  color: var(--orange);
  text-transform: uppercase;
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  min-height: 70px;
}

.top-meta,
.stardate-readout,
.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
}

.top-meta {
  color: var(--violet);
  font-weight: 900;
  text-transform: uppercase;
}

.status-light {
  width: 34px;
  height: 24px;
  border-radius: 16px 0 0 16px;
  background: var(--danger);
}

.brand-cap {
  width: 58px;
  height: 30px;
  border-radius: 18px 0 0 18px;
  background: linear-gradient(90deg, var(--orange), var(--gold));
}

.brand-lockup h1 {
  font-size: 36px;
}

.stardate-readout {
  justify-content: flex-end;
  color: var(--violet);
  font-weight: 900;
}

.stardate-readout strong {
  color: var(--orange);
  font-size: 30px;
}

.stardate-readout time {
  color: var(--violet);
}

.top-rail,
.bottom-rail {
  display: grid;
  grid-template-columns: 1.3fr 0.22fr 0.8fr 0.55fr;
  gap: 8px;
  min-height: 14px;
}

.bottom-rail {
  grid-template-columns: 0.24fr 1fr 0.68fr 0.5fr;
  min-height: 36px;
}

.segment-large {
  background: var(--magenta);
}

.segment-small {
  background: var(--orange);
}

.segment-blue {
  background: var(--violet);
}

.segment-gold {
  background: var(--gold);
}

.deck-grid {
  display: grid;
  grid-template-columns: 260px minmax(460px, 1fr) 350px;
  gap: 10px;
  min-height: 0;
  flex: 1;
}

.left-column,
.center-column,
.right-column {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

.center-column {
  min-width: 0;
}

.panel-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  min-height: 44px;
  padding: 9px 16px;
  color: #09060b;
  font-weight: 900;
  text-transform: uppercase;
  background: linear-gradient(90deg, var(--violet), var(--magenta));
}

.panel-title-dark {
  margin: 0 -18px;
  color: var(--ink);
  background: linear-gradient(90deg, #241a43, #080a12);
}

.panel-title-small {
  min-height: 38px;
  font-size: 14px;
}

.profile-panel {
  display: grid;
  grid-template-columns: 62px 1fr;
  gap: 13px;
  padding: 16px;
}

.profile-mark {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border: 2px solid rgba(157, 160, 255, 0.4);
  border-radius: 50%;
  background: rgba(157, 160, 255, 0.08);
}

.delta-mark {
  width: 0;
  height: 0;
  border-left: 16px solid transparent;
  border-right: 16px solid transparent;
  border-bottom: 38px solid var(--violet);
  filter: drop-shadow(0 0 10px rgba(157, 160, 255, 0.48));
}

.profile-panel h2,
.profile-panel p {
  margin: 0 0 5px;
}

.profile-panel h2 {
  color: var(--violet);
  font-size: 18px;
  text-transform: uppercase;
}

.outline-button {
  grid-column: 1 / -1;
  min-height: 38px;
  color: var(--orange);
  border: 1px solid rgba(255, 159, 28, 0.58);
  border-radius: 6px;
  background: transparent;
  font-weight: 900;
  text-transform: uppercase;
}

.side-nav {
  display: grid;
  gap: 8px;
}

.nav-button {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 0 16px;
  color: var(--ink);
  border: 1px solid rgba(157, 160, 255, 0.24);
  border-radius: 8px;
  background: linear-gradient(90deg, rgba(157, 160, 255, 0.36), rgba(90, 58, 134, 0.42));
  font-weight: 900;
  text-align: left;
  text-transform: uppercase;
}

.nav-button span {
  color: var(--gold);
}

.nav-button.active,
.nav-button:hover {
  color: #130b05;
  background: linear-gradient(90deg, var(--orange), #c47a36);
}

.nav-button.active span,
.nav-button:hover span {
  color: #130b05;
}

.systems-panel,
.tag-panel,
.settings-panel,
.stats-panel,
.weight-panel {
  padding-bottom: 12px;
}

.system-meter {
  display: grid;
  grid-template-columns: 72px 1fr 42px;
  gap: 9px;
  align-items: center;
  padding: 10px 14px 0;
}

meter {
  width: 100%;
  height: 10px;
}

meter::-webkit-meter-bar {
  border: 0;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.08);
}

meter::-webkit-meter-optimum-value {
  border-radius: 99px;
  background: var(--magenta);
}

.system-meter strong {
  color: var(--violet);
  font-size: 12px;
}

.tag-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 12px 14px 0;
}

.tag-grid button,
.template-actions button {
  min-height: 36px;
  color: #12090b;
  border: 0;
  border-radius: 6px;
  background: var(--gold);
  font-weight: 900;
  text-transform: uppercase;
}

.tag-grid button:nth-child(2n),
.template-actions button:nth-child(2n) {
  background: var(--violet);
}

.tag-grid button:nth-child(3n) {
  background: var(--magenta);
}

.composer-panel {
  flex: 0 0 auto;
}

.entry-form {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.field-grid {
  display: grid;
  grid-template-columns: 170px minmax(150px, 1fr) 160px;
  gap: 12px;
}

.suffix-input {
  position: relative;
  display: block;
}

.suffix-input input {
  padding-right: 48px;
}

.suffix-input span {
  position: absolute;
  right: 12px;
  top: 50%;
  color: var(--gold);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  transform: translateY(-50%);
}

.composer-actions {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}

.template-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.template-actions button {
  min-width: 88px;
}

.action-button {
  min-height: 44px;
  min-width: 154px;
  padding: 0 20px;
  color: #120905;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--orange), var(--gold));
  font-weight: 900;
  text-transform: uppercase;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.18);
}

.action-button.wide {
  width: 100%;
}

.timeline-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

.timeline-title {
  min-height: 48px;
}

.search-field {
  display: grid;
  grid-template-columns: auto minmax(160px, 260px);
  gap: 8px;
  align-items: center;
}

.search-field span {
  color: #09060b;
}

.search-field input {
  min-height: 32px;
  color: var(--ink);
}

.timeline {
  position: relative;
  flex: 1;
  min-height: 360px;
  overflow-y: auto;
  padding: 14px 14px 24px 42px;
  scrollbar-color: var(--orange) rgba(255, 255, 255, 0.08);
}

.timeline::before {
  content: "";
  position: absolute;
  top: 18px;
  bottom: 18px;
  left: 24px;
  width: 2px;
  background: linear-gradient(var(--violet), var(--magenta), var(--orange));
}

.timeline-entry {
  position: relative;
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) 92px 36px;
  gap: 16px;
  align-items: center;
  min-height: 82px;
  margin-bottom: 10px;
  padding: 13px 14px;
  border: 1px solid rgba(169, 172, 200, 0.28);
  border-radius: 8px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
}

.timeline-entry::before {
  content: "";
  position: absolute;
  left: -25px;
  width: 13px;
  height: 13px;
  border: 2px solid rgba(255, 255, 255, 0.36);
  border-radius: 50%;
  background: var(--magenta);
  box-shadow: 0 0 16px rgba(241, 135, 213, 0.5);
}

.timeline-entry.health::before {
  background: var(--mint);
  box-shadow: 0 0 16px rgba(113, 209, 179, 0.5);
}

.timeline-entry.mission::before {
  background: var(--orange);
  box-shadow: 0 0 16px rgba(255, 159, 28, 0.5);
}

.timeline-date strong {
  display: block;
  color: var(--orange);
  font-size: 22px;
}

.timeline-meta {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.entry-copy {
  min-width: 0;
}

.entry-copy p {
  margin: 0;
  line-height: 1.42;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  min-width: 82px;
  margin-bottom: 7px;
  padding: 3px 8px;
  color: #120905;
  border-radius: 6px;
  background: var(--violet);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.pill.personal,
.pill.health {
  background: var(--magenta);
}

.pill.reflection,
.pill.mission {
  background: var(--orange);
}

.pill.crew {
  background: var(--mint);
}

.timeline-weight {
  text-align: right;
}

.timeline-weight strong {
  display: block;
  color: var(--orange);
  font-size: 18px;
}

.timeline-weight small {
  color: var(--gold);
}

.delete-entry-button {
  position: relative;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid rgba(255, 107, 138, 0.52);
  border-radius: 50%;
  background: rgba(255, 107, 138, 0.08);
  box-shadow: inset 0 0 0 4px rgba(255, 107, 138, 0.04);
}

.delete-entry-button span,
.delete-entry-button::before,
.delete-entry-button::after {
  position: absolute;
  content: "";
  left: 50%;
  top: 50%;
  width: 15px;
  height: 3px;
  border-radius: 99px;
  background: var(--danger);
  transform-origin: center;
}

.delete-entry-button span {
  width: 6px;
  height: 6px;
  transform: translate(-50%, -50%);
}

.delete-entry-button::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.delete-entry-button::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.delete-entry-button:hover,
.delete-entry-button:focus-visible {
  border-color: var(--gold);
  background: rgba(255, 107, 138, 0.22);
  outline: none;
}

.timeline-empty,
.timeline-loader {
  position: relative;
  padding: 18px;
  border: 1px dashed rgba(169, 172, 200, 0.32);
  border-radius: 8px;
  color: var(--muted);
  text-transform: uppercase;
}

.settings-panel {
  display: grid;
  gap: 12px;
}

.control-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 0 14px;
}

.control-row > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.segmented button {
  min-height: 36px;
  color: var(--ink);
  border: 1px solid rgba(169, 172, 200, 0.24);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.segmented button.active {
  color: #120905;
  background: linear-gradient(90deg, var(--orange), #c47a36);
}

.dual-input {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.dual-input label {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 7px;
  color: var(--gold);
}

.stat-primary {
  display: grid;
  gap: 4px;
  padding: 16px 16px 10px;
}

.stat-primary strong {
  color: var(--gold);
  font-size: 42px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  padding: 0 14px 4px;
}

.stat-grid div {
  display: grid;
  gap: 3px;
  min-height: 82px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.04);
}

.stat-grid strong {
  color: var(--magenta);
  font-size: 24px;
}

.stat-grid small {
  color: var(--muted);
}

.weight-form {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.weight-form .action-button {
  width: 100%;
}

.chart-wrap {
  margin: 0 14px;
  min-height: 170px;
}

canvas {
  width: 100%;
  height: 170px;
  display: block;
}

@media (max-width: 1180px) {
  .app-shell {
    height: auto;
    min-height: 100svh;
  }

  .deck-grid {
    grid-template-columns: 230px minmax(0, 1fr);
  }

  .right-column {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .timeline {
    height: 56vh;
    min-height: 420px;
  }
}

@media (max-width: 860px) {
  .access-frame,
  .access-brand,
  .access-systems,
  .topbar,
  .deck-grid,
  .right-column {
    grid-template-columns: 1fr;
  }

  .access-frame {
    min-height: 0;
  }

  .access-brand h1 {
    font-size: 42px;
  }

  .topbar {
    align-items: start;
  }

  .stardate-readout {
    justify-content: start;
    flex-wrap: wrap;
  }

  .field-grid,
  .timeline-entry,
  .control-row,
  .search-field {
    grid-template-columns: 1fr;
  }

  .composer-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .template-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }

  .timeline {
    min-height: 520px;
    height: 66vh;
    padding-left: 36px;
  }

  .timeline::before {
    left: 19px;
  }

  .timeline-entry::before {
    left: -23px;
  }

  .timeline-weight {
    text-align: left;
  }

  .delete-entry-button {
    justify-self: start;
  }
}

@media (max-width: 560px) {
  .access-screen,
  .app-shell {
    padding: 8px;
  }

  .access-frame {
    padding: 10px;
  }

  .brand-lockup h1 {
    font-size: 30px;
  }

  .access-brand h1 {
    font-size: 34px;
  }

  .top-meta,
  .stardate-readout,
  .brand-lockup {
    flex-wrap: wrap;
  }

  .stat-grid,
  .tag-grid,
  .template-actions {
    grid-template-columns: 1fr;
  }

  .timeline {
    min-height: 440px;
  }
}
