/* Comment Video Factory · glass design system, mobile first */
:root {
  color-scheme: dark;

  --bg-0: #07060f;
  --bg-1: #110d26;
  --orb-violet: rgba(124, 92, 255, 0.5);
  --orb-cyan: rgba(34, 211, 238, 0.32);
  --orb-pink: rgba(236, 72, 153, 0.26);

  --glass-bg: linear-gradient(160deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.035));
  --glass-solid: rgba(22, 18, 44, 0.94);
  --glass-strong: rgba(20, 16, 40, 0.72);
  --glass-inner: rgba(255, 255, 255, 0.05);
  --glass-inner-hover: rgba(255, 255, 255, 0.09);
  --glass-field: rgba(6, 5, 18, 0.42);
  --glass-border: rgba(255, 255, 255, 0.13);
  --glass-border-strong: rgba(255, 255, 255, 0.22);
  --glass-highlight: inset 0 1px 0 rgba(255, 255, 255, 0.16);
  --glass-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  --blur: 18px;
  --blur-strong: 26px;

  --text: #f5f3ff;
  --text-muted: rgba(236, 233, 255, 0.72);
  --text-faint: rgba(236, 233, 255, 0.5);

  --accent: #7c5cff;
  --accent-2: #22d3ee;
  --accent-grad: linear-gradient(135deg, #7c5cff 0%, #5b8cff 50%, #22d3ee 100%);
  --accent-soft: rgba(124, 92, 255, 0.22);
  --accent-ring: rgba(124, 92, 255, 0.55);
  --success: #34d399;
  --success-grad: linear-gradient(135deg, #10b981, #34d399);
  --danger: #fb7185;
  --danger-soft: rgba(251, 113, 133, 0.14);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.16);

  --radius-xs: 8px;
  --radius-sm: 12px;
  --radius: 16px;
  --radius-lg: 22px;
  --radius-pill: 999px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;

  --tap: 44px;
  --field-font: 16px;
  --topbar-h: 60px;
  --dock-space: 124px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  --z-topbar: 20;
  --z-dock: 30;
  --z-toast: 60;
  --z-modal: 50;

  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
}

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

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: calc(var(--dock-space) + var(--safe-bottom));
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  background-color: var(--bg-0);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* Soft colour field behind the glass; a fixed layer because iOS ignores background-attachment: fixed. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(34rem 34rem at 8% -6%, var(--orb-violet), transparent 62%),
    radial-gradient(30rem 30rem at 105% 28%, var(--orb-cyan), transparent 60%),
    radial-gradient(32rem 32rem at 20% 108%, var(--orb-pink), transparent 62%),
    linear-gradient(180deg, var(--bg-1), var(--bg-0) 70%);
}

body.has-modal {
  overflow: hidden;
}

h2 {
  margin: 0;
}

code {
  font-family: var(--mono);
  font-size: 0.86em;
  padding: 1px 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--accent-2);
}

:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}

::selection {
  background: var(--accent-soft);
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: var(--radius-pill);
}

::-webkit-scrollbar-track {
  background: transparent;
}

/* Glass surfaces */
.topbar,
.card,
.action-dock,
.modal-card,
.toast {
  background: var(--glass-bg), var(--glass-strong);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-highlight), var(--glass-shadow);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(160%);
  backdrop-filter: blur(var(--blur)) saturate(160%);
}

.topbar,
.action-dock,
.modal-card,
.toast {
  -webkit-backdrop-filter: blur(var(--blur-strong)) saturate(170%);
  backdrop-filter: blur(var(--blur-strong)) saturate(170%);
}

/* Top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-topbar);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: calc(var(--topbar-h) + var(--safe-top));
  padding: calc(var(--space-2) + var(--safe-top)) var(--space-4) var(--space-2);
  border-width: 0 0 1px;
  border-radius: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: var(--accent-grad);
  box-shadow: 0 6px 18px rgba(124, 92, 255, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.brand-mark svg {
  width: 20px;
  height: 20px;
  fill: #fff;
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.15;
}

.brand-name {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.2px;
}

.brand-sub {
  font-size: 11px;
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: none;
}

/* Layout: one ordered column on phones, three columns on wide screens */
.workspace {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: var(--space-3);
}

