/* Shared readability and interaction rules for the existing Image Studio UI. */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-block: 24px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.6;
}

/* Scoped to app controls; exported images and the standalone canvas are unaffected. */
:is(#appShell, #authScreen, #developerApiDialog, #creationSettingsDialog,
  #smartProjectForm, #iterationPromptReview, #iterationAssistantDialog,
  #conversationStudioDialog, #storyboardWorkspaceDialog, #contextPolicyDialog,
  #batchDrawer, #imageModal, #imageExportDialog, #agentExecutionDialog,
  #workflowEditor, .help-assistant-panel, .smart-project-question-dialog)
  :is(button, select, summary, input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="range"])) {
  min-height: 44px;
  min-width: 44px;
  font-size: 14px;
  line-height: 1.5;
}

:is(#appShell, #developerApiDialog, #creationSettingsDialog, #smartProjectForm,
  #iterationPromptReview, #iterationAssistantDialog, #conversationStudioDialog,
  #storyboardWorkspaceDialog, #contextPolicyDialog, #batchDrawer)
  :is(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), select, textarea) {
  font-size: 16px;
  font-weight: 400;
}

textarea {
  line-height: 1.7;
  overflow-wrap: anywhere;
}

button:not(:disabled), summary, label:has(input[type="checkbox"]), label:has(input[type="radio"]) {
  cursor: pointer;
  touch-action: manipulation;
}

:is(button, a, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 3px solid var(--theme-accent, #4f6faf);
  outline-offset: 3px;
}

input::placeholder, textarea::placeholder {
  color: var(--theme-text-muted, #596579);
  opacity: 1;
}

.creation-task-card strong,
.plan-mode-panel .conversation-studio-trigger-copy strong,
.creation-tool-button strong,
.iteration-quick-tools strong {
  font-size: 16px;
  line-height: 1.5;
  font-weight: 650;
}

.creation-task-card small,
.creation-tool-button small,
.mode-screen-intro p,
.plan-mode-note,
.agent-plan-task-guidance {
  font-size: 14px;
  line-height: 1.6;
}

.creation-task-card {
  min-height: 96px;
  padding: 16px;
}

.creation-task-card > span:nth-child(2) { gap: 6px; }
.creation-task-grid { gap: 12px; }
.control-mode-switcher { gap: 8px; }
.workspace-tab { padding-inline: 16px; }
.workspace-tabs { gap: 8px; }
.rail-avatar { flex-shrink: 0; }

/* The task-specific settings hide the former tab strip, leaving three rows. */
.creation-settings-dialog {
  grid-template-rows: auto minmax(0, 1fr) auto;
}
.creation-settings-dialog[data-active-panel="output"] { height: auto; }
.creation-settings-footer {
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding-block: 16px;
}
.creation-settings-footer .secondary-button {
  flex: 0 0 auto;
  width: auto;
  padding: 10px 24px;
}

/* Keep status and cost details readable across all eight themes. */
html[data-theme] .log-item :is(strong, span, p),
html[data-theme] .account-task-batch :is(strong, small, b) {
  color: var(--theme-text);
}
html[data-theme] .log-item :is(span, p),
html[data-theme] .account-task-batch small {
  color: var(--theme-text-muted);
  font-size: 14px;
  font-weight: 500;
}

.creation-tool-button :is(strong, small) {
  overflow: visible;
  white-space: normal;
  text-overflow: clip;
  overflow-wrap: anywhere;
}
.creation-tool-button {
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
  min-height: 82px;
  gap: 4px;
  padding: 9px 6px;
  text-align: center;
}
.creation-tool-button > span { justify-items: center; text-align: center; }
.creation-tool-button strong { font-size: 13px; white-space: nowrap; }
.creation-tool-button small { font-size: 12px; line-height: 1.35; }

.model-search-input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--theme-border-strong);
  border-radius: 10px;
  padding: 8px 12px;
  background: var(--theme-panel-raised);
  color: var(--theme-text);
}
.model-search-status { color: var(--theme-text-muted); }
.batch-partial-note { color: var(--theme-danger); font-weight: 700; }
.account-task-center-button[aria-expanded="true"] { display: none; }
.app-shell:has(#accountTaskCenter:not([hidden])) .main-stage { padding-bottom: 94px; }

.sso-recovery-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0; }
.sso-recovery-actions :is(button, a) {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 9px 14px;
  border: 1px solid var(--theme-border-strong);
  border-radius: 10px;
  background: var(--theme-panel);
  color: var(--theme-text);
  font: inherit;
  text-decoration: none;
}
.sso-recovery-actions button:disabled { opacity: .65; cursor: wait; }

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  top: max(16px, env(safe-area-inset-top));
  right: 20px;
  bottom: auto;
  left: auto;
  transform: translateY(-12px);
}
.toast.show { transform: translateY(0); pointer-events: auto; }
.toast-close {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 7px;
  background: rgba(255, 255, 255, .15);
  color: inherit;
  font-size: 20px;
  line-height: 1;
}

