
  /* iOS system palette. Light is the default appearance; the dark block below
     mirrors what UIKit swaps in, so the page follows the OS setting. */
  :root {
    --bg: #f2f2f7;
    --bg-elevated: #ffffff;
    --surface: #ffffff;
    --surface-2: rgba(118, 118, 128, .12);
    --surface-3: rgba(118, 118, 128, .2);
    --line: rgba(60, 60, 67, .29);
    --line-strong: rgba(60, 60, 67, .36);
    --text: #000000;
    --muted: rgba(60, 60, 67, .6);
    --muted-2: rgba(60, 60, 67, .3);
    --accent: #007aff;
    --accent-strong: #0062cc;
    --accent-ink: #ffffff;
    --accent-soft: rgba(0, 122, 255, .1);
    --blue: #007aff;
    --ok: #248a3d;
    --err: #d70015;
    --warn: #b25000;
    --radius: 16px;
    --radius-sm: 10px;
    --radius-pill: 980px;
    --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 8px 24px rgba(0, 0, 0, .06);
    --nav-bg: rgba(249, 249, 249, .82);
    --segment-active: #ffffff;
    --scrim: rgba(0, 0, 0, .4);
    /* Matches the deceleration curve UIKit uses for presentations. */
    --ease: cubic-bezier(.32, .72, 0, 1);
  }
  @media (prefers-color-scheme: dark) {
    :root {
      --bg: #000000;
      --bg-elevated: #1c1c1e;
      --surface: #1c1c1e;
      --surface-2: rgba(118, 118, 128, .24);
      --surface-3: rgba(118, 118, 128, .36);
      --line: rgba(84, 84, 88, .65);
      --line-strong: rgba(84, 84, 88, .8);
      --text: #ffffff;
      --muted: rgba(235, 235, 245, .6);
      --muted-2: rgba(235, 235, 245, .3);
      --accent: #0a84ff;
      --accent-strong: #409cff;
      --accent-soft: rgba(10, 132, 255, .18);
      --blue: #0a84ff;
      --ok: #30d158;
      --err: #ff453a;
      --warn: #ff9f0a;
      --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 8px 24px rgba(0, 0, 0, .35);
      --nav-bg: rgba(30, 30, 32, .78);
      /* UIKit lifts the selected segment to a lighter grey in dark mode. */
      --segment-active: #636366;
      --scrim: rgba(0, 0, 0, .6);
    }
  }

  * { box-sizing: border-box; }
  html {
    color-scheme: light dark;
    -webkit-text-size-adjust: 100%;
  }
  body {
    margin: 0;
    min-width: 320px;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
      "PingFang SC", "Helvetica Neue", Helvetica, Arial, "Microsoft YaHei", sans-serif;
    font-size: 16px;
    line-height: 1.47;
    letter-spacing: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-tap-highlight-color: transparent;
  }
  button, input, textarea, select { font: inherit; letter-spacing: 0; }
  button { cursor: pointer; }
  /* iOS focuses with a tinted halo rather than a hard outline. */
  /* 按钮和链接的浅色光晕在白底上几乎看不见，键盘用户需要清晰的实线焦点框。 */
  button:focus-visible, a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }
  input:focus-visible, textarea:focus-visible, select:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px var(--accent-soft);
  }
  .hidden { display: none !important; }
  .muted { color: var(--muted); }

  .brand { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
  .brand-mark {
    display: block;
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    border: 0;
    border-radius: 8px;
    object-fit: cover;
    background: #000;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .18);
  }
  .brand-copy { min-width: 0; }
  .brand-name { display: block; color: var(--text); font-size: 15px; font-weight: 600; line-height: 1.2; }
  .brand-sub { display: block; margin-top: 1px; color: var(--muted); font-size: 11px; line-height: 1.2; }

  /* Authentication */
  .auth-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(400px, .78fr);
    min-height: 100vh;
  }
  .auth-context {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-width: 0;
    padding: 34px clamp(28px, 6vw, 84px) 40px;
    overflow-x: hidden;
    overflow-y: auto;
    background: linear-gradient(190deg, #0a84ff 0%, #0a5fe0 46%, #003ea8 100%);
    color: #ffffff;
  }
  /* Soft light bloom, the way iOS marketing surfaces layer gradients. */
  .auth-context::after {
    content: "";
    position: absolute;
    inset: -30% -20% auto -30%;
    height: 70%;
    background: radial-gradient(60% 60% at 30% 20%, rgba(255, 255, 255, .34), transparent 70%);
    pointer-events: none;
  }
  .auth-context > * { position: relative; z-index: 1; }
  .auth-context .brand-name { color: #ffffff; }
  .auth-context .brand-sub { color: rgba(255, 255, 255, .68); }
  .auth-context .brand-mark { background: #000; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); }
  .auth-intro { width: min(620px, 100%); margin: auto 0; padding: 36px 0; }
  .eyebrow {
    display: inline-flex;
    align-items: center;
    padding: 5px 12px;
    margin-bottom: 20px;
    border-radius: var(--radius-pill);
    background: rgba(255, 255, 255, .2);
    color: #ffffff;
    font-size: 13px;
    font-weight: 590;
  }
  .auth-intro h1 {
    max-width: 560px;
    margin: 0;
    font-size: 46px;
    line-height: 1.08;
    font-weight: 700;
    letter-spacing: -.02em;
  }
  .auth-intro > p { max-width: 520px; margin: 18px 0 0; color: rgba(255, 255, 255, .82); font-size: 17px; }
  .product-points { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 24px; }
  .landing-price {
    margin-top: 22px;
    padding: 14px 16px 16px;
    border-radius: 18px;
    background: rgba(0, 0, 0, .18);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .16);
    backdrop-filter: blur(12px);
  }
  .landing-price-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
  }
  .landing-price-kicker {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: #ffe14a;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .06em;
  }
  .landing-price-note { color: rgba(255, 241, 176, .82); font-size: 12px; }
  .landing-price-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }
  .landing-price-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .landing-price-item {
    min-width: 0;
    padding: 12px 14px;
    border-radius: 12px;
    background: rgba(255, 255, 255, .12);
  }
  .landing-price-item.hot {
    background: linear-gradient(180deg, rgba(255, 196, 0, .32), rgba(255, 255, 255, .12));
    box-shadow: inset 0 0 0 1px rgba(255, 214, 10, .6);
  }
  .landing-price-item .name {
    display: flex;
    align-items: center;
    gap: 6px;
    color: rgba(255, 255, 255, .72);
    font-size: 12px;
    font-weight: 590;
  }
  .landing-price-item .name em {
    padding: 1px 6px;
    border-radius: 999px;
    background: #ffffff;
    color: #0a5fe0;
    font-size: 10px;
    font-style: normal;
    font-weight: 700;
  }
  .landing-price-item .value {
    display: block;
    margin-top: 6px;
    color: #ffe14a;
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -.04em;
    line-height: 1.1;
    text-shadow: 0 2px 0 rgba(0, 40, 120, .18), 0 0 18px rgba(255, 210, 0, .45);
  }
  .landing-price-item.hot .value { color: #ffd60a; }
  .landing-price-item .hint {
    display: block;
    margin-top: 4px;
    color: rgba(255, 241, 176, .86);
    font-size: 12px;
    line-height: 1.4;
  }
  .landing-price-models {
    margin: 12px 0 0;
    color: rgba(255, 255, 255, .72);
    font-size: 13px;
    line-height: 1.5;
  }
  .docs-cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    margin-top: 22px;
    padding: 0 20px;
    border-radius: 12px;
    background: #ffffff;
    color: #0a5fe0;
    font-size: 16px;
    font-weight: 640;
    text-decoration: none;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
  }
  .docs-cta:hover { background: #f2f2f7; }
  .docs-cta:active { transform: scale(.97); opacity: .92; }
  .auth-foot a { color: #ffffff; font-weight: 590; text-decoration: none; }
  .product-point {
    min-width: 0;
    padding: 14px 16px;
    border-radius: 14px;
    background: rgba(255, 255, 255, .14);
    backdrop-filter: blur(8px);
  }
  .product-point b { display: block; margin-bottom: 3px; color: #ffffff; font-size: 15px; font-weight: 600; }
  .product-point span { display: block; color: rgba(255, 255, 255, .72); font-size: 13px; }
  .auth-foot { display: flex; align-items: center; justify-content: space-between; gap: 18px; color: rgba(255, 255, 255, .66); font-size: 13px; }
  .service-state { display: inline-flex; align-items: center; gap: 7px; }
  .state-dot { width: 8px; height: 8px; border-radius: 50%; background: #30d158; box-shadow: 0 0 0 4px rgba(48, 209, 88, .22); }

  .auth-side { display: grid; place-items: center; min-width: 0; padding: 32px; background: var(--bg); }
  .auth-panel { width: min(430px, 100%); }
  .auth-panel-head { margin-bottom: 22px; text-align: center; }
  .auth-panel-head h2 { margin: 0 0 6px; font-size: 28px; line-height: 1.2; font-weight: 700; letter-spacing: -.02em; }
  .auth-panel-head p { margin: 0; color: var(--muted); font-size: 15px; }
  /* UISegmentedControl */
  .auth-tabs, .view-tabs {
    display: inline-flex;
    gap: 2px;
    padding: 2px;
    border: 0;
    border-radius: 9px;
    background: var(--surface-2);
  }
  .auth-tabs { width: 100%; margin-bottom: 20px; }
  .auth-tab, .view-tab {
    min-height: 32px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--text);
    font-size: 14px;
    font-weight: 510;
    transition: background .2s var(--ease), color .2s var(--ease), transform .12s var(--ease);
  }
  .auth-tab { flex: 1; }
  a.view-tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--text);
    box-sizing: border-box;
  }
  a.view-tab-docs { color: var(--accent); font-weight: 620; }
  .auth-tab:active, .view-tab:active { transform: scale(.96); }
  .auth-tab.active, .view-tab.active {
    background: var(--segment-active);
    color: var(--text);
    font-weight: 590;
    box-shadow: 0 3px 8px rgba(0, 0, 0, .12), 0 3px 1px rgba(0, 0, 0, .04);
  }
  .field { margin-bottom: 14px; }
  .field label, .section-label { display: block; margin-bottom: 7px; color: var(--muted); font-size: 13px; font-weight: 510; }
  .input-wrap { position: relative; }
  /* Filled fields, no visible stroke until focus. */
  input, textarea {
    width: 100%;
    border: 0;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text);
    transition: box-shadow .18s var(--ease), background .18s var(--ease);
  }
  input { min-height: 46px; padding: 11px 14px; }
  textarea { display: block; min-height: 150px; padding: 14px; line-height: 1.55; resize: vertical; }
  input::placeholder, textarea::placeholder { color: var(--muted-2); }
  input:focus, textarea:focus {
    outline: none;
    background: var(--bg-elevated);
    box-shadow: 0 0 0 1.5px var(--accent), 0 0 0 5px var(--accent-soft);
  }
  .password-input { padding-right: 68px; }
  .reg-mode-tabs { margin-bottom: 16px; }
  .code-input { padding-right: 112px; letter-spacing: 4px; font-variant-numeric: tabular-nums; }
  .code-btn {
    min-width: 96px;
    border: 0;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 14px;
    font-weight: 590;
  }
  .code-btn:disabled { opacity: .4; cursor: not-allowed; }
  .field-hint { margin: 7px 2px 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
  .link-row { display: flex; justify-content: center; margin-top: 14px; }
  .link-btn {
    padding: 0;
    border: 0;
    background: none;
    color: var(--accent);
    font-size: 15px;
    cursor: pointer;
  }
  .link-btn:active { opacity: .5; }
  .password-toggle {
    position: absolute;
    top: 6px;
    right: 6px;
    min-height: 34px;
    padding: 0 12px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--accent);
    font-size: 14px;
    font-weight: 510;
  }
  .password-toggle:active { opacity: .5; }
  .primary-btn, .secondary-btn, .ghost-btn {
    min-height: 46px;
    border-radius: 12px;
    padding: 0 18px;
    font-size: 16px;
    font-weight: 590;
    transition: background .18s var(--ease), color .18s var(--ease), transform .12s var(--ease), opacity .18s var(--ease);
  }
  .primary-btn { border: 0; background: var(--accent); color: var(--accent-ink); }
  .primary-btn:hover:not(:disabled) { background: var(--accent-strong); }
  /* Tap feedback: iOS shrinks and dims rather than lifting. */
  .primary-btn:active:not(:disabled) { transform: scale(.97); opacity: .88; }
  .secondary-btn { border: 0; background: var(--accent-soft); color: var(--accent); }
  .secondary-btn:active:not(:disabled) { transform: scale(.97); opacity: .7; }
  .ghost-btn { border: 0; background: transparent; color: var(--accent); }
  .ghost-btn:active:not(:disabled) { opacity: .5; }
  button:disabled { opacity: .38; cursor: not-allowed; transform: none !important; }
  .auth-submit { width: 100%; margin-top: 6px; }
  .auth-docs-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    margin-top: 10px;
    text-decoration: none;
  }
  .status { min-height: 20px; margin-top: 10px; color: var(--muted); font-size: 13px; }
  .status.ok { color: var(--ok); }
  .status.err { color: var(--err); }
  .auth-note { margin: 18px 0 0; color: var(--muted); font-size: 13px; text-align: center; }
  .auth-note a { color: var(--accent); text-decoration: none; }

  /* SaaS shell */
  .app-shell { min-height: 100vh; }
  /* Translucent UINavigationBar. */
  .topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    min-height: 52px;
    padding: 0 clamp(16px, 4vw, 48px);
    padding-top: env(safe-area-inset-top);
    border-bottom: .5px solid var(--line);
    background: var(--nav-bg);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
  }
  .topbar-actions { display: flex; align-items: center; gap: 8px; min-width: 0; flex-shrink: 0; }
  .credit-chip {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    min-height: 30px;
    padding: 4px 12px;
    border: 0;
    border-radius: var(--radius-pill);
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 12px;
    font-weight: 510;
    white-space: nowrap;
  }
  .credit-chip b { font-size: 15px; font-weight: 640; font-variant-numeric: tabular-nums; }
  .topup-btn {
    display: inline-flex; align-items: center; justify-content: center; min-height: 30px;
    padding: 0 12px; border: 0; border-radius: var(--radius-pill);
    background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 620;
    text-decoration: none; white-space: nowrap; cursor: pointer;
  }
  .topup-btn:hover { background: var(--accent-strong); }
  .topup-btn:active { opacity: .88; }
  .wechat-chip {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    min-height: 30px;
    padding: 4px 12px;
    border: 0;
    border-radius: var(--radius-pill);
    background: var(--surface-2);
    color: var(--text);
    font-size: 12px;
    font-weight: 510;
    white-space: nowrap;
    cursor: pointer;
  }
  .wechat-chip b { font-size: 13px; font-weight: 640; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
  .wechat-chip.hidden { display: none; }
  .wechat-group-link { margin-left: 10px; color: var(--accent); font: inherit; font-weight: 620; background: none; border: 0; cursor: pointer; padding: 0; }
  .wechat-group-chip { display: inline-flex; align-items: center; justify-content: center; min-height: 30px; padding: 0 12px; border: 0; border-radius: var(--radius-pill); background: var(--surface-2); color: var(--text); font-size: 12px; font-weight: 560; white-space: nowrap; cursor: pointer; }
  .wechat-group-chip:hover { background: var(--accent-soft); color: var(--accent); }
  .wechat-group-chip.hidden { display: none; }
  .auth-wechat { margin: 14px 0 0; color: var(--muted); font-size: 13px; text-align: center; }
  .auth-wechat.hidden { display: none; }
  .auth-wechat button { color: var(--accent); font: inherit; font-weight: 640; background: none; border: 0; cursor: pointer; padding: 0; }
  .docs-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 30px;
    padding: 0 12px;
    border-radius: var(--radius-pill);
    background: var(--accent);
    color: var(--accent-ink);
    font-size: 13px;
    font-weight: 620;
    text-decoration: none;
    white-space: nowrap;
  }
  .docs-btn:hover { background: var(--accent-strong); }
  .docs-btn:active { opacity: .88; }
  .topbar .ghost-btn { min-height: 32px; padding: 0 10px; font-size: 14px; }

  /* API key management */
  .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
  .key-actions { display: flex; flex-wrap: wrap; gap: 6px; }
  .key-note { display: inline-block; margin-top: 4px; color: var(--muted); font: 11px/1.4 system-ui, sans-serif; }
  .new-key {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
  }
  .new-key code {
    flex: 1;
    min-width: 0;
    overflow-wrap: anywhere;
    color: var(--text);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
  }
  .code-snippet {
    margin: 10px 0;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    line-height: 1.6;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
  }
  .side-panel a, .redeem-panel a { color: var(--accent); text-decoration: none; }

  .workspace {
    width: min(1180px, calc(100% - 36px));
    margin: 0 auto;
    padding: 26px 0 calc(64px + env(safe-area-inset-bottom));
  }
  /* iOS Large Title. */
  .workspace-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 20px; }
  .workspace-heading h1 { margin: 0 0 4px; font-size: 34px; line-height: 1.12; font-weight: 700; letter-spacing: -.022em; }
  .workspace-heading p { margin: 0; color: var(--muted); font-size: 15px; }
  .workspace-heading-actions { display: flex; align-items: center; gap: 12px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
  .workspace-meta { color: var(--muted); font-size: 13px; white-space: nowrap; }
  .view-tabs { margin-bottom: 18px; }
  .view-tab { min-width: 104px; padding: 0 16px; }

  .workspace-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
  /* Inset grouped cards. */
  .tool-panel, .side-panel, .table-panel, .redeem-panel {
    border: 0;
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
  }
  .tool-panel { min-width: 0; padding: 22px; }
  .panel-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
  .panel-head h2 { margin: 0; font-size: 20px; font-weight: 640; letter-spacing: -.01em; }
  .panel-head span { color: var(--muted); font-size: 13px; }
  .prompt-presets { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
  .reference-panel { display: flex; align-items: center; gap: 12px; margin-top: 14px; padding: 12px; border: 0; border-radius: 12px; background: var(--surface-2); }
  .reference-picker { display: inline-flex; align-items: center; justify-content: center; min-height: 34px; padding: 0 14px; border: 0; border-radius: 9px; background: var(--accent-soft); color: var(--accent); cursor: pointer; font-size: 14px; font-weight: 510; }
  .reference-picker:active { opacity: .6; }
  .reference-meta { min-width: 0; flex: 1; color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .reference-panel { flex-wrap: wrap; }
  .reference-preview { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 10px; min-width: 0; flex: 0 1 auto; }
  .reference-item {
    position: relative; display: grid; grid-template-columns: 72px minmax(0, 1fr); align-items: center; gap: 8px;
    width: min(100%, 300px); min-height: 84px; padding: 6px 28px 6px 6px;
    border-radius: 10px; background: var(--surface);
  }
  .reference-item img { display: block; width: 72px; height: 72px; border-radius: 9px; border: 0; object-fit: cover; cursor: zoom-in; }
  .reference-name { min-width: 0; color: var(--text); font-size: 12px; line-height: 1.35; overflow-wrap: anywhere; }
  /* Delete badge hangs off the corner, the way iOS edit mode marks removable items. */
  .reference-clear {
    position: absolute;
    top: 4px;
    right: 4px;
    display: grid;
    place-items: center;
    width: 20px;
    height: 20px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(120, 120, 128, .82);
    color: #fff;
    font-size: 13px;
    line-height: 1;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
  }
  .reference-clear:active { background: var(--err); transform: scale(.9); }
  .reference-loading { position: absolute; left: 6px; top: 6px; display: inline-flex; align-items: center; gap: 4px; min-height: 22px; padding: 0 6px; border-radius: 999px; background: rgba(0, 0, 0, .62); color: #fff; font-size: 11px; line-height: 1; }
  .reference-loading i { display: block; width: 11px; height: 11px; border: 1.5px solid rgba(255,255,255,.45); border-top-color: #fff; border-radius: 50%; animation: reference-spin .8s linear infinite; }
  .reference-loading b { font-weight: 600; font-variant-numeric: tabular-nums; }
  .reference-loading.reference-error { background: rgba(190, 0, 20, .82); }
  .reference-loading.reference-error i { display: none; }
  @keyframes reference-spin { to { transform: rotate(360deg); } }
  .prompt-chip {
    min-height: 32px;
    padding: 0 14px;
    border: 0;
    border-radius: var(--radius-pill);
    background: var(--surface-2);
    color: var(--text);
    font-size: 14px;
    transition: background .18s var(--ease), transform .12s var(--ease);
  }
  .prompt-chip:active { background: var(--surface-3); transform: scale(.96); }
  .settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 22px; }
  .option-group { min-width: 0; }
  /* The resolution row reads as one segmented strip across the full width. */
  .option-group:last-child { grid-column: 1 / -1; }
  .pills { display: grid; gap: 8px; }
  #models { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  #ratios { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  #resolutions { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  #resolutions.single { grid-template-columns: minmax(0, 1fr); }
  #outputCounts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  #deliveries { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .pill {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-width: 0;
    min-height: 44px;
    padding: 7px 10px;
    border: 0;
    border-radius: 11px;
    background: var(--surface-2);
    color: var(--text);
    font-size: 14px;
    transition: background .18s var(--ease), color .18s var(--ease), transform .12s var(--ease);
  }
  .pill:active { transform: scale(.96); }
  .pill.active { background: var(--accent); color: var(--accent-ink); font-weight: 590; }
  .pill small { color: var(--muted); font-size: 12px; }
  .pill.active small { color: rgba(255, 255, 255, .78); }
  .shape { display: inline-block; flex: 0 0 auto; border: 1.5px solid currentColor; border-radius: 3px; opacity: .75; }
  .tool-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 22px; padding-top: 18px; border-top: .5px solid var(--line); }
  .tool-actions-copy { min-width: 0; }
  .tool-actions-copy strong { display: block; margin-bottom: 1px; font-size: 15px; font-weight: 590; }
  .tool-actions-copy span { display: block; color: var(--muted); font-size: 13px; }
  .generate-btn { min-width: 180px; }

  .side-panel { padding: 6px 18px; box-shadow: var(--shadow); }
  .side-panel h2 { margin: 14px 0 8px; font-size: 17px; font-weight: 640; }
  .summary-list { margin: 0; }
  /* Grouped list rows: hairline inset separators, none on the last row. */
  .summary-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 44px; padding: 10px 0; border-bottom: .5px solid var(--line); }
  .summary-row:last-child { border-bottom: 0; }
  .summary-row dt { color: var(--text); font-size: 15px; }
  .summary-row dd { margin: 0; color: var(--muted); font-size: 15px; text-align: right; font-variant-numeric: tabular-nums; }
  .summary-row dd.accent { color: var(--accent); font-size: 17px; font-weight: 590; }
  .side-note { margin: 0; padding: 14px 0 16px; border-top: .5px solid var(--line); color: var(--muted); font-size: 13px; }

  /* UIProgressView: thin capsule track with a tinted fill. */
  .progress { margin-top: 18px; }
  .progress-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
  .progress-head span:first-child { color: var(--text); font-size: 15px; font-weight: 510; }
  .progress-head span:last-child { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
  .progress-track { height: 6px; overflow: hidden; border-radius: var(--radius-pill); background: var(--surface-3); }
  .progress-fill {
    width: 0;
    height: 100%;
    border-radius: var(--radius-pill);
    background: var(--accent);
    transition: width .45s var(--ease);
  }
  .progress.done .progress-fill { background: var(--ok); }
  .progress.failed .progress-fill { background: var(--err); }

  .log {
    display: none;
    max-height: 220px;
    margin-top: 16px;
    overflow-y: auto;
    border: 0;
    border-radius: 12px;
    background: var(--surface-2);
    padding: 12px 14px;
    color: var(--muted);
    font-family: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
  }
  .log.show { display: block; }
  .log .line { padding: 3px 0; overflow-wrap: anywhere; }
  .log .line::before { content: "› "; color: var(--accent); }
  .spinner { display: inline-block; width: 13px; height: 13px; margin-right: 6px; border: 2px solid var(--surface-3); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -2px; }
  @keyframes spin { to { transform: rotate(360deg); } }

  .gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; margin-top: 16px; }
  .gallery > h3 { grid-column: 1 / -1; margin: 8px 0 0; font-size: 15px; font-weight: 650; }
  .hd4k-slot { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
  .image-card { margin: 0; overflow: hidden; border: 0; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
  .image-card.is-pending { min-height: 220px; display: grid; place-items: center; }
  .image-card img { display: block; width: 100%; height: auto; object-fit: contain; background: var(--surface-2); cursor: zoom-in; transition: transform .3s var(--ease); }
  .image-card img:hover { transform: scale(1.02); }
  .image-card figcaption { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; font-size: 13px; color: var(--muted); }
  .image-card a { color: var(--accent); font-size: 15px; text-decoration: none; }
  .image-card a:active { opacity: .5; }
  .image-card.is-image-error { min-height: 220px; display: grid; place-items: center; }
  .image-load-error { display: grid; gap: 6px; justify-items: center; padding: 28px 16px; color: var(--muted); text-align: center; }
  .image-load-error[hidden] { display: none !important; }
  .image-load-error strong { color: var(--text); font-size: 13px; font-weight: 600; }
  .image-load-error span { font-size: 12px; }
  .image-load-error button { min-height: 30px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--accent); cursor: pointer; }

  /* 生成时间线：每次提交一张卡片，新的插在最上面。卡片内部沿用
     .progress / .status / .log / .gallery 这几套现成样式，只补外壳。 */
  .gen-feed { display: grid; gap: 16px; margin-top: 16px; }
  .gen-card {
    min-width: 0;
    padding: 18px 20px 20px;
    border: 0;
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    animation: gen-card-in .32s var(--ease);
  }
  @keyframes gen-card-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
  .gen-card-head { display: flex; flex-direction: column; gap: 8px; }
  .gen-card-prompt {
    margin: 0;
    /* 提示词默认收起，避免长文本把任务卡撑满；点击后可查看全文。 */
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: var(--text);
    font-size: 15px;
    font-weight: 510;
    line-height: 1.5;
    overflow-wrap: anywhere;
  }
  .gen-card-prompt-wrap {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    width: fit-content;
    max-width: 78%;
    min-width: 0;
  }
  .gen-card-prompt.is-expanded {
    display: block;
    -webkit-line-clamp: unset;
    overflow: visible;
  }
  .gen-card-prompt-toggle {
    margin-top: 5px;
    padding: 0 2px;
    border: 0;
    background: transparent;
    color: var(--accent);
    font-size: 12px;
    line-height: 1.4;
    cursor: pointer;
  }
  .gen-card-prompt-toggle:hover { text-decoration: underline; }
  .gen-card-references {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    width: min(84%, 640px);
    margin: 12px auto 0 0;
  }
  .gen-card-references:empty { display: none; }
  .gen-card-reference {
    width: 76px;
    margin: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface-2);
  }
  .gen-card-reference img {
    display: block;
    width: 76px;
    height: 76px;
    object-fit: cover;
    cursor: zoom-in;
  }
  .gen-card-reference figcaption {
    padding: 3px 4px;
    color: var(--muted);
    font-size: 10px;
    line-height: 1.2;
    text-align: center;
  }
  .gen-card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
  .gen-chip {
    padding: 3px 9px;
    border-radius: var(--radius-pill);
    background: var(--surface-2);
    color: var(--muted);
    font-size: 12px;
    line-height: 1.5;
    white-space: nowrap;
  }
  .gen-card-time { margin-left: auto; color: var(--muted-2); font-size: 12px; font-variant-numeric: tabular-nums; }
  .gen-card .progress { margin-top: 14px; }
  .gen-card .status { margin-top: 10px; }
  .gen-card .log { margin-top: 10px; max-height: 160px; }
  .gen-card .gallery { margin-top: 14px; }
  .video-result { min-width: 0; margin: 0; overflow: hidden; border: 0; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
  .video-result video { display: block; width: 100%; max-height: min(68vh, 720px); aspect-ratio: 16 / 9; background: #000; object-fit: contain; }
  .video-result figcaption { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; color: var(--muted); font-size: 13px; }
  .video-result a { color: var(--accent); text-decoration: none; white-space: nowrap; }
  .video-result a:hover { text-decoration: underline; }
  .video-result-error { padding: 28px 16px; color: var(--muted); text-align: center; }
  .video-duration-notice { margin: 10px 0 0; max-width: 100%; white-space: normal; overflow-wrap: anywhere; font-size: 13px; line-height: 1.6; }
  .gen-log-toggle { min-height: 30px; margin-top: 6px; padding: 0; font-size: 13px; }
  .gen-busy { min-height: 20px; margin-top: 8px; color: var(--muted); font-size: 13px; }
  .gen-busy.is-busy { color: var(--accent); font-weight: 510; }
  /* 回填的历史卡片弱化一点，和本次会话新生成的区分开 */
  .gen-card.is-history { box-shadow: none; background: var(--surface-2); }
  .gen-card.is-history .gen-card-prompt { font-weight: 400; color: var(--muted); }
  .gen-card.is-history .image-card { box-shadow: 0 1px 2px rgba(0, 0, 0, .04); }

  /* Full-screen photo viewer with a blurred scrim. */
  .preview-modal {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    padding: 30px;
    background: rgba(0, 0, 0, .74);
    -webkit-backdrop-filter: blur(24px);
    backdrop-filter: blur(24px);
  }
  .preview-modal.hidden { display: none; }
  .preview-modal img { display: block; max-width: min(92vw, 1600px); max-height: 78vh; width: auto; height: auto; object-fit: contain; border: 0; border-radius: 14px; background: transparent; box-shadow: 0 30px 90px rgba(0, 0, 0, .55); }
  .preview-close { position: absolute; top: calc(18px + env(safe-area-inset-top)); right: 22px; display: grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: 50%; background: rgba(120, 120, 128, .5); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); color: #fff; font-size: 15px; line-height: 1; cursor: pointer; }
  .preview-close:active { transform: scale(.92); }
  .preview-caption { position: absolute; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); max-width: min(90vw, 760px); transform: translateX(-50%); color: rgba(255, 255, 255, .75); font-size: 13px; text-align: center; }
  .preview-actions { position: absolute; bottom: calc(18px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 14px; max-width: 92vw; padding: 8px 12px; border-radius: 12px; background: rgba(20, 20, 24, .84); }
  .preview-actions .preview-caption { position: static; transform: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .preview-download { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; min-height: 36px; padding: 0 14px; border-radius: 8px; background: var(--accent); color: #fff; font-size: 13px; font-weight: 600; text-decoration: none; }
  .preview-download[aria-busy="true"], .history-thumb-download[aria-busy="true"] { opacity: .65; cursor: progress; }
  .preview-download[aria-busy="true"]::after, .history-thumb-download[aria-busy="true"]::after { content: "…"; }
  body.preview-open { overflow: hidden; }

  /* Skill catalog */
  .skill-modal {
    position: fixed; inset: 0; z-index: 55; display: grid; place-items: center; padding: 22px;
    background: var(--scrim); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  }
  .skill-modal.hidden { display: none; }
  .skill-card { width: min(760px, 100%); max-height: min(760px, 90vh); overflow: auto; padding: 24px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
  .skill-modal-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 8px; }
  .skill-modal-head h3 { flex: 1; margin: 0; font-size: 21px; font-weight: 680; }
  .skill-modal-close { flex: 0 0 32px; width: 32px; height: 32px; border: 0; border-radius: 50%; background: var(--surface-2); color: var(--muted); cursor: pointer; font-size: 18px; line-height: 1; }
  .skill-intro { margin: 0 0 18px; color: var(--muted); font-size: 14px; line-height: 1.65; }
  .skill-list { display: grid; gap: 12px; }
  .skill-item { padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg-elevated); }
  .skill-item-head { display: flex; align-items: center; gap: 10px; }
  .skill-item-head h4 { flex: 1; margin: 0; font-size: 16px; font-weight: 640; }
  .skill-badge { padding: 3px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 11px; white-space: nowrap; }
  .skill-meta { margin: 6px 0 8px; color: var(--muted-2); font-size: 12px; }
  .skill-desc, .skill-readme { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; white-space: pre-line; }
  .skill-readme { margin-top: 8px; color: var(--muted-2); }
  .skill-item-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 13px; }
  .skill-empty { padding: 30px 12px; color: var(--muted); text-align: center; }
  body.skill-open { overflow: hidden; }

  /* Logged-in homepage announcements. */
  .announcement-modal {
    position: fixed; inset: 0; z-index: 58; display: grid; place-items: center; padding: 22px;
    background: var(--scrim); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  }
  .announcement-modal.hidden { display: none; }
  .announcement-card {
    width: min(560px, 100%); max-height: min(720px, 88vh); overflow: auto; padding: 26px;
    border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: var(--shadow);
  }
  .announcement-head { display: flex; align-items: flex-start; gap: 14px; }
  .announcement-head-copy { min-width: 0; flex: 1; }
  .announcement-kicker { display: block; margin-bottom: 7px; color: var(--accent); font-size: 12px; font-weight: 650; letter-spacing: .04em; }
  .announcement-head h3 { margin: 0; color: var(--text); font-size: 22px; line-height: 1.25; font-weight: 700; overflow-wrap: anywhere; }
  .announcement-time { display: block; margin-top: 7px; color: var(--muted-2); font-size: 12px; }
  .announcement-close { flex: 0 0 32px; width: 32px; height: 32px; border: 0; border-radius: 50%; background: var(--surface-2); color: var(--muted); cursor: pointer; font-size: 18px; line-height: 1; }
  .announcement-content { margin: 22px 0 0; color: var(--text); font-size: 15px; line-height: 1.75; white-space: pre-line; overflow-wrap: anywhere; }
  .announcement-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 24px; }
  .announcement-progress { min-height: 20px; color: var(--muted-2); font-size: 12px; }
  .announcement-actions { display: flex; justify-content: flex-end; gap: 8px; }
  .announcement-actions button { min-height: 40px; font-size: 14px; }
  body.announcement-open { overflow: hidden; }
  html[data-theme="dark"] .announcement-card { box-shadow: 0 22px 70px rgba(0, 0, 0, .42); }
  .wechat-group-modal { position: fixed; inset: 0; z-index: 59; display: grid; place-items: center; padding: 22px; background: var(--scrim); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
  .wechat-group-modal.hidden { display: none; }
  .wechat-group-card { width: min(390px, 100%); padding: 24px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: var(--shadow); text-align: center; }
  .wechat-group-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
  .wechat-group-head h3 { flex: 1; margin: 0; text-align: left; font-size: 20px; font-weight: 680; }
  .wechat-group-close { flex: 0 0 32px; width: 32px; height: 32px; border: 0; border-radius: 50%; background: var(--surface-2); color: var(--muted); font-size: 18px; line-height: 1; cursor: pointer; }
  .wechat-group-image-wrap { display: inline-flex; align-items: center; justify-content: center; min-width: 250px; min-height: 250px; padding: 10px; border-radius: 14px; background: #fff; }
  .wechat-group-image { display: block; width: min(300px, 72vw); height: auto; max-height: 60vh; object-fit: contain; }
  .wechat-group-hint { margin: 14px 0 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
  body.wechat-group-open { overflow: hidden; }

  .redeem-panel { width: 100%; padding: 22px; }
  .redeem-panel h2 { margin: 0 0 6px; font-size: 20px; font-weight: 640; letter-spacing: -.01em; }
  .redeem-panel > p { margin: 0 0 18px; color: var(--muted); font-size: 14px; }
  .inline-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
  .key-form { grid-template-columns: minmax(0, 1fr) 170px auto; }
  select {
    width: 100%;
    min-height: 46px;
    padding: 11px 14px;
    border: 0;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text);
    transition: box-shadow .18s var(--ease);
  }
  select:focus { outline: none; box-shadow: 0 0 0 1.5px var(--accent), 0 0 0 5px var(--accent-soft); }
  .payment-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
  .payment-panel { width: auto; min-width: 0; }
  .payment-form-grid { display: grid; grid-template-columns: minmax(0, 1fr) 190px; gap: 14px; }
  .payment-summary { display: flex; align-items: baseline; gap: 9px; margin: 6px 0 18px; padding: 14px 16px; border: 0; border-radius: 12px; background: var(--accent-soft); color: var(--muted); font-size: 14px; }
  .payment-summary b { color: var(--accent); font-size: 24px; font-weight: 640; font-variant-numeric: tabular-nums; }
  .payment-summary small { color: var(--muted); }
  .payment-note { margin: 14px 0 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
  .payment-side { min-width: 0; padding: 18px; }
  .payment-side h2 { margin: 0 0 10px; font-size: 17px; font-weight: 640; }
  .payment-side p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.6; }
  .payment-orders { margin-top: 16px; }
  .payment-orders table { min-width: 760px; }
  .payment-status { color: var(--warn); }
  .payment-status.paid { color: var(--ok); }
  .payment-status.failed { color: var(--err); }

  /* 扫码支付弹层 */
  .qr-modal {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: grid;
    place-items: center;
    padding: 24px;
    background: var(--scrim);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
  }
  .qr-card {
    width: min(360px, 100%);
    padding: 26px 24px;
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    text-align: center;
  }
  .qr-card h3 { margin: 0 0 4px; font-size: 19px; font-weight: 640; }
  .qr-card .qr-amount { margin: 0 0 18px; color: var(--muted); font-size: 14px; }
  .qr-card .qr-amount b { color: var(--accent); font-size: 22px; font-variant-numeric: tabular-nums; }
  .qr-image-wrap { position: relative; display: inline-block; border-radius: 12px; background: #fff; padding: 10px; }
  .qr-image-wrap img { display: block; width: 220px; height: 220px; }
  /* 过期后把码糊掉，避免用户对着一张失效的码一直扫 */
  .qr-image-wrap.expired img { filter: blur(4px) grayscale(1); opacity: .5; }
  .qr-expired-tip {
    position: absolute;
    inset: 0;
    display: none;
    place-items: center;
    color: var(--err);
    font-size: 14px;
    font-weight: 640;
  }
  .qr-image-wrap.expired .qr-expired-tip { display: grid; }
  .qr-hint { margin: 16px 0 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
  .qr-state { margin: 12px 0 0; min-height: 22px; font-size: 14px; font-weight: 560; }
  .qr-state.paid { color: var(--ok); }
  .qr-state.err { color: var(--err); }
  .qr-actions { display: flex; gap: 10px; margin-top: 18px; }
  .qr-actions button { flex: 1; }

  .history-stack { display: grid; gap: 16px; }
  .table-panel { min-width: 0; padding: 18px; }
  .table-panel h2 { margin: 0 0 14px; font-size: 20px; font-weight: 640; letter-spacing: -.01em; }
  .panel-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
  .panel-toolbar h2 { margin: 0; }
  .panel-toolbar-actions { display: flex; align-items: center; gap: 8px; }
  .panel-toolbar-actions select { width: auto; min-width: 160px; min-height: 38px; padding: 7px 12px; font-size: 14px; }
  .panel-toolbar-actions button { min-height: 38px; padding: 0 14px; }
  .call-summary { margin: 10px 0 10px; color: var(--muted); font-size: 14px; }
  .speed-summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 0 0 14px;
  }
  .speed-summary-label { color: var(--muted); font-size: 13px; }
  .speed-chip {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 999px;
    background: var(--surface-2);
    font-size: 13px;
  }
  .speed-chip.all { background: var(--accent-soft); }
  .speed-chip span { color: var(--muted); }
  .speed-chip b { font-weight: 640; }
  .speed-chip small { color: var(--muted); font-size: 12px; }
  .key-tag {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--muted);
    font-size: 13px;
    white-space: nowrap;
  }
  .key-tag.bound { background: rgba(0, 122, 255, .12); color: var(--accent); }
  .history-thumb-list { display: flex; flex-wrap: wrap; gap: 8px; min-width: 150px; }
  .history-thumb-item { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 68px; }
  .history-thumb-download { display: inline-flex; align-items: center; justify-content: center; min-height: 32px; width: 100%; border-radius: 7px; color: var(--accent); background: var(--accent-soft); font-size: 12px; font-weight: 600; text-decoration: none; }
  .history-thumb-download:hover { background: var(--surface-2); }
  .history-thumb { display: block; width: 68px; height: 68px; flex: 0 0 68px; border: 0; border-radius: 9px; object-fit: cover; background: var(--surface-2); cursor: zoom-in; transition: transform .2s var(--ease); }
  .history-thumb:hover { transform: scale(1.05); }
  .history-video { display: block; width: min(220px, 100%); max-height: 180px; border-radius: 9px; background: #000; }
  td.history-image-cell { width: 180px; }
  .history-no-image { color: var(--muted-2); font-size: 13px; }
  .history-bulk-bar { display:flex;align-items:center;flex-wrap:wrap;gap:10px;margin:10px 0 14px;padding:10px 12px;border:1px solid var(--line);border-radius:12px;background:var(--accent-soft); }
  .history-bulk-all { display:flex;align-items:center;gap:8px;min-height:36px;cursor:pointer;font-size:13px; }
  .history-bulk-all-mobile { display:none; }
  #viewHistory input.history-checkbox { appearance:auto;width:18px;height:18px;min-height:18px;flex:0 0 18px;padding:0;margin:0;accent-color:var(--accent);box-shadow:none;cursor:pointer; }
  #viewHistory input.history-checkbox:disabled { cursor:default; }
  .history-bulk-count { flex:1;color:var(--muted);font-size:13px;white-space:nowrap; }
  .history-bulk-bar button { min-height:36px;font-size:13px; }
  #genTable .history-select-cell { display:none; }
  #genTable.is-selecting .history-select-cell { display:table-cell;width:56px; }
  .history-select-label { display:flex;align-items:center;gap:7px;min-height:32px;cursor:pointer; }
  .history-select-label span { font-size:11px;color:var(--muted);white-space:nowrap; }
  #genTable tr.is-history-selected { background:var(--accent-soft); }
  #historyBulkStatus { margin:8px 0;font-size:13px; }
  #historyBulkStatus:empty { display:none; }
  @media (max-width:660px) {
    #viewHistory > .history-stack > .table-panel > .panel-toolbar { align-items:flex-start;flex-wrap:wrap;gap:10px; }
    #viewHistory .panel-toolbar-actions { flex-wrap:wrap;gap:6px; }
    #viewHistory .panel-toolbar-actions button { min-height:38px;padding:0 10px; }
    .history-bulk-bar { gap:8px;padding:10px; }
    .history-bulk-all { min-height:40px; }
    .history-bulk-all-desktop { display:none; }
    .history-bulk-all-mobile { display:inline; }
    .history-bulk-count { font-size:12px; }
    .history-bulk-bar button { min-height:40px;padding:0 10px; }
    #genTable.is-selecting td.history-select-cell { display:flex;width:auto;align-items:center; }
    #genTable .history-select-label { min-height:40px; }
    #genTable .history-select-label span { font-size:12px; }
    #genTable tr.is-history-selected { border-radius:10px;padding-left:8px;padding-right:8px; }
  }
  .table-scroll { overflow-x: auto; }
  table { width: 100%; min-width: 720px; border-collapse: collapse; font-size: 14px; }
  th, td { padding: 12px 10px; border-bottom: .5px solid var(--line); text-align: left; vertical-align: top; }
  /* Uppercase micro caps, like a UITableView section header. */
  th { color: var(--muted); font-size: 12px; font-weight: 590; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; }
  td { color: var(--text); }
  tbody tr:last-child td { border-bottom: 0; }
  .empty-row { color: var(--muted); text-align: center; padding: 30px 10px; }

  @media (max-width: 920px) {
    .auth-layout { grid-template-columns: 1fr; }
    .auth-context { min-height: 44vh; border-right: 0; padding: 26px 28px 32px; }
    .auth-intro { padding: 44px 0 32px; }
    .auth-intro h1 { font-size: 38px; }
    .auth-foot { display: none; }
    .auth-side { padding: 40px 24px; }
    .workspace-grid { grid-template-columns: 1fr; }
    .payment-layout { grid-template-columns: 1fr; }
    .side-panel { order: -1; }
  }

  @media (max-width: 660px) {
    body { font-size: 17px; }
    .auth-context { min-height: auto; padding: 20px 20px 26px; }
    .auth-intro { padding: 44px 0 8px; }
    .auth-intro h1 { font-size: 32px; }
    .auth-intro > p { font-size: 16px; }
    .product-points { grid-template-columns: 1fr; gap: 8px; margin-top: 24px; }
    .landing-price-grid, .landing-price-grid.cols-2 { grid-template-columns: 1fr; }
    .docs-cta { width: 100%; }
    .auth-side { padding: 30px 18px 44px; }
    .topbar { min-height: 48px; padding: 0 14px; }
    .topbar > .brand { flex-shrink: 0; }
    .brand-name { white-space: nowrap; }
    .brand-sub { display: none !important; }
    .credit-chip { padding: 4px 10px; }
    .topbar .ghost-btn { padding: 0 8px; }
    .workspace { width: min(1180px, calc(100% - 24px)); padding-top: 20px; }
    .workspace-heading { flex-direction: column; align-items: stretch; gap: 8px; margin-bottom: 12px; }
    .workspace-heading h1 { font-size: 30px; }
    .workspace-heading-actions { display: none; }
    /* On a phone the compose card should come first, not the summary. */
    .side-panel { order: 0; }
    .settings-grid { gap: 16px; }
    /* Flex rather than a fixed column count: tabs share the row when they fit and
       scroll instead of wrapping to a ragged second line when they do not. */
    .view-tabs { display: flex; width: 100%; overflow-x: auto; scrollbar-width: none; }
    .view-tabs::-webkit-scrollbar { display: none; }
    .view-tab { flex: 1 0 auto; min-width: 0; padding: 0 10px; }
    .tool-panel { padding: 17px; }
    .settings-grid { grid-template-columns: 1fr; }
    .payment-form-grid { grid-template-columns: 1fr; }
    .tool-actions { align-items: stretch; flex-direction: column; }
    .generate-btn { width: 100%; }
    .inline-form { grid-template-columns: 1fr; }
    .inline-form button { width: 100%; }

    /* Tables become stacked label/value rows. A 6-column table cannot be read on a
       390px screen, and sideways scrolling inside a card is easy to miss. */
    .table-scroll { overflow-x: visible; }
    table, .payment-orders table { min-width: 0; font-size: 15px; }
    thead { display: none; }
    tbody, tbody tr, tbody td { display: block; }
    tbody tr {
      padding: 12px 0;
      border-bottom: .5px solid var(--line);
    }
    tbody tr:last-child { border-bottom: 0; padding-bottom: 0; }
    tbody tr:first-child { padding-top: 0; }
    tbody td {
      display: flex;
      align-items: baseline;
      justify-content: space-between;
      gap: 14px;
      padding: 4px 0;
      border: 0;
      text-align: right;
    }
    tbody td::before {
      content: attr(data-label);
      flex: 0 0 auto;
      color: var(--muted);
      font-size: 14px;
      text-align: left;
    }
    tbody td:not([data-label]) { display: block; text-align: left; }
    tbody td.empty-row { display: block; text-align: center; }
    /* Long values need the full width under their label. */
    .history-thumb-list { justify-content: flex-end; }
    .history-video { margin-left: auto; }
    td.history-image-cell { width: auto; }
  }

  /* ---------- 图片保存期横幅 ---------- */
  /* 这条是会让用户丢东西的政策，所以用整幅警示条而不是角落里的小字 */
  .retention-banner {
    display: flex; align-items: flex-start; gap: 14px; margin-bottom: 20px; padding: 16px 20px;
    border: 1px solid rgba(178, 80, 0, .3); border-left: 4px solid var(--warn);
    border-radius: var(--radius); background: rgba(255, 149, 0, .08); color: var(--text);
  }
  .retention-icon {
    flex: none; display: grid; place-items: center; width: 24px; height: 24px; margin-top: 1px;
    border-radius: 50%; background: var(--warn); color: #fff; font-size: 15px; font-weight: 700; line-height: 1;
  }
  .retention-copy { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
  .retention-copy strong { font-size: 17px; font-weight: 650; letter-spacing: -.01em; color: var(--warn); }
  .retention-copy span { font-size: 14px; line-height: 1.55; color: var(--muted); }
  .retention-copy b { color: var(--text); font-weight: 600; }
  @media (max-width: 720px) {
    .retention-banner { padding: 14px; gap: 10px; }
    .retention-copy strong { font-size: 15px; }
    .retention-copy span { font-size: 13px; }
  }

  /* ---------- 无限画布 ---------- */
  .canvas-shell { display: flex; flex-direction: column; gap: 12px; }
  .canvas-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
  .canvas-toolbar-copy { display: flex; flex-direction: column; gap: 2px; }
  .canvas-toolbar-copy strong { font-size: 20px; font-weight: 640; letter-spacing: -.01em; }
  .canvas-toolbar-copy span { color: var(--muted); font-size: 13px; }
  .canvas-toolbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
  .canvas-zoom-group { display: flex; align-items: center; gap: 2px; padding: 2px; border-radius: var(--radius-pill); background: var(--surface-2); }
  .canvas-zoom-btn {
    width: 26px; height: 26px; border: 0; border-radius: 50%; background: transparent; color: var(--text);
    font-size: 16px; line-height: 1; cursor: pointer;
  }
  .canvas-zoom-btn:hover { background: var(--surface-3); }
  .canvas-zoom { min-width: 50px; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; text-align: center; }

  /* 视口负责裁剪和承接手势，世界层只做位移缩放，两者职责不能混。 */
  .canvas-viewport {
    position: relative; overflow: hidden; height: min(72vh, 780px);
    border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
    box-shadow: var(--shadow); cursor: grab; touch-action: none; contain: strict;
    -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  }
  .canvas-viewport.panning { cursor: grabbing; }
  .canvas-viewport.drop-target { outline: 2px dashed var(--accent); outline-offset: -8px; }
  /* 网格跟着缩放走，用户才有「在放大」而不是「图变大了」的感觉。
     --grid 由 JS 按当前 scale 写入。 */
  .canvas-viewport::before {
    content: ""; position: absolute; inset: 0; pointer-events: none;
    background-image: radial-gradient(circle, var(--grid-dot, var(--muted-2)) 1px, transparent 1px);
    background-size: var(--grid, 24px) var(--grid, 24px);
    background-position: var(--grid-x, 0) var(--grid-y, 0);
    opacity: .5;
  }
  .canvas-world { position: absolute; top: 0; left: 0; width: 0; height: 0; transform-origin: 0 0; }

  .canvas-empty {
    position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 6px; pointer-events: none; color: var(--muted);
  }
  .canvas-empty strong { font-size: 17px; font-weight: 600; color: var(--text); }
  .canvas-empty span { font-size: 13px; }
  .canvas-empty.hidden { display: none; }

  .canvas-card {
    position: absolute; border-radius: 10px; background: var(--surface-2);
    box-shadow: 0 2px 10px rgba(0, 0, 0, .12); overflow: hidden; cursor: grab;
    outline: 2px solid transparent; outline-offset: 2px;
  }
  .canvas-card.dragging { cursor: grabbing; box-shadow: 0 12px 36px rgba(0, 0, 0, .28); }
  .canvas-card.selected { outline-color: var(--accent); }
  .canvas-card img { display: block; width: 100%; height: 100%; object-fit: cover; -webkit-user-drag: none; user-select: none; }
  /* 提示词在下、操作在上：四个按钮和一段文字挤同一行的话，卡片一小就全糊了 */
  .canvas-card .canvas-card-bar {
    position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; gap: 6px;
    padding: 6px 8px; background: linear-gradient(transparent, rgba(0, 0, 0, .62));
    opacity: 0; transition: opacity .16s var(--ease);
  }
  .canvas-card:hover .canvas-card-bar, .canvas-card.selected .canvas-card-bar { opacity: 1; }
  .canvas-card-bar span { flex: 1; min-width: 0; color: rgba(255, 255, 255, .9); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .canvas-card-tools {
    position: absolute; top: 6px; right: 6px; display: flex; gap: 4px;
    opacity: 0; transition: opacity .16s var(--ease);
  }
  .canvas-card:hover .canvas-card-tools, .canvas-card.selected .canvas-card-tools { opacity: 1; }
  .canvas-card-tools button, .canvas-card-tools a {
    border: 0; border-radius: 6px; padding: 4px 8px; background: rgba(0, 0, 0, .55);
    color: #fff; font-size: 11px; line-height: 1.4; text-decoration: none; cursor: pointer;
    -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  }
  .canvas-card-tools button:hover, .canvas-card-tools a:hover { background: rgba(0, 0, 0, .78); }
  .canvas-card-tools .danger:hover { background: var(--err); }
  .canvas-card-tools .accent { background: rgba(0, 122, 255, .85); }
  .canvas-card-tools .accent:hover { background: var(--accent-strong); }
  .canvas-card-tools .upscale { background: rgba(140, 98, 255, .88); }
  .canvas-card-tools .upscale:hover { background: rgba(140, 98, 255, 1); }

  /* 卡片超分小浮层：选 2K/4K/8K 后原地开工 */
  .upscale-pop {
    position: absolute; z-index: 20; top: 34px; right: 6px; width: 168px; padding: 10px;
    border: 1px solid var(--line); border-radius: 12px;
    background: var(--bg-elevated); box-shadow: 0 14px 32px rgba(0, 0, 0, .2);
    display: flex; flex-direction: column; gap: 8px;
  }
  .upscale-pop-title { color: var(--muted); font-size: 11px; }
  .upscale-pop-pills { display: flex; gap: 4px; }
  .upscale-pop-pills .pill { flex: 1; min-height: 28px; padding: 4px 6px; border-radius: 7px; font-size: 11px; }
  .upscale-pop-actions { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
  .upscale-pop-actions .ghost-btn { padding: 0; background: transparent; border: 0; color: var(--muted); font-size: 11px; cursor: pointer; }
  .upscale-pop-go { flex: 1; border: 0; border-radius: 8px; padding: 6px 0; background: var(--accent); color: var(--accent-ink); font-size: 12px; cursor: pointer; }
  .upscale-pop-go:disabled { opacity: .6; cursor: wait; }

  /* 保质期到了图会 404，裂图图标什么都说明不了，换成一句能看懂的话 */
  .canvas-card.expired { display: grid; place-items: center; background: var(--surface-3); }
  .canvas-card.expired img { display: none; }
  .canvas-expired-note { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px; text-align: center; }
  .canvas-expired-note strong { font-size: 13px; color: var(--warn); }
  .canvas-expired-note span { font-size: 11px; color: var(--muted); }
  /* 缩放把手只在选中时出现，否则密集摆图时满屏都是小方块 */
  .canvas-resize {
    position: absolute; right: -5px; bottom: -5px; width: 14px; height: 14px; border-radius: 4px;
    border: 2px solid var(--accent); background: var(--surface); cursor: nwse-resize; opacity: 0;
  }
  .canvas-card.selected .canvas-resize { opacity: 1; }

  /* 生成中的占位：和成品卡片同样的位置与尺寸，避免出图瞬间跳一下 */
  .canvas-card.pending { display: grid; place-items: center; background: var(--surface-2); cursor: default; }
  .canvas-pending-inner { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 12px; text-align: center; }
  .canvas-pending-inner span { color: var(--muted); font-size: 12px; }
  .canvas-pending-bar { width: 76%; height: 4px; border-radius: 2px; background: var(--surface-3); overflow: hidden; }
  .canvas-pending-fill { height: 100%; width: 0; background: var(--accent); transition: width .3s var(--ease); }

  .canvas-composer {
    position: absolute; width: 320px; max-height: min(92%, 460px); overflow-y: auto; padding: 12px;
    border: 1px solid var(--line); border-radius: 12px;
    background: var(--bg-elevated); box-shadow: 0 18px 48px rgba(0, 0, 0, .22); display: flex; flex-direction: column; gap: 8px;
  }
  .canvas-composer textarea {
    width: 100%; min-height: 66px; resize: vertical; padding: 8px 10px; border: 1px solid var(--line);
    border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; font-size: 13px;
  }
  .canvas-composer-row { display: flex; gap: 6px; }
  .canvas-composer-row select { flex: 1; min-width: 0; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); font-size: 12px; }
  .canvas-composer-actions { display: flex; justify-content: flex-end; gap: 8px; }
  .canvas-composer-actions button { border-radius: 8px; padding: 6px 14px; font-size: 13px; }
  .canvas-composer-pills { display: flex; gap: 4px; }
  .canvas-composer-pills button {
    flex: 1; min-width: 0; min-height: 32px; padding: 4px 6px; border: 1px solid var(--line);
    border-radius: 8px; background: var(--surface); color: var(--text); font-size: 11px; line-height: 1.2;
  }
  .canvas-composer-pills button.active {
    background: var(--accent); color: #fff; border-color: var(--accent);
  }
  .canvas-composer-hint { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.4; }
  .canvas-kind-chip {
    position: absolute; top: 6px; left: 6px; padding: 3px 8px; border-radius: var(--radius-pill);
    background: rgba(0, 0, 0, .55); color: #fff; font-size: 10px; line-height: 1.5;
    -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  }
  .canvas-card:has(.canvas-ref-chip) .canvas-kind-chip { top: 28px; }
  .canvas-status { min-height: 18px; color: var(--muted); font-size: 13px; }
  .canvas-status.err { color: var(--err); }
  .canvas-status.ok { color: var(--ok); }

  /* 全屏用定位而不是 Fullscreen API：后者会把浏览器地址栏一起吞掉，
     而画布常要跟其它标签页来回切，压住整个视口就够了。 */
  .canvas-shell.fullscreen {
    position: fixed; inset: 0; z-index: 60; margin: 0; padding: 16px;
    background: var(--bg); overflow: auto;
  }
  .canvas-shell.fullscreen .canvas-viewport { height: calc(100vh - 120px); }
  body.canvas-full { overflow: hidden; }

  /* 参考图角标：一眼看出这张是从哪张改出来的 */
  .canvas-ref-chip {
    position: absolute; top: 6px; left: 6px; display: flex; align-items: center; gap: 4px;
    padding: 3px 8px; border-radius: var(--radius-pill); background: rgba(0, 122, 255, .85);
    color: #fff; font-size: 10px; line-height: 1.5;
  }
  .canvas-composer-ref {
    display: flex; align-items: center; gap: 8px; padding: 6px 8px;
    border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2);
  }
  .canvas-composer-ref img { width: 34px; height: 34px; border-radius: 6px; object-fit: cover; }
  .canvas-composer-ref span { flex: 1; min-width: 0; font-size: 12px; color: var(--muted); }

  /* ---------- 导入历史图片 ---------- */
  .import-modal { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 20px; background: var(--scrim); }
  .import-modal.hidden { display: none; }
  .import-card {
    display: flex; flex-direction: column; gap: 12px; width: min(880px, 96vw); max-height: 88vh; padding: 20px;
    border-radius: var(--radius); background: var(--bg-elevated); box-shadow: 0 30px 90px rgba(0, 0, 0, .4);
  }
  .import-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
  .import-head h3 { margin: 0; font-size: 19px; font-weight: 640; }
  .import-head span { color: var(--muted); font-size: 13px; }
  .import-toolbar { display: flex; align-items: center; gap: 8px; }
  .import-hint { color: var(--muted); font-size: 12px; }
  .import-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 10px;
    overflow: auto; padding: 2px; min-height: 120px;
  }
  .import-item {
    position: relative; border: 2px solid transparent; border-radius: 10px; overflow: hidden;
    background: var(--surface-2); cursor: pointer; aspect-ratio: 1;
  }
  .import-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
  .import-item.picked { border-color: var(--accent); }
  .import-item.already { opacity: .42; cursor: not-allowed; }
  .import-item .import-tick {
    position: absolute; top: 6px; left: 6px; display: grid; place-items: center; width: 20px; height: 20px;
    border: 2px solid #fff; border-radius: 50%; background: rgba(0, 0, 0, .35); color: #fff; font-size: 12px; line-height: 1;
  }
  .import-item.picked .import-tick { background: var(--accent); border-color: var(--accent); }
  .import-item .import-label {
    position: absolute; left: 0; right: 0; bottom: 0; padding: 4px 6px;
    background: linear-gradient(transparent, rgba(0, 0, 0, .7)); color: #fff; font-size: 10px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .import-actions { display: flex; justify-content: flex-end; gap: 8px; }
  .import-empty { grid-column: 1 / -1; padding: 30px; text-align: center; color: var(--muted); font-size: 14px; }

  @media (max-width: 720px) {
    .canvas-viewport { height: 62vh; }
    .canvas-composer { width: min(300px, 80vw); }
    .canvas-shell.fullscreen .canvas-viewport { height: calc(100vh - 150px); }
    .import-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
  }

  /* ================================================================
     Workspace shell — single source of layout truth.
     One fixed side navigation, one centred work stage. This block
     replaces four stacked layout patches that were each re-positioning
     .topbar / .view-tabs on top of one another.
     ================================================================ */
  :root {
    --bg: #f6f7f9;
    --bg-elevated: #ffffff;
    --surface: #ffffff;
    --surface-2: #f0f1f4;
    --surface-3: #e4e6ea;
    --line: #e5e7eb;
    --line-strong: #d5d8dd;
    --text: #1f2329;
    --muted: #646a73;
    --muted-2: #686e77;
    --grid-dot: #9aa1aa;
    --accent: #3a5bdb;
    --accent-strong: #3d5ce8;
    --accent-soft: #edf0ff;
    --accent-ink: #ffffff;
    --nav-bg: #f1f2f5;
    --segment-active: #ffffff;
    --radius: 16px;
    --shadow: 0 10px 34px rgba(31, 35, 41, .07);
    --nav-w: 248px;
    --topbar-h: 58px;
    --stage-w: 880px;
    --composer-w: 720px;
  }
  html[data-theme="light"] { color-scheme: light; --ok: #1e7e34; --err: #d70015; --warn: #b25000; }
  html[data-theme="dark"] {
    color-scheme: dark;
    --bg: #131416;
    --bg-elevated: #1c1d20;
    --surface: #1c1d20;
    --surface-2: #26282c;
    --surface-3: #303338;
    --line: #2c2e33;
    --line-strong: #3a3d43;
    --text: #f0f1f3;
    --muted: #a1a6ae;
    --muted-2: #858a93;
    --grid-dot: #6d727a;
    --accent: #7d95ff;
    --accent-strong: #93a8ff;
    --accent-soft: rgba(125, 149, 255, .16);
    --accent-ink: #11131a;
    --ok: #30d158;
    --err: #ff453a;
    --warn: #ff9f0a;
    --nav-bg: #0f1012;
    --segment-active: #303338;
    --shadow: 0 14px 44px rgba(0, 0, 0, .34);
  }
  body { background: var(--bg); }

  /* ---------------- shell ----------------
     The shell owns the viewport: the rail is fixed, the main column
     scrolls internally so the composer can stay pinned to the bottom. */
  .app-shell { min-height: 100vh; background: var(--bg); }
  .nav-scrim {
    position: fixed; inset: 0; z-index: 55; opacity: 0; pointer-events: none;
    background: rgba(0, 0, 0, .45); transition: opacity .22s var(--ease);
  }
  .app-main {
    display: flex; flex-direction: column; overflow: hidden;
    height: 100vh; height: 100dvh;
    margin-left: var(--nav-w); transition: margin-left .18s var(--ease);
  }

  /* ---------------- side navigation ---------------- */
  .side-nav {
    position: fixed; z-index: 60; top: 0; bottom: 0; left: 0;
    display: flex; flex-direction: column;
    width: var(--nav-w); height: 100vh; height: 100dvh;
    padding: 13px 12px calc(12px + env(safe-area-inset-bottom));
    border-right: 1px solid var(--line); background: var(--nav-bg);
    transition: transform .24s var(--ease);
  }
  .side-nav-head { display: flex; align-items: center; gap: 6px; min-height: 38px; padding: 0 4px; margin-bottom: 14px; }
  .side-nav-head .brand { flex: 1; gap: 9px; overflow: hidden; }
  .side-nav-head .brand-mark { width: 26px; height: 26px; flex-basis: 26px; border-radius: 8px; }
  .side-nav-head .brand-name { font-size: 16px; font-weight: 680; letter-spacing: -.01em; white-space: nowrap; }
  .side-nav-head .brand-sub { display: none; }
  .nav-icon-btn {
    display: inline-grid; place-items: center; flex: 0 0 30px; width: 30px; height: 30px;
    padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--muted);
    transition: background .16s var(--ease), color .16s var(--ease);
  }
  .nav-icon-btn:hover { background: var(--surface-2); color: var(--text); }
  .nav-icon-btn svg { width: 17px; height: 17px; }

  .view-tabs {
    display: flex; flex-direction: column; gap: 2px; flex: 0 0 auto;
    width: 100%; margin: 0; padding: 0; border: 0; border-radius: 0; background: transparent;
  }
  a.view-tab, .view-tab {
    display: flex; align-items: center; justify-content: flex-start; gap: 10px;
    width: 100%; min-width: 0; min-height: 37px; padding: 0 10px;
    border: 0; border-radius: 9px; background: transparent; box-shadow: none;
    color: var(--muted); font-size: 14px; font-weight: 500; text-align: left;
    text-decoration: none; white-space: nowrap; overflow: hidden;
  }
  a.view-tab, .view-tab { flex: 0 0 auto; }
  .view-tab svg { flex: 0 0 18px; width: 18px; height: 18px; }
  .view-tab:hover { background: var(--surface-2); color: var(--text); }
  a.view-tab.active, .view-tab.active {
    background: var(--surface); color: var(--text); font-weight: 620;
    box-shadow: 0 1px 3px rgba(31, 35, 41, .09);
  }
  html[data-theme="dark"] a.view-tab.active { background: var(--surface-2); box-shadow: none; }
  a.view-tab-docs { color: var(--muted); font-weight: 500; }
  .tab-badge {
    margin-left: auto; padding: 1px 5px; border-radius: 5px;
    background: var(--accent); color: var(--accent-ink); font-size: 10px; font-weight: 700; line-height: 1.5;
  }

  .side-group { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; margin-top: 16px; }
  .side-group-head {
    display: flex; align-items: center; gap: 6px; padding: 0 6px 6px;
    color: var(--muted-2); font-size: 12px; font-weight: 600;
  }
  .side-group-head .side-group-title { flex: 1; }
  .side-group-head .task-count { color: var(--muted-2); font-size: 11px; font-variant-numeric: tabular-nums; }
  .side-group-head .ghost-btn {
    min-height: 22px; padding: 0 7px; border-radius: 6px; border: 0;
    background: transparent; color: var(--muted-2); font-size: 11px;
  }
  .side-group-head .ghost-btn:hover { background: var(--surface-2); color: var(--text); }

  .nav-search { display: none; margin: 0 2px 8px; }
  .nav-search.open { display: block; }
  .nav-search input {
    width: 100%; min-height: 32px; padding: 0 10px; border: 1px solid var(--line);
    border-radius: 8px; background: var(--surface); color: var(--text); font-size: 13px;
  }

  /* Task list lives in the rail so the stage stays clean. */
  .task-rail {
    display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0;
    padding: 0; margin: 0; border: 0; border-radius: 0; background: transparent;
    box-shadow: none; overflow-y: auto; overscroll-behavior: contain;
  }
  .task-rail::-webkit-scrollbar { width: 6px; }
  .task-rail::-webkit-scrollbar-thumb { border-radius: 3px; background: var(--surface-3); }
  .task-list { display: flex; flex-direction: column; gap: 2px; }
  .task-list-empty { padding: 12px 8px; color: var(--muted-2); font-size: 12px; text-align: left; }
  .task-list-item {
    display: block; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px;
    background: transparent; color: var(--muted); text-align: left;
    text-decoration: none;
  }
  .task-list-item:hover { background: var(--surface-2); color: var(--text); }
  .task-list-item.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(31, 35, 41, .09); }
  html[data-theme="dark"] .task-list-item.active { background: var(--surface-2); box-shadow: none; }
  .task-list-title { display: block; overflow: hidden; font-size: 13px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
  .task-list-meta { display: flex; justify-content: space-between; gap: 8px; margin-top: 2px; color: var(--muted-2); font-size: 11px; }
  .task-list-state.running { color: var(--accent); }
  .task-list-state.done { color: var(--ok); }
  .task-list-state.failed { color: var(--err); }
  .video-task-list-item .task-list-progress { margin-top: 7px; }
  .video-task-list-item .task-list-progress-head {
    display: flex; justify-content: space-between; gap: 8px; color: var(--muted-2);
    font-size: 10px; line-height: 1.35;
  }
  .video-task-list-item .task-list-progress-label {
    min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .video-task-list-item .task-list-progress-percent {
    flex: 0 0 auto; font-variant-numeric: tabular-nums;
  }
  .video-task-list-item .task-list-progress-track {
    height: 4px; margin-top: 4px; overflow: hidden; border-radius: 999px; background: var(--surface-3);
  }
  .video-task-list-item .task-list-progress-fill {
    width: 0; height: 100%; border-radius: inherit; background: var(--accent);
    transition: width .35s ease, background-color .2s ease;
  }
  .video-task-list-item[data-video-task-status="succeeded"] .task-list-progress-fill { background: var(--ok); }
  .video-task-list-item[data-video-task-status="failed"] .task-list-progress-fill { background: var(--err); }
  .video-task-list-id {
    display: block; max-width: 100%; margin-top: 5px; overflow: hidden; color: var(--muted-2);
    font: 10px/1.35 ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
    text-overflow: ellipsis; white-space: nowrap;
  }

  .task-settings-host { display: none; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
  .task-rail.settings-open .task-settings-host { display: block; }
  /* Generation parameters are only meaningful on the creation view. */
  .app-shell:not([data-active-view="gen"]) .task-settings-host,
  .app-shell:not([data-active-view="gen"]) .task-settings-toggle { display: none; }
  .task-settings-title { margin: 0 4px 8px; color: var(--muted-2); font-size: 11px; font-weight: 600; }
  .task-settings-host .settings-grid {
    display: grid !important; grid-template-columns: 1fr !important;
    gap: 8px !important; margin: 0 !important; overflow: visible !important;
  }
  .task-settings-host .option-group { grid-column: auto !important; min-width: 0 !important; padding: 9px !important; border-radius: 10px; background: var(--surface) !important; }
  html[data-theme="dark"] .task-settings-host .option-group { background: var(--surface-2) !important; }
  .task-settings-host .section-label { display: block; margin-bottom: 6px; font-size: 11px; }
  .task-settings-host .pills { gap: 5px; }
  .task-settings-host #models,
  .task-settings-host #resolutions,
  .task-settings-host #deliveries { grid-template-columns: minmax(0, 1fr); }
  .task-settings-host #ratios,
  .task-settings-host #outputCounts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .task-settings-host .pill {
    justify-content: flex-start; min-height: 30px !important; padding: 0 8px !important;
    border-radius: 8px; font-size: 11.5px !important;
  }
  .task-settings-host #ratios .pill, .task-settings-host #outputCounts .pill { justify-content: center; }
  .task-settings-host .pill small { font-size: 10px; }
  .task-settings-host .side-note { padding: 8px 0 0; font-size: 11px; }

  .side-nav-foot { flex: 0 0 auto; margin-top: 10px; padding-top: 10px; }
  .side-promo {
    position: relative; display: flex; align-items: center; gap: 11px; width: 100%;
    margin-bottom: 10px; padding: 12px;
    border: 1px solid color-mix(in srgb, var(--accent) 26%, transparent);
    border-radius: 14px; background: var(--surface); color: var(--text); text-decoration: none; text-align: left;
    box-shadow: 0 1px 3px rgba(31, 35, 41, .07);
    transition: border-color .16s var(--ease), box-shadow .16s var(--ease), transform .16s var(--ease);
  }
  html[data-theme="dark"] .side-promo { background: var(--surface-2); border-color: rgba(10, 132, 255, .4); box-shadow: none; }
  .side-promo:hover { transform: translateY(-1px); border-color: var(--accent); box-shadow: 0 6px 18px rgba(31, 35, 41, .13); }
  html[data-theme="dark"] .side-promo:hover { box-shadow: 0 6px 18px rgba(0, 0, 0, .45); }
  .side-promo:active { transform: translateY(0); }
  .side-promo-icon {
    display: grid; place-items: center; flex: 0 0 36px; width: 36px; height: 36px;
    border-radius: 11px; background: var(--accent); color: var(--accent-ink);
    box-shadow: 0 3px 10px color-mix(in srgb, var(--accent) 42%, transparent);
  }
  .side-promo-icon svg { width: 19px; height: 19px; }
  .side-promo-copy { min-width: 0; flex: 1; }
  .side-promo-copy strong { display: block; font-size: 13.5px; font-weight: 640; line-height: 1.2; }
  .side-promo-copy span { display: block; margin-top: 3px; color: var(--muted-2); font-size: 11.5px; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .side-promo-copy #invitePromoCode { color: var(--accent); font-weight: 600; letter-spacing: .02em; }
  .side-promo-arrow { flex: 0 0 16px; width: 16px; height: 16px; color: var(--muted-2); transition: transform .16s var(--ease), color .16s var(--ease); }
  .side-promo:hover .side-promo-arrow { color: var(--accent); transform: translateX(2px); }
.toast-root { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 2000; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { background: #2a2d37; color: #eef1f6; border: 1px solid rgba(255,255,255,.09); border-radius: 10px; padding: 10px 16px; font-size: 13px; line-height: 1.4; box-shadow: 0 10px 30px rgba(0,0,0,.4); max-width: min(92vw, 460px); text-align: center; opacity: 0; transform: translateY(8px); transition: opacity .22s ease, transform .22s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.hide { opacity: 0; transform: translateY(8px); }
  .side-user { display: flex; align-items: center; gap: 9px; padding: 6px 4px 0; }
  .side-avatar {
    display: grid; place-items: center; flex: 0 0 26px; width: 26px; height: 26px;
    border-radius: 50%; background: var(--accent); color: var(--accent-ink);
    font-size: 12px; font-weight: 700; text-transform: uppercase;
  }
  .side-user-name { flex: 1; min-width: 0; overflow: hidden; color: var(--text); font-size: 13px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
  .side-user .nav-icon-btn { flex: 0 0 28px; width: 28px; height: 28px; }
  .side-user .nav-icon-btn svg { width: 15px; height: 15px; }

  /* ---------------- top bar ---------------- */
  .topbar {
    position: static; z-index: 30; display: flex; align-items: center; gap: 12px;
    flex: 0 0 auto; min-height: var(--topbar-h); padding: 0 22px; padding-top: env(safe-area-inset-top);
    border: 0; border-bottom: 1px solid var(--line); background: var(--bg);
    -webkit-backdrop-filter: none; backdrop-filter: none;
  }
  .topbar > .brand { display: none; }
  .mobile-menu-btn { display: none; }
  .workspace-heading {
    display: flex; align-items: center; justify-content: flex-start; gap: 12px;
    flex: 1 1 auto; min-width: 0; margin: 0; overflow: hidden;
  }
  .workspace-heading h1 { margin: 0; font-size: 15px; font-weight: 620; letter-spacing: 0; white-space: nowrap; }
  .workspace-heading p { display: none; }
  .workspace-heading-actions { display: flex; align-items: center; gap: 10px; min-width: 0; }
  .heading-docs { display: none; }
  .workspace-meta { overflow: hidden; color: var(--muted-2); font-size: 12px; text-overflow: ellipsis; }
  .topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; min-width: 0; flex-shrink: 1; }
  .topbar .credit-chip { min-width: 0; min-height: 30px; padding: 4px 11px; background: var(--surface-2); color: var(--muted); font-size: 12px; }
  .topbar .credit-chip b { color: var(--text); font-size: 13px; }
  .topbar .wechat-chip { min-height: 30px; background: transparent; color: var(--muted); font-size: 12px; }
  .topbar .wechat-chip:hover { background: var(--surface-2); }
  .topbar .docs-btn { min-height: 30px; font-size: 12.5px; }
  .theme-toggle {
    position: static; display: inline-grid; place-items: center; flex: 0 0 32px; width: 32px; height: 32px;
    padding: 0; border: 0; border-radius: 9px; background: transparent; color: var(--muted);
    box-shadow: none; font-size: 15px;
  }
  .theme-toggle:hover { background: var(--surface-2); color: var(--text); }
  .theme-toggle-label { display: none; }

  /* ---------------- work area ---------------- */
  .workspace {
    display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; overflow-y: auto;
    width: 100%; max-width: none; margin: 0;
    padding: 0 22px calc(14px + env(safe-area-inset-bottom));
  }
  .retention-banner {
    display: flex; align-items: center; gap: 9px; flex: 0 0 auto;
    width: min(var(--stage-w), 100%); margin: 14px auto 0; padding: 8px 12px;
    border: 1px solid transparent; border-radius: 11px; background: #fff6e5; color: #8a5a00;
  }
  html[data-theme="dark"] .retention-banner { background: #241f14; border-color: #3a3324; color: #d9b978; }
  .retention-icon {
    display: grid; place-items: center; flex: 0 0 18px; width: 18px; height: 18px;
    border-radius: 50%; background: #f0a92c; color: #fff; font-size: 11px; font-weight: 700;
  }
  .retention-copy { display: flex; flex-wrap: wrap; align-items: baseline; gap: 3px 8px; min-width: 0; }
  .retention-copy strong { font-size: 12.5px; font-weight: 620; }
  .retention-copy > span { color: inherit; opacity: .78; font-size: 12px; }

  /* 优惠活动提示：紧凑卡片，放在左侧边栏底部，可手动关闭（本地记住） */
  .sale-banner {
    position: relative; display: flex; flex-direction: column; gap: 6px;
    width: 100%; margin: 0 0 10px; padding: 9px 10px;
    border: 1px solid rgba(255, 122, 24, .5);
    border-radius: 13px;
    background: linear-gradient(135deg, rgba(255, 138, 0, .16), rgba(255, 45, 85, .12));
    color: var(--text); font-size: 11.5px; line-height: 1.4;
  }
  html[data-theme="dark"] .sale-banner { border-color: rgba(255, 138, 0, .55); background: linear-gradient(135deg, rgba(255, 138, 0, .22), rgba(255, 45, 85, .18)); }
  .sale-banner.hidden { display: none; }
  .sale-banner-head { display: flex; align-items: center; gap: 8px; }
  .sale-banner-tag {
    flex: 0 0 auto; padding: 2px 9px; border-radius: 999px;
    background: linear-gradient(135deg, #ff8a00, #ff2d55); color: #fff;
    font-size: 10.5px; font-weight: 800; letter-spacing: .04em;
    box-shadow: 0 2px 8px rgba(255, 45, 85, .38);
  }
  .sale-banner-close {
    flex: 0 0 auto; width: 18px; height: 18px; margin-left: auto;
    display: grid; place-items: center; border: 0; border-radius: 50%;
    background: transparent; color: var(--muted); font-size: 13px; line-height: 1; cursor: pointer;
  }
  .sale-banner-close:hover { background: rgba(255, 45, 85, .18); color: #ff2d55; }
  .sale-banner-body { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
  .sale-banner-title { font-weight: 750; font-size: 12px; color: var(--text); }
  .sale-banner-desc { color: var(--muted); font-size: 11px; }
  .sale-banner-sep { display: none; }
  .sale-banner-status { display: flex; }
  .sale-banner-eligible {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 11px; font-weight: 700; color: var(--ok); white-space: nowrap;
  }
  .sale-banner-eligible::before { content: ""; flex: 0 0 auto; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
  .sale-banner-eligible.not { color: #e8590c; }
  html[data-theme="dark"] .sale-banner-eligible.not { color: #ffa94d; }
  .sale-banner-terms { display: flex; flex-wrap: wrap; gap: 3px; }
  .sale-banner-terms span {
    padding: 1px 7px; border-radius: 7px; font-size: 10px; font-weight: 650; color: #b54708;
    background: rgba(255, 138, 0, .16);
    border: 1px solid rgba(255, 138, 0, .42);
  }
  html[data-theme="dark"] .sale-banner-terms span { color: #ffb457; background: rgba(255, 138, 0, .2); border-color: rgba(255, 138, 0, .48); }

  #viewGen { display: flex; flex: 1 1 auto; flex-direction: column; width: 100%; min-height: 0; }
  #viewGen.hidden { display: none; }
  .generation-layout {
    display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0;
    width: 100%; margin: 0; gap: 0; grid-template-columns: none;
  }
  .task-stage { display: flex; flex: 1 1 auto; flex-direction: column; min-width: 0; min-height: 0; }
  .gen-feed, #viewGen .task-stage .gen-feed {
    display: flex; flex: 1 1 auto; flex-direction: column-reverse; gap: 26px; min-height: 0;
    width: min(var(--stage-w), 100%); margin: 0 auto; padding: 22px 0 16px; overflow-y: auto;
  }
  .gen-feed::-webkit-scrollbar { width: 7px; }
  .gen-feed::-webkit-scrollbar-thumb { border-radius: 4px; background: var(--surface-3); }
  #viewGen .task-stage .gen-card { display: none; }
  #viewGen .task-stage .gen-card.active-task { display: block; }
  .task-stage-empty {
    display: grid; flex: 0 0 auto; place-items: center; min-height: 0;
    padding: 8px 0 16px; color: var(--muted); text-align: center;
  }
  .task-stage-empty strong {
    display: block; margin-bottom: 8px; color: var(--text);
    font-size: 30px; font-weight: 600; letter-spacing: -.02em;
  }
  .task-stage-empty span { font-size: 14px; }
  /* Nothing generated yet: centre the greeting and the composer as one group. */
  .task-stage.is-empty { justify-content: center; }
  .task-stage.is-empty .gen-feed,
  #viewGen .task-stage.is-empty .gen-feed { flex: 0 0 auto; overflow: visible; padding: 0 0 10px; }

  /* ---------------- composer ---------------- */
  #viewGen .workspace-grid, #viewGen .task-stage .workspace-grid {
    position: static; display: block; flex: 0 0 auto;
    width: min(var(--composer-w), 100%); margin: 0 auto; padding: 0; background: none;
  }
  #viewGen .side-panel, #viewGen .panel-head, #viewGen .field-hint { display: none; }
  #viewGen .tool-panel, #viewGen .task-stage .tool-panel {
    padding: 12px 14px 10px; border: 1px solid var(--line); border-radius: 20px;
    background: var(--surface); box-shadow: 0 8px 30px rgba(31, 35, 41, .09);
  }
  html[data-theme="dark"] #viewGen .tool-panel { box-shadow: 0 10px 36px rgba(0, 0, 0, .42); }
  #viewGen .section-label[for="prompt"] { display: none; }
  #viewGen #prompt, #viewGen .task-stage #prompt {
    display: block; width: 100%; min-height: 52px; height: 52px; max-height: min(55vh, 560px); padding: 6px 4px;
    border: 0; border-radius: 0; background: transparent; color: var(--text);
    font-size: 15px; line-height: 1.5; resize: vertical; overflow-y: auto;
  }
  #viewGen #prompt:focus { outline: none; box-shadow: none; background: transparent; }
  #viewGen #prompt::placeholder { color: var(--muted-2); }
  .prompt-editor { position: relative; }
  .prompt-resize-btn {
    position: absolute; z-index: 2; top: 2px; right: 2px; min-height: 28px; padding: 0 9px;
    border: 0; border-radius: 7px; background: var(--surface-2); color: var(--muted);
    font-size: 12px; cursor: pointer;
  }
  .prompt-resize-btn:hover { color: var(--text); background: var(--surface-3); }
  .prompt-editor #prompt { padding-right: 54px; }
  .prompt-editor.is-expanded #prompt { height: min(44vh, 480px) !important; max-height: min(55vh, 560px); }
  #viewGen .settings-grid { display: none; }
  .composer-parameter-bar { position: relative; flex-wrap: wrap; gap: 6px; }
  .composer-upload-trigger { display: inline-flex; align-items: center; gap: 5px; min-height: 30px; padding: 0 8px; border-radius: 8px; color: var(--muted); font-size: 12px; cursor: pointer; }
  .composer-upload-trigger:hover { background: var(--surface-2); color: var(--text); }
  .composer-plus { font-size: 20px; font-weight: 300; line-height: 1; }
  .composer-param { position: relative; flex: 0 0 auto; }
  .composer-param > summary { display: inline-flex; align-items: center; gap: 5px; min-height: 30px; padding: 0 8px; border-radius: 8px; color: var(--muted); font-size: 12px; cursor: pointer; list-style: none; }
  .composer-param > summary::-webkit-details-marker { display: none; }
  .composer-param > summary::after { content: "⌄"; color: var(--muted-2); font-size: 13px; }
  .composer-param > summary:hover { background: var(--surface-2); color: var(--text); }
  .composer-param > summary b { color: var(--text); font-weight: 520; }
  .composer-param-popover { position: absolute; z-index: 20; left: 0; bottom: calc(100% + 8px); width: 260px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg-elevated); box-shadow: 0 14px 32px rgba(0, 0, 0, .16); }
  .composer-param-popover .section-label { display: block; margin: 0 0 7px; color: var(--muted); font-size: 11px; }
  .composer-param-popover .pills { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; }
  .composer-param-popover #models { grid-template-columns: 1fr; }
  .composer-param-popover .pill { min-height: 30px; padding: 4px 7px; border-radius: 7px; font-size: 11px; }
  .custom-ratio-row { display: flex; gap: 6px; margin-top: 9px; }
  .custom-ratio-row input { min-width: 0; flex: 1; height: 30px; padding: 0 8px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--text); font: inherit; font-size: 11px; }
  .custom-ratio-row input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
  .custom-ratio-apply { height: 30px; padding: 0 9px; border: 0; border-radius: 7px; background: var(--accent); color: var(--accent-ink); font-size: 11px; cursor: pointer; }
  .custom-ratio-hint { margin-top: 6px; color: var(--muted); font-size: 10px; line-height: 1.35; }
  .composer-resolution-popover { width: 290px; }
  .composer-resolution-popover #resolutions, .composer-resolution-popover #deliveries { grid-template-columns: 1fr; }
  .composer-resolution-popover #outputCounts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  #viewGen .reference-panel { margin: 6px 0 0; padding: 8px 10px; border-radius: 12px; background: var(--surface-2); }
  #viewGen .continue-banner {
    display: flex; align-items: center; gap: 10px; margin: 0 0 8px; padding: 7px 10px;
    border-radius: 10px; background: var(--accent-soft); color: var(--accent); font-size: 12.5px;
  }
  #viewGen .continue-banner span { flex: 1; }
  #viewGen .continue-banner button { border: 0; background: transparent; color: var(--accent); font-size: 12.5px; }
  .tool-actions, #viewGen .task-stage .tool-actions {
    display: flex; flex-direction: row; flex-wrap: nowrap; align-items: center;
    justify-content: flex-start; gap: 10px;
    margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line);
  }
  .tool-actions-copy { display: none; }
  .composer-spacer { flex: 1 1 auto; }
  .generate-btn, #viewGen .task-stage .generate-btn {
    flex: 0 0 auto; min-width: 148px; min-height: 36px; padding: 0 16px; border-radius: 10px; font-size: 13.5px;
  }
  #viewGen .prompt-presets { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 10px 0 0; }
  #viewGen .prompt-chip {
    min-height: 30px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px;
    background: var(--surface); color: var(--muted); font-size: 12.5px;
  }
  #viewGen .prompt-chip:hover { border-color: var(--line-strong); color: var(--text); }
  /* Empty status lines must not reserve height inside the composer card. */
  #viewGen .tool-panel .status:empty, #viewGen .gen-busy:empty { min-height: 0; margin: 0; }
  .image-only-notice { margin: 8px 0 0; color: var(--muted-2); font-size: 11px; text-align: center; }
  .recommended-strip {
    display: flex; align-items: center; gap: 14px; flex: 0 0 auto;
    width: min(var(--composer-w), 100%); margin: 12px auto 0; padding: 9px 13px;
    border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--muted);
  }
  .recommended-strip strong { color: var(--text); font-size: 12.5px; font-weight: 600; }
  .recommended-strip span { flex: 1; font-size: 12px; }
  .recommended-strip a { color: var(--accent); font-size: 12px; text-decoration: none; white-space: nowrap; }
  .recommend-dots { display: flex; gap: 4px; }
  .recommend-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--muted-2); }
  .recommend-dots i.active { width: 14px; border-radius: 4px; background: var(--accent); }

  /* ---------------- conversation cards ---------------- */
  .gen-card { padding: 0; background: transparent; box-shadow: none; animation: gen-card-in .25s ease; }
  .gen-card-head { align-items: flex-end; }
  .gen-card-user-message {
    display: flex; flex-direction: column; align-items: stretch;
    width: fit-content; max-width: 78%; padding: 8px;
    border-radius: 16px 16px 4px 16px; background: var(--accent);
  }
  .gen-card-user-message .gen-card-prompt-wrap { width: 100%; max-width: 100%; }
  .gen-card-prompt {
    max-width: 100%; padding: 4px 6px; border-radius: 0;
    background: transparent; color: #fff; font-weight: 400;
  }
  .gen-card-user-message .gen-card-references {
    width: 100%; max-width: 100%; margin: 0 0 6px; justify-content: flex-end;
  }
  .gen-card-user-message .gen-card-reference { border-color: rgba(255,255,255,.32); background: rgba(255,255,255,.12); }
  .gen-card-user-message .gen-card-reference figcaption { color: rgba(255,255,255,.88); }
  .gen-card-user-message .gen-card-prompt-toggle { color: #fff; opacity: .9; }
  .gen-card-followup-prompt {
    width: fit-content; max-width: 78%; margin: 14px 0 0 auto; padding: 10px 14px;
    border-radius: 16px 16px 4px 16px; background: var(--accent); color: #fff;
    line-height: 1.5; white-space: pre-wrap;
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
  }
  .gen-card-followup-prompt.is-expanded { display: block; -webkit-line-clamp: unset; overflow: visible; }
  .gen-card-meta { max-width: 78%; justify-content: flex-end; }
  .gen-card-time { margin-left: 0; }
  .gen-card .progress, .gen-card .status, .gen-card .log, .gen-card .gallery, .gen-card .gen-log-toggle {
    width: min(84%, 640px); margin-left: 0; margin-right: auto;
  }
  .gen-card .status { margin-top: 14px; }
  .gen-card .gallery { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
  .gen-card.is-history { padding: 0; background: transparent; }
  .gen-card.is-history .gen-card-prompt { color: #fff; font-weight: 400; }
  .image-card { border: 1px solid var(--line); box-shadow: none; }
  .result-actions { display: flex; flex-wrap: wrap; gap: 8px; grid-column: 1 / -1; width: 100%; margin: 2px auto 0 0; }
  .continue-btn {
    min-height: 34px; padding: 0 13px; border: 1px solid var(--line); border-radius: 10px;
    background: var(--surface); color: var(--text); font-size: 12.5px;
  }
  .continue-btn:hover { background: var(--surface-2); }

  /* ---------------- secondary views ---------------- */
  #viewTopup, #viewHistory, #viewKeys, #viewCanvas {
    flex: 0 0 auto; width: min(1120px, 100%); margin: 20px auto 0;
  }
  #viewTopup.hidden, #viewHistory.hidden, #viewKeys.hidden, #viewCanvas.hidden { display: none; }

  /* ---------------- sign-in ---------------- */
  .auth-layout { grid-template-columns: minmax(0, 1fr) minmax(400px, 500px); background: var(--bg); }
  .auth-context {
    margin: 16px; min-height: calc(100vh - 32px); padding: 34px clamp(26px, 5vw, 68px); border-radius: 26px;
    background: linear-gradient(145deg, #0a84ff 0%, #2167d9 52%, #143b91 100%);
    box-shadow: 0 18px 56px rgba(12, 76, 180, .2);
  }
  .auth-context::after { inset: 0; height: 100%; background: radial-gradient(circle at 78% 18%, rgba(255, 255, 255, .25), transparent 32%); }
  .auth-intro h1 { font-size: clamp(36px, 4.4vw, 58px); }
  .auth-side { padding: 42px; background: var(--bg); }
  .auth-panel { position: relative; overflow: hidden; padding: 34px; border: 1px solid var(--line); border-radius: 22px; background: var(--surface); box-shadow: var(--shadow); }
  .auth-panel::before { content: ""; position: absolute; inset: 0 0 auto; height: 3px; background: var(--accent); }
  .auth-panel-head { text-align: left; }
  .auth-tabs { padding: 3px; border-radius: 11px; background: var(--surface-2); }
  .auth-tab { min-height: 36px; border-radius: 9px; }
  .auth-panel input { min-height: 48px; background: var(--surface-2); box-shadow: inset 0 0 0 1px transparent; }
  .auth-panel input:hover { box-shadow: inset 0 0 0 1px var(--line); }
  .auth-panel .field label { color: var(--text); font-weight: 590; }
  .auth-panel .auth-note { border-top: 1px solid var(--line); padding-top: 16px; }
  .auth-submit { min-height: 48px; border-radius: 13px; }

  /* ---------------- tablet ---------------- */
  @media (max-width: 1080px) {
    :root { --nav-w: 224px; --stage-w: 760px; --composer-w: 680px; }
    .workspace { padding: 0 18px 14px; }
    .topbar { padding: 0 18px; }
    .topbar .wechat-chip { display: none; }
  }

  /* ---------------- phone / drawer ---------------- */
  @media (max-width: 860px) {
    :root { --stage-w: 100%; --composer-w: 100%; }
    .app-main { margin-left: 0; }
    .side-nav {
      width: min(300px, 86vw); transform: translateX(-102%);
      box-shadow: 20px 0 60px rgba(0, 0, 0, .28);
    }
    .app-shell.nav-open .side-nav { transform: translateX(0); }
    .app-shell.nav-open .nav-scrim { opacity: 1; pointer-events: auto; }
    .topbar { gap: 8px; padding: 0 12px; }
    .topbar > .brand { display: inline-flex; flex: 0 1 auto; overflow: hidden; }
    .topbar .brand-mark { width: 26px; height: 26px; flex-basis: 26px; }
    .topbar .brand-name { font-size: 15px; }
    .topbar .brand-sub { display: none; }
    .mobile-menu-btn {
      display: inline-grid; place-items: center; flex: 0 0 34px; width: 34px; height: 34px;
      padding: 0; border: 0; border-radius: 9px; background: transparent; color: var(--text); font-size: 18px;
    }
    .workspace-heading { display: none; }
    .topbar .docs-btn { display: none; }
    .topbar .credit-chip { padding: 4px 9px; font-size: 11px; }
    .workspace { padding: 0 12px 12px; }
    .retention-banner { margin-top: 10px; padding: 7px 10px; }
    .retention-copy > span { display: none; }
    .gen-feed, #viewGen .task-stage .gen-feed { gap: 20px; padding: 16px 0 12px; }
    .task-stage-empty strong { font-size: 24px; }
    .task-stage-empty span { font-size: 13px; }
    #viewGen .workspace-grid, #viewGen .task-stage .workspace-grid { flex: 0 0 auto; align-self: stretch; height: auto; min-height: 0; }
    #viewGen .tool-panel, #viewGen .task-stage .tool-panel { display: block; height: auto; min-height: 0; padding: 10px 12px 9px; border-radius: 18px; }
    #viewGen #prompt, #viewGen .task-stage #prompt { display: block; min-height: 46px; height: 46px; max-height: 44vh; margin: 0; overflow-y: auto; resize: vertical; }
    #viewGen .continue-banner { margin-bottom: 6px; padding: 6px 8px; gap: 6px; font-size: 11.5px; line-height: 1.35; }
    #viewGen .continue-banner button { flex: 0 0 auto; padding: 0 2px; font-size: 11.5px; white-space: nowrap; }
    .tool-actions, #viewGen .task-stage .tool-actions { flex-direction: row; align-items: center; }
    /* The desktop tool-actions selector is more specific than the mobile class.
       Keep the phone toolbar a real grid so controls cannot become 352px flex items. */
    #viewGen .task-stage .composer-parameter-bar {
      display: grid !important; grid-template-columns: repeat(4, minmax(0, 1fr));
      grid-auto-rows: auto; align-items: center; gap: 4px; margin-top: 6px; padding-top: 6px;
    }
    #viewGen .task-stage .composer-parameter-bar .composer-upload-trigger,
    #viewGen .task-stage .composer-parameter-bar .composer-param {
      min-width: 0; width: auto !important; max-width: 100%;
    }
    #viewGen .task-stage .composer-parameter-bar .composer-upload-trigger,
    #viewGen .task-stage .composer-parameter-bar .composer-param > summary {
      justify-content: center; width: 100%; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
    }
    .composer-parameter-bar .composer-upload-trigger span:last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .composer-parameter-bar .composer-param > summary > span { display: none; }
    .composer-parameter-bar .composer-param > summary b { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
    .composer-parameter-bar .composer-spacer, .composer-parameter-bar .tool-actions-copy { display: none; }
    #viewGen .task-stage .composer-parameter-bar .generate-btn {
      grid-column: 1 / -1; width: 100% !important; min-width: 0 !important;
      flex: none !important; min-height: 42px;
    }
    .composer-param-popover { left: auto; right: 0; }
    .composer-upload-trigger, .composer-param > summary { min-height: 32px; padding: 0 4px; font-size: 11px; }
    .composer-plus { flex: 0 0 auto; font-size: 17px; }
    .generate-btn, #viewGen .task-stage .generate-btn { flex: 1 1 auto; width: auto; min-width: 0; }
    #viewGen .prompt-presets { gap: 5px; margin-top: 8px; }
    #viewGen .prompt-chip { min-height: 28px; padding: 0 10px; font-size: 12px; }
    .recommended-strip { margin-top: 10px; padding: 8px 11px; }
    .recommended-strip span { display: none; }
    .gen-card-prompt, .gen-card .progress, .gen-card .status, .gen-card .log,
    .gen-card .gallery, .gen-card .gen-log-toggle, .result-actions { width: 100%; max-width: 100%; }
    .gen-card-prompt { max-width: 100%; }
    .gen-card-prompt-wrap { max-width: 90%; }
    .gen-card-references { width: 90%; }
    .gen-card .gallery { grid-template-columns: 1fr; }
    #viewTopup, #viewHistory, #viewKeys, #viewCanvas { margin-top: 14px; }
    .auth-layout { grid-template-columns: 1fr; }
    .auth-context { min-height: auto; margin: 10px; padding: 26px 22px; border-radius: 20px; }
    .auth-intro { padding: 28px 0 4px; }
    .auth-intro h1 { font-size: 32px; }
    .auth-intro > p { font-size: 14px; }
    .product-points, .landing-price { display: none; }
    .auth-side { padding: 18px 12px 34px; }
    .auth-panel { padding: 22px 18px; border-radius: 18px; }
  }
  @media (max-width: 480px) {
    body { font-size: 15px; }
    .topbar .brand-copy { display: none; }
    .topbar .credit-chip { font-size: 0; gap: 0; padding: 4px 9px; }
    .topbar .credit-chip::before { content: "余额"; margin-right: 5px; font-size: 11px; }
    .task-stage-empty strong { font-size: 21px; }
    .task-stage-empty span { font-size: 12.5px; }
    .workspace { padding-left: 8px; padding-right: 8px; }
    #viewGen .tool-panel, #viewGen .task-stage .tool-panel { padding-left: 10px; padding-right: 10px; border-radius: 14px; }
    .composer-param-popover { position: fixed; z-index: 80; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); width: auto; max-height: min(60vh, 420px); overflow-y: auto; }
    .wechat-group-card { padding: 18px; }
    .wechat-group-image-wrap { min-width: 0; min-height: 0; width: 100%; }
  }

  /* ---------------- compact mobile conversation shell ----------------
     Keep the phone view focused on one action: read the conversation, then
     send the next prompt. Desktop keeps the full workspace controls. */
  @media (max-width: 660px) {
    body { background: var(--bg); }
    .app-main { height: 100dvh; }
    .topbar {
      position: relative; justify-content: center; min-height: 72px;
      padding: env(safe-area-inset-top) 52px 4px; border-bottom: 0;
    }
    .topbar > .brand { display: none; }
    .mobile-menu-btn {
      position: absolute; left: 14px; bottom: 12px; width: 34px; height: 34px;
      font-size: 0; border-radius: 10px;
    }
    .mobile-menu-btn::before { content: "☰"; font-size: 23px; line-height: 1; }
    .workspace-heading {
      display: flex; flex-direction: column; align-items: center; justify-content: center;
      gap: 2px; width: 100%; margin: 0; text-align: center;
    }
    .workspace-heading h1 { font-size: 0; line-height: 1.2; }
    .workspace-heading h1::after { content: "新对话"; font-size: 21px; font-weight: 680; }
    .workspace-heading-actions { display: block; }
    .workspace-meta { display: block; max-width: 220px; font-size: 0; line-height: 1.3; }
    .workspace-meta::after { content: "内容由画境 AI 生成"; font-size: 13px; color: var(--muted-2); }
    .topbar-actions { position: absolute; right: 12px; bottom: 12px; gap: 4px; }
    .topbar .credit-chip, .topbar .wechat-chip, .topbar .credit-detail-link,
    .topbar .docs-btn, .topbar .theme-toggle { display: none; }
    .topbar .topup-btn { min-height: 32px; padding: 0 8px; border-radius: 9px; font-size: 12px; }
    .workspace { padding: 0 10px calc(8px + env(safe-area-inset-bottom)); }
    .retention-banner { display: flex; }
    #viewGen { min-height: 0; }
    .generation-layout { min-height: 0; }
    .task-stage, .task-stage.is-empty { justify-content: flex-start; }
    .gen-feed, #viewGen .task-stage .gen-feed {
      gap: 16px; padding: 8px 2px 18px; scroll-padding-bottom: 12px;
    }
    .task-stage.is-empty .gen-feed,
    #viewGen .task-stage.is-empty .gen-feed {
      display: flex; flex: 1 1 auto; justify-content: center;
      min-height: 0; overflow-y: auto; padding: 8px 2px 18px;
    }
    .task-stage-empty { padding: 0 0 14px; }
    .task-stage-empty strong { margin-bottom: 5px; font-size: 0; }
    .task-stage-empty strong::after { content: "新对话"; font-size: 28px; font-weight: 680; }
    .task-stage-empty span { font-size: 0; }
    .task-stage-empty span::after { content: "描述一张图片，开始创作"; font-size: 14px; color: var(--muted-2); }
    #viewGen .workspace-grid, #viewGen .task-stage .workspace-grid {
      position: sticky; bottom: 0; z-index: 24; display: flex; flex-direction: column;
      width: calc(100% + 20px); margin-left: -10px; padding: 8px 10px calc(4px + env(safe-area-inset-bottom));
      background: var(--bg); border-top: 1px solid var(--line);
    }
    #viewGen .prompt-presets,
    #viewGen > .recommended-strip {
      display: none;
    }
    /* Keep the prompt composer as the only bottom action on phones. */
    #viewGen .prompt-presets {
      order: -1; justify-content: flex-start; flex-wrap: nowrap; overflow-x: auto;
      width: calc(100% + 2px); margin: 0 0 7px; padding: 0 1px 2px; scrollbar-width: none;
    }
    #viewGen .prompt-presets::-webkit-scrollbar { display: none; }
    #viewGen .prompt-chip { flex: 0 0 auto; min-height: 30px; padding: 0 12px; background: var(--surface); }
    #viewGen .tool-panel, #viewGen .task-stage .tool-panel {
      width: 100%; padding: 9px 10px 8px; border-radius: 19px; box-shadow: 0 5px 18px rgba(31, 35, 41, .08);
    }
    #viewGen #prompt, #viewGen .task-stage #prompt {
      min-height: 46px; height: 46px; max-height: 44vh; padding: 5px 3px; font-size: 15px; resize: vertical; overflow-y: auto;
    }
    #viewGen .reference-panel { margin: 5px 0 0; padding: 7px 8px; }
    #viewGen .reference-preview { max-height: 84px; }
    #viewGen .reference-meta { font-size: 11px; }
    #viewGen .task-stage .composer-parameter-bar {
      grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 3px; margin-top: 5px; padding-top: 5px;
    }
    #viewGen .task-stage .composer-parameter-bar .composer-upload-trigger,
    #viewGen .task-stage .composer-parameter-bar .composer-param > summary {
      min-height: 31px; padding: 0 3px; border-radius: 8px; font-size: 11px;
    }
    #viewGen .task-stage .composer-parameter-bar .generate-btn {
      min-height: 42px; margin-top: 2px; border-radius: 12px; font-size: 14px;
    }
    #viewGen .image-only-notice { display: none; }
    #viewGen .gen-card-prompt { max-width: 90%; }
    #viewGen .gen-card .gallery { grid-template-columns: 1fr; }
  }

  .invite-card { max-width: 520px; }
  .invite-row {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 0; border-bottom: 1px dashed rgba(127,127,127,.25);
  }
  .invite-label { flex: 0 0 auto; font-size: 13px; color: var(--text-2); }
  .invite-code {
    font: 600 18px/1 var(--font-mono, monospace); letter-spacing: 2px;
    color: var(--accent, #0af); background: rgba(127,127,127,.12);
    padding: 6px 10px; border-radius: 8px;
  }
  .invite-link {
    flex: 1 1 auto; min-width: 0; font-size: 12px; color: var(--accent, #0af);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .invite-tip { font-size: 12px; color: var(--text-2); margin: 10px 0 4px; }
  .invite-sub { font-size: 13px; margin: 14px 0 6px; }
  .invite-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
  .invite-list li {
    font-size: 12px; color: var(--text-2);
    background: rgba(127,127,127,.08); padding: 6px 10px; border-radius: 8px;
  }
  .invite-list li.invite-none { color: var(--text-3, #999); background: transparent; }
  .invite-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 12px 0; }
  .invite-stat { padding: 10px; border-radius: 8px; background: var(--surface-2); }
  .invite-stat span { display: block; color: var(--text-2); font-size: 11px; }
  .invite-stat strong { display: block; margin-top: 3px; font-size: 17px; }
  .invite-rules { display: grid; gap: 4px; margin: 10px 0; color: var(--text-2); font-size: 12px; }
  .invite-transfer { display: grid; grid-template-columns: minmax(0, 1fr) 100px auto; gap: 8px; margin-top: 12px; }
  .invite-transfer input { min-width: 0; }
  .invite-status { color: var(--text-2); font-size: 11px; }
  .invite-status.ok { color: var(--ok, #38b87c); }
  .invite-status.pending { color: var(--text-3, #999); }
  @media (max-width: 560px) {
    .invite-stats { grid-template-columns: 1fr; }
    .invite-transfer { grid-template-columns: 1fr 1fr; }
    .invite-transfer button { grid-column: 1 / -1; }
  }
.ledger-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 14px; }
.ledger-card { padding: 12px 14px; border-radius: 10px; background: var(--surface-2); }
.ledger-card span { display: block; color: var(--muted); font-size: 12px; }
.ledger-card b { display: block; margin-top: 4px; font-size: 18px; }
.ledger-card b.in { color: var(--ok); }
.ledger-card b.out { color: var(--err); }
.ledger-filters { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.ledger-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ledger-chip { border: 0; cursor: pointer; padding: 5px 12px; border-radius: 999px; font-size: 12px; background: var(--surface-2); color: var(--muted); }
.ledger-chip.active { background: var(--accent); color: #fff; }
.ledger-range { display: flex; gap: 8px; align-items: center; }
.ledger-day-row td { background: var(--surface-2); color: var(--muted); font-size: 12px; font-weight: 600; }
.ledger-tag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; background: var(--surface-2); color: var(--muted); }
.ledger-amount.in { color: var(--ok); }
.ledger-amount.out { color: var(--err); }
.ledger-more { text-align: center; margin-top: 12px; }
.credit-detail-link { display: inline-flex; align-items: center; min-height: 30px; padding: 0 10px; border-radius: 8px; background: var(--surface-2); color: var(--accent); font-size: 13px; text-decoration: none; }
  /* 登录页的微信号、微信群、忘记密码只有 19-22px 高，手机上很难点中。
     用透明伪元素把可点区域扩到约 44px，文字大小和排版都不变。 */
  #authView .link-btn, #authView .auth-wechat button { position: relative; }
  #authView .link-btn::after, #authView .auth-wechat button::after {
    content: ""; position: absolute; inset: -12px -4px;
  }
  .password-toggle { min-height: 36px; }
  /* 系统开启「减少动态效果」时关掉动画，加载转圈保留，否则用户看不出在处理中。 */
  @media (prefers-reduced-motion: reduce) {
    *:not(.spinner), *::before, *::after {
      animation-duration: .01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: .01ms !important;
      scroll-behavior: auto !important;
    }
  }
  /* Parameter popovers used 10-11px labels; too small to read on a phone. */
  .composer-param-popover .pill { font-size: 12px; }
  .custom-ratio-hint { font-size: 12px; }
  @media (max-width: 480px) {
    .composer-param-popover .pill { font-size: 13px; min-height: 36px; }
    .composer-param-popover .section-label { font-size: 12px; }
  }
  /* Canvas zoom buttons are 26px; widen the touch area without changing the look. */
  .canvas-zoom-btn { position: relative; }
  .canvas-zoom-btn::after { content: ""; position: absolute; inset: -8px -3px; }
.video-layout { display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 16px; align-items: start; }
.video-panel, .video-info-panel, .video-history-panel { border-radius: var(--radius); }
.video-panel > textarea { display: block; width: 100%; min-height: 150px; resize: vertical; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text); }
.creation-type-switch { display: inline-flex; gap: 4px; margin: 0 0 10px; padding: 3px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-2); }
.creation-type-switch .pill { min-width: 68px; min-height: 30px; justify-content: center; padding: 0 12px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 12px; }
.creation-type-switch .pill.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(31, 35, 41, .12); }
.video-options { display: contents; }
#viewGen #videoPaddingPanel > summary > span { display:inline; }
#viewGen #videoPaddingPanel.is-enabled > summary { border-color:var(--accent);background:var(--accent-soft); }
.video-padding-popover { width:320px;max-width:calc(100vw - 20px);max-height:min(70vh,420px);overflow-y:auto;padding:12px; }
.video-padding-controls { display:flex;align-items:center;justify-content:space-between;gap:10px;font-size:12px; }
.video-padding-controls label { display:inline-flex;align-items:center;gap:7px;cursor:pointer;color:var(--text);font-weight:550; }
.video-padding-default { margin-left:auto;color:var(--muted);font-size:11px; }
.video-padding-close { display:grid;place-items:center;flex:0 0 24px;width:24px;min-height:24px;padding:0;border:0;border-radius:6px;background:transparent;color:var(--muted);font-size:18px;cursor:pointer; }
.video-padding-close:hover { background:var(--surface-2);color:var(--text); }
#viewGen .video-padding-controls input[type="checkbox"] { appearance:none;display:block;flex:0 0 30px;width:30px;height:18px;min-height:0;margin:0;padding:2px;border:0;border-radius:999px;background:var(--line-strong);box-shadow:none;cursor:pointer; }
#viewGen .video-padding-controls input[type="checkbox"]::before { content:"";display:block;width:14px;height:14px;border-radius:50%;background:#fff;box-shadow:0 1px 3px rgba(0,0,0,.15);transition:transform .15s ease; }
#viewGen .video-padding-controls input[type="checkbox"]:checked { background:var(--accent); }
#viewGen .video-padding-controls input[type="checkbox"]:checked::before { transform:translateX(12px); }
#viewGen .video-padding-controls input[type="checkbox"]:focus-visible { outline:2px solid var(--accent);outline-offset:3px; }
.video-padding-purpose { margin:10px 0 0;color:var(--text);font-size:12px;line-height:1.65; }
.video-padding-mode-row { display:flex;align-items:center;gap:8px;margin-top:10px;color:var(--muted);font-size:12px; }
.video-padding-mode-row select { flex:1;min-width:0;height:30px;margin:0;padding:4px 8px;border:1px solid var(--line);border-radius:7px;background:var(--surface);color:var(--text);font:inherit; }
#viewGen #videoPaddingColor { flex:0 0 30px;width:30px;height:28px;min-height:0;padding:2px;border:1px solid var(--line);border-radius:6px;background:var(--surface);cursor:pointer; }
#viewGen #videoPaddingExplanation { display:block;margin:8px 0 0;color:var(--muted);font-size:11px;line-height:1.6; }
#viewGen #videoPaddingHint { display:block;margin:7px 0 0;color:var(--muted);font-size:11px;line-height:1.5; }
.video-padding-preview-toggle { margin-top:10px;border-top:1px solid var(--line);padding-top:8px; }
.video-padding-preview-toggle > summary { width:fit-content;color:var(--accent);font-size:12px;cursor:pointer; }
.video-padding-preview-toggle > summary::marker { font-size:10px; }
.video-padding-comparison { display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;margin-top:8px; }
.video-padding-comparison figure { margin:0;min-width:0; }
.video-padding-comparison figcaption { margin-bottom:5px;color:var(--muted);font-size:11px; }
.video-padding-comparison img,.video-padding-comparison canvas { display:block;width:100%;height:112px;object-fit:contain;border-radius:7px;background-color:#eee;background-image:linear-gradient(45deg,#ddd 25%,transparent 25%),linear-gradient(-45deg,#ddd 25%,transparent 25%),linear-gradient(45deg,transparent 75%,#ddd 75%),linear-gradient(-45deg,transparent 75%,#ddd 75%);background-size:16px 16px;background-position:0 0,0 8px,8px -8px,-8px 0; }
@media (min-width:481px) { .video-padding-popover { left:auto;right:0; } }
@media (max-width:480px) { .video-padding-popover { width:auto;max-width:none; } }
#viewGen .task-stage .composer-parameter-bar { display: flex !important; flex-wrap: wrap; gap: 6px; margin-top: 8px; padding-top: 10px; }
.composer-select { display: inline-flex; align-items: center; gap: 4px; min-height: 34px; min-width: 0; padding: 0 4px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--muted); font-size: 12px; }
.composer-select select { width: auto; min-width: 0; min-height: 32px; height: 32px; margin: 0; padding: 0 5px 0 2px; border: 0; border-radius: 7px; background-color: transparent; color: var(--text); font: inherit; font-weight: 550; cursor: pointer; }
.composer-select:focus-within { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.composer-select select:focus { outline: none; box-shadow: none; }
.composer-select option { background: var(--surface); color: var(--text); }
.composer-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 12px; }
.composer-footer-copy { display: grid; gap: 3px; min-width: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.composer-keyboard-hint { color: var(--muted); font-size: 11px; }
.video-price-hint { color: var(--text); font-variant-numeric: tabular-nums; }
.video-reference-panel { margin: 8px 0 0; padding: 10px; border-radius: 12px; background: var(--surface-2); }
.video-reference-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 12px; }
.video-reference-feedback { margin: 7px 0 0; color: var(--warn); font-size: 12px; line-height: 1.5; }
.video-reference-feedback:empty { display: none; }
.reference-clear-all { flex: 0 0 auto; border: 0; padding: 4px 5px; border-radius: 6px; background: transparent; color: var(--muted); font: inherit; cursor: pointer; }
.reference-clear-all:hover { color: var(--err); background: var(--surface); }
.video-ref-row, .video-submit-row { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.video-ref-row > span, .video-submit-row .field-hint { color: var(--muted); font-size: 12px; }
.video-reference-preview { display: flex; flex-wrap: nowrap; gap: 8px; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x proximity; padding: 3px 3px 7px; margin-top: 6px; }
.video-reference-item { position: relative; flex: 0 0 76px; width: 76px; padding: 4px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); scroll-snap-align: start; }
.video-reference-item img { display: block; width: 66px; height: 62px; border-radius: 6px; object-fit: cover; }
.video-reference-item .reference-name { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 10px; padding-top: 3px; }
.video-reference-item .reference-clear { width: 25px; height: 25px; top: 0; right: 0; background: #424855; font-size: 17px; cursor: pointer; }
.video-reference-add { display: flex; flex: 0 0 76px; min-height: 91px; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: 1px dashed var(--line-strong); border-radius: 10px; color: var(--accent); font-size: 11px; cursor: pointer; }
.video-reference-add span:first-child { font-size: 24px; }
.video-result { display: grid; justify-items: start; gap: 10px; margin-top: 18px; }
.video-result video { display: block; width: min(100%, 760px); max-height: 70vh; border-radius: 14px; background: #000; }
.video-history-panel { margin-top: 16px; padding: 16px; }
.task-list-kind { color: var(--accent); font-weight: 600; }
.task-list-state.queued { color: var(--warn); }
.video-cost-matrix { margin-top: 16px; padding: 16px; }
.video-cost-matrix .table-scroll { overflow-x: auto; }
.video-cost-matrix table { min-width: 420px; }
.video-cost-note { margin: 10px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.video-history-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.video-history-card { min-width: 0; padding: 10px; border-radius: 12px; background: var(--surface-2); }
.video-history-card video { display: block; width: 100%; aspect-ratio: 16 / 9; border-radius: 8px; background: #000; object-fit: contain; }
.video-history-card p { margin: 8px 0 4px; overflow-wrap: anywhere; font-size: 13px; }
.video-history-card small { color: var(--muted); }
@media (max-width: 860px) { .video-layout { grid-template-columns: 1fr; } }
@media (max-width: 560px) { .video-history-grid { grid-template-columns: 1fr; } }
/* Shared creation and page controls. Both media types use the same editor. */
#viewGen .tool-panel:focus-within { border-color: var(--line-strong); }
#viewGen .tool-panel.is-dragging-files { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
#viewGen .reference-preview { max-height: 184px; overflow-y: auto; width: 100%; }
#viewGen .task-stage.is-empty { justify-content: safe center; padding: 28px 0; }
#viewGen .task-stage-empty strong { font-size: clamp(23px, 2.4vw, 30px); }
.task-stage.new-task-mode .gen-feed { flex: 0 0 auto !important; }
#viewGen .composer-parameter-bar .composer-upload-trigger,
#viewGen .composer-parameter-bar .composer-param > summary { min-height: 34px; width: auto; padding: 0 8px; border: 1px solid var(--line); background: var(--surface); }
#viewGen .composer-param { width: auto !important; }
#viewGen .composer-param > summary > span { display: inline; }
#viewGen .composer-footer .generate-btn { min-width: 158px; min-height: 39px; white-space: nowrap; }
.panel-description { margin: -4px 0 14px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.history-filter { max-width: 140px; min-height: 34px; padding: 5px 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; font-size: 12px; }
.video-history-card { border: 1px solid var(--line); background: var(--surface); padding: 12px; }
.video-history-card small { display: block; line-height: 1.6; }
.video-history-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 9px; }
.video-history-actions a { color: var(--accent); text-decoration: none; font-size: 12px; padding: 6px 8px; border-radius: 7px; background: var(--accent-soft); }
.video-history-actions .ghost-btn { min-height: 30px; padding: 0 8px; font-size: 12px; }
button:focus-visible, a:focus-visible, summary:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
@media (max-width: 860px) {
  .side-nav { box-shadow: none; visibility: hidden; }
  .app-shell.nav-open .side-nav { visibility: visible; box-shadow: 20px 0 60px rgba(0, 0, 0, .28); }
  #viewGen .composer-parameter-bar .composer-upload-trigger { width: auto !important; }
  #viewGen .task-stage.is-empty { padding: 18px 0; }
  .composer-select { min-height: 36px; }
  .composer-select select { min-height: 34px; height: 34px; }
}
@media (min-width: 861px) {
  .app-shell.nav-collapsed .side-nav { transform: translateX(-102%); visibility: hidden; }
  .app-shell.nav-collapsed .app-main { margin-left: 0; }
  .app-shell.nav-collapsed .mobile-menu-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; flex: 0 0 34px; padding: 0; border: 0; border-radius: 8px; background: var(--surface-2); color: var(--text); font-size: 18px; }
}
@media (max-width: 660px) {
  .workspace-heading h1 { font-size: 19px; }
  .workspace-heading h1::after, .workspace-meta::after, .task-stage-empty strong::after, .task-stage-empty span::after { content: none; }
  .workspace-meta { font-size: 11px; }
  #viewGen .task-stage-empty strong { font-size: 24px; }
  .task-stage-empty span { font-size: 12px; line-height: 1.6; }
  #viewGen .task-stage.is-empty .gen-feed { flex: 0 0 auto; justify-content: center; overflow: visible; }
  #viewGen .task-stage.is-empty { justify-content: safe center; padding: 20px 0; }
  #viewGen .task-stage.is-empty .workspace-grid { position: static; width: 100%; margin-left: 0; padding: 0; }
  #viewGen .task-stage .composer-parameter-bar { gap: 6px; }
  #viewGen .composer-parameter-bar .composer-param > summary { padding: 0 7px; font-size: 12px; }
  #viewGen .composer-param > summary > span { display: none; }
  .composer-footer { flex-wrap: wrap; gap: 9px; }
  .composer-footer-copy { flex: 1 1 100%; }
  #viewGen .composer-footer .generate-btn { width: 100%; min-height: 42px; }
  .composer-keyboard-hint { display: none; }
  .video-reference-preview { max-height: 150px; }
  .panel-toolbar { flex-wrap: wrap; gap: 8px; }
}
/* Responsive navigation and shared page layout. */
.side-nav { overflow-y: auto; overscroll-behavior: contain; padding-bottom: calc(13px + env(safe-area-inset-bottom)); }
.side-nav-head, .view-tabs, .side-nav-foot { flex-shrink: 0; }
.side-group { min-height: 76px; }
.nav-collapse-btn { display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; min-height: 36px; margin: 0 0 10px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--muted); font: inherit; font-size: 12px; }
.nav-collapse-btn svg { width: 16px; height: 16px; }
.nav-collapse-btn:hover { color: var(--text); background: var(--surface-2); }
.nav-expand-label { font-size: 12px; white-space: nowrap; }
.panel-head, .panel-toolbar-actions { flex-wrap: wrap; }
.panel-head h2, .panel-toolbar h2 { min-width: 0; }
.panel-toolbar-actions { max-width: 100%; }
.panel-toolbar-actions select { min-width: 0; max-width: 100%; }
.panel-toolbar-actions button, .ledger-range button { flex-shrink: 0; white-space: nowrap; }
.key-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.key-form #keyLabel { grid-column: 1 / -1; }
.key-form #createKeyBtn { grid-column: 1 / -1; justify-self: end; min-width: 128px; }
#viewKeys .code-snippet { max-height: 340px; overflow: auto; overscroll-behavior: contain; }
.ledger-range select { width: 140px !important; min-width: 0; }
.ledger-range button { min-height: 40px; }
.skill-item-head { align-items: flex-start; flex-wrap: wrap; }
.skill-item-head h4 { min-width: 0; overflow-wrap: anywhere; }
.skill-meta, .skill-desc, .skill-readme { overflow-wrap: anywhere; }
.plugin-panel .skill-intro { margin: 16px 0 20px; max-width: 760px; }
.plugin-panel { margin-top: 16px; }
.app-shell:is([data-active-view="topup"], [data-active-view="ledger"], [data-active-view="keys"], [data-active-view="plugins"]) .retention-banner { display: none; }
.app-shell:is([data-active-view="topup"], [data-active-view="ledger"], [data-active-view="keys"]) .workspace { padding-top: 16px; }
.skill-modal, .announcement-modal, .wechat-group-modal, .qr-modal { z-index: 90; padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
.skill-card, .announcement-card, .wechat-group-card, .qr-card { max-height: calc(100dvh - 32px); overflow-y: auto; overscroll-behavior: contain; }
.skill-modal-head, .wechat-group-head { position: sticky; top: 0; z-index: 1; padding-bottom: 8px; background: var(--surface); }
.workspace { scrollbar-gutter: stable; }
@media (min-width: 861px) {
  .app-shell.nav-collapsed .mobile-menu-btn { display: inline-flex; gap: 6px; width: auto; flex: 0 0 auto; padding: 0 10px; min-height: 36px; }
}
@media (min-width: 861px) and (max-width: 1190px) {
  .topbar .wechat-chip, .topbar .credit-detail-link { display: none; }
  .workspace-meta { display: none; }
  .workspace-heading h1 { white-space: nowrap; }
}
@media (max-width: 860px) {
  .nav-expand-label { display: none; }
  .nav-collapse-btn { min-height: 44px; font-size: 13px; }
  .view-tab { min-height: 42px; }
  .panel-toolbar-actions { gap: 6px; }
  .ledger-chip { min-height: 34px; }
  .canvas-toolbar-actions { gap: 6px; }
  .canvas-toolbar-actions > button { min-height: 40px; padding: 0 10px; white-space: nowrap; }
  .skill-item-actions a { min-height: 42px; }
}
@media (max-width: 660px) {
  .topbar { display: grid; grid-template-columns: 40px minmax(0, 1fr); grid-template-rows: auto auto; align-content: center; justify-content: stretch; row-gap: 8px; min-height: calc(102px + env(safe-area-inset-top)); padding: calc(10px + env(safe-area-inset-top)) 12px 10px; }
  .mobile-menu-btn { position: static; grid-column: 1; grid-row: 1; width: 40px; height: 40px; }
  .mobile-menu-btn > span[aria-hidden] { display: none; }
  .workspace-heading { grid-column: 2; grid-row: 1; align-items: flex-start; text-align: left; width: auto; }
  .workspace-heading h1 { font-size: 18px; }
  .workspace-meta { font-size: 11px; }
  .topbar-actions { position: static; grid-column: 1 / -1; grid-row: 2; justify-content: flex-end; flex-wrap: nowrap; margin: 0; gap: 6px; }
  .topbar .credit-chip { display: inline-flex; margin-right: auto; min-height: 32px; font-size: 0; gap: 5px; padding: 4px 9px; }
  .credit-label { display: none; }
  .topbar .credit-chip::before { content: "余额"; margin: 0; font-size: 11px; }
  .topbar .credit-chip::after { content: "分"; font-size: 11px; }
  .topbar .theme-toggle { display: inline-flex; min-width: 32px; min-height: 32px; padding: 0 7px; }
  .theme-toggle-label { display: none; }
  .topbar .wechat-group-chip { min-height: 32px; padding: 0 10px; }
  .table-panel, .redeem-panel { padding: 16px; }
  .panel-head { align-items: flex-start; gap: 8px; }
  .panel-head h2, .panel-toolbar h2 { font-size: 18px; }
  .panel-head .panel-toolbar-actions { margin-left: auto; }
  .ledger-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .ledger-card { padding: 12px; }
  .ledger-range { width: 100%; justify-content: flex-end; }
  #ledgerTable .ledger-day-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px; margin: 10px 0; border: 0; border-radius: 8px; background: var(--surface-2); }
  #ledgerTable .ledger-day-row td { display: block; padding: 0; border: 0; text-align: left; flex: 0 1 auto; }
  #ledgerTable .ledger-day-row td::before { display: none; }
  #ledgerTable .ledger-day-row td:last-child { white-space: nowrap; text-align: right; }
  .new-key { flex-wrap: wrap; }
  .new-key code { overflow-wrap: anywhere; }
  .key-form { grid-template-columns: minmax(0, 1fr); }
  .key-form #createKeyBtn { width: 100%; }
}
@media (min-width: 661px) and (max-width: 860px) {
  .topbar > .brand { display: none; }
  .workspace-heading { display: flex; min-width: 0; }
  .workspace-heading h1 { font-size: 17px; white-space: nowrap; }
  .workspace-heading-actions { display: none; }
  .topbar .credit-detail-link { display: none; }
}
/* Compact API key page and native, keyboard-accessible dialogs. */
.keys-panel { padding:22px;border:1px solid var(--line);border-radius:var(--radius);background:var(--surface); }
.keys-panel > .status:empty { display:none; }
.keys-header { display:flex;align-items:flex-start;justify-content:space-between;gap:16px;flex-wrap:wrap; }
.keys-header h2 { margin:0;font-size:20px;font-weight:650; }
.keys-header p { margin:6px 0 0;color:var(--muted);font-size:13px;line-height:1.6; }
.keys-header-actions { display:flex;align-items:center;gap:8px; }
.keys-header-actions button { min-height:36px;padding:0 12px;font-size:13px;white-space:nowrap; }
.keys-count { margin-left:7px;color:var(--muted);font-size:13px;font-weight:400; }
.keys-list { display:grid;gap:10px;margin-top:16px; }
.keys-empty { padding:32px 12px;border:1px dashed var(--line);border-radius:12px;color:var(--muted);text-align:center;font-size:13px; }
.keys-card { display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;gap:16px;padding:14px;border:1px solid var(--line);border-radius:12px;background:var(--bg-elevated); }
.keys-card-copy { min-width:0; }
.keys-card-heading { display:flex;align-items:center;gap:8px;min-width:0; }
.keys-card-heading h3 { margin:0;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:14px;font-weight:600; }
.keys-state { flex:0 0 auto;padding:2px 6px;border-radius:5px;background:var(--surface-2);color:var(--muted);font-size:10px; }
.keys-state.active { color:var(--ok);background:color-mix(in srgb,var(--ok) 9%,transparent); }
.keys-masked { display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;margin-top:7px;color:var(--muted);font-size:12px; }
.keys-meta { display:flex;align-items:center;gap:6px 10px;flex-wrap:wrap;margin-top:8px;color:var(--muted);font-size:11px;line-height:1.5; }
.keys-calls-link { min-height:20px;padding:0;border:0;background:transparent;color:var(--accent);font:inherit;cursor:pointer; }
.keys-actions { display:flex;gap:7px; }
.keys-actions button { min-width:62px;min-height:36px;padding:0 12px;border:1px solid var(--line);border-radius:8px;background:var(--surface);color:var(--text);font-size:12px;cursor:pointer; }
.keys-actions button:last-child { color:var(--accent);background:var(--accent-soft);border-color:transparent; }
.keys-actions button:disabled { opacity:.45;cursor:default; }
.keys-footer { margin:16px 0 0;color:var(--muted);font-size:12px;line-height:1.6; }
.keys-footer a { color:var(--accent); }
.key-dialog { width:min(500px,calc(100vw - 32px));max-width:none;max-height:min(760px,calc(100dvh - 32px));margin:auto;padding:0;border:1px solid var(--line);border-radius:18px;background:var(--surface);color:var(--text);box-shadow:var(--shadow); }
.key-dialog[open] { display:flex;flex-direction:column; }
.key-dialog::backdrop { background:var(--scrim);backdrop-filter:blur(4px); }
.key-dialog-head { display:flex;align-items:center;justify-content:space-between;gap:12px;padding:18px 20px 12px;flex:0 0 auto; }
.key-dialog-head h2 { margin:0;font-size:18px;font-weight:650; }
.key-dialog-close { display:grid;place-items:center;flex:0 0 30px;width:30px;min-height:30px;padding:0;border:0;border-radius:8px;background:var(--surface-2);color:var(--muted);font-size:19px;cursor:pointer; }
.key-dialog-body { min-height:0;overflow:auto;overscroll-behavior:contain;padding:0 20px 20px; }
.key-dialog-intro { margin:0 0 16px;color:var(--muted);font-size:13px;line-height:1.65; }
.key-create-form { display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px 12px; }
.key-create-field { display:grid;gap:6px;min-width:0;color:var(--muted);font-size:12px; }
.key-create-field:first-child { grid-column:1 / -1; }
.key-create-field input,.key-create-field select { width:100%;min-width:0;min-height:40px;margin:0;padding:8px 10px;border:1px solid var(--line);border-radius:8px;background:var(--surface-2);color:var(--text);font:inherit;font-size:13px; }
.key-dialog-foot { display:flex;justify-content:flex-end;align-items:center;gap:8px;padding:12px 20px;border-top:1px solid var(--line);flex:0 0 auto; }
.key-dialog-foot button { min-height:38px;padding:0 16px;font-size:13px; }
.key-dialog .status:empty { display:none; }
.key-secret-value { display:block;resize:none;min-height:84px;height:84px;width:100%;padding:12px;border:1px solid var(--line);border-radius:10px;background:var(--surface-2);color:var(--text);font:13px/1.6 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;overflow-wrap:anywhere; }
.key-secret-label { display:block;margin-bottom:7px;color:var(--muted);font-size:12px; }
.key-secret-name { overflow-wrap:anywhere; }
.key-legacy { margin:0 0 16px; }
.key-legacy p { color:var(--muted);font-size:13px;line-height:1.6; }
.key-legacy button { margin-top:8px;min-height:36px;font-size:12px; }
.key-details { margin-top:16px;padding-top:12px;border-top:1px solid var(--line); }
.key-details > summary { color:var(--muted);font-size:12px;cursor:pointer; }
.key-details dl { display:grid;grid-template-columns:76px minmax(0,1fr);gap:8px;margin:14px 0;color:var(--muted);font-size:12px;line-height:1.5; }
.key-details dt,.key-details dd { margin:0;overflow-wrap:anywhere; }
.key-details dd { color:var(--text); }
.key-revoke { min-height:34px;padding:0 10px;border:1px solid var(--line);border-radius:7px;background:transparent;color:var(--err);font-size:12px;cursor:pointer; }
.key-calls-dialog { width:min(960px,calc(100vw - 32px)); }
.key-calls-toolbar { display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-bottom:12px; }
.key-calls-toolbar select { flex:1;min-width:0;min-height:36px;padding:6px 9px;border:1px solid var(--line);border-radius:8px;background:var(--surface-2);color:var(--text);font-size:12px; }
.key-calls-toolbar button { min-height:36px;padding:0 12px;font-size:12px; }
.key-calls-dialog .call-summary { margin:0 0 10px;font-size:12px;line-height:1.6; }
.key-calls-dialog .speed-summary { margin:0 0 12px; }
.key-calls-dialog #callTable { width:100%;min-width:0;font-size:12px; }
.key-calls-dialog #callTable td { overflow-wrap:anywhere; }
.key-calls-dialog #callTable th,.key-calls-dialog #callTable td { padding:10px 8px; }
.key-calls-shown { margin:12px 0 0;color:var(--muted);font-size:11px; }
@media (max-width:660px) {
  .keys-panel { padding:14px; }
  .keys-header { gap:12px; }
  .keys-header h2 { font-size:18px; }
  .keys-header-actions { width:100%; }
  .keys-header-actions button { flex:1;min-height:40px; }
  .keys-card { grid-template-columns:minmax(0,1fr);gap:12px;padding:13px; }
  .keys-actions { justify-content:flex-end; }
  .keys-actions button { min-height:40px;min-width:78px; }
  .keys-calls-link { min-height:30px; }
  .key-dialog,.key-calls-dialog { width:calc(100vw - 20px);max-height:calc(100dvh - 20px);border-radius:14px; }
  .key-dialog-head { padding:16px 14px 12px; }
  .key-dialog-body { padding:0 14px 16px; }
  .key-dialog-foot { padding:12px 14px; }
  .key-dialog-foot button { min-height:42px; }
  .key-create-form { grid-template-columns:minmax(0,1fr); }
  .key-create-field input,.key-create-field select { min-height:44px; }
  .key-calls-dialog .table-scroll { overflow-x:visible; }
  .key-calls-dialog #callTable,.key-calls-dialog #callTable tbody,.key-calls-dialog #callTable tr,.key-calls-dialog #callTable td { display:block; }
  .key-calls-dialog #callTable thead { display:none; }
  .key-calls-dialog #callTable tr { padding:12px 0;border-bottom:1px solid var(--line); }
  .key-calls-dialog #callTable td { display:flex;align-items:baseline;justify-content:space-between;gap:12px;padding:3px 0;text-align:right;border:0;font-size:12px; }
  .key-calls-dialog #callTable td::before { content:attr(data-label);flex:0 0 auto;color:var(--muted);font-size:12px; }
  .key-calls-dialog #callTable td.empty-row { display:block;text-align:center; }
  .key-calls-dialog #callTable td.empty-row::before { display:none; }
}
