/* V2 control states are owned here, after the shared legacy/theme layers. */
:root {
  --control-radius: 8px;
  --control-selected: var(--navigation-accent);
  --control-on-selected: var(--opal-on-action);
}

#view :is(input, textarea, select) { letter-spacing: 0; }
#view :is(.button, .input, .select, .textarea, .mode-option, .choice) { border-radius: var(--control-radius); }
#view .button.primary {
  color: var(--control-on-selected);
  box-shadow: 0 3px 8px color-mix(in srgb, var(--navigation-accent) 14%, transparent);
}
#view:not([data-page="home"]) .button.primary {
  background: var(--navigation-accent);
  border-color: color-mix(in srgb, var(--navigation-accent) 85%, var(--ink));
  box-shadow: inset 0 1px 0 #ffffff30, 0 2px 4px color-mix(in srgb, var(--navigation-accent) 12%, transparent);
}
#view .icon-button {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  background: var(--panel);
}
#view .icon-button svg { width: 18px; height: 18px; }
#view .icon-button:hover { color: var(--ink); background: var(--soft); border-color: var(--line2); }
#view .icon-button.danger { color: var(--danger); }
#view .icon-button.danger:hover { background: color-mix(in srgb, var(--danger) 8%, var(--panel)); }
#view [data-clear-qr] { width: 44px; min-width: 44px; padding: 0; }
#view .visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
#view :is(button:disabled, a[aria-disabled="true"]) { cursor: not-allowed; }
#view :is(.input, .select, .field input:not([type="checkbox"])) { min-height: 44px; height: auto; padding: 10px 12px; }
#view :is(.input, .textarea, .select)::placeholder { color: var(--muted); opacity: .8; }
#view .field { min-width: 0; }
#view .field-label { display: flex; align-items: center; gap: 5px; }
#view .field-required { color: var(--danger); font-size: 12px; }
#view .field-count { justify-self: end; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
#view .choice-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; align-items: stretch; }
#view .choice-row[data-choice-count="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
#view .choice {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  min-width: 0;
  padding: 9px 12px;
  border: 1px solid var(--line2);
  background: var(--panel);
  color: var(--muted);
  font-weight: 500;
  line-height: 1.45;
  transition: border-color 160ms, background-color 160ms, color 160ms;
}
#view .choice:hover:not(:disabled) { border-color: var(--navigation-accent); background: var(--soft); }
#view .choice-check {
  display: grid;
  place-items: center;
  flex: 0 0 16px;
  width: 16px;
  height: 16px;
  border: 1px solid var(--line2);
  border-radius: 50%;
}
#view .choice-check svg { width: 12px; height: 12px; opacity: 0; }
#view .choice.selected,
#view .choice[aria-pressed="true"] {
  border-color: var(--navigation-accent);
  background: var(--strong);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--navigation-accent);
}
#view .choice.selected .choice-check {
  border-color: var(--control-selected);
  background: var(--control-selected);
  color: var(--control-on-selected);
}
#view .choice.selected .choice-check svg { opacity: 1; }
#view .ratio-choices { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); max-width: 440px; }
#view .ratio-choices .choice {
  position: relative;
  flex-direction: column;
  gap: 5px;
  padding: 10px 6px;
  min-height: 76px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
#view .ratio-choices .choice-check { position: absolute; right: 5px; top: 5px; visibility: hidden; }
#view .ratio-choices .selected .choice-check { visibility: visible; }
#view .ratio-preview { display: grid; place-items: center; width: 28px; height: 28px; color: var(--muted); }
#view .ratio-preview i { display: block; border: 1.5px solid currentColor; border-radius: 2px; background: color-mix(in srgb, currentColor 5%, transparent); }
#view .selected .ratio-preview { color: var(--navigation-accent); }

