/* AI 表情包生成台（/tools/ai-studio）—— 复用 styles.css 主题变量，深色随 body.dark */
:root { --as-line: rgba(127, 127, 127, 0.24); --as-soft: rgba(77, 107, 254, 0.08); }
body.dark { --as-line: rgba(255, 255, 255, 0.13); --as-soft: rgba(93, 121, 255, 0.14); }

.as-main { width: 100%; max-width: 1560px; margin: 0 auto; padding: 84px 16px 48px; box-sizing: border-box; }
body.gj-has-dock .as-main { padding-bottom: 104px; }

.as-topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  display: flex; align-items: center; gap: 12px; padding: 12px 16px; box-sizing: border-box;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(12px) saturate(1.5);
  -webkit-backdrop-filter: blur(12px) saturate(1.5);
  color: var(--text-color);
  border-bottom: 1px solid rgba(77, 107, 254, 0.14);
  box-shadow: 0 1px 12px rgba(23, 35, 80, 0.06);
}
body.dark .as-topbar { background: rgba(28, 30, 38, 0.82); border-bottom: 1px solid rgba(255, 255, 255, 0.09); box-shadow: none; }
.as-topbar a { color: var(--text-color); text-decoration: none; white-space: nowrap; }
.as-top-title { flex: 1; min-width: 0; font-weight: 700; font-size: 1em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.as-top-actions { display: flex; align-items: center; gap: 8px; }
.as-top-link { font-size: 0.82em; opacity: 0.78; border: 1px solid var(--as-line); border-radius: 999px; padding: 4px 10px; }
.as-top-link:hover { opacity: 1; border-color: var(--primary-color); }
.as-topbar select {
  /* 2026-11-19 语言切换器 token 归一：与全站多数派（archive/persona 等）逐字对齐 */
  padding: 3px 6px; border-radius: 6px; border: 1px solid rgba(77, 107, 254, 0.35);
  background: transparent; color: var(--text-color); font-size: 0.85em;
}
body.dark .as-topbar select { border-color: rgba(143, 166, 255, 0.4); }
.as-icon-btn {
  border: 1px solid var(--as-line); background: var(--bg-color); color: var(--text-color);
  border-radius: 8px; padding: 4px 8px; cursor: pointer; font-size: 0.9em;
}
.as-icon-btn:hover { border-color: var(--primary-color); }

.as-hero { text-align: center; margin: 2px auto 16px; max-width: 980px; }
.as-hero h1 { font-size: clamp(1.25em, 2.2vw, 1.75em); margin: 0 0 6px; line-height: 1.35; }
.as-h1-tail { font-size: 0.62em; font-weight: 500; opacity: 0.72; white-space: nowrap; }
.as-hero p { margin: 4px auto 0; font-size: 0.9em; opacity: 0.8; max-width: 760px; }
.as-hero .as-hero-note { font-size: 0.76em; opacity: 0.55; margin-top: 6px; }

.as-layout { display: grid; grid-template-columns: 320px minmax(0, 1fr) 360px; gap: 16px; align-items: start; min-width: 0; }
.as-stage, .as-library, .as-side, .as-card, .as-panel, .as-slots, .as-grid, .as-chips, .as-row, .as-board { min-width: 0; }
.as-library, .as-side { max-width: 100%; }
@media (max-width: 1199.98px) {
  .as-layout { grid-template-columns: 300px minmax(0, 1fr); }
  .as-side { grid-column: 1 / -1; }
}
@media (max-width: 1023.98px) {
  .as-layout { display: flex; flex-direction: column; gap: 14px; width: 100%; max-width: 100%; min-width: 0; }
  .as-stage { order: 1; width: 100%; max-width: 100%; min-width: 0; }
  .as-library { order: 2; width: 100%; max-width: 100%; min-width: 0; }
  .as-side { order: 3; width: 100%; max-width: 100%; min-width: 0; }
  .as-chips { max-width: 100%; }
}

.as-panel, .as-card {
  border: 1px solid var(--as-line); border-radius: 14px; padding: 12px;
  background: var(--bg-color);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7), 0 2px 10px rgba(23, 35, 80, 0.07);
  box-sizing: border-box;
}
body.dark .as-panel, body.dark .as-card { box-shadow: none; }
.as-card { padding: 14px; }
.as-panel-head, .as-card-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.as-panel-head h2, .as-card-head h2 { margin: 0; font-size: 0.98em; flex: 1; min-width: 0; }
.as-muted { font-size: 0.75em; opacity: 0.62; }
.as-note { font-size: 0.72em; opacity: 0.62; line-height: 1.6; margin: 10px 0 0; }