.smart-project-question-instruction { color: var(--theme-text-muted); font-size: 13px; }
.smart-project-question-options button[aria-pressed="true"] {
  border: 2px solid var(--theme-accent);
  background: var(--theme-accent-soft);
  box-shadow: 0 0 0 2px var(--theme-panel);
}
.smart-project-question-options button[aria-pressed="true"]::after {
  content: "✓ 已选择";
  grid-column: 2;
  color: var(--theme-accent);
  font-size: 13px;
  font-weight: 700;
}
.reference-dropzone .drop-copy :is(strong, small) {
  overflow: visible;
  white-space: normal;
  text-overflow: clip;
}
.creation-settings-content #referencePreview.has-files { grid-row: 1; }
.creation-settings-content .reference-item { grid-template-columns: 42px minmax(0, 1fr) 36px; }
.creation-settings-content .reference-item button { width: 36px; height: 36px; }
.api-key-list-title { margin: 22px 0 10px; color: var(--theme-text); font-size: 15px; }
.creation-settings-content .field-note { line-height: 1.6; }

.agent-plan-task-summary {
  min-height: 80px;
  padding: 14px 16px;
  gap: 12px;
}
.agent-plan-task-summary > span:nth-child(2) { gap: 6px; }
.agent-plan-task-summary > span:nth-child(2) strong {
  color: var(--theme-text);
  font-size: 16px;
  line-height: 1.5;
  white-space: normal;
  overflow-wrap: anywhere;
}
.agent-plan-task-summary > span:nth-child(2) small {
  color: var(--theme-text-muted);
  font-size: 14px;
  line-height: 1.5;
  white-space: normal;
}
.agent-plan-task-summary > em { font-size: 14px; color: var(--theme-text-muted); }
.agent-plan-task > .agent-plan-task-content { padding: 0 16px 20px 62px; border-color: var(--theme-border); }
.agent-plan-quick-settings { gap: 12px; }
.smart-project-dialog .agent-plan-task .agent-plan-count-setting {
  grid-template-columns: auto minmax(0, 1fr);
  min-width: 220px;
  padding: 8px 12px;
}
.smart-project-dialog .agent-plan-count-setting label { margin: 0; width: auto; }
.agent-plan-count-stepper { display: grid; grid-template-columns: 44px minmax(52px, 1fr) 44px; gap: 8px; align-items: center; }
.agent-plan-count-stepper button { padding: 0; border: 1px solid var(--theme-border-strong); border-radius: 8px; background: var(--theme-panel); color: var(--theme-text); font-size: 20px; }
#smartProjectForm .agent-plan-count-stepper input { width: 100%; padding: 8px; text-align: center; font-variant-numeric: tabular-nums; }
.agent-plan-common-prompt textarea,
.agent-plan-prompt-field textarea,
.iteration-final-prompt-field textarea { line-height: 1.75; min-height: 160px; }
.agent-plan-task-guidance { margin-block: 14px; color: var(--theme-text-muted); }
.smart-project-dialog .smart-project-status.success { color: var(--theme-success); }
.smart-project-dialog .smart-project-status.error { color: var(--theme-danger); }
.iteration-original-request p { font-size: 16px; line-height: 1.75; }

