:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #080b10;
  color: #f7f8fa;
  font-synthesis: none;
  --surface: #10151d;
  --surface-raised: #171e28;
  --border: #28313e;
  --muted: #8993a3;
  --red: #ff3b3b;
  --red-dark: #b91620;
  --green: #31d17c;
  --amber: #f2b84b;
  --deck-accent: #ff4655;
  --deck-contrast: #ffffff;
  --deck-glow: rgba(255, 70, 85, 0.18);
  --deck-border: rgba(255, 70, 85, 0.42);
}

body[data-deck="jf"] {
  --deck-accent: #ff4655;
  --deck-contrast: #ffffff;
  --deck-glow: rgba(255, 70, 85, 0.18);
  --deck-border: rgba(255, 70, 85, 0.42);
}

body[data-deck="eng1"] {
  --deck-accent: #3187ff;
  --deck-contrast: #ffffff;
  --deck-glow: rgba(49, 135, 255, 0.2);
  --deck-border: rgba(49, 135, 255, 0.46);
}

body[data-deck="eng2"] {
  --deck-accent: #f0ad35;
  --deck-contrast: #171108;
  --deck-glow: rgba(240, 173, 53, 0.2);
  --deck-border: rgba(240, 173, 53, 0.48);
}

body[data-deck="eng3"] {
  --deck-accent: #9b6cff;
  --deck-contrast: #ffffff;
  --deck-glow: rgba(155, 108, 255, 0.2);
  --deck-border: rgba(155, 108, 255, 0.46);
}

body[data-deck="eng4"] {
  --deck-accent: #19c3cf;
  --deck-contrast: #061416;
  --deck-glow: rgba(25, 195, 207, 0.2);
  --deck-border: rgba(25, 195, 207, 0.46);
}

