/* Workflow UI styles. Dark theme shared with the drawing editor (web/editor/editor.css).
   Every selector starts with an app- class; nothing here reaches into [data-eus-editor]. */

html,
body {
  margin: 0;
  height: 100%;
  overscroll-behavior: none;
  background: #14161a;
  color: #e6e8eb;
}

.app-root {
  --tap: 44px;
  --app-bg: #14161a;
  --app-stage: #0b0c0e;
  --app-panel: #1e2126;
  --app-line: #343941;
  --app-text: #e6e8eb;
  --app-muted: #9aa3ad;
  --app-btn: #2a2e35;
  --app-accent: #2f6fdf;
  --app-focus: #9cc2ff;
  --app-warning: #f5b301;
  --app-danger: #ff6b6b;
  min-height: 100%;
  box-sizing: border-box;
  background: var(--app-bg);
  color: var(--app-text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

.app-root *,
.app-root *::before,
.app-root *::after {
  box-sizing: border-box;
}

.app-hidden {
  display: none !important;
}

.app-screen {
  padding: 16px;
}

.app-title {
  margin: 0;
  font-size: 24px;
  font-weight: 650;
}

.app-lead {
  margin: 0;
  color: var(--app-muted);
}

.app-label {
  font-weight: 600;
}

.app-muted {
  color: var(--app-muted);
}

.app-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.app-btn,
.app-btn--primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--tap);
  min-width: var(--tap);
  padding: 0 14px;
  border: 1px solid var(--app-line);
  border-radius: 10px;
  background: var(--app-btn);
  color: inherit;
  font: inherit;
  font-weight: 600;
  white-space: nowrap;
  touch-action: manipulation;
  cursor: pointer;
}

.app-btn--primary {
  background: var(--app-accent);
  border-color: var(--app-focus);
  color: #fff;
}

.app-btn:disabled,
.app-btn--primary:disabled {
  opacity: 0.4;
  cursor: default;
}

.app-btn:focus-visible,
.app-btn--primary:focus-visible,
.app-input:focus-visible,
.app-video-item:focus-visible {
  outline: 2px solid var(--app-focus);
  outline-offset: 2px;
}

.app-input {
  min-height: var(--tap);
  padding: 0 12px;
  border: 1px solid var(--app-line);
  border-radius: 10px;
  background: var(--app-stage);
  color: inherit;
  font: inherit;
  font-size: 16px;
}

.app-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--app-line);
  border-radius: 10px;
  background: var(--app-panel);
}

.app-banner--error {
  border-color: var(--app-danger);
}

.app-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
}

.app-dialog {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(520px, calc(100% - 32px));
  padding: 20px;
  border: 1px solid var(--app-line);
  border-radius: 14px;
  background: var(--app-panel);
}

/* ---- login ----------------------------------------------------------------- */

.app-login {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 360px;
  margin: 0 auto;
  padding-top: 12vh;
}

.app-login-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ---- video list ------------------------------------------------------------ */

.app-videos {
  max-width: 900px;
  margin: 0 auto;
}

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

.app-video-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
}

.app-video-item {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 100%;
  min-height: 64px;
  padding: 12px 16px;
  border: 1px solid var(--app-line);
  border-radius: 12px;
  background: var(--app-panel);
  color: inherit;
  text-decoration: none;
}

.app-video-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
}

/* ---- annotation screen ------------------------------------------------------- */

/* Narrow screens: one column (top bar, stage, navigation, filmstrip, label panel); the page scrolls. */
.app-annotate {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "top" "stage" "nav" "strip" "panel";
}

.app-annotate > .app-topbar {
  grid-area: top;
}

.app-annotate > .app-stage {
  grid-area: stage;
  height: 60vh;
  height: 60dvh;
}

.app-annotate > .app-panel {
  grid-area: panel;
}

.app-annotate > .app-nav {
  grid-area: nav;
}

.app-annotate > .app-filmstrip {
  grid-area: strip;
}

/* Wide screens: the label panel sits beside the editor and scrolls inside itself. */
@media (min-width: 900px) {
  .app-annotate {
    grid-template-columns: minmax(0, 1fr) 340px;
    grid-template-rows: auto minmax(0, 1fr) auto auto;
    grid-template-areas: "top top" "stage panel" "nav nav" "strip strip";
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }

  .app-annotate > .app-stage {
    height: auto;
  }

  .app-annotate > .app-panel {
    min-height: 0;
    overflow-y: auto;
    border-top: 0;
    border-left: 1px solid var(--app-line);
  }
}

/* ---- label panel ------------------------------------------------------------------ */

.app-panel {
  padding: 12px;
  border-top: 1px solid var(--app-line);
  background: var(--app-panel);
  -webkit-overflow-scrolling: touch;
}

.app-panel-title {
  margin: 0 0 12px;
  font-size: 18px;
  font-weight: 650;
}