.developer-api-form-fields,
.developer-api-builder-defaults,
.developer-api-batch-fields { gap: 16px; }
.developer-api-tabs { gap: 8px; }
#developerApiDialog :is(pre, code) { font-size: 14px; line-height: 1.7; }
#developerApiDialog label:has(input[type="checkbox"]),
#developerApiDialog label:has(input[type="radio"]) {
  min-height: 44px;
  align-items: center;
  gap: 10px;
  padding-block: 8px;
}
.developer-api-dialog :is(input[type="checkbox"], input[type="radio"]) {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.modal-zoom-toolbar { gap: 8px; padding: 8px; }
.image-modal > .modal-zoom-toolbar { position: fixed; z-index: 3; }
.modal-zoom-toolbar button { flex-shrink: 0; }
.modal-footer { line-height: 1.6; }
.modal-nav { min-width: 48px; min-height: 48px; background: rgba(15, 23, 42, .82); }
.modal-nav:not(:disabled):hover { background: rgba(45, 55, 75, .95); }
.modal-nav:disabled { opacity: .55; }
.batch-drawer-meta { flex-wrap: wrap; row-gap: 8px; }
.batch-drawer-prompt { font-size: 16px; line-height: 1.75; }
.batch-drawer-recipe-toggle-copy { min-width: 0; }
/* A prompt can contain thousands of characters. Keep the collapsed recipe
   compact so its auto-sized grid row cannot displace the generated images. */
.batch-drawer-recipe-toggle-copy strong {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  max-height: 3em;
  overflow: hidden;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.5;
}

/* Preserve a usable image scroll area even on short windows or at high zoom.
   If the fixed controls need more room, the dialog itself remains scrollable. */
.batch-drawer {
  grid-template-rows: auto auto auto minmax(min(200px, 35dvh), 1fr);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.batch-drawer-header {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--theme-panel);
}
.batch-drawer-recipe-content { min-height: 0; }
.batch-drawer-prompt,
.batch-drawer-original-prompt p { overflow-wrap: anywhere; }

@container studio-controls (max-width: 430px) {
  .creation-task-card { min-height: 88px; padding: 14px; }
  .plan-mode-panel .mode-screen-intro p { font-size: 14px; }
  .control-mode-button { padding-inline: 8px; white-space: normal; }
}

@media (max-width: 760px) {
  .agent-plan-task > .agent-plan-task-content { padding-inline: 16px; }
  .agent-plan-quick-settings { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .agent-plan-count-setting { grid-column: 1 / -1; }
  .workspace-tab { padding-inline: 10px; }
  .modal-gesture-hint { display: none; }
}

@media (max-width: 720px) {
  .image-modal > .modal-nav { position: fixed; top: 50%; z-index: 3; transform: translateY(-50%); }
  .image-modal > .modal-nav-previous { left: 10px; right: auto; }
  .image-modal > .modal-nav-next { right: 10px; left: auto; }
  .image-modal > .modal-zoom-toolbar { top: auto; bottom: calc(12px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100vw - 24px); }
  .image-modal { padding-bottom: calc(88px + env(safe-area-inset-bottom)); }
}

@media (max-width: 480px) {
  .smart-project-dialog-body { padding: 16px 10px; }
  .smart-project-dialog .agent-plan-preview { padding: 0; border: 0; background: transparent; }
  .smart-project-dialog-header { grid-template-columns: minmax(0, 1fr) 44px; gap: 12px; padding: 16px; }
  .smart-project-dialog-mark, .smart-project-dialog-eyebrow, .smart-project-dialog-header p { display: none; }
  .smart-project-dialog-header h3 { font-size: 18px; line-height: 1.5; }
  .smart-project-dialog-footer { gap: 10px; padding: 12px 16px; }
  .smart-project-dialog-footer > div:first-child > strong { display: none; }
  .smart-project-dialog .smart-project-status { margin: 0; line-height: 1.5; }
  .smart-project-dialog .smart-project-actions { display: flex; flex-wrap: wrap; gap: 8px; width: 100%; }
  .smart-project-dialog .smart-project-actions button { flex: 1 1 120px; width: auto; min-width: 0; padding: 10px; }
  .smart-project-dialog .agent-plan-common-prompt textarea { min-height: 220px; }
  .smart-project-dialog .agent-plan-task .agent-plan-count-setting { min-width: 0; width: 100%; }
  .creation-settings-header { padding: 16px; }
  .creation-settings-content { padding: 20px 16px; }
  .creation-settings-footer { padding: 12px 16px max(16px, env(safe-area-inset-bottom)); }
  .creation-settings-footer .secondary-button { width: 100%; }
  .agent-plan-task-summary { padding-inline: 12px; }
  .agent-plan-task-summary > em { white-space: normal; }
  .developer-api-tabs { overflow-x: auto; flex-shrink: 0; }
  .developer-api-tabs button { flex-shrink: 0; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .creation-settings-dialog,
  .creation-task-card,
  .agent-plan-task-summary::after { transition: none; }
}
