/* Creative OS · UI polish layer (2026-10-22)
   Loaded last on the main workbench. Visual only: no DOM, ids, events or
   business logic depend on this file. Remove the <link> to roll back.

   Goals
   - One UI typeface (HarmonyOS Sans subset already shipped in /assets).
   - Readable type scale: nothing interactive below 12px on desktop.
   - Calmer dark palette: lime reserved for primary action and current state.
   - Clear affordance on secondary buttons and upload slots.
   - Motion only on transform/opacity, all of it off under reduced motion.
*/

@font-face {
  font-family: "Creative UI";
  src: url("/assets/studio-harmony-regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Creative UI";
  src: url("/assets/studio-harmony-medium.woff2") format("woff2");
  font-weight: 500 800;
  font-style: normal;
  font-display: swap;
}

/* ---------- Tokens (both skins) ---------- */
:root {
  --font: "Creative UI", "PingFang SC", "Microsoft YaHei UI", "Source Han Sans SC", system-ui, sans-serif;
  --polish-ease: cubic-bezier(.2, .8, .2, 1);
  --polish-fast: .14s;
  --polish-mid: .22s;
  --polish-radius: 12px;
  --polish-radius-sm: 8px;
  --polish-focus: 0 0 0 2px var(--page), 0 0 0 4px rgba(61,61,61, .55);
}

html.creative-ui {
  --page: #0e1012;
  --surface: #16191c;
  --surface-strong: #1d2125;
  --surface-soft: #121518;
  --ink: #eef1f3;
  --ink-2: #ccd3d9;
  --muted: #9aa3ac;   /* 6.6:1 on --surface */
  --soft: #7d8690;
  --line: rgba(255, 255, 255, .075);
  --line-strong: rgba(255, 255, 255, .14);
  --accent: #c2f25b;
  --accent-ink: #18210a;
  --accent-wash: rgba(194, 242, 91, .09);
  --polish-hover: rgba(255, 255, 255, .055);
  --polish-focus: 0 0 0 2px var(--page), 0 0 0 4px rgba(194, 242, 91, .6);
}

html[data-ui-skin="light"] {
  --accent-ink: #fff;
  --accent-wash: rgba(61,61,61, .08);
  --polish-hover: rgba(26,26,26, .045);
}

/* ---------- Typography ---------- */
html, body, button, input, textarea, select { font-family: var(--font); }
body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: "tnum" 0;
}
input[type="number"], .zoom-readout, [class*="count"] input, time { font-variant-numeric: tabular-nums; }

html.creative-ui body { font-size: 13px; line-height: 1.55; }
html.creative-ui button { font-weight: 560; }
html.creative-ui label { font-size: 12px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
html.creative-ui select, html.creative-ui input, html.creative-ui textarea { font-size: 13px; }
html.creative-ui textarea { line-height: 1.65; }
html.creative-ui .head h3 { font-weight: 600; letter-spacing: -.01em; }
html.creative-ui .head p { font-size: 12px; color: var(--muted); }
html.creative-ui .chip { font-size: 12px; }
html.creative-ui .card-title strong { font-size: 14px; font-weight: 600; color: var(--ink); }
html.creative-ui .agent-message-body { font-size: 14px; line-height: 1.7; }
html.creative-ui .agent-tool > span { font-size: 11px; }
html.creative-ui .agent-tool input { font-size: 12px; }
html.creative-ui .action-chip { font-size: 12px; border-radius: 999px; }
html.creative-ui .action-reference-head strong { font-size: 12px; font-weight: 600; }
html.creative-ui .action-chip:not(.active):hover { color: var(--ink); background: var(--polish-hover); }
html.creative-ui .empty-result { font-size: 13px; line-height: 1.7; color: var(--muted); }

/* ---------- Focus (both skins) ---------- */
:is(button, a, [role="button"], input, select, textarea, summary):focus-visible {
  outline: none !important;
  box-shadow: var(--polish-focus) !important;
}

/* ---------- Side navigation ---------- */
html.creative-ui .side { background: #0a0c0e; border-right-color: var(--line); }
html.creative-ui .nav button {
  position: relative;
  color: var(--muted);
  border-radius: 10px;
  transition: color var(--polish-fast) ease, background-color var(--polish-fast) ease;
}
html.creative-ui .nav button:hover { color: var(--ink); background: var(--polish-hover); transform: none; }
html.creative-ui .nav button.active { color: var(--ink); background: var(--surface-strong); }
html.creative-ui .nav button.active .nav-icon { color: var(--accent); }
html.creative-ui .nav button::before {
  content: "";
  position: absolute;
  left: -10px;
  top: 50%;
  width: 3px;
  height: 22px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
  transform: translateY(-50%) scaleY(0);
  transition: transform var(--polish-mid) var(--polish-ease);
}
html.creative-ui .nav button.active::before { transform: translateY(-50%) scaleY(1); }
/* Desktop rail widened slightly so 12px labels ("Agent创作") fit without clipping. */
@media (min-width: 761px) {
  html.creative-ui .app { grid-template-columns: 120px minmax(0, 1fr); }
  html.creative-ui:not(.mobile-screen) .nav button {
    width: 102px;
    grid-template-columns: 20px minmax(0, 1fr);
    justify-items: start;
    column-gap: 8px;
    padding: 5px 6px 4px 8px;
  }
}
html.creative-ui .nav b { font-size: 12px; font-weight: 500; letter-spacing: 0; white-space: nowrap; }
html.creative-ui .nav button.active b { font-weight: 600; }

/* ---------- Top bar ---------- */
html.creative-ui .topbar { border-bottom: 1px solid var(--line); background: var(--page); }
html.creative-ui .topbar .title h2 { font-size: 16px; font-weight: 600; letter-spacing: 0; }
html.creative-ui .topbar .status { gap: 6px; }
html.creative-ui .topbar .status > .chip,
html.creative-ui #feedbackTrigger {
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  color: var(--ink-2);
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--line);
  font-size: 12px;
  font-weight: 500;
  transition: background-color var(--polish-fast) ease, color var(--polish-fast) ease;
}
html.creative-ui .topbar .status > .chip:hover,
html.creative-ui #feedbackTrigger:hover { color: var(--ink); background: var(--polish-hover); transform: none; }
html.creative-ui #themeToggleBtn b { font-size: 12px; font-weight: 500; }
html.creative-ui #licenseStatusPill { color: var(--muted); max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
html.creative-ui #licenseLogoutBtn::before { display: none; }
html.creative-ui #licenseLogoutBtn:hover { color: var(--danger); }
html.creative-ui .announcement-trigger { border-radius: 999px; }