.app-fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.app-fieldset:disabled {
  opacity: 0.55;
}

.app-field + .app-field {
  margin-top: 16px;
}

.app-field-title {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--app-muted);
}

.app-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.app-chips--apart {
  margin-top: 10px;
}

.app-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  min-width: var(--tap);
  padding: 8px 14px;
  border: 1px solid var(--app-line);
  border-radius: 22px;
  background: var(--app-btn);
  color: inherit;
  font: inherit;
  font-size: 16px;
  line-height: 1.2;
  text-align: center;
  white-space: normal;
  touch-action: manipulation;
  cursor: pointer;
}

.app-chip[aria-pressed="true"] {
  border-color: var(--app-focus);
  background: var(--app-accent);
  color: #fff;
}

.app-chip[data-default-state="true"][aria-pressed="true"] {
  border-color: var(--app-muted);
  background: transparent;
  color: var(--app-muted);
}

.app-chip:focus-visible {
  outline: 2px solid var(--app-focus);
  outline-offset: 2px;
}

.app-chip:disabled {
  cursor: default;
}

.app-chip--block {
  width: 100%;
}

.app-hint {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--app-muted);
}

.app-warning {
  margin: 8px 0 0;
  font-size: 14px;
  color: var(--app-warning);
}

.app-note {
  display: block;
  width: 100%;
  min-height: 88px;
  padding: 10px 12px;
  font-size: 16px;
  resize: vertical;
}

/* ---- conflict dialog and login overlay ------------------------------------------------ */

.app-conflict {
  background: rgba(5, 6, 8, 0.72);
}

.app-dialog-title {
  margin: 0 0 8px;
  font-size: 20px;
}

.app-dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 16px;
}

.app-login-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  overflow-y: auto;
  background: rgba(10, 11, 13, 0.94);
}

.app-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 4px 12px;
  border-bottom: 1px solid var(--app-line);
  background: var(--app-panel);
}

.app-topbar-strong {
  font-weight: 700;
}

.app-indicator {
  margin-left: auto;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--app-btn);
  color: var(--app-muted);
  font-size: 14px;
}

.app-stage {
  position: relative;
  min-height: 240px;
  overflow: hidden;
  background: var(--app-stage);
}

.app-editor-host {
  position: absolute;
  inset: 0;
}

.app-frame-error {
  position: absolute;
  top: 12px;
  left: 50%;
  z-index: 10;
  transform: translateX(-50%);
  max-width: calc(100% - 24px);
}

.app-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid var(--app-line);
  background: var(--app-panel);
}

.app-slider-wrap {
  position: relative;
  display: flex;
  flex: 1 1 200px;
  align-items: center;
  min-width: 160px;
}

.app-slider {
  width: 100%;
  height: var(--tap);
  min-height: var(--tap);
  margin: 0;
  accent-color: var(--app-accent);
  touch-action: manipulation;
}

.app-slider-target {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 13px;
  color: var(--app-muted);
  white-space: nowrap;
  pointer-events: none;
}

.app-jump {
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-jump-input {
  height: var(--tap);
  width: 96px;
  min-width: 88px;
}

/* ---- filmstrip and preview ----------------------------------------------------- */

.app-filmstrip {
  display: flex;
  gap: 6px;
  min-height: 100px;
  padding: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  border-top: 1px solid var(--app-line);
  background: var(--app-bg);
  -webkit-overflow-scrolling: touch;
}

.app-thumb {
  position: relative;
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: var(--tap);
  min-height: var(--tap);
  padding: 4px;
  border: 1px solid var(--app-line);
  border-radius: 8px;
  background: var(--app-panel);
  color: inherit;
  font: inherit;
  font-size: 12px;
  line-height: 1.2;
  touch-action: manipulation;
  cursor: pointer;
}

.app-thumb img {
  display: block;
  height: 54px;
  width: auto;
  border-radius: 4px;
  background: var(--app-stage);
}

.app-thumb[data-current="true"] {
  outline: 2px solid var(--app-accent);
  outline-offset: -1px;
  border-color: var(--app-accent);
}

.app-thumb-number {
  font-weight: 700;
}

.app-thumb-time {
  color: var(--app-muted);
}

.app-thumb-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--app-warning);
}

.app-preview {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  background: rgba(5, 6, 8, 0.96);
}

.app-preview-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.app-preview-image {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  object-fit: contain;
}

.app-preview-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
}

/* ---- language switch (login screen, video list, annotation top bar) ------------ */

.app-lang-switch {
  display: inline-flex;
  flex: none;
  gap: 4px;
}

.app-login > .app-lang-switch {
  align-self: flex-end;
}

.app-lang-btn {
  padding: 0 10px;
  font-weight: 500;
}

.app-lang-btn[aria-pressed="true"] {
  background: var(--app-accent);
  border-color: var(--app-focus);
  color: #fff;
  font-weight: 650;
}

.app-header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}