body[data-deck="eng5"] {
  --deck-accent: #33c676;
  --deck-contrast: #06150c;
  --deck-glow: rgba(51, 198, 118, 0.2);
  --deck-border: rgba(51, 198, 118, 0.46);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: #080b10;
  -webkit-text-size-adjust: 100%;
}

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background: radial-gradient(circle at 88% 7%, var(--deck-glow), transparent 28rem), #080b10;
  overscroll-behavior-y: none;
  transition: background 280ms ease;
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  width: min(100%, 980px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(32px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
}

.topbar,
.deck-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.topbar {
  padding: 6px 2px 24px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.settings-link,
.monitor-link {
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #0d1118;
  color: #c5ccd6;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-decoration: none;
  text-transform: uppercase;
}

.eyebrow,
.section-kicker,
.label {
  display: block;
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  line-height: 1.35;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.45rem, 5vw, 2rem);
  letter-spacing: -0.035em;
}

.network-state,
.deck-state {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: none;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #0d1118;
  color: #b5bdc9;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.network-dot,
.state-light {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 0 4px rgba(242, 184, 75, 0.1);
}

.network-state[data-state="online"] .network-dot,
.deck-state[data-state="stopped"] .state-light,
.deck-state[data-state="playing"] .state-light {
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(49, 209, 124, 0.1);
}

.network-state[data-state="offline"] .network-dot,
.deck-state[data-state="offline"] .state-light,
.deck-state[data-state="recording"] .state-light {
  background: var(--red);
  box-shadow: 0 0 0 4px rgba(255, 59, 59, 0.12);
}

.deck-state[data-state="recording"] .state-light {
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  50% { opacity: 0.38; }
}

.deck-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 26px;
  padding: 5px;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: #0d1117;
  box-shadow: 0 0 0 1px var(--deck-border), 0 14px 34px rgba(0, 0, 0, 0.18);
  transition: box-shadow 220ms ease;
}

.deck-tab {
  min-height: 48px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-weight: 850;
  letter-spacing: 0.05em;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.deck-tab[data-active="true"] {
  background: var(--deck-accent);
  color: var(--deck-contrast);
  box-shadow: 0 5px 18px var(--deck-glow);
}

.deck-tab[data-deck="jf"]:not([data-active="true"]) { color: #d98289; }
.deck-tab[data-deck="eng1"]:not([data-active="true"]) { color: #78a9e9; }
.deck-tab[data-deck="eng2"]:not([data-active="true"]) { color: #d6ad68; }
.deck-tab[data-deck="eng3"]:not([data-active="true"]) { color: #a98ce0; }
.deck-tab[data-deck="eng4"]:not([data-active="true"]) { color: #68bdc3; }
.deck-tab[data-deck="eng5"]:not([data-active="true"]) { color: #6fbd8e; }
.deck-tab[data-configured="false"] { opacity: 0.52; }

.deck-tab:focus-visible,
.control-button:focus-visible,
.hold-stop:focus-visible,
.modal button:focus-visible,
.modal input:focus-visible {
  outline: 3px solid #7bb7ff;
  outline-offset: 2px;
}

.settings-link:focus-visible,
.monitor-link:focus-visible {
  outline: 3px solid #7bb7ff;
  outline-offset: 2px;
}

.deck-heading {
  margin-bottom: 13px;
  padding: 0 2px;
}

.deck-heading h2 {
  margin: 4px 0 0;
  font-size: clamp(2.45rem, 12vw, 4.7rem);
  line-height: 0.95;
  letter-spacing: -0.065em;
  color: var(--deck-accent);
  text-shadow: 0 0 30px var(--deck-glow);
  transition: color 220ms ease, text-shadow 220ms ease;
}

.status-panel {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: inset 0 3px 0 var(--deck-accent), 0 22px 60px rgba(0, 0, 0, 0.25);
  transition: box-shadow 220ms ease;
}

.status-main {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 5px 16px;
  padding: 24px;
  background: var(--surface-raised);
}

.status-main .label {
  grid-column: 1 / -1;
}

.status-main strong {
  min-width: 0;
  font-size: clamp(1.35rem, 5vw, 2rem);
  letter-spacing: -0.035em;
}

.timecode {
  color: #c2cad5;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: clamp(0.85rem, 3.2vw, 1.05rem);
  letter-spacing: 0.04em;
}

.file-row {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  padding: 19px 24px;
  border-top: 1px solid var(--border);
}

.file-icon {
  margin-top: 18px;
  color: var(--red);
  font-size: 0.66rem;
}

.file-icon.previous {
  color: #667184;
}

.file-row strong {
  display: block;
  overflow: hidden;
  margin-top: 5px;
  color: #f3f5f7;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.92rem;
  font-weight: 650;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.file-copy-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
}

.file-copy-row strong {
  flex: 1 1 auto;
  min-width: 0;
}

.copy-file-button {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 82px;
  min-height: 38px;
  margin-top: 3px;
  padding: 7px 10px;
  border: 1px solid #3a4658;
  border-radius: 10px;
  background: #202938;
  color: #e9eef5;
  font: 750 0.72rem/1 system-ui, sans-serif;
  letter-spacing: 0.08em;
  cursor: pointer;
  touch-action: manipulation;
}

.copy-file-button:hover:not(:disabled),
.copy-file-button:focus-visible {
  border-color: #708199;
  background: #2a3546;
}

.copy-file-button[data-copied="true"] {
  border-color: #24c98a;
  color: #45e5aa;
}

.copy-file-button:disabled {
  opacity: 0.32;
  cursor: default;
}

.file-duration:not([hidden]) {
  display: block;
  margin-top: 8px;
  color: #b6c0ce;
  font-size: 0.9rem;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 18px;
}

.control-button {
  display: flex;
  align-items: center;
  gap: 13px;
  min-height: 88px;
  padding: 16px 18px;
  border: 1px solid transparent;
  border-radius: 17px;
  color: white;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 100ms ease, opacity 120ms ease, background 120ms ease;
}

.control-button:active:not(:disabled) {
  transform: scale(0.975);
}

.control-button:disabled {
  cursor: not-allowed;
  opacity: 0.36;
}

.control-button strong,
.control-button small {
  display: block;
}

.control-button strong {
  font-size: 1rem;
  letter-spacing: 0.09em;
}

.control-button small {
  margin-top: 3px;
  opacity: 0.72;
  font-size: 0.75rem;
}

.record-button {
  background: var(--red-dark);
  border-color: #d7353f;
}

.record-button:hover:not(:disabled) {
  background: #cd1b27;
}

.control-symbol {
  display: block;
  flex: none;
  width: 24px;
  height: 24px;
}

.record-symbol {
  border: 3px solid white;
  border-radius: 50%;
}

.hold-stop {
  position: relative;
  display: flex;
  align-items: center;
  gap: 13px;
  min-height: 88px;
  overflow: hidden;
  padding: 16px 18px;
  border: 1px solid #3b4657;
  border-radius: 17px;
  background: #202834;
  color: white;
  text-align: left;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  transition: opacity 140ms ease;
}

.hold-stop:disabled {
  cursor: not-allowed;
  opacity: 0.36;
}

.hold-stop-progress {
  position: absolute;
  z-index: 0;
  inset: auto 0 0;
  height: 5px;
  background: #a81620;
  transform: scaleX(0);
  transform-origin: left;
}

.hold-stop[data-holding="true"] .hold-stop-progress {
  animation: stop-hold-progress 1s linear forwards;
}

.hold-stop[data-holding="true"] {
  border-color: #b82731;
  background: #2b2028;
}

.hold-stop[data-holding="true"] .stop-symbol {
  border-color: #ff5962;
}

.hold-stop > :not(.hold-stop-progress) {
  position: relative;
  z-index: 1;
}

.hold-stop-copy strong,
.hold-stop-copy small {
  display: block;
}

.hold-stop-copy strong {
  font-size: 1rem;
  letter-spacing: 0.09em;
}

.hold-stop-copy small {
  margin-top: 3px;
  color: #aeb7c4;
  font-size: 0.75rem;
}

.stop-symbol {
  display: block;
  flex: none;
  width: 24px;
  height: 24px;
  border: 3px solid white;
  border-radius: 3px;
}

@keyframes stop-hold-progress {
  to { transform: scaleX(1); }
}

.message {
  min-height: 22px;
  margin: 18px 3px 5px;
  color: #aab3c0;
  font-size: 0.86rem;
  line-height: 1.45;
}

.message[data-kind="success"] { color: var(--green); }
.message[data-kind="error"] { color: #ff747b; }
.message[data-kind="working"] { color: var(--amber); }

.updated {
  margin: 0 3px;
  color: #667184;
  font-size: 0.74rem;
}

.modal {
  width: min(calc(100% - 32px), 430px);
  padding: 0;
  border: 1px solid #3a4554;
  border-radius: 20px;
  background: #151b24;
  color: #f7f8fa;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.65);
}

.modal::backdrop {
  background: rgba(2, 4, 8, 0.78);
  backdrop-filter: blur(5px);
}

.modal form {
  padding: 26px;
}

.modal h2 {
  margin: 7px 0 8px;
  font-size: 1.55rem;
  letter-spacing: -0.035em;
}

.modal p:not(.section-kicker):not(.pin-error) {
  margin-bottom: 20px;
  color: #aab3c0;
  line-height: 1.5;
}

.modal input {
  width: 100%;
  height: 54px;
  margin-bottom: 6px;
  padding: 0 16px;
  border: 1px solid #465164;
  border-radius: 11px;
  background: #0b0f15;
  color: white;
  font-size: 1.25rem;
  letter-spacing: 0.18em;
}

.pin-error {
  min-height: 20px;
  margin: 0 0 6px;
  color: #ff747b;
  font-size: 0.8rem;
}

.modal-mark {
  width: 24px;
  height: 24px;
  margin-bottom: 18px;
  border: 4px solid var(--red);
  border-radius: 4px;
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1.25fr;
  gap: 10px;
  margin-top: 10px;
}

.modal button {
  min-height: 48px;
  padding: 10px 14px;
  border: 1px solid transparent;
  border-radius: 11px;
  color: white;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.secondary-button {
  border-color: #3a4554 !important;
  background: #202834;
}

.primary-button {
  background: #1977df;
}

.danger-button {
  background: var(--red-dark);
}

@media (min-width: 768px) {
  .app-shell {
    padding-top: max(30px, env(safe-area-inset-top));
    padding-right: max(30px, env(safe-area-inset-right));
    padding-left: max(30px, env(safe-area-inset-left));
  }

  .topbar {
    padding-bottom: 28px;
  }

  .deck-tabs {
    grid-template-columns: repeat(6, 1fr);
    gap: 10px;
    padding: 6px;
  }

  .deck-tab {
    min-height: 54px;
    font-size: 1rem;
  }

  .status-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .status-main {
    grid-column: 1 / -1;
    padding: 28px 30px;
  }

  .file-row {
    min-height: 105px;
    padding: 21px 28px;
  }

  .current-file {
    border-right: 1px solid var(--border);
  }

  .controls {
    gap: 14px;
  }

  .control-button,
  .hold-stop {
    min-height: 94px;
    padding-right: 22px;
    padding-left: 22px;
  }
}

@media (min-width: 1100px) {
  .app-shell {
    width: min(100%, 1080px);
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding-top: max(10px, env(safe-area-inset-top));
    padding-right: max(12px, env(safe-area-inset-right));
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    padding-left: max(12px, env(safe-area-inset-left));
  }

  .topbar {
    align-items: flex-start;
    gap: 10px;
    padding: 0 1px 10px;
  }

  .topbar h1 {
    max-width: 210px;
    font-size: 1.2rem;
    line-height: 1;
  }

  .eyebrow,
  .section-kicker,
  .label {
    font-size: 0.64rem;
    letter-spacing: 0.12em;
  }

  .network-state {
    gap: 6px;
    padding: 5px 8px;
    font-size: 0.64rem;
  }

  .topbar-actions {
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
  }

  .settings-link,
  .monitor-link {
    padding: 5px 8px;
    font-size: 0.62rem;
  }

  .deck-tabs {
    gap: 4px;
    margin-bottom: 12px;
    padding: 4px;
    border-radius: 13px;
  }

  .deck-tab {
    min-height: 39px;
    border-radius: 9px;
    font-size: 0.76rem;
  }

  .deck-heading {
    margin-bottom: 8px;
  }

  .deck-heading h2 {
    margin-top: 2px;
    font-size: 2.35rem;
  }

  .deck-state {
    padding: 6px 9px;
    font-size: 0.64rem;
  }

  .status-panel {
    border-radius: 16px;
  }

  .status-main,
  .file-row {
    padding-left: 15px;
    padding-right: 15px;
  }

  .status-main {
    grid-template-columns: 1fr auto;
    gap: 3px 10px;
    padding-top: 13px;
    padding-bottom: 13px;
  }

  .status-main .label {
    grid-column: 1 / -1;
  }

  .status-main strong {
    font-size: 1.18rem;
  }

  .timecode {
    font-size: 0.76rem;
  }

  .file-row {
    grid-template-columns: 13px minmax(0, 1fr);
    gap: 9px;
    padding-top: 11px;
    padding-bottom: 11px;
  }

  .file-icon {
    margin-top: 15px;
  }

  .file-row strong {
    margin-top: 3px;
    font-size: 0.78rem;
    line-height: 1.3;
  }

  .file-copy-row {
    gap: 7px;
  }

  .copy-file-button {
    min-width: 44px;
    min-height: 38px;
    padding: 6px 8px;
  }

  .copy-file-button span:last-child {
    display: none;
  }

  .file-duration:not([hidden]) {
    margin-top: 4px;
    font-size: 0.76rem;
    line-height: 1.35;
  }

  .controls {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 10px;
  }

  .control-button,
  .hold-stop {
    min-height: 66px;
    gap: 9px;
    padding: 10px 12px;
    border-radius: 14px;
  }

  .control-symbol,
  .stop-symbol {
    width: 21px;
    height: 21px;
  }

  .control-button strong,
  .hold-stop-copy strong {
    font-size: 0.78rem;
    letter-spacing: 0.06em;
  }

  .control-button small,
  .hold-stop-copy small {
    margin-top: 2px;
    font-size: 0.66rem;
  }

  .message {
    min-height: 18px;
    margin-top: 10px;
    margin-bottom: 2px;
    font-size: 0.75rem;
  }

  .updated {
    font-size: 0.68rem;
  }
}

@media (max-width: 370px) {
  .app-shell {
    padding-right: 10px;
    padding-left: 10px;
  }

  .eyebrow {
    font-size: 0.64rem;
  }

  .topbar h1 {
    max-width: 195px;
    font-size: 1.08rem;
  }

  .network-state {
    gap: 6px;
    padding: 6px 8px;
    font-size: 0.66rem;
  }

  .deck-tabs {
    gap: 4px;
    padding: 4px;
  }

  .deck-tab {
    min-height: 37px;
    font-size: 0.7rem;
  }

  .deck-heading h2 {
    font-size: 2.15rem;
  }

  .file-row strong {
    font-size: 0.74rem;
  }

  .control-button,
  .hold-stop {
    padding-right: 9px;
    padding-left: 9px;
  }
}

@media (orientation: landscape) and (max-height: 700px) and (min-width: 600px) {
  .app-shell {
    padding-top: max(12px, env(safe-area-inset-top));
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }

  .topbar {
    padding-bottom: 12px;
  }

  .deck-tabs {
    margin-bottom: 14px;
  }

  .deck-heading {
    margin-bottom: 8px;
  }

  .deck-heading h2 {
    font-size: 2.7rem;
  }

  .status-main {
    padding-top: 18px;
    padding-bottom: 18px;
  }

  .file-row {
    min-height: 86px;
    padding-top: 14px;
    padding-bottom: 14px;
  }

  .controls {
    grid-template-columns: 1fr 1fr;
  }

  .control-button,
  .hold-stop {
    min-height: 76px;
  }

  .message {
    margin-top: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
