/* Final UI pass: shared rhythm, responsive behavior and touch-safe controls. */
:root {
  --ui-ink: #183348;
  --ui-muted: #607080;
  --ui-blue: #174e75;
  --ui-coral: #c46e4e;
  --ui-bg: #f3f6f8;
  --ui-surface: #fff;
  --ui-line: #dde5eb;
  --ui-soft: #edf3f6;
  --ui-radius: 16px;
  --ui-shadow: 0 8px 26px rgba(24, 51, 72, .07);
}

html { overflow-x: hidden; scroll-behavior: smooth; }
body {
  min-width: 320px;
  overflow-x: hidden;
  color: var(--ui-ink);
  background: var(--ui-bg);
  font-family: "Microsoft YaHei UI", "PingFang SC", system-ui, sans-serif;
}

img, svg, video, canvas { max-width: 100%; }
.main, .content, .panel, .field, .workspace > *, .result-card,
.home-hero-copy, .home-storyboard, .promo-page, .dh-layout > * { min-width: 0; }
h1, h2, h3, p, a, button, label, td, th, small, strong { overflow-wrap: anywhere; }
h1, h2, h3 { text-wrap: balance; }
a, button { touch-action: manipulation; }
button, .primary, .home-primary, .home-secondary, .nav, .skill-function,
.choice, .scenario-card, .industry-card, .promo-script-card { transition: background-color .18s ease, border-color .18s ease, color .18s ease, box-shadow .18s ease, transform .18s ease; }

/* Desktop: leave generous reading width while keeping the workspace anchored. */
@media (min-width: 701px) {
  .content { max-width: 1440px; padding: 38px clamp(28px, 4vw, 56px) 76px; }
  .topbar { position: sticky; top: 0; z-index: 12; min-height: 70px; backdrop-filter: blur(12px); }
  .panel { border-radius: var(--ui-radius); box-shadow: var(--ui-shadow); }
  .workspace { gap: clamp(20px, 2.2vw, 32px); }
  .industry-heading { max-width: 1060px; }
  .industry-heading h1 { max-width: 22ch; }
  .industry-heading .subtitle { max-width: 72ch; }
  .quick-upload { min-height: 190px; }
  .skill-function { min-height: 82px; }
  .result-card { min-height: 220px; }
}