.workspace-col {
  display: contents;
}

.card-project { order: 1; }
.card-source { order: 2; }
.card-comments { order: 3; }
.card-template { order: 4; }
.card-stage { order: 5; }
.card-log { order: 6; }

.card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-width: 0;
  padding: var(--space-4);
  border-radius: var(--radius-lg);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  min-height: 28px;
}

.card-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.1px;
}

.step {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 800;
  color: #fff;
  background: var(--accent-grad);
}

.card-meta {
  min-width: 0;
  overflow: hidden;
  font-size: 12px;
  color: var(--text-faint);
  white-space: nowrap;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}

.row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.grow {
  flex: 1 1 auto;
  min-width: 0;
}

/* Chips */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  color: var(--text-muted);
  background: var(--glass-inner);
  border: 1px solid var(--glass-border);
  font-variant-numeric: tabular-nums;
}

.chip-accent {
  color: #e3dcff;
  background: var(--accent-soft);
  border-color: rgba(124, 92, 255, 0.4);
}

.chip-warn {
  color: var(--warn);
  background: var(--warn-soft);
  border-color: rgba(251, 191, 36, 0.4);
}

.chip-glass {
  color: var(--text);
  background: rgba(8, 6, 20, 0.55);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

/* Form fields: 16px text keeps iOS from zooming on focus */
.field {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 14px;
  font: inherit;
  font-size: var(--field-font);
  color: var(--text);
  background: var(--glass-field);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.field::placeholder {
  color: var(--text-faint);
}

.field:focus {
  outline: none;
  border-color: var(--accent-ring);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

select.field {
  appearance: none;
  padding-right: 36px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 19px) 50%, calc(100% - 14px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

select.field option {
  color: var(--text);
  background: var(--bg-1);
}

.field-area {
  min-height: 104px;
  resize: vertical;
  line-height: 1.5;
}

.field-number {
  width: 84px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.field-center {
  text-align: center;
  letter-spacing: 1px;
}

/* Icons: inline SVG so no glyph depends on the phone's fonts */
.icon {
  flex: none;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-solid {
  fill: currentColor;
  stroke: none;
}

.icon-inline {
  width: 1.15em;
  height: 1.15em;
  vertical-align: -0.22em;
}

.btn-news {
  position: relative;
}

.news-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 9px;
  height: 9px;
  border-radius: var(--radius-pill);
  background: var(--danger);
  box-shadow: 0 0 0 2px var(--bg-0), 0 0 10px var(--danger);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--tap);
  padding: 0 16px;
  font: inherit;
  font-size: 15px;
  font-weight: 650;
  line-height: 1.1;
  color: var(--text);
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  background: var(--glass-inner);
  transition: transform 0.15s var(--ease), background 0.2s var(--ease), border-color 0.2s var(--ease), box-shadow 0.2s var(--ease), opacity 0.2s;
}

.btn:hover {
  background: var(--glass-inner-hover);
  border-color: var(--glass-border-strong);
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.22);
  background: var(--accent-grad);
  box-shadow: 0 8px 22px rgba(91, 140, 255, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.btn-primary:hover {
  background: var(--accent-grad);
  box-shadow: 0 10px 26px rgba(91, 140, 255, 0.48), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.btn-success {
  color: #04221a;
  border-color: rgba(255, 255, 255, 0.25);
  background: var(--success-grad);
  box-shadow: 0 8px 22px rgba(16, 185, 129, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.btn-success:hover {
  background: var(--success-grad);
}

.btn-ghost {
  background: var(--glass-inner);
}

.btn-danger-ghost {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: rgba(251, 113, 133, 0.3);
}

.btn-danger-ghost:hover {
  background: rgba(251, 113, 133, 0.22);
  border-color: rgba(251, 113, 133, 0.5);
}

.btn-icon {
  flex: none;
  width: var(--tap);
  padding: 0;
  font-size: 18px;
}

.btn-compact {
  min-height: 38px;
  padding: 0 12px;
  font-size: 14px;
}

.btn-sm {
  min-height: 40px;
  padding: 0 10px;
  font-size: 13px;
  border-radius: var(--radius-xs);
}

.btn-block {
  width: 100%;
  min-height: 50px;
}

.link-btn {
  align-self: flex-start;
  min-height: 36px;
  padding: 0;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent-2);
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
}

.link-btn:hover {
  text-decoration: underline;
}

.link-center {
  align-self: center;
  text-align: center;
}

/* Segmented control */
.segmented {
  display: grid;
  grid-auto-columns: 1fr;
  grid-auto-flow: column;
  gap: var(--space-1);
  padding: var(--space-1);
  border-radius: var(--radius-sm);
  background: var(--glass-field);
  border: 1px solid var(--glass-border);
}

.segment {
  min-height: 40px;
  padding: 0 8px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-xs);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}

.segment:hover {
  color: var(--text);
}

.segment.is-active {
  color: #fff;
  background: linear-gradient(160deg, rgba(124, 92, 255, 0.55), rgba(34, 211, 238, 0.35));
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: var(--glass-highlight), 0 4px 14px rgba(124, 92, 255, 0.3);
}

/* Source panels */
.source-panel {
  display: none;
  flex-direction: column;
  gap: var(--space-3);
}

.source-panel.is-active {
  display: flex;
}

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

.hint-center {
  text-align: center;
}

.label {
  font-size: 14px;
  font-weight: 600;
}

.hint-chip {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* Progress */
.progress {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.progress-track {
  position: relative;
  flex: 1;
  height: 6px;
  overflow: hidden;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.1);
}

.progress-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--accent-grad);
  box-shadow: 0 0 12px rgba(34, 211, 238, 0.6);
  transition: width 0.4s var(--ease);
}

.progress-fill.is-indeterminate {
  width: 35%;
  animation: progress-sweep 1.3s ease-in-out infinite;
}

.progress-text {
  min-width: 3.5em;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-2);
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

@keyframes progress-sweep {
  0% { transform: translateX(-110%); }
  100% { transform: translateX(310%); }
}

/* Templates */
.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: var(--space-2);
}

.template-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 76px;
  padding: var(--space-2);
  font: inherit;
  color: var(--text-muted);
  background: var(--glass-inner);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform 0.15s var(--ease), background 0.2s var(--ease), border-color 0.2s var(--ease), color 0.2s;
}

.template-card:hover {
  color: var(--text);
  background: var(--glass-inner-hover);
}

.template-card:active {
  transform: scale(0.97);
}

.template-card.is-active {
  color: #fff;
  background: linear-gradient(160deg, rgba(124, 92, 255, 0.4), rgba(34, 211, 238, 0.18));
  border-color: rgba(124, 92, 255, 0.75);
  box-shadow: var(--glass-highlight), 0 6px 18px rgba(124, 92, 255, 0.3);
}

.template-icon {
  font-size: 22px;
  line-height: 1;
}

.template-name {
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}

/* Duration */
.duration {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding-top: var(--space-3);
  border-top: 1px solid var(--glass-border);
}

.duration-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2);
}

.duration-custom {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 14px;
  color: var(--text-muted);
}

/* Comments */
.comment-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.comment-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-3);
  border-radius: var(--radius);
  background: var(--glass-inner);
  border: 1px solid var(--glass-border);
  transition: opacity 0.2s var(--ease), border-color 0.2s var(--ease);
}