/* ---------- Surfaces ---------- */
html.creative-ui .card {
  border-radius: var(--polish-radius);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
}
html.creative-ui .card-title { min-height: 48px; padding: 0 14px 0 16px; border-bottom: 1px solid var(--line); background: transparent; }

/* Secondary text buttons inside card headers gain a visible hit area. */
html.creative-ui .card-title .quick-row { gap: 4px; }
html.creative-ui .card-title .quick-row .btn,
html.creative-ui .quick-row#quickPrompts .btn {
  min-height: 30px;
  padding: 0 10px;
  border-radius: var(--polish-radius-sm);
  color: var(--ink-2);
  background: transparent;
  font-size: 12px;
  font-weight: 500;
  transition: background-color var(--polish-fast) ease, color var(--polish-fast) ease;
}
html.creative-ui .quick-row#quickPrompts .btn { box-shadow: inset 0 0 0 1px var(--line); }
html.creative-ui .card-title .quick-row .btn:hover,
html.creative-ui .quick-row#quickPrompts .btn:hover { color: var(--ink); background: var(--polish-hover); transform: none; }

/* Buttons */
html.creative-ui .btn { font-size: 13px; font-weight: 500; }
html.creative-ui .btn:hover { transform: none; }
html.creative-ui .btn.primary { color: var(--accent-ink); background: var(--accent); font-weight: 600; letter-spacing: .01em; }
html.creative-ui .btn.primary:hover { background: #d0f877; }
:is(.btn, .chip, .action-chip, .count-step, .nav button):active { transform: scale(.97); transition-duration: .06s; }

/* Form controls */
html.creative-ui select,
html.creative-ui input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
html.creative-ui textarea {
  border-radius: var(--polish-radius-sm);
  transition: box-shadow var(--polish-fast) ease, background-color var(--polish-fast) ease;
}
html.creative-ui textarea::placeholder,
html.creative-ui input::placeholder { color: var(--soft); }

/* Upload slots: dashed edge says "drop here"; solid lime on hover/drag. */
html.creative-ui .slot { background: transparent; box-shadow: none; padding: 0; }
html.creative-ui .slot b { font-size: 12px; font-weight: 500; color: var(--muted); }
/* !important is needed to beat creative-user-ui.css, which zeroes slot borders with !important. */
html.creative-ui .view :is(.slot, .batch-upload-item) .drop:not(.has-image) {
  border: 1px dashed var(--line-strong) !important;
  border-radius: 10px;
  background: var(--surface-soft) !important;
  color: var(--muted);
  font-size: 12px;
  transition: border-color var(--polish-fast) ease, background-color var(--polish-fast) ease, color var(--polish-fast) ease;
}
html.creative-ui .view :is(.slot, .batch-upload-item) .drop:not(.has-image):is(:hover, :focus-visible, .is-dragover) {
  border-color: rgba(194, 242, 91, .55) !important;
  border-style: solid !important;
  background: var(--accent-wash) !important;
  color: var(--ink);
}

/* Agent chat */
html.creative-ui .bubble .agent-message-shell { border-radius: 14px; background: var(--surface-strong); }
html.creative-ui .agent-composer { border-radius: 16px; box-shadow: inset 0 0 0 1px var(--line); background: var(--surface); }
html.creative-ui .agent-composer:focus-within { box-shadow: inset 0 0 0 1px rgba(194, 242, 91, .35); }

/* Footer */
html.creative-ui .app-legal-footer { color: var(--soft); font-size: 11px; }

/* ---------- Motion ---------- */
@keyframes polish-view-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes polish-sheet-in { from { opacity: 0; transform: translateY(10px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes polish-drawer-in { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
@keyframes polish-fade-in { from { opacity: 0; } to { opacity: 1; } }

html.creative-ui .view.active,
html[data-ui-skin="light"] .view.active { animation: polish-view-in var(--polish-mid) var(--polish-ease) both; }
.view[data-view="infinite"].active { animation: polish-fade-in var(--polish-mid) ease both; }
.popover.show .popover-card { animation: polish-sheet-in var(--polish-mid) var(--polish-ease) both; }
.popover.show { animation: polish-fade-in var(--polish-fast) ease both; }
.announcement-drawer:not([hidden]),
.feedback-panel:not([hidden]) { animation: polish-drawer-in var(--polish-mid) var(--polish-ease) both; }
.announcement-backdrop:not([hidden]),
.feedback-backdrop:not([hidden]) { animation: polish-fade-in var(--polish-fast) ease both; }
[popover]:popover-open { animation: polish-sheet-in var(--polish-fast) var(--polish-ease) both; }

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

/* ---------- Phones, iOS Safari, home-screen app ---------- */
@media (max-width: 760px), (max-width: 960px) and (max-height: 500px) {
  /* License pill was centred inside a clipped box, cutting the start of the text. */
  html.mobile-screen[data-ui-skin] #licenseStatusPill {
    display: block;
    max-width: 112px;
    padding: 0 10px;
    line-height: 32px;
    text-align: left;
    direction: ltr;
  }
  html.mobile-screen[data-ui-skin] .topbar { padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(10px, env(safe-area-inset-right)); }
  html.mobile-screen[data-ui-skin] .topbar h2 { font-size: 17px; font-weight: 600; }

  /* Bottom tab bar: clearer current tab, calmer idle tabs. */
  html.mobile-screen[data-ui-skin] .nav button::before { display: none; }
  html.mobile-screen[data-ui-skin] .nav button { color: var(--muted); border-radius: 12px; }
  html.mobile-screen[data-ui-skin] .nav button.active { color: var(--accent); background: var(--accent-wash); }
  html.mobile-screen[data-ui-skin] .nav b { font-size: 11px; }

  /* Quick-prompt buttons read as tappable chips instead of floating text. */
  html.mobile-screen[data-ui-skin] .quick-row#quickPrompts { display: flex; flex-wrap: wrap; gap: 8px; }
  html.mobile-screen[data-ui-skin] .quick-row#quickPrompts .btn {
    flex: 1 1 calc(50% - 4px);
    min-height: 44px;
    box-shadow: inset 0 0 0 1px var(--line-strong);
    background: var(--surface-soft);
    font-size: 14px;
  }
  html.mobile-screen[data-ui-skin] .card-title .quick-row .btn { min-height: 44px; font-size: 13px; }
  html.mobile-screen[data-ui-skin] .card-title strong { font-size: 15px; }
  html.mobile-screen[data-ui-skin] label { font-size: 13px; }
  html.mobile-screen[data-ui-skin] .drop { font-size: 14px; }

  /* Keep the composer above the home indicator and soft keyboard. */
  html.mobile-screen[data-ui-skin] .composer { margin-bottom: max(8px, calc(env(safe-area-inset-bottom) * .25)); }
}

@media (display-mode: standalone) {
  html.mobile-screen[data-ui-skin] .topbar { padding-top: 0; }
}

/* Light skin: share the type scale and the quieter hover behaviour. */
html[data-ui-skin="light"] button:hover { transform: none; }
html[data-ui-skin="light"] .nav b { font-size: 12px; }
html[data-ui-skin="light"] .drop { border-style: dashed; }
html[data-ui-skin="light"] .drop:hover { border-color: rgba(61,61,61, .45); background: var(--accent-wash); }
