:root {
  --paper-grain: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22768%22%20height%3D%22512%22%20viewBox%3D%220%200%20768%20512%22%3E%3Cfilter%20id%3D%22paper%22%20x%3D%220%22%20y%3D%220%22%20width%3D%22100%25%22%20height%3D%22100%25%22%3E%3CfeTurbulence%20type%3D%22fractalNoise%22%20baseFrequency%3D%22.20%20.27%22%20numOctaves%3D%223%22%20seed%3D%2212%22%20stitchTiles%3D%22stitch%22%20result%3D%22grain%22%2F%3E%3CfeDiffuseLighting%20in%3D%22grain%22%20surfaceScale%3D%22.85%22%20diffuseConstant%3D%221%22%20lighting-color%3D%22%23fffdf7%22%3E%3CfeDistantLight%20azimuth%3D%22225%22%20elevation%3D%2260%22%2F%3E%3C%2FfeDiffuseLighting%3E%3C%2Ffilter%3E%3Cpath%20fill%3D%22%23f7f4ec%22%20filter%3D%22url%28%23paper%29%22%20d%3D%22M0%200h768v512H0z%22%2F%3E%3C%2Fsvg%3E");
  --paper: #f6f3ec;
  --surface: #faf8f3;
  --surface-alt: #efeae0;
  --ink: #171614;
  --muted: #5c574f;
  --line: #dfd9cc;
  --line-strong: #b9b1a1;
  --accent: #b93a2b;
  --accent-hover: #962b1e;
  --wash: #f3e8e3;
  --danger: #b42318;
  --backdrop: rgba(23, 22, 20, .44);
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 14px;
  --shadow-dialog: 0 24px 72px rgba(23, 22, 20, .18);
  --shadow-card: 0 8px 24px rgba(23, 22, 20, .06);
  --sans: "Helvetica Neue", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  --display: "Changxi Display", "Noto Serif SC", "Songti SC", SimSun, serif;
  scrollbar-gutter: stable;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 15px/1.85 var(--sans); min-height: 100vh; }
/* Paper belongs to the document, so its fibers scroll with the printed content. */
body::before, #login-dialog::before, .knowledge-dialog::before { content: ""; position: absolute; inset: 0; pointer-events: none; z-index: -1; background: var(--paper-grain) repeat; background-size: 768px 512px; opacity: var(--paper-grain-opacity, .32); mix-blend-mode: multiply; }
body { position: relative; isolation: isolate; }
::selection { background: #b8322926; color: var(--ink); }
textarea { caret-color: var(--accent); }
button, textarea { font: inherit; color: inherit; }
button { min-height: 44px; cursor: pointer; border: 0; background: transparent; padding: 8px 12px; border-radius: 3px; transition: background .16s ease, color .16s ease, border-color .16s ease; }
button:hover { background: var(--surface-alt); }
button:disabled { opacity: .35; cursor: default; }
button:focus-visible, textarea:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
[hidden] { display: none !important; }
h1, h2, p { margin: 0; }

header { height: 68px; max-width: 1192px; margin: auto; padding: 0 36px; display: flex; align-items: center; justify-content: space-between; }
.brand { height: 76px; width: 76px; object-fit: contain; mix-blend-mode: multiply; }
.header-actions { display: flex; align-items: center; gap: 23px; }
.preview-label { font-size: 11px; color: var(--muted); letter-spacing: .1em; }
.new-chat { display: flex; align-items: center; gap: 9px; padding: 8px 0 8px 16px; border-radius: 0; border-left: 1px solid var(--line); font-size: 12px; }
.new-chat svg { width: 16px; height: 16px; }

main { width: min(1040px, calc(100% - 72px)); margin: 30px auto 32px; }
.intro { --hero-size: clamp(68px, 8.2vw, 112px); display: grid; grid-template-columns: minmax(0, 1fr) 172px; align-items: end; gap: 36px; margin: 0 0 35px; }
.intro-copy { min-width: 0; }
.continue-work { display: block; max-width: 100%; color: var(--accent); text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.intro .eyebrow { color: var(--muted); font-size: 11px; letter-spacing: .09em; margin-bottom: 28px; }
h1 { font-family: var(--sans); font-weight: 500; }
.title-lead { display: block; font-size: 18px; line-height: 1.5; font-weight: 400; letter-spacing: .14em; margin-bottom: 7px; }
.title-tail { display: flex; align-items: baseline; width: max-content; max-width: 100%; font-size: var(--hero-size); line-height: 1.16; white-space: nowrap; }
.title-solid { font-weight: 600; letter-spacing: -.075em; }
.title-emphasis { font-family: var(--display); font-weight: 400; letter-spacing: -.085em; margin-left: .045em; transform: translateY(.055em); }
.title-question { color: var(--accent); font-family: var(--display); font-size: .92em; font-weight: 400; line-height: 1; margin-left: .035em; transform: translateY(-.16em); }

.composer { position: relative; width: 100%; margin: 0 auto; background: var(--paper); border: 0; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--line); border-radius: 0; padding: 24px 0 16px; box-shadow: none; z-index: 2; }
.composer:focus-within { border-top-color: var(--accent); border-bottom-color: var(--ink); box-shadow: none; }
.composer textarea { display: block; width: 100%; min-height: 78px; max-height: 220px; resize: vertical; border: 0; outline: none; background: transparent; line-height: 1.9; padding: 0; font-size: 16px; }
.composer textarea::placeholder { color: var(--muted); }
.composer textarea:focus-visible { outline: none; }
.composer:has(textarea:focus-visible) { outline: 2px solid var(--ink); outline-offset: 6px; }
.composer-bottom { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 9px; }
.composer-hint { font-size: 12px; color: var(--muted); }
.send { background: var(--ink); color: #fff; width: 46px; height: 46px; display: grid; place-items: center; border-radius: 0; padding: 0; flex: none; }
.send:hover { background: var(--accent); }
.send svg { width: 22px; height: 22px; }
.calendar-toggle { font-size: 12px; display: flex; gap: 8px; align-items: center; padding-left: 0; }
.calendar-toggle svg { width: 17px; height: 17px; }
.reply-target { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 12px; border-bottom: 1px solid var(--line); margin: -8px 0 13px; padding: 0 0 4px; }
.reply-target button { width: 44px; padding: 8px; }

.calendar { margin-top: 44px; padding: 0; }
.calendar-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 15px; padding-top: 0; }
.calendar-head h2 { font-size: 16px; font-weight: 400; display: flex; align-items: baseline; gap: 16px; }
.calendar-head .calendar-month { order: -1; font: 500 52px/1.1 var(--sans); letter-spacing: -.075em; }
.calendar-month .month-unit { font: 400 15px/1 var(--sans); letter-spacing: 0; margin-left: 9px; }
.calendar-year { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.calendar-count { font-size: 12px; color: var(--muted); padding-left: 16px; border-left: 1px solid var(--line); }
.month-nav { display: flex; align-items: center; gap: 2px; }
.month-nav button { width: 44px; height: 44px; padding: 0; font-size: 25px; font-family: Arial, sans-serif; border: 0; border-radius: 0; }
.month-nav button:hover { background: var(--ink); color: var(--surface); }
.weekdays, .days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.weekdays { font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line-strong); }
.weekdays span { padding: 5px 10px 10px; }
.day { min-width: 0; min-height: 96px; padding: 9px 7px 11px; border-bottom: 1px solid var(--line); position: relative; }
.day:nth-child(7n) { border-right: 0; }
.day.outside { min-height: 0; }
.day-heading { display: flex; align-items: center; justify-content: flex-start; margin-bottom: 3px; }
.day-heading .weekday { display: none; }
.date-number { display: grid; place-items: center; height: 32px; min-height: 32px; width: 32px; padding: 0; border-radius: 2px; }
.number { font: 500 19px/1.2 var(--sans); font-variant-numeric: tabular-nums; letter-spacing: -.04em; }
.day.today .date-number { color: var(--accent); box-shadow: inset 0 -2px var(--accent); }
.day.selected { background: var(--wash); }
.date-number[aria-pressed=true] { background: var(--ink); color: var(--surface); }
.festival-choice { display: block; width: 100%; min-height: 32px; padding: 5px 6px; border-radius: 3px; white-space: normal; overflow-wrap: break-word; font-size: 12px; line-height: 1.6; text-align: left; color: var(--ink); }
.festival-choice + .festival-choice { margin-top: 2px; }
.festival-choice:hover { background: var(--surface-alt); color: var(--accent); }
.festival-choice[aria-pressed=true] { background: var(--ink); color: var(--surface); }
.calendar-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 12px; font-size: 12px; color: var(--muted); }
.calendar-foot button { font-size: 12px; text-decoration: underline; text-underline-offset: 5px; padding-right: 0; }
.fine-print { text-align: center; color: var(--muted); font-size: 12px; margin: 27px 0 12px; }

