:root {
  color-scheme: light;
  --bg: #fcf9f8;
  --panel: #ffffff;
  --ink: #00061d;
  --text: #1c1b1b;
  --muted: #45464e;
  --muted-light: #75777f;
  --line: #c5c6cf;
  --line-soft: #e5e2e1;
  --green: #00061d;
  --green-dark: #0f1e40;
  --green-soft: #f0edec;
  --gold: #de2c3b;
  --red: #ba0626;
  --red-dark: #93000a;
  --shadow: none;
  --radius: 4px;
  --radius-lg: 8px;
  --font-heading: "Plus Jakarta Sans", Inter, ui-sans-serif, system-ui, sans-serif;
  --font-body: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  font-family: var(--font-body);
}

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

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

.app-shell {
  width: 100%;
  margin: 0 auto;
  padding: 0 0 48px;
}

.auth-panel {
  min-height: calc(100vh - 64px);
  display: grid;
  place-items: center;
}

.startup-skeleton {
  display: block;
  width: min(1220px, calc(100% - 48px));
  margin: 24px auto 0;
}

.auth-card {
  width: min(520px, 100%);
  display: grid;
  gap: 14px;
}

.auth-card h1 {
  font-size: clamp(1.8rem, 5vw, 3rem);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  min-height: 64px;
  border-bottom: 1px solid var(--line);
  background: rgba(252, 249, 248, 0.96);
  margin-bottom: 0;
  padding: 0 24px;
}

.brand-mark {
  color: var(--ink);
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 800;
}

.main-nav {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  align-items: center;
}

.main-nav .nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
  padding: 6px 4px;
}

.main-nav .nav-link:hover,
.main-nav .nav-link:focus-visible,
.main-nav .nav-link.active {
  border-bottom-color: var(--red);
  outline: 0;
}

.account-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar p {
  margin: 0;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 700;
}

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

#appContent > .hero,
#appContent > .workspace,
#appContent > .sessions-panel,
#appContent > .settings-panel {
  width: min(1220px, calc(100% - 48px));
  margin-right: auto;
  margin-left: auto;
}

#appContent > .settings-panel {
  margin-top: 24px;
}

.settings-panel {
  display: grid;
  gap: 12px;
  max-width: 420px;
  margin-bottom: 14px;
}

.settings-subform {
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--line);
  margin-top: 8px;
  padding-top: 12px;
}

.danger-zone {
  border-color: #f0cccc;
}

.auth-switch {
  margin-bottom: 0;
  text-align: center;
}

.auth-switch a {
  color: var(--green);
  font-weight: 800;
}

.skeleton-stack {
  display: grid;
  gap: 12px;
  width: 100%;
}

.skeleton-bar,
.skeleton-card,
.skeleton-pill {
  display: block;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--line-soft);
  position: relative;
}

.skeleton-bar {
  width: 72%;
  height: 18px;
}

.skeleton-bar.wide {
  width: 92%;
  height: 32px;
}

.skeleton-bar.title {
  width: min(620px, 80vw);
  height: clamp(42px, 7vw, 66px);
}

.skeleton-bar.short {
  width: 48%;
}

.skeleton-card {
  height: 118px;
}

.skeleton-pill {
  width: 92px;
  height: 40px;
}

.skeleton-bar::after,
.skeleton-card::after,
.skeleton-pill::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.55), transparent);
  animation: skeletonSweep 1.35s infinite;
}

.hero {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-top: 32px;
  margin-bottom: 32px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--red);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 680px;
  margin-bottom: 0;
  font-size: clamp(1.6rem, 3.4vw, 2.85rem);
  font-family: var(--font-heading);
  font-weight: 800;
  line-height: 1.1;
}

h2 {
  margin-bottom: 4px;
  font-family: var(--font-heading);
  font-size: 1.08rem;
  font-weight: 800;
}

.panel-heading p {
  margin-bottom: 0;
  color: var(--muted);
}

.stat-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
  min-width: min(100%, 640px);
}

