:root {
  color-scheme: dark;
  --bg: #050505;
  --line: #333333;
  --text: #e6e6e6;
  --muted: #909090;
  --accent-strong: #b6925e;
  --cue-size: 1.42rem;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  transition: background-color 1.5s ease;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #1a1a1a;
  color: var(--text);
}

button:active {
  transform: translateY(1px);
}

.app-shell {
  height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr;
  padding: max(16px, env(safe-area-inset-top)) 16px max(18px, env(safe-area-inset-bottom));
  background: var(--bg);
  transition: background-color 1.5s ease;
}

.top-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow,
.cue-label,
.next-cue,
.hint {
  color: var(--muted);
}

.eyebrow {
  min-height: 1.4em;
  margin: 0 0 6px;
  font-size: 0.78rem;
  letter-spacing: 0;
}

h1,
h2 {
  margin: 0;
  font-weight: 650;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(1.1rem, 7vw, 1.8rem);
}

.clock {
  min-width: 8ch;
  padding-top: 2px;
  color: #d8d8d8;
  font-variant-numeric: tabular-nums;
  font-size: 1.06rem;
  text-align: right;
}

.main-view {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
  gap: 14px;
  min-height: 0;
  overflow: hidden;
}

.cue-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  justify-items: center;
  gap: 18px;
  min-height: 0;
  overflow: hidden;
  text-align: center;
}

.cue-label {
  min-height: 1.35em;
  margin: 0;
  color: var(--accent-strong);
  font-size: 0.9rem;
}

.cue-text {
  width: min(100%, 34rem);
  height: 100%;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 8px 2px 14px;
  white-space: pre-wrap;
  line-height: 1.72;
  color: var(--text);
  font-size: var(--cue-size);
  text-align: center;
}

.next-cue,
.hint {
  margin: 0;
  min-height: 1.4em;
  font-size: 0.82rem;
  line-height: 1.5;
}

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

.transport button {
  font-variant-numeric: tabular-nums;
}

.primary {
  border-color: #51412c;
  background: #241e17;
  color: #f0dfc4;
  font-weight: 700;
}

.secondary-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.secondary-actions button {
  min-height: 38px;
  color: #c8c8c8;
  font-size: 0.9rem;
}

dialog {
  width: min(92vw, 34rem);
  max-height: min(78dvh, 42rem);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0c0c0c;
  color: var(--text);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.72);
}

.dialog-body {
  padding: 16px;
}

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

.dialog-header h2 {
  font-size: 1.1rem;
}

.icon-close {
  width: 44px;
  padding: 0;
  color: var(--muted);
}

.history-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 1.4rem;
}

.history-list li {
  color: #d2d2d2;
  line-height: 1.55;
}

.history-list time {
  color: var(--accent-strong);
  font-variant-numeric: tabular-nums;
}

.settings-grid {
  display: grid;
  gap: 16px;
}

.settings-grid label,
fieldset {
  display: grid;
  gap: 8px;
  margin: 0;
}

fieldset {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

legend {
  color: var(--muted);
  padding: 0 4px;
}

input,
select {
  min-height: 42px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #151515;
  color: var(--text);
  padding: 0 12px;
}

.toggle-row {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.toggle-row input {
  width: 22px;
  min-height: 22px;
}

.inline-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.font-small {
  --cue-size: 1.18rem;
}

.font-large {
  --cue-size: 1.7rem;
}

.font-xlarge {
  --cue-size: 2rem;
}

.high-contrast {
  --text: #ffffff;
  --muted: #c5c5c5;
  --line: #555555;
}

@media (min-width: 720px) {
  .app-shell {
    width: min(100%, 48rem);
    margin: 0 auto;
    padding-inline: 24px;
  }
}