#view :is(.mode-option.active, .source-cover-modes [aria-pressed="true"]) {
  border-color: var(--control-selected);
  background: var(--control-selected);
  color: var(--control-on-selected);
  box-shadow: none;
}
#view .mode-option.active :is(b, small) { color: inherit; }
#view .mode-option { min-height: 54px; }
#view :is(.candidate-card, .source-ppt-template) {
  position: relative;
  padding: 16px;
  border: 1px solid var(--line2);
  border-radius: 8px;
  background: var(--panel);
  min-width: 0;
  overflow-wrap: anywhere;
}
#view :is(.candidate-card, .source-ppt-template).selected {
  border-color: var(--navigation-accent);
  background: var(--strong);
  box-shadow: inset 0 0 0 1px var(--navigation-accent);
}
#view :is(.candidate-card, .source-ppt-template).selected::after {
  content: "\2713";
  display: grid;
  place-items: center;
  position: absolute;
  top: 8px;
  right: 8px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--control-selected);
  color: var(--control-on-selected);
  font-size: 13px;
}
#view .candidate-card > :first-child { padding-right: 24px; }
#view .candidate-card b { font-size: 17px; line-height: 1.5; color: var(--ink); }
#view .candidate-card :is(p, small, span) { font-size: 13px; line-height: 1.65; }
#view :is(.source-title-choices .selected, .source-book-question-tabs .selected) {
  color: var(--control-on-selected);
  background: var(--control-selected);
  border-color: var(--control-selected);
}
#view :is(.source-book-chapters > button.selected, .source-ppt-thumbnails > button.selected) {
  background: var(--strong);
  color: var(--ink);
  border-color: var(--navigation-accent);
  box-shadow: inset 0 0 0 1px var(--navigation-accent);
}
#view :is(.source-book-mobile-tabs, .source-poster-tabs) [aria-selected="true"] {
  background: var(--strong);
  color: var(--navigation-accent);
  border-bottom-color: var(--navigation-accent);
}
#view :is(.source-book-mobile-tabs, .source-poster-tabs) button { border-radius: 6px 6px 0 0; }
#view :is(input[type="checkbox"], input[type="radio"]) { width: 18px; height: 18px; min-height: 18px; flex: none; accent-color: var(--navigation-accent); }
#view :is(.source-book-question-tabs, .source-book-toolbar) button,
#view :is(.source-ppt-icon, .source-writing-format button) { min-width: 44px; min-height: 44px; }
#view :is(.task-warning, .task-error) { border-radius: 6px; padding: 12px 14px; line-height: 1.65; font-size: 13px; overflow-wrap: anywhere; }
#view .task-warning { border-left: 3px solid var(--gold); background: color-mix(in srgb, var(--gold) 8%, var(--panel)); color: var(--text); }
#view .task-error { border-left: 3px solid var(--danger); background: color-mix(in srgb, var(--danger) 8%, var(--panel)); color: var(--danger); }

.project-dialog, .tool-search { border-radius: 8px; }
.project-dialog > header { position: sticky; top: -20px; z-index: 2; padding-block: 10px; background: var(--panel); }
.project-dialog .button.primary { color: var(--control-on-selected); }
.project-dialog .icon-button { display: grid; place-items: center; flex: 0 0 44px; width: 44px; height: 44px; }

@media (max-width: 820px) {
  #view :is(.input, .textarea, .select, .field input) { font-size: 16px; }
  #view .choice { font-size: 14px; }
  #view .choice-row.choice-long { grid-template-columns: minmax(0, 1fr); }
  #view .choice-long .choice { justify-content: space-between; }
  #view .choice-row[data-choice-count="3"]:not(.choice-long) .choice { flex-direction: column; gap: 4px; padding: 8px 4px; }
}
@media (prefers-reduced-motion: reduce) {
  #view .choice { transition: none; }
}
.video-recovery-actions { margin-block: 16px; display: flex; flex-wrap: wrap; gap: 10px; }
.video-recovery-actions p { flex-basis: 100%; margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