.messages { max-width: 800px; margin: 0 auto 34px; min-width: 0; }
.message { margin: 0 0 28px; overflow-wrap: anywhere; }
.message.user { margin-left: 18%; display: flex; justify-content: flex-end; }
.message.user { flex-wrap: wrap; }
.message-share { display: block; margin-top: 6px; padding: 3px 8px; min-height: 30px; color: var(--muted); font-size: 12px; opacity: 0; transition: opacity .16s ease; }
.message:hover .message-share, .message:focus-within .message-share, .message-share:focus-visible { opacity: 1; }
@media (hover: none) { .message-share { opacity: .65; } }
.message.user .message-share { flex-basis: 100%; margin-left: auto; text-align: right; }
.message.user p { padding: 14px 19px; border-radius: 12px 12px 2px 12px; background: var(--surface-alt); border: 1px solid var(--line); white-space: pre-wrap; }
.message.assistant .speaker { font-size: 12px; font-weight: 600; margin-bottom: 13px; display: flex; align-items: center; gap: 9px; }
.message.assistant .speaker::before { content: ""; width: 3px; height: 13px; background: var(--accent); transform: skew(-12deg); }
.message.assistant p { white-space: pre-wrap; line-height: 1.95; }
.choices { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 17px; }
.choices button { border: 1px solid var(--line); font-size: 13px; padding: 9px 14px; text-align: left; background: var(--surface); border-radius: var(--radius-sm); }
.choices button:hover { background: var(--surface-alt); border-color: var(--ink); }
.inline-proposal { border-left: 2px solid var(--ink); padding: 6px 0 6px 19px; margin: 20px 0; }
.inline-proposal strong { font-weight: 600; }
.inline-proposal small { display: block; color: var(--muted); font-size: 12px; margin-top: 6px; }
.generate { border: 1px solid var(--accent); border-radius: var(--radius-md); font-size: 13px; font-weight: 500; margin-top: 16px; background: var(--accent); color: #fff; padding: 10px 20px; }
.generate:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.art { margin-top: 20px; max-width: 285px; }
.poster { width: 100%; min-height: 345px; border: 1px solid var(--line); background: var(--surface); padding: 24px; display: flex; flex-direction: column; text-align: left; border-radius: var(--radius-sm); cursor: pointer; box-shadow: var(--shadow-card); }
.poster:hover { background: var(--surface); outline: 1px solid var(--ink); }
.poster .mock { font-size: 12px; color: var(--muted); letter-spacing: .05em; }
.poster .headline { font: 400 34px/1.45 var(--display); margin: 36px 0 20px; white-space: pre-wrap; }
.poster .subline { font-size: 12px; margin-bottom: 26px; }
.poster .facts { border-top: 1px solid var(--line-strong); padding-top: 12px; margin-top: auto; font-size: 12px; white-space: pre-wrap; }
.poster.alt { background: var(--surface-alt); border-left: 12px solid var(--ink); }
.poster.invitation { min-height: 240px; }
.poster.invitation .headline { font-size: 27px; margin: 22px 0; }
.art-caption { font-size: 12px; color: var(--muted); display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 7px; }
.art-caption button { font-size: 12px; }
.art-note { font-size: 12px; color: var(--muted); margin-top: 5px; }
.chat-mode main { margin-top: 30px; }
.chat-mode .composer { position: sticky; max-width: 800px; bottom: 0; padding: 14px 0 max(14px, env(safe-area-inset-bottom)); background: linear-gradient(to bottom, rgba(246, 243, 236, 0) 0%, var(--paper) 22%); box-shadow: none; }
.chat-mode.calendar-open .composer { position: relative; bottom: auto; }
.chat-mode .composer textarea { min-height: 60px; }
.chat-mode .fine-print { margin-top: 18px; }
.status { font-size: 12px; color: var(--muted); margin-top: 8px; }
.status:empty { display: none; }
.archived-note { font-size: 12px; color: var(--muted); text-align: center; margin-bottom: 18px; }
.archived-note button { font-size: 12px; text-decoration: underline; }

body.holiday-open { overflow: hidden; }
.holiday-dialog { padding: 0; border: 1px solid var(--line); border-radius: var(--radius-lg); width: min(660px, calc(100% - 40px)); max-width: none; max-height: min(840px, 86dvh); color: var(--ink); background: var(--surface); box-shadow: var(--shadow-dialog); overflow: hidden; }
.holiday-dialog::backdrop { background: var(--backdrop); backdrop-filter: blur(3px); }
.holiday-frame { display: flex; flex-direction: column; max-height: min(840px, 86dvh); }
.holiday-head { position: relative; flex: none; padding: 28px 32px 22px; border-top: 3px solid var(--ink); border-bottom: 1px solid var(--line); }
.holiday-date { font-size: 12px; color: var(--muted); letter-spacing: .05em; padding-right: 44px; }
.holiday-head h2 { font: 400 31px/1.55 var(--display); margin: 9px 36px 0 0; overflow-wrap: anywhere; outline: none; }
.holiday-head h2:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.holiday-close { position: absolute; right: 16px; top: 17px; width: 44px; height: 44px; padding: 10px; color: var(--muted); }
.holiday-close svg { display: block; width: 22px; height: 22px; }
.holiday-content { padding: 23px 32px 26px; overflow-y: auto; overscroll-behavior: contain; min-height: 0; scrollbar-width: thin; overflow-wrap: anywhere; }
.holiday-summary { font-size: 14px; line-height: 1.95; white-space: pre-line; }
.holiday-history { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 27px 0 13px; }
.holiday-history h3 { font-size: 13px; font-weight: 600; margin: 0; }
.holiday-history span { font-size: 11px; color: var(--muted); }
.holiday-signal { padding: 16px 0; border-top: 1px solid var(--line); }
.holiday-signal h4 { font-size: 12px; font-weight: 400; color: var(--muted); margin: 0 0 10px; }
.holiday-terms { display: flex; flex-wrap: wrap; gap: 7px; }
.holiday-term { border: 1px solid var(--line); background: var(--surface-alt); border-radius: var(--radius-sm); padding: 7px 12px; min-height: 42px; font-size: 13px; line-height: 1.65; text-align: left; max-width: 100%; overflow-wrap: anywhere; }
.holiday-term[aria-expanded=true] { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.holiday-term:hover { background: var(--wash); border-color: var(--accent); color: var(--ink); }
.holiday-explanation { font-size: 14px; line-height: 1.9; padding: 14px 16px; margin-top: 12px; background: var(--surface-alt); border-left: 2px solid var(--accent); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; white-space: pre-line; overflow-wrap: anywhere; }
.holiday-explanation h5 { font-size: 14px; font-weight: 600; margin: 0 0 7px; }
.holiday-reference { color: var(--accent); text-underline-offset: 3px; }
.holiday-disclosure { border-top: 1px solid var(--line); padding-top: 5px; }
.holiday-disclosure summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; list-style: none; cursor: pointer; min-height: 44px; font-size: 12px; color: var(--muted); padding: 7px 0; }
.holiday-disclosure summary::-webkit-details-marker { display: none; }
.holiday-disclosure summary::after { content: '+'; font-size: 19px; font-weight: 300; }
.holiday-disclosure[open] summary::after { content: '−'; }
.holiday-disclosure p { margin: 6px 0 13px; font-size: 13px; line-height: 1.95; white-space: pre-line; }
.holiday-sources { display: grid; gap: 5px; padding-bottom: 12px; }
.holiday-sources a { display: flex; align-items: flex-start; gap: 9px; min-height: 44px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 12px; line-height: 1.8; text-decoration: none; color: var(--ink); overflow-wrap: anywhere; }
.holiday-sources a:hover .source-title { text-decoration: underline; text-underline-offset: 3px; }
.source-number { flex: none; min-width: 24px; color: var(--muted); font-size: 11px; }
.source-title { min-width: 0; overflow-wrap: anywhere; }
.holiday-source-note { font-size: 11px !important; color: var(--muted); }
.holiday-missing { font-size: 13px; color: var(--muted); }
.holiday-footer { flex: none; padding: 16px 32px 20px; border-top: 1px solid var(--line); background: var(--paper); }
.holiday-chat { display: flex; align-items: center; justify-content: center; gap: 16px; width: 100%; min-height: 48px; background: var(--ink); color: var(--surface); border-radius: var(--radius-md); font-size: 14px; }
.holiday-chat:hover { background: var(--accent); color: #fff; }
.holiday-chat span { font-size: 18px; }
.holiday-footer p { font-size: 11px; text-align: center; color: var(--muted); margin-top: 8px; }
.holiday-inline-note { flex-basis: 100%; font-size: 13px; line-height: 1.95; white-space: pre-line; margin: 0 0 6px; }
.holiday-inline-note strong { display: block; font-size: 12px; font-weight: 600; margin-bottom: 5px; }
.holiday-research-meta, .holiday-research-evidence { font-size: 11px; line-height: 1.8; color: var(--muted); white-space: normal; }
.holiday-research-meta { margin-bottom: 9px; }
.holiday-research-evidence { margin-top: 10px; }

@media (max-width: 900px) {
  .intro { --hero-size: clamp(64px, 9.5vw, 84px); grid-template-columns: minmax(0, 1fr) 148px; gap: 22px; }
  .intro .eyebrow { font-size: 11px; letter-spacing: .04em; }
}

@media (max-width: 640px) {
  :root { scrollbar-gutter: auto; }
  header, body:not(.chat-mode) header { width: 100%; height: 60px; padding: 0 14px; gap: 8px; }
  .brand-lockup { gap: 8px; flex: none; }
  .brand, .brand-lockup .brand { width: 42px; height: 42px; }
  .brand-caption { display: none; }
  .header-actions { gap: 4px; min-width: 0; }
  .header-actions > button, .header-actions > a { padding: 6px 6px; font-size: 12px; }
  .preview-label { font-size: 10px; }
  .new-chat { padding-left: 8px; gap: 4px; font-size: 12px; }
  main { width: calc(100% - 40px); margin: 22px auto 24px; }
  .intro { --hero-size: clamp(51px, 15vw, 82px); grid-template-columns: minmax(0, 1fr); gap: 19px; margin-bottom: 25px; }
  .intro .eyebrow { font-size: 10px; letter-spacing: .045em; margin-bottom: 22px; }
  .title-lead { font-size: 14px; letter-spacing: .12em; margin-bottom: 6px; }
  .composer { padding: 21px 0 14px; }
  .composer textarea { min-height: 90px; font-size: 16px; }
  .composer-hint { max-width: 210px; font-size: 11px; }
  .send { width: 44px; height: 44px; }
  .calendar { margin-top: 35px; }
  .calendar-head { gap: 8px; }
  .calendar-head h2 { gap: 9px; flex-wrap: wrap; max-width: 225px; }
  .calendar-head .calendar-month { font-size: 43px; }
  .calendar-month .month-unit { font-size: 13px; margin-left: 5px; }
  .calendar-year { font-size: 12px; }
  .calendar-count { font-size: 11px; padding-left: 9px; }
  .month-nav { gap: 3px; }
  .month-nav button { width: 44px; min-width: 44px; }
  .weekdays { display: none; }
  .days { grid-template-columns: repeat(2, minmax(0, 1fr)); border-top: 1px solid var(--line-strong); }
  .day { min-height: 0; padding: 10px 7px 12px; }
  .day.outside, .day.empty { display: none; }
  .day:not(.outside):not(.empty) { border-right: 0; }
  .day-heading { justify-content: space-between; margin-bottom: 3px; }
  .day-heading .weekday { display: block; font-size: 11px; color: var(--muted); padding-right: 7px; }
  .date-number { width: 44px; height: 44px; min-height: 44px; margin-left: -5px; }
  .number { font-size: 22px; }
  .festival-choice { min-height: 44px; padding: 10px 6px; font-size: 12px; }
  .festival-choice + .festival-choice { margin-top: 1px; }
  .calendar-foot { gap: 5px; flex-wrap: wrap; font-size: 11px; margin-top: 8px; }
  .calendar-foot span { max-width: 180px; }
  .calendar-foot button { font-size: 11px; margin-left: auto; }
  .fine-print { font-size: 10px; }
  .message.user { margin-left: 10%; }
  .message.assistant p { font-size: 15px; }
  .choices { gap: 7px; }
  .chat-mode main { margin-top: 22px; }
  .chat-mode .composer { bottom: 10px; }
  .art { max-width: 265px; }
  .holiday-dialog { position: fixed; inset: auto 0 0; margin: 0; width: 100%; max-height: 88dvh; border-radius: 10px 10px 0 0; border-bottom: 0; }
  .holiday-frame { max-height: 88dvh; }
  .holiday-head { padding: 24px 22px 18px; border-top: 0; }
  .holiday-head::before { content: ''; position: absolute; top: 9px; left: calc(50% - 16px); width: 32px; height: 3px; border-radius: 2px; background: var(--line-strong); }
  .holiday-head h2 { font-size: 26px; }
  .holiday-close { top: 18px; right: 12px; }
  .holiday-content { padding: 18px 22px 22px; }
  .holiday-history { margin-top: 21px; }
  .holiday-footer { padding: 13px 22px max(16px, env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}

.account-control { font-size: 12px; }
.brand-context { margin: 14px 0 0; font-size: 12px; color: var(--muted); }
.brand-context-row { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 14px; }
.brand-context button,.brand-context select { min-height: 36px; background: transparent; color: inherit; font: inherit; }
.brand-context select { max-width: min(300px,100%); border: 0; border-bottom: 1px solid var(--line); }
.header-actions { gap: 16px; }
.header-actions > button,.header-actions > a { white-space: nowrap; }
.brand-toggle { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; cursor: pointer; color: var(--muted); }
.brand-toggle:has(input:checked) { color: var(--ink); }
.brand-toggle input { appearance: none; width: 28px; height: 16px; margin: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--line); cursor: pointer; flex: none; }
.brand-toggle input::before { content: ''; display: block; width: 10px; height: 10px; margin: 2px; border-radius: 50%; background: var(--paper); }
.brand-toggle input:checked { background: var(--accent); border-color: var(--accent); }
.brand-toggle input:checked::before { transform: translateX(12px); }
#brand-empty { font-size: 11px; }
#brand-ratio-control { display: inline-flex; align-items: center; gap: 8px; }
#brand-summary,#brand-status { margin: 4px 0; font-size: 11px; }
#brand-status:empty { display: none; }
.message-brand { display: block; margin-top: 8px; color: var(--muted); font-size: 12px; }
.delivery-dialog { width: min(1140px,calc(100% - 32px)); max-height: calc(100dvh - 32px); overflow: auto; padding: 28px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--paper); color: var(--ink); box-shadow: var(--shadow-dialog); }
.delivery-dialog::backdrop { background: var(--backdrop); backdrop-filter: blur(3px); }
.delivery-dialog h2 { margin: 0; font-size: 27px; font-weight: 600; }
.delivery-dialog h3 { margin: 0 0 10px; font-size: 14px; font-weight: 600; }
.delivery-dialog h4 { margin: 0; font-size: 12px; font-weight: 500; }
.delivery-head,.delivery-layer-head,.delivery-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.delivery-dialog button { min-height: 44px; background: transparent; color: inherit; font: inherit; font-size: 12px; }
.delivery-head { margin-bottom: 12px; }
.delivery-layout { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1.1fr); gap: 28px; align-items: start; }
.delivery-preview { position: sticky; top: 0; min-width: 0; text-align: center; }
#delivery-canvas { display: block; width: 100%; max-height: 62vh; object-fit: contain; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); cursor: grab; touch-action: none; }
#delivery-canvas:active { cursor: grabbing; }
.delivery-kit { border-top: 1px solid var(--line); padding-top: 14px; }
.delivery-kit summary { cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--ink); }
.delivery-kit-block { margin-top: 12px; display: grid; gap: 8px; }
.delivery-kit-block h4 { margin: 0; font-size: 12px; font-weight: 600; color: var(--muted); }
.delivery-kit-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.delivery-kit-row input { flex: 1; min-width: 130px; }
.delivery-kit-row button, #delivery-batch-export { padding: 8px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.delivery-kit-row button:hover, #delivery-batch-export:hover { border-color: var(--ink); }
.delivery-batch-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 6px 10px; font-size: 12.5px; color: var(--ink); }
.delivery-batch-grid label { display: flex; align-items: center; gap: 6px; margin: 0; }
.delivery-stamp-item { margin-top: 10px; padding: 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); display: grid; gap: 8px; }
.delivery-stamp-controls { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
.delivery-stamp-controls label { display: grid; gap: 4px; font-size: 11px; color: var(--muted); }
.delivery-stamp-corners { display: flex; gap: 4px; }
.delivery-stamp-corners button { min-height: 32px; padding: 4px 8px; font-size: 11px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.delivery-note { color: var(--muted); font-size: 12px; line-height: 1.8; margin: 8px 0; overflow-wrap: anywhere; }
.delivery-warning { color: var(--accent); font-size: 12px; line-height: 1.8; }
.delivery-warning:empty { display: none; }
#delivery-fields { margin: 0; padding: 0; min-width: 0; border: 0; }
.delivery-section { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 12px; }
.delivery-section:first-child { border-top: 0; margin-top: 0; padding-top: 0; }
.delivery-size { display: grid; grid-template-columns: auto minmax(0,1fr); align-items: center; gap: 8px; max-width: 380px; font-size: 13px; }
.delivery-dialog select,.delivery-dialog textarea,.delivery-dialog input:not([type=checkbox]):not([type=range]) { min-width: 0; width: 100%; min-height: 40px; border: 1px solid var(--line); background: var(--surface); color: inherit; font: inherit; font-size: 13px; padding: 8px 10px; border-radius: var(--radius-sm); }
.delivery-dialog textarea { resize: vertical; line-height: 1.7; }
.delivery-layer { padding: 12px 0; border-top: 1px dashed var(--line); }
.delivery-layer > label { display: grid; gap: 6px; font-size: 11px; }
.delivery-layer-controls { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 10px; margin-top: 10px; }
.delivery-layer-controls label { display: grid; gap: 6px; font-size: 10px; }
.delivery-actions { justify-content: flex-start; flex-wrap: wrap; padding-top: 20px; margin-top: 18px; border-top: 1px solid var(--line); }
.delivery-actions button { padding: 10px 16px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
#delivery-save { background: var(--ink); color: var(--surface); border-color: var(--ink); }
#delivery-save:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
#delivery-discard-dialog { --compact-dialog-width: 400px; }
#delivery-discard-dialog .creation-actions { justify-content: flex-end; }
#delivery-discard-dialog .creation-actions button { min-height: 44px; padding-inline: 14px; }
#delivery-keep-editing { background: var(--ink); color: var(--surface); border-color: var(--ink); }
#delivery-keep-editing:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
@media(max-width:700px) {
  .delivery-dialog { width: calc(100% - 20px); max-height: calc(100dvh - 20px); padding: 12px; }
  .delivery-layout { grid-template-columns: minmax(0,1fr); gap: 12px; }
  .delivery-preview { position: static; }
  #delivery-canvas { max-height: 52vh; }
  .delivery-dialog h2 { font-size: 24px; }
  .delivery-dialog textarea,.delivery-dialog select,.delivery-dialog input:not([type=checkbox]) { font-size: 16px; }
}
.brand-dialog { --compact-dialog-width: 640px; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--paper); color: var(--ink); box-shadow: var(--shadow-dialog); }
.brand-dialog::backdrop { background: var(--backdrop); backdrop-filter: blur(3px); }
.brand-dialog-head,.brand-editor-nav,.brand-section-head,.brand-dialog-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand-dialog button { min-height: var(--compact-control-height); background: transparent; color: inherit; font: inherit; font-size: 13px; padding: 4px 9px; white-space: nowrap; }
.brand-guidance { margin: 16px 0 22px; max-width: 54em; color: var(--muted); font-size: 12px; line-height: 1.8; }
.brand-toolbar { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,310px); gap: 4px 12px; padding-bottom: 8px; margin-bottom: 8px; border-bottom: 1px solid var(--line); }
.brand-editor-nav { display: grid; grid-template-columns: minmax(0,1fr) auto auto; gap: 4px; }
#brand-version:empty { display: none; }
#brand-version { font-size: 11px; color: var(--muted); white-space: nowrap; }
.brand-dialog select,.brand-dialog input:not([type=checkbox]),.brand-dialog textarea { width: 100%; min-width: 0; min-height: var(--compact-control-height); border: 1px solid var(--line); background: var(--surface); color: inherit; padding: 5px 9px; border-radius: var(--radius-sm); font: inherit; font-size: var(--compact-control-font); }
.brand-dialog textarea { resize: vertical; line-height: 1.5; }
.brand-ratio-preference { display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 6px; }
.brand-ratio-preference label,#preferred-ratio-status { font-size: 13px; }
#preferred-ratio-status { grid-column: 1/-1; margin: 0; color: var(--muted); }
#preferred-ratio-status:empty { display: none; }
#brand-fields { min-width: 0; border: 0; margin: 0; padding: 0; }
.brand-field-grid { display: grid; grid-template-columns: minmax(0,1.1fr) minmax(0,.85fr) minmax(0,1.45fr); gap: 8px; }
.brand-notes-grid { grid-template-columns: repeat(2,minmax(0,1fr)); margin-top: 8px; }
.brand-field-grid label { display: grid; align-content: start; gap: 3px; min-width: 0; font-size: 13px; }
.brand-field-grid :is(input,textarea)::placeholder { color: var(--muted); }
.brand-form-section { margin-top: 6px; }
.brand-ratio-section,.brand-assets-section { padding-top: 4px; border-top: 1px solid var(--line); }
.brand-form-section h3 { font-size: 14px; font-weight: 600; margin: 0; }
.brand-form-section p { color: var(--muted); font-size: 12px; line-height: 1.5; margin: 2px 0 6px; }
.brand-assets-section:has(.brand-empty) > p { display: none; }
.brand-assets-section:has(.brand-empty),.brand-form-section:has(> #brand-works > .brand-empty) { display: flex; flex-wrap: wrap; align-items: center; gap: 0 8px; }
.brand-assets-section:has(.brand-empty) .brand-section-head { display: contents; }
.brand-assets-section:has(.brand-empty) #brand-upload { order: 1; margin-left: auto; }
.brand-ratio-section { display: flex; flex-wrap: wrap; align-items: center; gap: 0 8px; }
.brand-ratios { display: flex; flex-wrap: wrap; gap: 0 4px; }
.brand-ratios label { display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-width: 44px; min-height: var(--compact-control-height); padding-inline: 2px; font-size: 13px; white-space: nowrap; }
.brand-dialog input[type=checkbox] { accent-color: var(--accent); width: 16px; height: 16px; flex: none; }
.brand-ratios input { margin: 0; }
.brand-image-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 8px; }
.brand-image-grid label { position: relative; display: flex; flex-direction: column; gap: 7px; font-size: 11px; }
.brand-image-grid input { position: absolute; left: 7px; top: 7px; }
.brand-image-grid img { display: block; width: 100%; height: 88px; object-fit: contain; background: var(--surface); border: 1px solid var(--line); }
.brand-image-item button { font-size: 11px; color: var(--muted); padding: 4px 0; }
.brand-image-grid .brand-empty { grid-column: 1/-1; margin: 0; }
.brand-error { font-size: 12px; line-height: 1.8; color: var(--accent); }
.brand-error:empty { display: none; }
.brand-dialog-actions { flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding-top: 8px; margin-top: 8px; border-top: 1px solid var(--line); }
.brand-dialog-actions .brand-error { flex-basis: 100%; }
#brand-archive { margin-right: auto; color: var(--muted); }
#brand-save,#preferred-ratio-save { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); padding-inline: 10px; }
#brand-save-use { background: var(--ink); color: var(--surface); border-radius: var(--radius-sm); padding-inline: 12px; }
#brand-save-use:hover { background: var(--accent); color: #fff; }
@media(max-width:640px) {
  .brand-toolbar { grid-template-columns: minmax(0,1fr); }
  .brand-field-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .brand-address { grid-column: 1/-1; }
}
@media(max-width:600px) {
  .brand-dialog { scroll-padding-bottom: 68px; }
  .brand-dialog-actions { position: sticky; bottom: 0; z-index: 1; background: var(--paper); padding: 8px 0 4px; }
  .brand-ratio-section { display: block; }
  .brand-ratios { display: grid; grid-template-columns: repeat(7,minmax(0,1fr)); gap: 0; }
  .brand-ratios label { padding-inline: 0; }
  .brand-image-grid { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .brand-context select { max-width: 210px; }
}
@media(max-width:380px) {
  .brand-ratios { grid-template-columns: repeat(4,minmax(0,1fr)); }
  .brand-ratio-preference { grid-template-columns: minmax(0,1fr) auto; }
  .brand-ratio-preference label { grid-column: 1/-1; }
}


.composer,.chat-mode .composer { display: grid; grid-template-columns: minmax(0,1fr); gap: 8px; padding: 12px 0 8px; }
.composer > [hidden] { display: none !important; }
.composer > .model-toolbar { margin: 0; min-height: 44px; }
.composer > .status:empty { display: none; }
.composer textarea,.chat-mode .composer textarea { min-height: 32px; height: 32px; max-height: 140px; resize: none; padding-right: 54px; line-height: 1.7; }
.composer-bottom { margin-top: 4px; justify-content: flex-end; }
.composer-hint { display: none; }
.composer .send { position: absolute; right: 0; top: 7px; width: 40px; height: 40px; }
.composer .calendar-toggle { font-size: 11px; min-height: 32px; padding: 4px; }
.model-toolbar { display: flex; flex-wrap: nowrap; align-items: center; justify-content: flex-start; gap: 8px; margin-top: 8px; }
.model-toolbar .send { position: static; flex: 0 0 40px; margin-left: auto; }
.toolbar-control { flex: 0 0 auto; min-width: 0; }
.toolbar-control > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 6px; min-height: 44px; padding: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.toolbar-control > summary::-webkit-details-marker { display: none; }
.toolbar-control > summary:hover,.toolbar-control[open] > summary { background: #20211e08; color: var(--ink); }
.toolbar-control > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.toolbar-control svg { width: 23px; height: 23px; flex: 0 0 auto; }
#control-model { flex: 0 1 240px; }
#model-trigger-label { overflow: hidden; text-overflow: ellipsis; }
#control-skill.has-selection > summary { color: var(--ink); box-shadow: inset 0 -2px var(--accent); }
.toolbar-panel { position: absolute; bottom: calc(100% + 8px); left: 0; width: min(380px,100%); max-height: min(480px,60dvh); overflow: auto; padding: 12px; border: 1px solid var(--line); background: var(--paper); box-shadow: 0 10px 35px #20211e20; z-index: 5; }
.toolbar-panel p { font-size: 12px; color: var(--muted); margin: 8px 0; }
.toolbar-option { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; position: relative; text-align: left; width: 100%; padding: 12px 28px 12px 10px; color: var(--ink); font: inherit; font-size: 13px; }
.toolbar-option small { flex-basis: 100%; font-size: 11px; line-height: 1.6; color: var(--muted); }
.toolbar-option[aria-pressed=true] { background: #20211e08; }
.selected-mark { position: absolute; right: 9px; top: 12px; }
.ratio-options,.output-options { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 5px; }
.ratio-options .toolbar-option,.output-options .toolbar-option { border: 1px solid var(--line); }
.model-toolbar .calendar-toggle { margin-left: auto; flex: 0 0 32px; }
.model-toolbar .calendar-toggle span { display: none; }
.model-toolbar .calendar-toggle:not([hidden]) + .send { margin-left: 0; }
.composer textarea { padding-right: 0; }
@media(max-width:600px) { .model-toolbar { gap: 3px; } .toolbar-control > summary { padding: 4px; font-size: 11px; gap: 4px; } #control-model svg { display: none; } }
.decision-card { border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); margin: 20px 0; padding: 20px; box-shadow: var(--shadow-card); }
.decision-card fieldset { border: 0; padding: 0; margin: 0 0 18px; min-width: 0; }
.decision-card legend { font-size: 16px; font-weight: 600; margin-bottom: 12px; }
.decision-option { display: flex; align-items: flex-start; gap: 10px; border: 1px solid var(--line); padding: 12px; margin: 8px 0; cursor: pointer; }
.decision-option:has(input:checked) { border-color: var(--ink); background: #20211e08; }
.decision-option input { margin-top: 6px; }
.decision-option small { display: block; color: var(--muted); font-size: 12px; }
.decision-card textarea { display: block; width: 100%; min-height: 54px; background: transparent; border: 1px solid var(--line); padding: 10px; font: inherit; font-size: 13px; }
.decision-card button[type=submit] { background: var(--ink); color: var(--paper); padding: 10px 18px; }
.decision-card .decision-error { color: #963e35; font-size: 12px; }
.decision-card fieldset.needs-answer { border-left: 2px solid #963e35; padding-left: 12px; }
.decision-card .defer-answer { font-size: 12px; text-decoration: underline; text-underline-offset: 4px; margin-top: 6px; color: var(--muted); }
.decision-history,.clarify-suggestions { font-size: 12px; color: var(--muted); }
.activity-fields-card { margin: 16px 0; padding: 10px 14px; border-radius: 6px; }
.activity-fields-card fieldset { margin: 0; }
.activity-fields-card legend { margin-bottom: 6px; font-size: 14px; line-height: 1.5; }
.activity-fields-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(128px, 100%), 1fr)); gap: 8px; }
.activity-fields-grid label { display: grid; gap: 4px; min-width: 0; font-size: 12px; line-height: 1.5; }
.activity-fields-grid label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-fields-grid input {
  display: block; width: 100%; min-width: 0; min-height: 36px; padding: 5px 8px;
  border: 1px solid var(--line); border-radius: 4px; background: var(--surface);
  color: var(--ink); font: inherit; font-size: 14px; caret-color: var(--accent);
}
.activity-fields-grid input::placeholder { color: var(--muted); }
.activity-fields-grid input:focus-visible { outline: 1px solid var(--accent); outline-offset: 1px; }
.activity-fields-card .decision-error { margin: 8px 0 0; }
.activity-fields-card .decision-error:empty { margin: 0; }
.activity-fields-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.activity-fields-card .activity-fields-actions button { min-height: 32px; padding: 4px 10px; border-radius: 4px; font-size: 12px; line-height: 1.5; }
.activity-fields-card button.activity-fields-skip { border: 0; background: transparent; color: var(--muted); }
.activity-fields-card button.activity-fields-skip:hover { color: var(--ink); background: var(--wash); }
@media (pointer: coarse) {
  .activity-fields-grid input { min-height: 40px; font-size: 16px; }
  .activity-fields-card .activity-fields-actions button { min-height: 40px; }
}
.holiday-terms .holiday-note-card { display: flex; flex-direction: column; align-items: flex-start; text-align: left; gap: 6px; flex: 1 1 210px; max-width: 100%; white-space: normal; }
.holiday-note-card small { font-size: 12px; line-height: 1.7; font-weight: 400; color: var(--muted); overflow-wrap: anywhere; }

.retry-query { min-height: 44px; background: transparent; color: var(--muted); font: inherit; font-size: 12px; text-decoration: underline; text-underline-offset: 4px; }
.retry-query { padding: 4px 0; }
.media-picker { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding-top: 15px; font-size: 11px; color: var(--muted); }
.skill-picker { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; padding-top: 16px; font-size: 12px; color: var(--muted); }
.skill-picker select { min-height: 44px; max-width: 100%; background: transparent; border: 1px solid var(--line); padding: 6px 10px; color: var(--ink); font: inherit; }
.skill-picker details { width: 100%; }
.skill-picker summary { cursor: pointer; width: fit-content; min-height: 32px; }
#skill-instructions { max-height: 320px; overflow: auto; padding: 16px; border: 1px solid var(--line); color: var(--ink); font-size: 12px; }
.media-picker label { display: inline-flex; gap: 6px; align-items: center; }
.media-picker [hidden] { display: none; }
#image-credit { flex-basis: 100%; color: var(--ink); }
.direction-cards { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 16px; margin: 24px 0 14px; }
.direction-card { border-top: 2px solid var(--ink); padding: 20px 14px; background: rgba(120,110,90,.035); }
.direction-number { font-size: 12px; color: var(--muted); }
.direction-card h3 { margin: 18px 0; font-size: 20px; }
.direction-card p { font-size: 13px; line-height: 1.8; overflow-wrap: anywhere; }
.direction-card p span { display: block; margin-top: 18px; color: var(--muted); font-size: 11px; }
.direction-card button,.other-directions { background: transparent; border: 1px solid var(--line); padding: 12px; color: var(--ink); font: inherit; cursor: pointer; }
.direction-card button { margin-top: 14px; width: 100%; }
.direction-card button:hover,.other-directions:hover { background: var(--ink); color: var(--paper,#fff); }
.direction-hint { font-size: 12px; color: var(--muted); }
@media(max-width:700px) { .direction-cards { grid-template-columns: 1fr; } }
.media-picker select { max-width: 250px; min-height: 44px; border: 1px solid var(--line); border-radius: 0; background: transparent; color: var(--ink); padding: 6px 10px; font: inherit; }
#text-model { margin-left: auto; }
.agent-text { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.95; }
.image-proposal { margin: 18px 0 28px; padding: 18px 20px; border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: var(--radius-md); background: var(--surface); box-shadow: var(--shadow-card); }
.image-proposal p, .image-proposal small { display: block; font-size: 12px; color: var(--muted); margin: 6px 0; }
.image-proposal summary { cursor: pointer; min-height: 44px; padding: 10px 0; font-size: 13px; }
.image-proposal details .agent-text { font-size: 13px; margin: 12px 0; }
.proposal-prompt { display: block; width: 100%; max-height: 55vh; resize: vertical; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--paper); color: var(--ink); font: inherit; line-height: 1.55; }
.proposal-reset-prompt { min-height: 44px; padding: 6px 0; font-size: 13px; color: var(--accent); }
.proposal-reset-prompt:disabled { color: var(--muted); }
.generated-image { margin: 20px 0 28px; width: min(420px, 100%); max-width: 100%; }
.generated-image .generated-image-preview { position: relative; display: block; padding: 0; width: 100%; min-height: 180px; max-height: 460px; overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); box-shadow: var(--shadow-card); cursor: zoom-in; }
.generated-image img { display: block; width: 100%; height: auto; max-height: 460px; object-fit: contain; }
.generated-image-preview span { position: absolute; right: 10px; bottom: 10px; padding: 4px 9px; border-radius: var(--radius-sm); background: rgba(23, 22, 20, .78); color: #fff; font-size: 12px; opacity: .88; transition: opacity .16s ease; }
.generated-image-preview:hover span { opacity: 1; }
.generated-image figcaption { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-top: 10px; font-size: 13px; }
.generated-image figcaption > button, .generated-image figcaption > a { padding: 6px 10px; min-height: 36px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); text-decoration: none; display: inline-flex; align-items: center; font: inherit; font-size: 12px; }
.generated-image figcaption > button:hover, .generated-image figcaption > a:hover { border-color: var(--ink); background: var(--surface-alt); }
.generated-image figcaption [data-video-from-image] { border-color: var(--accent); color: var(--accent); }
.generated-image figcaption [data-video-from-image]:hover { background: var(--wash); }
.generated-image .delete-image { color: var(--danger); }
.generated-image .delete-image:hover { background: var(--wash); color: var(--danger); }
.generated-image a:not([href]) { display: none; }
.image-preview-dialog { width: min(1100px, calc(100% - 24px)); max-width: none; max-height: calc(100dvh - 24px); padding: 14px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--paper); color: var(--ink); box-shadow: var(--shadow-dialog); }
.image-preview-dialog::backdrop { background: rgba(23, 22, 20, .82); backdrop-filter: blur(4px); }
.image-preview-frame { display: flex; flex-direction: column; gap: 8px; }
.image-preview-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.image-preview-actions a,.image-preview-actions button { color: inherit; min-height: 44px; padding: 10px; font-size: 13px; }
.image-preview-dialog img { display: block; width: 100%; height: min(780px, calc(100dvh - 110px)); object-fit: contain; }
body:has(.image-preview-dialog[open]) { overflow: hidden; }
.run-progress, .run-error { display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; font-size: 13px; padding: 12px 0 22px; color: var(--muted); }
.run-error { color: #963e35; }
.run-progress button, .run-error button { text-decoration: underline; text-underline-offset: 4px; }
.login-dialog { width: min(420px, calc(100% - 24px)); border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--paper); color: var(--ink); padding: 18px; box-shadow: var(--shadow-dialog); }
.login-dialog::backdrop { background: var(--backdrop); backdrop-filter: blur(3px); }
.login-dialog form { position: relative; }
.login-dialog h2 { margin-bottom: 12px; font-size: 22px; }
.login-dialog p { font-size: 12px; color: var(--muted); }
.login-dialog label { display: block; margin: 8px 0; font-size: 13px; }
.login-dialog input { display: block; width: 100%; min-height: 44px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); padding: 8px; margin-top: 4px; font: inherit; }
.login-close { position: absolute; right: 0; top: -8px; min-width: 44px; min-height: 44px; padding: 0; font-size: 24px; }
.login-submit { width: 100%; background: var(--ink); color: var(--surface); }
.login-dialog > .login-close { top: 10px; right: 10px; }
.login-form-actions { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.login-form-actions > button { min-height: 44px; }
.login-form-actions .login-submit { flex: 1; width: auto; }
#login-register-toggle { color: var(--accent); white-space: nowrap; }
#login-dialog[data-registering] #wechat-login-toggle { display: none; }
#registration-invite-status:empty { display: none; }
#login-error:empty { display: none; }
@media(pointer:coarse) { .login-dialog input { font-size:16px; } }
#login-dialog { isolation: isolate; }
#login-dialog::before { border-radius: inherit; opacity: .32; }
#wechat-login-toggle {
  display: flex; align-items: center; justify-content: center; gap: 9px;
  width: 100%; min-height: 46px; margin: 4px 0 12px; border: 1px solid #19744755;
  border-radius: var(--radius-sm); background: #07844613; color: #155035; font-weight: 650;
}
.login-wechat-mark { width: 23px; height: 23px; flex: none; color: #078447; }
#wechat-login-toggle:hover { background: #07844622; }
#wechat-login-toggle:focus-visible { outline-color: #078447; }
#wechat-login-toggle[data-password-mode] {
  margin: 0; border-color: transparent; background: transparent; color: var(--muted); font-weight: 400;
}
#wechat-login-toggle[data-password-mode] .login-wechat-mark { display: none; }
#wechat-login-toggle:not([hidden]) + #login-form .login-submit {
  border: 1px solid var(--line-strong); background: transparent; color: var(--ink);
}
#wechat-login-toggle:not([hidden]) + #login-form .login-submit:hover { background: var(--surface-alt); }
#wechat-login-retry { width: 100%; border-color: var(--line); color: var(--ink); }
#wechat-login-panel { text-align: center; padding: 12px 0; }
#wechat-login-image { display: block; margin: 0 auto 12px; border: 1px solid var(--line); background: white; }
#wechat-login-image[hidden] { display: none; }
#wechat-login-status { margin: 0 0 12px; }
#wechat-login-toggle[aria-busy="true"], #wechat-login-status[data-waiting="1"] { position: relative; }
#wechat-login-status[data-waiting="1"] { min-height: 64px; display: grid; place-items: center; font-size: 0; }
#wechat-login-toggle[aria-busy="true"]::after, #wechat-login-status[data-waiting="1"]::after {
  content: ""; position: absolute; left: calc(50% - 17px); bottom: 2px; width: 34px; height: 2px;
  background: linear-gradient(90deg, var(--accent) 45%, transparent 45%) no-repeat;
  animation: wechat-login-wait 850ms ease-in-out infinite alternate;
}
#wechat-login-status[data-waiting="1"]::after { bottom: calc(50% - 1px); }
@keyframes wechat-login-wait { to { background-position: 19px 0; } }
@media (prefers-reduced-motion: reduce) {
  #wechat-login-toggle[aria-busy="true"]::after, #wechat-login-status[data-waiting="1"]::after { animation: none; }
}
#login-error:empty { display: none; }
/* Selected paper homepage: editorial title, fine calendar rules, vermilion action. */
body:not(.chat-mode) header { width: min(1370px, calc(100% - 80px)); max-width: none; height: 68px; padding: 0; border-bottom: 1px solid var(--line); }
body:not(.chat-mode) main { width: min(1370px, calc(100% - 80px)); margin-top: 32px; }
body:not(.chat-mode) .intro { display: block; margin-bottom: 42px; }
body:not(.chat-mode) .intro .eyebrow { font-size: 16px; letter-spacing: .06em; margin-bottom: 12px; color: var(--ink); }
body:not(.chat-mode) h1 { display: flex; flex-wrap: wrap; align-items: baseline; font: 400 clamp(48px, 6.4vw, 96px)/1.28 var(--display); letter-spacing: -.04em; }
body:not(.chat-mode) .title-lead { display: inline; font: inherit; letter-spacing: inherit; margin: 0; }
body:not(.chat-mode) .title-tail { display: inline-flex; width: auto; font: inherit; line-height: inherit; }
body:not(.chat-mode) .title-solid, body:not(.chat-mode) .title-emphasis { font: inherit; letter-spacing: inherit; margin: 0; transform: none; }
body:not(.chat-mode) .title-question { margin: 0; transform: none; font-size: 1em; }
body:not(.chat-mode) .composer { background: transparent; border-top-color: var(--line); padding: 17px 0 15px; gap: 12px; }
body:not(.chat-mode) .composer textarea { font-size: 18px; min-height: 34px; }
body:not(.chat-mode) .composer textarea::placeholder { color: var(--muted); }
body:not(.chat-mode) .model-toolbar { gap: 10px; }
body:not(.chat-mode) .toolbar-panel { top: calc(100% + 8px); bottom: auto; max-height: min(400px, 45dvh); }
body:not(.chat-mode) .toolbar-control > summary { padding: 6px 14px; border: 1px solid var(--line); border-radius: 24px; color: var(--ink); }
body:not(.chat-mode) #control-skill.has-selection > summary { box-shadow: none; border-color: var(--accent); }
body:not(.chat-mode) .model-toolbar .send { flex-basis: 48px; width: 48px; height: 48px; border-radius: 50%; background: var(--accent); }
body:not(.chat-mode) .send:hover { background: #93251e; }
body:not(.chat-mode) .send svg { transform: rotate(90deg); }
body:not(.chat-mode) .calendar { margin-top: 25px; }
body:not(.chat-mode) .calendar-head .calendar-month { font: 400 64px/1.1 var(--display); letter-spacing: -.04em; }
body:not(.chat-mode) .calendar-month .month-unit { font: 400 36px/1 var(--display); margin-left: 4px; }
body:not(.chat-mode) .calendar-year { font: 400 30px/1 var(--display); }
body:not(.chat-mode) .month-nav { gap: 10px; }
body:not(.chat-mode) .month-nav button { border: 1px solid var(--line); border-radius: 50%; }
body:not(.chat-mode) .weekdays { border-bottom: 0; color: var(--ink); }
body:not(.chat-mode) .weekdays span { text-align: center; padding-bottom: 10px; }
body:not(.chat-mode) .days { border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
body:not(.chat-mode) .day { border-right: 1px solid var(--line); min-height: 80px; padding: 6px 10px 9px; }
body:not(.chat-mode) .number { font: 400 20px/1.2 var(--display); }
body:not(.chat-mode) .calendar-foot { margin-top: 16px; }
body:not(.chat-mode) .calendar-foot button { border: 1px solid var(--accent); border-radius: 24px; padding: 8px 20px; color: var(--accent); text-decoration: none; }
body:not(.chat-mode) .fine-print { border-top: 1px solid var(--line); padding-top: 16px; margin-top: 20px; }
@media (max-width: 600px) {
  body:not(.chat-mode) header, body:not(.chat-mode) main { width: calc(100% - 40px); }
  body:not(.chat-mode) header { height: auto; min-height: 76px; }
  body:not(.chat-mode) main { margin-top: 24px; }
  body:not(.chat-mode) .intro { margin-bottom: 26px; }
  body:not(.chat-mode) .intro .eyebrow { font-size: 12px; letter-spacing: .02em; margin-bottom: 16px; }
  body:not(.chat-mode) h1 { font-size: clamp(40px, 11.6vw, 68px); row-gap: 2px; }
  body:not(.chat-mode) .title-lead { flex-basis: 100%; }
  body:not(.chat-mode) .composer textarea { font-size: 16px; }
  body:not(.chat-mode) .model-toolbar { gap: 4px; flex-wrap: wrap; }
  body:not(.chat-mode) .toolbar-control > summary { padding: 5px 8px; gap: 4px; }
  body:not(.chat-mode) #control-model { flex: 0 1 108px; }
  body:not(.chat-mode) .model-toolbar .send { flex-basis: 44px; width: 44px; height: 44px; }
  body:not(.chat-mode) .calendar-head .calendar-month { font-size: 46px; }
  body:not(.chat-mode) .calendar-month .month-unit { font-size: 24px; }
  body:not(.chat-mode) .calendar-year { font-size: 20px; }
  body:not(.chat-mode) .calendar-count { flex-basis: 100%; border-left: 0; padding: 0; }
  body:not(.chat-mode) .month-nav { gap: 6px; }
  body:not(.chat-mode) .day { min-height: 0; padding: 9px 7px; }
  body:not(.chat-mode) .day:not(.outside):not(.empty) { border-right: 1px solid var(--line); }
  body:not(.chat-mode) .calendar-foot span { max-width: none; }
}
select:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
@media (max-width: 600px) {
  header { height: auto; min-height: 64px; padding-top: 6px; padding-bottom: 6px; gap: 10px; }
  .brand { flex: none; }
  .header-actions { gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

  .account-control { max-width: 130px; overflow-wrap: anywhere; font-size: 11px; }
  .media-picker { gap: 6px; }
  .media-picker select { max-width: 225px; }
  #text-model { flex-basis: 100%; margin-left: 0; }
  .generated-image { max-width: 100%; }
  .login-dialog { padding: 14px; }
}

/* Reference images stay with the message they accompany. */
.attach-images { display:flex; align-items:center; justify-content:center; flex:0 0 auto; width:44px; height:44px; min-height:44px; padding:0; border:1px solid var(--line); border-radius:24px; background:transparent; color:var(--muted); font-size:22px; line-height:1; }
body:not(.chat-mode) .attach-images { width:40px; height:40px; min-height:40px; }
.reference-previews { display:flex; gap:12px; flex-wrap:wrap; padding:8px 0; }
.reference-preview { position:relative; width:112px; }
.reference-preview > button:first-child { padding:0; width:100%; background:transparent; border:1px solid var(--line); border-radius:6px; overflow:hidden; }
.reference-preview img { display:block; width:100%; height:78px; object-fit:contain; }
.reference-preview select { width:100%; font:inherit; font-size:12px; padding:5px 0; border:0; background:transparent; }
.reference-preview .remove-reference { position:absolute; right:-6px; top:-6px; width:24px; height:24px; min-height:24px; padding:0; border-radius:50%; border:1px solid var(--line); background:var(--paper,#f6f3ec); }
.message-reference { display:inline-flex; flex-direction:column; gap:4px; padding:5px; margin:6px 6px 0 0; background:transparent; border:1px solid var(--line); border-radius:6px; font-size:11px; }
.message-reference img { width:112px; height:84px; object-fit:cover; }
@media(max-width:600px) { body:not(.chat-mode) .attach-images { width:44px; height:44px; min-height:44px; } .model-toolbar { flex-wrap:wrap; } .reference-preview { width:96px; } }

/* Header: three actions and one account menu. */
.header-actions .account-menu > summary { width: 44px; min-height: 44px; padding: 0; justify-content: center; border-radius: 50%; color: var(--ink); }
.header-actions .account-panel { inset: calc(100% + 4px) 0 auto auto; width: 168px; z-index: 20; }
.account-panel > .account-control { max-width: none; margin-top: 4px; border-top: 1px solid var(--line); border-radius: 0; color: var(--muted); font-size: inherit; }
.account-avatar-frame { display: grid; place-items: center; width: 32px; height: 32px; border: 1px solid var(--line); border-radius: 50%; overflow: hidden; background: var(--surface-alt); color: var(--muted); }
.account-menu > summary:hover .account-avatar-frame, .account-menu[open] .account-avatar-frame { border-color: var(--line-strong); color: var(--ink); }
#account-avatar { width: 100%; height: 100%; }
#account-avatar-placeholder { display: none; font-size: 14px; font-weight: 650; line-height: 1; color: var(--ink); }
#account-avatar[hidden] + #account-avatar-placeholder { display: block; }
#account-avatar, .account-avatar-preview, .account-avatar-preview img { border-radius: 50%; object-fit: cover; }
.account-dialog { --compact-dialog-width: 430px; }
.account-dialog .dialog-tabs button[aria-pressed="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.account-avatar-row { display: flex; align-items: center; gap: 10px; }
.account-password-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
.account-avatar-preview { position: relative; display: grid; place-items: center; width: 64px; height: 64px; flex: none; background: var(--surface-alt); color: var(--muted); border: 1px solid var(--line); font-size: 23px; overflow: hidden; }
.account-avatar-preview img { position: absolute; inset: 0; width: 100%; height: 100%; }
.account-avatar-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.account-avatar-row .creation-note { margin: 6px 0 0; }
.account-dialog .creation-actions { margin-bottom: 0; }
.account-status { margin: 10px 0 0; color: var(--muted); font-size: 13px; }
.account-status:empty { display: none; }
.account-status[data-error] { color: var(--accent); }
.composer-models:not(:has(> details:not([hidden]))) { display: none; }
@media (max-width: 600px) {
  .header-actions { flex-wrap: nowrap; gap: 2px; font-size: 12px; }
  .header-actions > button { padding-inline: 8px; }
  .header-actions .new-chat { padding-left: 10px; gap: 5px; }
}
.header-actions > button, .header-actions .account-panel > button { font-size: 13px; }

.work-reviews { padding: 12px 14px; border-top: 1px solid var(--line); background: var(--surface-alt); display: grid; gap: 10px; }
.work-reviews-title { font-size: 11.5px; font-weight: 600; color: var(--muted); letter-spacing: .04em; }
.work-review-item { padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); display: grid; gap: 6px; font-size: 13px; }
.work-review-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.work-review-badge { display: inline-flex; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.work-review-badge.is-approved { background: rgba(34,116,71,.12); color: #1d643d; }
.work-review-badge.is-changes { background: rgba(185,58,43,.12); color: var(--accent); }
.work-review-item p { margin: 0; color: var(--ink); line-height: 1.6; }
.work-review-apply { justify-self: start; min-height: 32px; padding: 5px 11px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--paper); color: var(--ink); font-size: 12px; cursor: pointer; }
.work-review-apply:hover { border-color: var(--accent); color: var(--accent); }