/* Shared controls use one visible rhythm across all workflow steps. */
.panel { border-color: var(--ui-line); }
.section-title { align-items: flex-start; }
.section-title h2 { line-height: 1.35; }
.field { gap: 8px; }
.field > span { line-height: 1.45; }
input, select, textarea { min-height: 44px; }
textarea { min-height: 104px; }
button, .primary { min-height: 44px; }
.primary { background: var(--ui-blue); border-color: var(--ui-blue); }
.primary:hover:not(:disabled) { background: #103b5b; border-color: #103b5b; }
.quick-upload:focus-within, .skill-function:focus-visible, .choice:focus-visible,
.scenario-card:focus-visible { outline: 3px solid #86b8d7; outline-offset: 3px; }
.notice, .info { max-width: 100%; overflow-wrap: anywhere; }
.steps { scrollbar-width: thin; }
.table-scroll { max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; }
.shots { min-width: 620px; }
.error-inline {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 14px;
  align-items: center;
  border: 1px solid #e4b9ae;
  color: #8f342a;
  background: #fff6f3;
  padding: 14px 16px;
  border-radius: 12px;
  line-height: 1.6;
}
.error-inline strong { min-width: 0; }
.error-inline code { grid-column: 1 / -1; font-size: 12px; color: #a14e43; overflow-wrap: anywhere; }
.error-inline button { min-height: 44px; color: #8f342a; border-color: #e4b9ae; background: #fff; }
.error-inline button:hover { border-color: #b86b5d; background: #fffaf8; }
.analysis-section textarea { min-height: 132px; }

/* Home page: keep the storyboard expressive, but give copy and actions a stable edge. */
.home-page { width: 100%; overflow: hidden; }
.home-hero-copy, .home-section-heading { max-width: 760px; }
.home-actions { align-items: center; }
.home-primary { min-height: 52px; }
.home-storyboard { min-width: 0; }
.home-scene-caption small { overflow-wrap: anywhere; }
.home-direction-grid > a, .home-process li { min-width: 0; }

/* Creator, account and admin pages share the same safe-area bottom navigation. */
@media (max-width: 700px) {
  html { scroll-behavior: auto; }
  body { padding-bottom: calc(78px + env(safe-area-inset-bottom)); }
  .shell { display: block; min-height: 100dvh; }
  .main { width: 100%; }
  .topbar { min-height: 60px; padding: 10px 16px; gap: 10px; }
  .topbar .workspace-crumb { max-width: 48%; line-height: 1.45; }
  .topbar .header-links { max-width: 52%; gap: 8px; line-height: 1.45; }
  .content { padding: 24px 16px calc(106px + env(safe-area-inset-bottom)); }
  .panel { padding: 18px; margin-bottom: 16px; border-radius: 16px; }
  .panel.compact { padding: 16px; }
  h1 { font-size: clamp(26px, 7.5vw, 34px); line-height: 1.3; letter-spacing: -.035em; }
  h2 { font-size: 20px; line-height: 1.4; }
  h3 { font-size: 16px; line-height: 1.45; }
  p { line-height: 1.75; }
  .subtitle { font-size: 15px; line-height: 1.75; }
  .industry-heading { margin: 4px 0 24px; padding-left: 14px; }
  .industry-heading h1 { font-size: clamp(27px, 8vw, 34px); }
  .industry-heading .subtitle { margin-bottom: 0; }
  .workspace { display: flex; flex-direction: column; gap: 0; }
  .workspace > aside { width: 100%; }
  .form-grid, .result-list, .settings-grid { grid-template-columns: 1fr; }
  .field.wide, .form-grid .wide { grid-column: auto; }
  .section-title { gap: 10px; flex-wrap: wrap; }
  .section-title h2 { font-size: 18px; margin-bottom: 0; }
  .number { flex: 0 0 26px; }
  .quick-upload { min-height: 168px; padding: 18px; }
  .skill-function { min-height: 72px; padding: 15px 13px; gap: 11px; }
  .skill-function strong { font-size: 15px; }
  .skill-function small { font-size: 13px; line-height: 1.55; }
  .market-row { align-items: stretch; flex-direction: column; gap: 10px; }
  .market-label { font-size: 14px; }
  .market-switch { width: 100%; }
  .market-switch button { flex: 1; }
  .actions { align-items: stretch; flex-direction: column; gap: 10px; }
  .actions > *, .actions .field, .actions button, .actions .primary { width: 100%; max-width: none; }
  .actions small { line-height: 1.6; }
  .steps { gap: 8px; margin: 18px 0 22px; padding-bottom: 5px; }
  .step { flex: 0 0 118px; min-width: 118px; padding: 10px 8px; font-size: 12px; }
  .choice, .scenario-card { width: 100%; min-height: 48px; padding: 14px; }
  .choice p, .scenario-card p { font-size: 14px; line-height: 1.65; }
  .checks { gap: 8px; }
  .checks label { min-height: 44px; padding: 10px; }
  .kv { table-layout: fixed; }
  .kv th, .kv td { padding: 11px 8px; font-size: 13px; }
  .kv th { width: 31%; }
  .shots { min-width: 620px; }
  .admin-table { min-width: 720px; }
  .asset-grid { grid-template-columns: 1fr; }
  .asset-actions { width: 100%; }
  .asset-actions button, .asset-download { min-height: 44px; flex: 1 1 auto; }
  .admin-modal { width: calc(100% - 20px); max-height: calc(100dvh - 34px); }
  .error-inline { grid-template-columns: 1fr; }
  .error-inline button { width: 100%; }

  /* Bottom nav is deliberately quiet; the active state carries the hierarchy. */
  .sidebar:not(.admin-nav) { height: calc(72px + env(safe-area-inset-bottom)); padding: 5px 4px calc(5px + env(safe-area-inset-bottom)); }
  .sidebar:not(.admin-nav) .nav { min-height: 54px; padding: 8px 3px; gap: 5px; font-size: 11px !important; line-height: 1.2; }
  .sidebar:not(.admin-nav) .nav svg { width: 20px; height: 20px; }
  .sidebar:not(.admin-nav) .nav.active { background: #f9e8df; color: #873924; box-shadow: inset 0 3px #c46e4e; }
  .sidebar.admin-nav { height: calc(66px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); }
  .sidebar.admin-nav .nav { min-height: 54px; padding: 14px 11px; }

  /* Home nav remains a compact header instead of becoming a second bottom bar. */
  .shell:has(.home-page) { padding-bottom: 0; }
  .shell:has(.home-page) .sidebar { position: relative; height: 68px; padding: 0 16px; }
  .shell:has(.home-page) .sidebar .nav[href="#create"] { min-height: 44px; }
  .shell:has(.home-page) .sidebar .nav[href="/account"] { min-height: 44px; }
  .shell:has(.home-page) .content { padding-bottom: 0; }
  .home-hero { padding: 38px 20px 52px; gap: 34px; }
  .home-hero h1 { max-width: 13ch; font-size: clamp(36px, 10vw, 49px); line-height: 1.2; }
  .home-lead { max-width: 34ch; font-size: 16px !important; line-height: 1.75 !important; }
  .home-actions { align-items: stretch; flex-direction: column; gap: 10px; }
  .home-primary { width: 100%; }
  .home-secondary { justify-content: center; min-height: 44px; }
  .home-storyboard { width: 100%; }
  .home-scene-caption strong, .home-scene-caption small { white-space: normal; }
  .home-process, .home-directions { padding: 46px 20px 52px; }
  .home-process li { min-height: 76px; }
  .home-direction-grid > a { min-height: 0; padding: 21px; }
  .home-case { margin-inline: 0; }
}

@media (max-width: 420px) {
  .content { padding-inline: 13px; }
  .panel { padding: 16px; }
  .topbar { padding-inline: 13px; }
  .topbar .workspace-crumb { max-width: 43%; }
  .topbar .header-links { max-width: 57%; }
  .industry-heading { padding-left: 11px; }
  .home-hero { padding-inline: 16px; }
  .home-process, .home-directions { padding-inline: 16px; }
  .home-scene-grid { gap: 6px; }
  .home-scene-caption { padding-inline: 6px; }
  .home-scene-caption strong { font-size: 11px; }
  .home-scene-caption small { font-size: 9px; }
  .field > span { font-size: 14px; }
  .skill-function { padding-inline: 10px; }
}

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