:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #101114;
  color: #f4f2ed;
  --panel: #1b1d21;
  --panel-2: #24272d;
  --line: #373b43;
  --accent: #f2c14e;
  --accent-2: #2ec4b6;
  --danger: #ff6b6b;
  --muted: #a7adb8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(46, 196, 182, 0.12), transparent 34%),
    linear-gradient(225deg, rgba(242, 193, 78, 0.12), transparent 38%),
    #101114;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: #f4f2ed;
  color: #111318;
  min-height: 42px;
  border-radius: 8px;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 700;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

button.secondary {
  background: var(--panel-2);
  color: #f4f2ed;
}

.ghost-button {
  min-height: 30px;
  padding: 0 10px;
  background: transparent;
  color: var(--accent-2);
}

button.recording {
  border-color: var(--danger);
  background: var(--danger);
  color: #111318;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(600px, 38vw);
  gap: 18px;
  width: min(1680px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px;
}

.workspace,
.inspector {
  min-width: 0;
}

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

.brand {
  display: grid;
  gap: 8px;
  min-width: 240px;
}

.brand-logo {
  display: block;
  width: min(420px, 100%);
  max-height: 112px;
  object-fit: contain;
  object-position: left center;
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: end;
  gap: 10px;
  flex-wrap: wrap;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 4vw, 4.2rem);
  line-height: 0.95;
  letter-spacing: 0;
}

h2 {
  font-size: 1rem;
  letter-spacing: 0;
}

.status {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 12px;
  color: var(--muted);
  background: rgba(27, 29, 33, 0.82);
  white-space: nowrap;
}

.admin-login {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(120px, 1fr) auto;
  align-items: end;
  gap: 10px;
  margin: -2px 0 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(27, 29, 33, 0.95);
}

.admin-login.hidden {
  display: none;
}

.admin-login .helper {
  grid-column: 1 / -1;
}

.stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  min-height: 420px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #08090b;
}

video,
canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

video {
  transform: scaleX(-1);
}

.camera-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 8px;
  text-align: center;
  color: var(--muted);
  background: radial-gradient(circle at center, rgba(244, 242, 237, 0.07), transparent 38%);
}

.camera-empty strong {
  color: #f4f2ed;
  font-size: 1.5rem;
}

.camera-empty.hidden {
  display: none;
}

.motion-countdown {
  position: absolute;
  z-index: 4;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: grid;
  place-items: center;
  min-width: 96px;
  min-height: 96px;
  border: 3px solid var(--accent);
  border-radius: 999px;
  background: rgba(17, 19, 24, 0.84);
  color: var(--accent);
  font-size: 3.3rem;
  font-weight: 950;
  line-height: 1;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.36);
}

.motion-countdown.hidden {
  display: none;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.inspector {
  display: grid;
  align-content: start;
  gap: 12px;
}

.training-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(27, 29, 33, 0.92);
  padding: 16px;
}

.train-panel {
  min-width: 0;
}

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

.panel-heading span,
.helper,
.confidence,
.compact li {
  color: var(--muted);
  font-size: 0.92rem;
}

.translation {
  min-height: 68px;
  padding: 14px;
  border-radius: 8px;
  background: #111318;
  color: var(--accent-2);
  font-size: 1.75rem;
  font-weight: 850;
  line-height: 1.1;
}

.confidence {
  margin-top: 10px;
}

.phrase {
  min-height: calc(1.45em * 2 + 14px);
  max-height: calc(1.45em * 2 + 14px);
  margin-top: 12px;
  padding-top: 12px;
  padding-bottom: 2px;
  border-top: 1px solid var(--line);
  line-height: 1.45;
  overflow: hidden;
  white-space: normal;
}

.phrase.expanded {
  max-height: calc(1.45em * 10 + 18px);
  overflow: auto;
  white-space: normal;
}

.phrase-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.order-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}

.order-row button {
  min-height: 34px;
  padding: 0 12px;
}