.comment-card.is-pinned {
  border-color: rgba(251, 191, 36, 0.55);
  background: linear-gradient(160deg, rgba(251, 191, 36, 0.12), rgba(255, 255, 255, 0.04));
}

.comment-card.is-excluded {
  opacity: 0.45;
}

.comment-card.is-excluded .comment-body {
  text-decoration: line-through;
}

.comment-head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 800;
  color: #fff;
  background: var(--accent-grad);
}

.comment-who {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.author-name {
  overflow: hidden;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.pin-tag {
  flex: none;
  font-size: 11px;
  font-weight: 700;
  color: var(--warn);
}

.comment-meta {
  display: flex;
  gap: var(--space-1);
  flex: none;
}

.comment-meta .chip {
  padding: 2px 8px;
  font-size: 11px;
}

.comment-body {
  padding: 6px 8px;
  margin: 0 -8px;
  font-size: 15px;
  line-height: 1.5;
  word-break: break-word;
  border-radius: var(--radius-xs);
  outline: none;
  transition: background 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.comment-body:focus {
  background: var(--glass-field);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.comment-reasons {
  font-size: 12px;
  color: var(--text-faint);
}

.comment-actions {
  display: grid;
  grid-template-columns: 1.4fr 0.7fr 0.7fr 1.4fr;
  gap: 6px;
}

.comments-more {
  min-height: var(--tap);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent-2);
  background: rgba(34, 211, 238, 0.06);
  border: 1px dashed rgba(34, 211, 238, 0.35);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: var(--space-5) var(--space-3);
  text-align: center;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 28px;
}

/* Stage */
.stage {
  position: relative;
  display: grid;
  place-items: center;
  width: min(100%, calc(72vh * 9 / 16));
  width: min(100%, calc(72dvh * 9 / 16));
  aspect-ratio: 9 / 16;
  margin: 0 auto;
  overflow: hidden;
  border-radius: var(--radius);
  background: rgba(3, 2, 10, 0.7);
  border: 1px solid var(--glass-border);
}

.stage-media {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.stage-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-4);
  text-align: center;
  color: var(--text-muted);
}

.stage-empty svg {
  width: 52px;
  height: 52px;
  fill: currentColor;
  opacity: 0.6;
}

.stage-badges {
  position: absolute;
  top: var(--space-2);
  left: var(--space-2);
  pointer-events: none;
}

/* Action dock: fixed to the bottom edge on phones so export is always one tap away */
.action-dock {
  order: 7;
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: var(--z-dock);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-width: 720px;
  margin: 0 auto;
  padding: var(--space-3) var(--space-3) calc(var(--space-3) + var(--safe-bottom));
  border-width: 1px 0 0;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.dock-buttons {
  display: flex;
  gap: var(--space-2);
}

.dock-buttons .btn {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 50px;
  padding: 0 12px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dock-buttons .btn-preview {
  flex: 0 0 auto;
}

/* With a finished video on stage, preview shrinks to its icon so save and export keep full labels. */
.dock-buttons:has(.btn-success:not([hidden])) .btn-preview .btn-label {
  display: none;
}

.btn.is-busy .btn-glyph {
  display: none;
}

.btn.is-busy::before {
  content: "";
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
  border-radius: var(--radius-pill);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.btn-cta {
  font-size: 16px;
  font-weight: 750;
}

.progress-render {
  padding: 0 var(--space-1);
}

/* Log */
.card-log {
  gap: 0;
  padding: 0;
}

.log-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  width: 100%;
  min-height: 52px;
  padding: 0 var(--space-4);
  font: inherit;
  color: var(--text);
  background: none;
  border: none;
  cursor: pointer;
}

.log-body {
  max-height: 240px;
  overflow-y: auto;
  padding: 0 var(--space-4) var(--space-4);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.55;
}

.card-log.is-collapsed .log-body {
  display: none;
}

.log-entry {
  display: flex;
  gap: var(--space-2);
  padding: 3px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.log-time {
  flex: none;
  color: var(--text-faint);
}

.log-info { color: var(--text-muted); }
.log-success { color: var(--success); }
.log-warn { color: var(--warn); }
.log-error { color: var(--danger); }

/* Toast */
.toast {
  position: fixed;
  top: calc(var(--topbar-h) + var(--safe-top) + var(--space-3));
  left: 50%;
  z-index: var(--z-toast);
  width: max-content;
  max-width: calc(100vw - 32px);
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  border-radius: var(--radius);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -12px);
  transition: opacity 0.25s var(--ease), transform 0.25s var(--ease);
}

.toast {
  background: var(--glass-bg), var(--glass-solid);
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.is-success { border-color: rgba(52, 211, 153, 0.55); }
.toast.is-info { border-color: rgba(91, 140, 255, 0.55); }
.toast.is-warn { border-color: rgba(251, 191, 36, 0.6); color: #fde68a; }
.toast.is-error { border-color: rgba(251, 113, 133, 0.65); color: #fecdd3; }

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  padding: calc(var(--safe-top) + 8vh) var(--space-3) calc(var(--safe-bottom) + var(--space-5));
  background: rgba(5, 4, 14, 0.5);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.modal-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  width: 100%;
  max-width: 420px;
  padding: var(--space-5);
  border-radius: var(--radius-lg);
  background: var(--glass-bg), var(--glass-solid);
}

.modal-card.is-wide {
  max-width: 620px;
}

.modal-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
}

.modal-icon {
  font-size: 32px;
}

.modal-title {
  font-size: 19px;
  font-weight: 800;
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.modal-actions {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: var(--space-2);
  margin-top: var(--space-1);
}

.form-error {
  font-size: 13px;
  text-align: center;
  color: var(--danger);
}

.guest-block {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.divider {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: 12px;
  color: var(--text-faint);
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--glass-border);
}

.share-link-preview {
  display: block;
  padding: var(--space-3);
  overflow-wrap: anywhere;
  border-radius: var(--radius-sm);
  background: var(--glass-field);
}

/* Share guide */
.guide-panel {
  display: none;
  flex-direction: column;
  gap: var(--space-3);
}

.guide-panel.is-active {
  display: flex;
}

.guide-download {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.guide-steps,
.guide-checks {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin: 0;
  padding-left: 22px;
  font-size: 14px;
  color: var(--text-muted);
}

.guide-steps b,
.guide-checks b,
.guide-note b {
  color: var(--text);
}

/* Release notes */
.release-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.release-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.release-list li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--text-muted);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  background: var(--glass-inner);
}

.release-list b {
  color: var(--text);
}

.release-list li.is-highlight {
  color: var(--text);
  border-color: var(--accent-ring);
  background: var(--accent-soft);
  box-shadow: 0 8px 24px rgba(91, 140, 255, 0.18);
}

.release-roadmap li {
  border-style: dashed;
  background: transparent;
}

.release-icon {
  flex: none;
  font-size: 18px;
  line-height: 1.3;
}

.guide-subtitle {
  font-size: 14px;
  font-weight: 700;
}

.guide-note {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-3);
  font-size: 13px;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  background: var(--glass-inner);
  border: 1px solid var(--glass-border);
}

.copy-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.copy-row code {
  flex: 1;
  min-width: 0;
  padding: 8px;
  overflow-wrap: anywhere;
}

/* Wide screens: controls | comments | sticky stage with an inline dock */
@media (min-width: 1180px) {
  :root {
    --field-font: 14px;
  }

  body {
    padding-bottom: var(--space-5);
    font-size: 14px;
  }

  .workspace {
    display: grid;
    grid-template-columns: minmax(320px, 380px) minmax(0, 1fr) minmax(320px, 400px);
    align-items: start;
    gap: var(--space-4);
    max-width: 1640px;
    padding: var(--space-4) var(--space-5);
  }

  .workspace-col {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    min-width: 0;
  }

  .col-stage {
    position: sticky;
    top: calc(var(--topbar-h) + var(--space-4));
  }

  .stage {
    width: min(100%, calc((100vh - 300px) * 9 / 16));
    width: min(100%, calc((100dvh - 300px) * 9 / 16));
  }

  .action-dock {
    position: static;
    max-width: none;
    margin: 0;
    padding: var(--space-3);
    border-width: 1px;
    border-radius: var(--radius-lg);
  }

  .toast {
    top: auto;
    bottom: var(--space-5);
    transform: translate(-50%, 12px);
  }
}

@media (max-width: 380px) {
  .brand-sub {
    display: none;
  }

  .dock-buttons .btn {
    font-size: 14px;
  }
}

/* Solid surfaces where blur is missing or the user asked for less transparency */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .topbar,
  .card,
  .action-dock,
  .modal-card,
  .toast {
    background: var(--glass-solid);
  }
}

@media (prefers-reduced-transparency: reduce) {
  .topbar,
  .card,
  .action-dock,
  .modal-card,
  .toast,
  .chip-glass,
  .modal-overlay {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    background: var(--glass-solid);
  }
}

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