/* ---------- tabs / chips / buttons ---------- */
.as-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 8px; }
.as-tab {
  flex: 1 1 auto; padding: 6px 10px; border-radius: 9px; cursor: pointer; font-size: 0.84em;
  border: 1px solid var(--as-line); background: transparent; color: var(--text-color);
}
.as-tab.on { background: var(--primary-color); color: #fff; border-color: var(--primary-color); }
.as-chips { display: flex; gap: 6px; overflow-x: auto; padding: 6px 0; scrollbar-width: thin; }
.as-chip {
  flex: 0 0 auto; padding: 4px 11px; border-radius: 999px; cursor: pointer; font-size: 0.78em;
  border: 1px solid var(--as-line); background: transparent; color: var(--text-color); white-space: nowrap;
}
.as-chip.on { background: var(--primary-color); color: #fff; border-color: var(--primary-color); }
.as-btn {
  padding: 8px 14px; border-radius: 9px; border: 1px solid var(--primary-color);
  background: var(--bg-color); color: var(--text-color); cursor: pointer; font-size: 0.86em;
  transition: background-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}
.as-btn:hover:not(:disabled) { background: var(--primary-color); color: #fff; }
.as-btn:active:not(:disabled) { transform: scale(0.95); }
.as-btn.primary { background: var(--primary-grad, var(--primary-color)); color: #fff; font-weight: 600; border-color: transparent; }
.as-btn.primary:hover:not(:disabled) { filter: brightness(1.07); background: var(--primary-grad, var(--primary-color)); }
.as-btn.ghost { border-color: var(--as-line); }
.as-btn.small { padding: 5px 10px; font-size: 0.78em; }
.as-btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---------- library ---------- */
.as-mine-tools { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 8px; }
.as-search {
  width: 100%; box-sizing: border-box; padding: 8px 12px; border-radius: 9px;
  border: 1px solid var(--as-line); background: var(--bg-color); color: var(--text-color);
}
.as-count { font-size: 0.74em; opacity: 0.6; margin: 2px 0 6px; }
.as-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px;
  max-height: min(64vh, 680px); overflow-y: auto; padding: 2px; scrollbar-width: thin;
}
.as-thumb {
  position: relative; aspect-ratio: 3 / 4; border-radius: 10px; overflow: hidden; cursor: pointer;
  border: 2px solid transparent; background: rgba(127, 127, 127, 0.12);
}
.as-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.as-thumb.pose img { object-fit: contain; background: #f6f7fb; }
body.dark .as-thumb.pose img { background: #24262e; }
.as-thumb:hover { border-color: var(--as-line); }
.as-thumb .as-thumb-tag {
  position: absolute; left: 4px; bottom: 4px; right: 4px; font-size: 0.6em; padding: 2px 5px;
  border-radius: 5px; background: rgba(20, 30, 60, 0.66); color: #fff;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.as-thumb .as-thumb-badge {
  position: absolute; top: 4px; left: 4px; font-size: 0.58em; padding: 1px 5px;
  border-radius: 5px; background: rgba(255, 255, 255, 0.86); color: #1e232c;
}
.as-lib-note { font-size: 0.78em; opacity: 0.66; text-align: center; padding: 12px 0 4px; line-height: 1.6; }
.as-sentinel { height: 8px; }

/* ---------- stage / slots ---------- */
.as-stage { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.as-slots { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.as-slot {
  border: 1px dashed var(--as-line); border-radius: 12px; padding: 8px; min-height: 100px;
  display: flex; flex-direction: column; gap: 6px; background: var(--bg-color); position: relative;
}
.as-slot.on { border-style: solid; border-color: var(--primary-color); background: var(--as-soft); }
.as-slot-title { font-size: 0.72em; opacity: 0.62; }
.as-slot-body { display: flex; gap: 6px; align-items: center; min-width: 0; }
.as-slot-body img { width: 46px; height: 60px; object-fit: cover; border-radius: 7px; background: rgba(127, 127, 127, 0.12); }
.as-slot-name { font-size: 0.74em; line-height: 1.35; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.as-slot-empty { font-size: 0.72em; opacity: 0.5; padding: 12px 0; }
.as-row-inline { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; }
.as-slot-clear {
  position: absolute; top: 4px; right: 4px; border: 0; background: rgba(20, 30, 60, 0.55); color: #fff;
  border-radius: 999px; width: 20px; height: 20px; line-height: 18px; font-size: 0.7em; cursor: pointer;
}
.as-slot-clear:hover { background: var(--primary-color); }

.as-board { display: flex; gap: 8px; flex-wrap: wrap; min-height: 96px; align-items: flex-start; }
.as-board-tile {
  width: 96px; border-radius: 10px; overflow: hidden; border: 1px solid var(--as-line); background: var(--bg-color);
  position: relative;
}
.as-board-remove {
  position: absolute; top: 3px; right: 3px; z-index: 2; border: 0; border-radius: 999px;
  width: 20px; height: 20px; background: rgba(20, 30, 60, 0.62); color: #fff; cursor: pointer; font-size: 0.68em;
}
.as-board-tile img { display: block; width: 100%; height: 118px; object-fit: contain; background: #f6f7fb; }
body.dark .as-board-tile img { background: #24262e; }
.as-board-tile span { display: block; font-size: 0.62em; padding: 4px 5px; opacity: 0.7; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.as-board-empty { font-size: 0.78em; opacity: 0.5; padding: 26px 4px; }

.as-row { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 8px; }
.as-label { flex: 0 0 52px; font-size: 0.78em; opacity: 0.65; padding-top: 6px; }
.as-row .as-chips { flex: 1; min-width: 0; flex-wrap: wrap; overflow: visible; }
.as-textarea {
  width: 100%; box-sizing: border-box; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--as-line); background: var(--bg-color); color: var(--text-color);
  font: inherit; font-size: 0.86em; line-height: 1.65; resize: vertical; min-height: 140px;
}
.as-prompt-foot { display: flex; gap: 10px; justify-content: space-between; margin-top: 6px; }
.as-controls { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.as-size-label { display: flex; align-items: center; gap: 6px; font-size: 0.8em; }
.as-size-label select {
  padding: 6px 8px; border-radius: 8px; border: 1px solid var(--as-line);
  background: var(--bg-color); color: var(--text-color); font-size: 1em;
}
.as-status { font-size: 0.76em; opacity: 0.68; min-width: 0; }
.as-status.error { color: #d64545; opacity: 1; }
.as-status.ok { color: #2f9e6b; opacity: 1; }

.as-result { min-height: 120px; }
.as-result-empty { font-size: 0.8em; opacity: 0.5; padding: 30px 4px; }
.as-result img { display: block; max-width: 100%; max-height: 520px; border-radius: 12px; margin: 0 auto 10px; border: 1px solid var(--as-line); }
.as-result-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

/* ---------- side / provider ---------- */
.as-provider-tabs { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 10px; }
.as-provider-tab {
  padding: 5px 9px; border-radius: 8px; border: 1px solid var(--as-line);
  background: transparent; color: var(--text-color); cursor: pointer; font-size: 0.78em;
}
.as-provider-tab.on { background: var(--primary-color); color: #fff; border-color: var(--primary-color); }
.as-provider-form { display: flex; flex-direction: column; gap: 9px; }
.as-field { display: flex; flex-direction: column; gap: 4px; }
.as-field label { font-size: 0.74em; opacity: 0.68; }
.as-field input, .as-field select, .as-input {
  width: 100%; box-sizing: border-box; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--as-line); background: var(--bg-color); color: var(--text-color); font-size: 0.82em;
}
.as-field input[readonly] { opacity: 0.66; }
.as-field-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 0.76em; }
.as-field-row input[type="checkbox"] { width: auto; }
.as-hint { font-size: 0.7em; opacity: 0.55; line-height: 1.5; }
.as-side-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.as-history-head { margin-top: 14px; }
.as-history { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; max-height: 420px; overflow-y: auto; }
.as-history-card { border: 1px solid var(--as-line); border-radius: 9px; overflow: hidden; background: var(--bg-color); position: relative; }
.as-history-card img { display: block; width: 100%; aspect-ratio: 1 / 1; object-fit: cover; cursor: pointer; }
.as-history-card .as-history-meta { padding: 4px 6px; font-size: 0.62em; opacity: 0.62; display: flex; justify-content: space-between; gap: 4px; }
.as-history-card button {
  position: absolute; top: 4px; right: 4px; border: 0; border-radius: 999px; width: 20px; height: 20px;
  background: rgba(20, 30, 60, 0.6); color: #fff; cursor: pointer; font-size: 0.7em;
}
.as-history-empty { grid-column: 1 / -1; font-size: 0.78em; opacity: 0.5; padding: 14px 4px; text-align: center; }

/* ---------- about / footer ---------- */
.as-about { max-width: 900px; margin: 40px auto 0; padding: 0 4px; line-height: 1.85; font-size: 0.92em; }
.as-about h2 { font-size: 1.12em; margin: 26px 0 8px; }
.as-about h3 { font-size: 0.98em; margin: 16px 0 4px; }
.as-about p { margin: 6px 0; opacity: 0.82; }
.as-about a { color: var(--primary-color); }
.as-about code { background: var(--as-soft); padding: 1px 5px; border-radius: 5px; font-size: 0.9em; }
.as-footer { max-width: 900px; margin: 34px auto 10px; padding: 18px 4px 0; border-top: 1px solid var(--as-line); font-size: 0.74em; opacity: 0.64; line-height: 1.8; }
.as-footer p { margin: 2px 0; }
.as-footer a { color: inherit; }

/* ---------- dialogs / toast ---------- */
.as-dialog {
  border: 1px solid var(--as-line); border-radius: 16px; padding: 0; max-width: min(560px, 92vw);
  background: var(--bg-color); color: var(--text-color); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}
.as-dialog::backdrop { background: rgba(10, 14, 24, 0.55); backdrop-filter: blur(3px); }
.as-dlg-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--as-line); }
.as-dlg-head h3 { margin: 0; font-size: 0.98em; flex: 1; }
.as-dlg-body { padding: 14px; font-size: 0.84em; line-height: 1.75; }
.as-dlg-actions { display: flex; gap: 8px; flex-wrap: wrap; padding: 0 14px 14px; }
.as-viewer-main { text-align: center; margin-bottom: 8px; }
.as-viewer-main img { max-width: 100%; max-height: 46vh; object-fit: contain; border-radius: 10px; background: #f6f7fb; }
body.dark .as-viewer-main img { background: #24262e; }
.as-viewer-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.as-viewer-item { border: 1px solid var(--as-line); border-radius: 10px; overflow: hidden; cursor: pointer; background: var(--bg-color); }
.as-viewer-item.on { border-color: var(--primary-color); box-shadow: 0 0 0 2px rgba(77, 107, 254, 0.22); }
.as-viewer-item img { display: block; width: 100%; aspect-ratio: 3 / 4; object-fit: contain; background: #f6f7fb; }
body.dark .as-viewer-item img { background: #24262e; }
.as-viewer-item span { display: block; padding: 4px 6px; font-size: 0.7em; opacity: 0.7; }
.as-toast {
  position: fixed; left: 50%; bottom: 84px; transform: translate(-50%, 12px); z-index: 1200;
  background: rgba(20, 26, 40, 0.92); color: #fff; padding: 8px 16px; border-radius: 999px;
  font-size: 0.82em; opacity: 0; pointer-events: none; transition: opacity 0.2s ease, transform 0.2s ease;
  max-width: 86vw; text-align: center;
}
.as-toast.on { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 640px) {
  .as-main { padding-top: 78px; }
  .as-top-actions .as-top-link { display: none; }
  .as-h1-tail { display: block; white-space: normal; }
  .as-slots { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .as-grid { grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); max-height: 52vh; }
  .as-history { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .as-label { flex-basis: 42px; }
}