.stat-strip div {
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--panel);
  min-width: 0;
  padding: 18px 20px;
}

.stat-strip span {
  display: block;
  color: var(--ink);
  font-family: var(--font-heading);
  font-size: clamp(1.65rem, 2.35vw, 2.35rem);
  font-weight: 800;
  line-height: 0.95;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.stat-strip div:nth-child(3) span {
  color: var(--red);
}

.stat-strip small {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(220px, 260px) minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}

.single-page .workspace {
  grid-template-columns: 1fr;
}

.single-page .settings-panel {
  max-width: 640px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 18px;
}

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

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

.entry-launch-panel {
  display: grid;
  gap: 16px;
  align-self: start;
}

.entry-launch-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.sidebar-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  list-style: none;
}

.sidebar-summary::-webkit-details-marker {
  display: none;
}

.sidebar-summary span:last-child {
  border: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 800;
  padding: 6px 8px;
  text-transform: uppercase;
}

.entry-launch-panel[open] .sidebar-summary {
  padding-bottom: 16px;
}

.section-label {
  color: var(--muted-light);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  margin: 0;
  text-transform: uppercase;
}

.folder-choice {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.session-preview {
  border: 1px solid var(--green);
  border-radius: var(--radius);
  background: var(--green-soft);
  color: var(--green-dark);
  font-weight: 800;
  margin-bottom: 0;
  padding: 10px 12px;
}

.custom-keypad {
  display: none;
  position: fixed;
  right: max(12px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
  left: max(12px, env(safe-area-inset-left));
  z-index: 40;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  max-width: 520px;
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 14px;
  touch-action: manipulation;
}

.custom-keypad.top {
  top: max(12px, env(safe-area-inset-top));
  bottom: auto;
}

.custom-keypad.active {
  display: grid;
}

.keypad-header,
.keypad-done {
  grid-column: 1 / -1;
}

.keypad-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-weight: 900;
}

.custom-keypad button {
  min-height: clamp(44px, 11vw, 58px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
  color: var(--ink);
  cursor: pointer;
  font-size: clamp(1.1rem, 5vw, 1.35rem);
  font-weight: 900;
}

.custom-keypad .keypad-mini-button {
  min-height: auto;
  padding: 7px 10px;
  color: var(--green-dark);
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.custom-keypad .keypad-done {
  background: var(--green);
  color: white;
}

.keypad-target-active {
  border-color: var(--green);
  box-shadow:
    0 0 0 2px rgba(0, 6, 29, 0.14),
    inset 4px 0 0 var(--green);
  background-image: linear-gradient(var(--green), var(--green));
  background-position: right 12px center;
  background-repeat: no-repeat;
  background-size: 2px 1.35em;
}

.viewer-notice {
  align-self: stretch;
}

label {
  display: grid;
  gap: 7px;
  color: var(--ink);
  font-weight: 800;
}

label span,
.filters span {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.checkbox-setting {
  display: flex;
  align-items: center;
  gap: 10px;
}

.checkbox-setting input {
  width: auto;
}

em {
  color: var(--muted);
  font-style: normal;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  padding: 8px 10px;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--green);
  outline: 2px solid rgba(0, 6, 29, 0.12);
}

.segmented,
.result-mode {
  display: grid;
  gap: 8px;
  border: 0;
  margin: 0;
  padding: 0;
}

.segmented {
  grid-template-columns: repeat(4, 1fr);
}

.result-mode {
  grid-template-columns: repeat(2, 1fr);
}

.segmented label,
.result-mode label {
  display: block;
  cursor: pointer;
  font-weight: 800;
}

.segmented input,
.result-mode input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented span,
.result-mode span {
  display: block;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  font-family: var(--font-heading);
  font-size: 0.84rem;
  font-weight: 800;
  letter-spacing: 0;
  padding: 8px 10px;
  text-align: center;
  text-transform: none;
}

.segmented input:checked + span,
.result-mode input:checked + span {
  border-color: var(--green);
  background: var(--panel);
  color: var(--green-dark);
  box-shadow: inset 0 -3px 0 var(--red);
}

.form-grid,
.filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.filters {
  margin: 14px 0;
}

.trends-layout {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
}

.optional-filter-side {
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--panel);
  padding: 12px;
}

.optional-filter-side > span {
  display: block;
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.filter-option,
.filter-clear {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
  color: var(--green-dark);
  cursor: pointer;
  font-family: var(--font-mono);
  font-weight: 800;
}

.filter-option {
  padding: 10px 12px;
  text-align: left;
}

.filter-option + .filter-option,
.date-filter-panel + .filter-option {
  margin-top: 10px;
}

.filter-option.active,
.filter-option[aria-pressed="true"] {
  border-color: var(--green);
  background: var(--green-soft);
  box-shadow: inset 3px 0 0 var(--red);
}

.date-filter-panel {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.date-filter-panel label {
  gap: 5px;
}

.date-filter-panel input,
.date-filter-panel select {
  padding: 9px 10px;
}

.filter-clear {
  padding: 9px 10px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  overflow: auto;
  background: rgba(0, 6, 29, 0.38);
  padding: 18px;
}

.modal-card {
  width: min(560px, 100%);
  max-height: min(720px, calc(100vh - 36px));
  overflow: auto;
}

.route-entry .modal {
  position: static;
  display: block;
  overflow: visible;
  background: transparent;
  padding: 0;
}

.route-entry .modal-card {
  width: 100%;
  max-height: none;
}

.keypad-open.route-entry .app-shell {
  padding-bottom: min(230px, 46vh);
}

.keypad-open.keypad-top.route-entry .app-shell {
  padding-top: min(230px, 46vh);
  padding-bottom: 24px;
}

body.modal-open {
  overflow: hidden;
}

.trends-panel {
  padding: 0;
  overflow: hidden;
}

.panel-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  padding: 14px 16px;
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 900;
  text-align: left;
}

.panel-toggle-icon {
  color: var(--red);
  transition: transform 0.18s ease;
}

.panel-toggle[aria-expanded="true"] .panel-toggle-icon {
  transform: rotate(180deg);
}

.trends-content {
  border-top: 1px solid var(--line);
  padding: 16px;
}

.primary-button,
.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: var(--font-mono);
  font-weight: 800;
  letter-spacing: 0.02em;
  text-align: center;
}

.primary-button {
  background: var(--green);
  color: white;
  padding: 9px 12px;
}

.primary-button:hover {
  background: var(--green-dark);
}

.entry-launch-actions .primary-button {
  background: var(--red);
}

.entry-launch-actions .primary-button:hover {
  background: var(--red-dark);
}

.primary-button.confirm-pending,
.ghost-button.confirm-pending,
.delete-button.confirm-pending {
  background: var(--gold);
  color: white;
}

.primary-button.save-cue {
  animation: saveCue 5s ease forwards;
  background: var(--green-dark);
}

.primary-button:disabled,
.ghost-button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.ghost-button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--green-dark);
  padding: 8px 10px;
}