.ordered-translation {
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111318;
  color: #f4f2ed;
  line-height: 1.45;
  max-height: calc(1.45em * 10 + 20px);
  overflow: auto;
}

.ordered-translation:empty {
  display: none;
}

.field {
  display: grid;
  gap: 7px;
  color: var(--muted);
}

.scope-status {
  display: inline-flex;
  width: fit-content;
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 9px;
  color: var(--accent);
  background: #111318;
  font-size: 0.82rem;
  font-weight: 800;
}

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

.letter-output {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 70px;
  margin-bottom: 12px;
  border-radius: 8px;
  background: #111318;
  color: var(--accent);
  font-size: 2.8rem;
  font-weight: 900;
  line-height: 1;
}

.train-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 12px 0 8px;
}

.train-actions button:last-child {
  grid-column: 1 / -1;
}

.motion-timers {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  margin-top: 12px;
}

.sign-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  max-height: 230px;
  overflow: auto;
  padding-right: 4px;
}

.sample-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.search-field {
  margin-top: 12px;
}

.sign-chip,
.sample-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  background: var(--panel-2);
}

.sample-chip {
  border-style: dashed;
  background: #111318;
}

.saved-entry {
  display: block;
}

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

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

.saved-entry summary::before {
  content: ">";
  color: var(--accent-2);
  font-weight: 900;
}

.saved-entry[open] summary::before {
  content: "v";
}

.saved-entry summary span {
  flex: 1;
}

.saved-sample-list {
  display: grid;
  gap: 7px;
  margin-top: 9px;
  padding-top: 9px;
  border-top: 1px solid var(--line);
}

.saved-sample-chip {
  padding: 7px 8px;
}

.sign-chip button,
.sample-chip button {
  min-height: 30px;
  padding: 0 9px;
  background: transparent;
  color: var(--danger);
}

.sign-chip small {
  color: var(--accent-2);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.compact ul {
  margin: 12px 0 0;
  padding-left: 18px;
}

.credits-section {
  width: min(1680px, 100%);
  margin: 0 auto;
  padding: 0 18px 24px;
}

.credits-inner {
  display: grid;
  grid-template-columns: minmax(260px, 1.15fr) repeat(2, minmax(240px, 1fr));
  gap: 16px;
}

.credit-card {
  min-height: 250px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(27, 29, 33, 0.94);
  padding: 18px;
}

.team-card {
  background:
    linear-gradient(135deg, rgba(255, 107, 107, 0.16), transparent 45%),
    rgba(27, 29, 33, 0.94);
}

.credit-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.credit-icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(242, 193, 78, 0.14);
  font-size: 1.35rem;
}

.credit-person {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
}

.avatar {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: #e5262d;
  color: #fff;
  font-size: 0.95rem;
  font-weight: 900;
}

.accent-avatar {
  background: var(--accent);
  color: #111318;
}

.credit-person strong {
  display: block;
  color: #f4f2ed;
  font-size: 0.95rem;
  line-height: 1.2;
}

.credit-person small {
  display: block;
  margin-top: 3px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 700;
}

.tutor-badge {
  margin-top: 18px;
  border-radius: 8px;
  padding: 11px 12px;
  background: var(--accent);
  color: #111318;
  font-size: 0.82rem;
  font-weight: 900;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

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

  .credits-inner {
    grid-template-columns: 1fr;
  }

  .stage {
    min-height: 320px;
  }
}

@media (max-width: 560px) {
  .app-shell {
    padding: 12px;
  }

  .topbar {
    align-items: start;
    flex-direction: column;
  }

  .top-actions,
  .admin-login {
    width: 100%;
  }

  .admin-login {
    grid-template-columns: 1fr;
  }

  .status {
    white-space: normal;
  }

  .controls,
  .train-actions,
  .motion-timers {
    display: grid;
    grid-template-columns: 1fr;
  }
}