.ghost-button:hover {
  border-color: var(--green);
}

.message {
  min-height: 1.2rem;
  margin: 0;
  color: var(--green);
  font-family: var(--font-mono);
  font-size: 0.86rem;
  font-weight: 700;
}

.message.error {
  color: var(--red);
}

.live-scoreboard {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.live-scoreboard div {
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--panel);
  padding: 12px;
  text-align: center;
}

.live-scoreboard span {
  display: block;
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 900;
}

.live-scoreboard small {
  color: var(--muted);
}

.live-shot-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.live-shot-button {
  min-height: 120px;
  border: 0;
  border-radius: var(--radius);
  color: white;
  cursor: pointer;
  font-size: 1.2rem;
  font-weight: 900;
}

.live-shot-button.good {
  background: var(--green);
}

.live-shot-button.miss {
  background: var(--red);
}

.live-shot-button:active {
  transform: translateY(1px);
}

.chart-wrap {
  position: relative;
  min-height: 320px;
  border: 1px solid var(--line);
  border-radius: 0;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  background: var(--panel);
}

#trendChart {
  display: block;
  min-width: 100%;
  height: 320px;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  color: var(--muted);
  font-weight: 700;
  text-align: center;
  padding: 20px;
}

.sessions-panel {
  margin-top: 0;
}

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

.sessions-actions {
  display: flex;
  align-items: end;
  gap: 10px;
}

.sessions-actions label {
  min-width: 180px;
}

.session-list {
  display: grid;
  gap: 0;
  margin-top: 12px;
}

.session-folder-heading {
  margin: 18px 0 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
  font-family: var(--font-mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.session-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 14px 16px;
  background: var(--panel);
}

.session-card + .session-card {
  margin-top: -1px;
}

.session-title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  margin: 0 0 6px;
  font-family: var(--font-heading);
  font-weight: 900;
}

.session-title small {
  color: var(--muted);
  font-family: var(--font-body);
  font-weight: 700;
}

.session-meta {
  margin: 0;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.82rem;
}

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

.session-edit-form {
  display: grid;
  gap: 10px;
  margin-top: 10px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.session-edit-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.session-edit-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.session-actions .ghost-button,
.session-edit-actions .ghost-button {
  white-space: nowrap;
}

.delete-button {
  border: 1px solid var(--red);
  border-radius: var(--radius);
  background: #fff;
  color: var(--red);
  cursor: pointer;
  font-family: var(--font-mono);
  font-weight: 800;
  padding: 8px 10px;
}

.delete-button:hover {
  background: var(--red);
  color: white;
}

.hidden {
  display: none !important;
}

@keyframes saveCue {
  0% {
    opacity: 1;
  }
  72% {
    opacity: 1;
  }
  100% {
    opacity: 0.2;
  }
}

@keyframes skeletonSweep {
  100% {
    transform: translateX(100%);
  }
}

@media (max-width: 860px) {
  .hero,
  .workspace {
    display: grid;
  }

  .app-topbar {
    position: static;
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 14px 16px;
  }

  .main-nav {
    position: static;
    transform: none;
    order: 3;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    width: 100%;
  }

  .main-nav .nav-link {
    border: 1px solid var(--line);
    text-align: center;
  }

  .account-actions {
    justify-content: space-between;
  }

  #appContent > .hero,
  #appContent > .workspace,
  #appContent > .sessions-panel,
  #appContent > .settings-panel {
    width: min(100% - 24px, 1220px);
  }

  .stat-strip {
    min-width: 0;
  }

  .workspace {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .trends-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: 100%;
    padding: 0 0 24px;
  }

  body {
    font-size: 14px;
  }

  input,
  select,
  textarea {
    font-size: 16px;
  }

  .hero {
    gap: 12px;
    margin-top: 22px;
    margin-bottom: 18px;
  }

  .topbar-actions {
    display: grid;
  }

  h1 {
    font-size: 1.9rem;
  }

  .stat-strip,
  .result-mode,
  .form-grid,
  .filters,
  .live-shot-actions {
    grid-template-columns: 1fr;
  }

  .stat-strip {
    gap: 10px;
  }

  .stat-strip div {
    padding: 16px;
  }

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

  .live-shot-button {
    min-height: 108px;
  }

  .panel {
    padding: 16px;
  }

  .modal {
    align-items: start;
    min-height: 100dvh;
    padding: 8px;
  }

  .modal-card {
    max-height: calc(100dvh - 16px);
  }

  .trends-content {
    padding: 12px;
  }

  .session-card,
  .row-heading,
  .sessions-actions,
  .session-actions,
  .session-edit-grid,
  .session-edit-actions {
    display: grid;
  }

  .session-card {
    padding: 16px;
  }

  .sessions-actions label {
    min-width: 0;
  }
}
