:root {
  --bg: #f5f5f7;
  --panel: rgba(255, 255, 255, .72);
  --text: #17181c;
  --muted: #707783;
  --line: rgba(0, 0, 0, .08);
  --primary: #007aff;
  --primary-2: #34c759;
  --danger: #ef4444;
  --success: #16a34a;
  --shadow: 0 22px 70px rgba(30, 35, 50, .14);
  --glass: rgba(255, 255, 255, .68);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(85,106,241,.13), transparent 34%),
    linear-gradient(180deg, #fbfcff 0%, var(--bg) 100%);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", Arial, sans-serif;
}
body.template-surface {
  min-height: 100vh;
  padding-bottom: 330px;
  background:
    radial-gradient(circle at 18% -10%, rgba(0,122,255,.13), transparent 28%),
    radial-gradient(circle at 84% 8%, rgba(52,199,89,.12), transparent 24%),
    #f5f5f7;
}
body.template-surface .topbar {
  display: none;
}
body.template-surface .page {
  width: min(1500px, calc(100% - 80px));
  margin-top: 24px;
}
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }
button,
.send-btn,
.tool-pill,
.mini-pill,
.pill,
.nav button,
td button,
.row-form button {
  -webkit-tap-highlight-color: transparent;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease, border-color .18s ease, opacity .18s ease;
}
button:active,
.send-btn:active,
.tool-pill:active,
.mini-pill:active,
.pill:active,
td button:active {
  transform: scale(.97);
}
img { max-width: 100%; display: block; }

.topbar {
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255,255,255,.78);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; }
.brand-mark {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border-radius: 10px;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
}
.nav { display: flex; align-items: center; gap: 18px; font-size: 14px; }
.pill, .nav button {
  border: 0;
  border-radius: 999px;
  padding: 9px 14px;
  color: #fff;
  background: var(--primary);
  cursor: pointer;
}
.inline-form { margin: 0; }

.page { width: min(1440px, calc(100% - 40px)); margin: 28px auto 70px; }
.panel {
  background: var(--panel);
  border: 1px solid rgba(255,255,255,.72);
  border-radius: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
}
.studio { display: grid; grid-template-columns: 410px 1fr; gap: 24px; align-items: start; }
.composer { padding: 22px; position: sticky; top: 88px; }
.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.tabs button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 7px 11px;
  color: var(--muted);
}
.tabs .active { color: #fff; background: var(--primary); border-color: var(--primary); }
h1, h2, h3 { margin: 0; letter-spacing: 0; }
h1 { font-size: 30px; }
h2 { font-size: 23px; }
h3 { font-size: 16px; }
.muted, .section-head p { color: var(--muted); line-height: 1.65; }
.generate-form textarea, .stack-form input, .stack-form textarea, .stack-form select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  outline: none;
  background: #fff;
}
.generate-form textarea:focus, .stack-form input:focus, .stack-form textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(85,106,241,.13);
}
.ratio-row { display: flex; flex-wrap: wrap; gap: 9px; margin: 14px 0; }
.ratio-row label, .check-line {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  color: var(--muted);
}
.send-btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 48px;
  border: 0;
  border-radius: 16px;
  padding: 0 22px;
  color: #fff;
  background: linear-gradient(135deg, #007aff, #5856d6);
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 14px 28px rgba(0,122,255,.24);
}
.generate-form .send-btn { width: 100%; }
.link-btn { margin-top: 8px; }
.ghost { background: #151923; }

.template-panel, .gallery-block { min-width: 0; }
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  margin-bottom: 16px;
}
.section-head a { color: var(--primary); font-weight: 700; }
.template-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.template-grid.large { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.template-card {
  overflow: hidden;
  min-height: 260px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease;
}
.template-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.template-card img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: #e8ebf4; }
.template-card h3, .template-card p { padding: 0 14px; }
.template-card h3 { margin-top: 13px; }
.template-card p { color: var(--muted); font-size: 13px; line-height: 1.55; }
.template-library-card {
  cursor: default;
}
.template-library-card .prompt-preview {
  display: -webkit-box;
  min-height: 62px;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
}
.template-library-card.expanded .prompt-preview {
  display: block;
  min-height: 0;
  overflow: visible;
}
.template-card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 14px 14px;
}
.template-card-actions .mini-pill {
  min-height: 34px;
  padding: 0 11px;
  border-radius: 11px;
  font-size: 13px;
  white-space: nowrap;
}
.prompt-toggle {
  cursor: pointer;
}
.gallery-block { margin-top: 34px; }
.image-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.image-card {
  padding: 10px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid var(--line);
}
.image-card img { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; border-radius: 12px; }
.image-card strong, .image-card span { display: block; padding: 8px 4px 0; }
.image-card span { color: var(--muted); font-size: 13px; }
.image-card small {
  display: block;
  padding: 6px 4px 0;
  color: var(--primary);
  line-height: 1.45;
}
.image-card-pending {
  cursor: default;
}
.image-placeholder {
  width: 100%;
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  border-radius: 12px;
  color: #182033;
  background:
    radial-gradient(circle at 28% 22%, rgba(0,122,255,.18), transparent 34%),
    linear-gradient(145deg, rgba(255,255,255,.88), rgba(237,241,248,.92));
  border: 1px solid rgba(0,0,0,.06);
}
.image-placeholder b {
  font-size: 18px;
}
.image-placeholder em {
  color: var(--muted);
  font-style: normal;
  font-size: 13px;
}
.loader-dot {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid rgba(0,122,255,.16);
  border-top-color: var(--primary);
  animation: spin .9s linear infinite;
}
.image-card.failed .image-placeholder {
  background: #fff1f2;
  color: var(--danger);
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

.auth-card { width: min(460px, 100%); margin: 70px auto; padding: 28px; }
.stack-form { display: grid; gap: 14px; }
.stack-form label { display: grid; gap: 7px; color: var(--muted); }
.flash { margin-bottom: 14px; padding: 12px 14px; border-radius: 12px; background: #eef2ff; color: var(--primary); }
.flash.error { background: #fef2f2; color: var(--danger); }
.flash.success { background: #ecfdf5; color: var(--success); }
.wallet-layout, .detail-layout { display: grid; grid-template-columns: 380px 1fr; gap: 22px; align-items: start; }
.wallet-layout .panel, .detail-layout .panel { padding: 24px; }
.balance { font-size: 66px; font-weight: 900; color: var(--primary); }
.detail-image { width: 100%; border-radius: 18px; box-shadow: var(--shadow); background: #fff; }
.prompt-box { padding: 14px; border-radius: 14px; background: #f5f7fb; line-height: 1.8; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-size: 13px; }

.admin-body { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.admin-side {
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(22,25,32,.96), rgba(10,12,18,.98)),
    #151923;
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.admin-side .brand {
  margin-bottom: 18px;
}
.admin-nav-group {
  margin: 14px 8px 4px;
  color: rgba(255,255,255,.46);
  font-size: 12px;
  font-weight: 900;
}
.admin-side a {
  padding: 12px 13px;
  border-radius: 14px;
  color: rgba(255,255,255,.86);
  font-weight: 800;
  transition: background .18s ease, transform .18s ease;
}
.admin-side a:hover { background: rgba(255,255,255,.1); transform: translateX(2px); }
.admin-main { padding: 30px; min-width: 0; }
.admin-head { margin-bottom: 20px; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.stat { padding: 24px; border-radius: 24px; background: rgba(255,255,255,.78); box-shadow: var(--shadow); border: 1px solid rgba(255,255,255,.8); }
.stat strong { display: block; font-size: 38px; color: var(--primary); }
.stat span { color: var(--muted); }
.wide-form { padding: 22px; margin-bottom: 22px; }
.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}
.settings-card {
  padding: 22px;
  display: grid;
  gap: 14px;
  align-content: start;
}
.settings-card h2 {
  font-size: 20px;
}
.settings-card p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.6;
}
.settings-card label {
  display: grid;
  gap: 7px;
  color: #4f5663;
  font-weight: 800;
}
.settings-card input,
.settings-card select {
  width: 100%;
  border: 1px solid rgba(0,0,0,.08);
  border-radius: 14px;
  padding: 12px 13px;
  background: rgba(255,255,255,.86);
  outline: none;
}
.settings-inline {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.callback-preview {
  display: grid;
  gap: 8px;
  padding: 12px;
  border-radius: 16px;
  background: rgba(0,122,255,.06);
  border: 1px solid rgba(0,122,255,.12);
}
.callback-preview span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}
.callback-preview code {
  overflow-wrap: anywhere;
  font-size: 12px;
  color: #0f172a;
}
.settings-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
}
.table-wrap { padding: 14px; overflow: auto; }
.row-form { display: flex; gap: 8px; align-items: center; margin: 0; }
.row-form input[type="number"] { width: 110px; }
.row-form input {
  max-width: 160px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.row-form button, td button {
  border: 0;
  border-radius: 12px;
  padding: 9px 13px;
  background: rgba(0,122,255,.11);
  color: #006ee6;
  font-weight: 900;
  cursor: pointer;
}
.thumb { width: 72px; height: 54px; object-fit: cover; border-radius: 10px; background: #eef0f5; }
.install-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }

.template-home {
  padding: 0 0 18px;
}
.template-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  margin: 4px 0 34px;
}
.template-toolbar h1 {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 38px;
  font-weight: 900;
  color: #101114;
}
.title-mark {
  width: 30px;
  height: 30px;
  border: 5px solid #111;
  border-radius: 50%;
  position: relative;
  display: inline-block;
}
.title-mark:before,
.title-mark:after {
  content: "";
  position: absolute;
  inset: -9px;
  border: 4px solid #111;
  border-radius: 50%;
  transform: rotate(60deg) scaleX(.42);
}
.title-mark:after {
  transform: rotate(-60deg) scaleX(.42);
}
.template-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}
.tool-pill,
.template-actions button {
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255,255,255,.78);
  border-radius: 16px;
  padding: 0 16px;
  background: rgba(255,255,255,.76);
  color: #17191f;
  font-weight: 800;
  box-shadow: 0 10px 28px rgba(20,24,35,.08), inset 0 1px 0 rgba(255,255,255,.95);
  backdrop-filter: blur(18px) saturate(180%);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  cursor: pointer;
}
.tool-pill:hover,
.template-actions button:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 34px rgba(20,24,35,.12), inset 0 1px 0 rgba(255,255,255,.95);
}
.masonry-grid {
  column-count: 5;
  column-gap: 18px;
}
.masonry-card {
  position: relative;
  overflow: hidden;
  display: inline-block;
  width: 100%;
  margin: 0 0 18px;
  border-radius: 30px;
  background:
    linear-gradient(135deg, rgba(255,255,255,.7), rgba(255,255,255,.18)),
    #e9ebef;
  cursor: pointer;
  isolation: isolate;
  box-shadow: 0 10px 28px rgba(0,0,0,.06), inset 0 1px 0 rgba(255,255,255,.5);
  transform: translateZ(0);
  transition: transform .24s ease, box-shadow .24s ease, filter .24s ease;
}
.masonry-card.span-1 { aspect-ratio: 1 / 1.23; }
.masonry-card.span-2 { aspect-ratio: 1 / .97; }
.masonry-card.span-3 { aspect-ratio: 1 / 1.34; }
.masonry-card.span-4 { aspect-ratio: 1 / 1.04; }
.masonry-card.span-5 { aspect-ratio: 1 / 1.18; }
.masonry-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .28s ease;
}
.masonry-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 44px rgba(0,0,0,.12);
}
.masonry-card:hover img {
  transform: scale(1.035);
}
.card-shade {
  position: absolute;
  inset: auto 0 0;
  height: 45%;
  z-index: 1;
  background: linear-gradient(180deg, transparent, rgba(0,0,0,.55));
}
.masonry-card h3 {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 18px;
  z-index: 2;
  color: #fff;
  font-size: 17px;
  font-weight: 900;
  text-shadow: 0 2px 16px rgba(0,0,0,.45);
}
.composer-dock {
  position: fixed;
  left: max(18px, calc((100vw - 1500px) / 2 + 18px));
  right: max(18px, calc((100vw - 1500px) / 2 + 18px));
  bottom: 18px;
  z-index: 30;
  margin: 0;
  padding: 16px;
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 18px;
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(255,255,255,.86), rgba(248,250,255,.76));
  border: 1px solid rgba(255,255,255,.82);
  box-shadow: 0 24px 80px rgba(0,0,0,.18), inset 0 1px 0 rgba(255,255,255,.9);
  max-height: min(56vh, 520px);
  overflow: auto;
  backdrop-filter: blur(26px) saturate(180%);
  -webkit-backdrop-filter: blur(26px) saturate(180%);
}
.composer-dock .generate-form {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  gap: 12px;
  align-items: start;
}
.composer-title {
  display: flex;
  align-items: center;
  gap: 12px;
}
.composer-title > div {
  min-width: 0;
  flex: 1;
}
.composer-title h2 {
  font-size: 20px;
}
.composer-title p {
  margin: 4px 0 0;
  color: var(--muted);
  line-height: 1.5;
  font-size: 13px;
}
.composer-orb {
  width: 42px;
  height: 42px;
  border-radius: 16px;
  background: linear-gradient(135deg, #007aff, #34c759);
  box-shadow: 0 12px 24px rgba(0,122,255,.25);
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 13px;
  font-weight: 1000;
  letter-spacing: 0;
  position: relative;
  overflow: hidden;
}
.composer-orb:before {
  content: "AI";
  position: relative;
  z-index: 1;
}
.composer-orb:after {
  content: "";
  position: absolute;
  inset: 4px 5px auto;
  height: 15px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255,255,255,.58), transparent);
}
.composer-toggle {
  display: none;
  min-height: 36px;
  border: 0;
  border-radius: 13px;
  padding: 0 13px;
  color: #fff;
  background: #111827;
  font-weight: 900;
  cursor: pointer;
}
.composer-pulse {
  animation: composerPulse .65s ease;
}
@keyframes composerPulse {
  0%, 100% { transform: translateY(0) scale(1); }
  45% { transform: translateY(-4px) scale(1.01); }
}
.control-block {
  display: grid;
  gap: 8px;
  grid-column: 1 / -1;
}
.control-block strong {
  font-size: 14px;
}
.ratio-row label {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid rgba(0,0,0,.08);
  border-radius: 999px;
  background: rgba(255,255,255,.72);
  color: #30333a;
  font-weight: 700;
  cursor: pointer;
}
.ratio-row input,
.segmented input {
  display: none;
}
.ratio-row label:has(input:checked) {
  color: #fff;
  background: #111827;
  border-color: #111827;
}
.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  min-width: 300px;
  border-radius: 16px;
  background: rgba(118,118,128,.12);
}
.segmented label {
  min-height: 40px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  color: #555b66;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
}
.segmented input:checked + span {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border-radius: 12px;
  color: #111;
  background: rgba(255,255,255,.96);
  box-shadow: 0 5px 14px rgba(0,0,0,.12);
}
.quick-controls {
  display: flex;
  align-items: stretch;
  gap: 10px;
}
.quick-controls .send-btn {
  width: auto;
  white-space: nowrap;
}
.reference-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  grid-column: 1 / -1;
}
.reference-grid label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}
.reference-grid input,
.reference-grid textarea,
.generate-form textarea {
  width: 100%;
  border: 1px solid rgba(0,0,0,.08);
  border-radius: 16px;
  padding: 12px;
  background: rgba(255,255,255,.82);
  outline: none;
}
.reference-grid input[type="file"] {
  padding: 8px;
  color: #5b6472;
  cursor: pointer;
}
.reference-grid input[type="file"]::file-selector-button {
  margin-right: 10px;
  border: 0;
  border-radius: 12px;
  padding: 9px 13px;
  color: #fff;
  background: linear-gradient(135deg, #111827, #2f3645);
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(17,24,39,.18);
}
.reference-grid input[type="file"]::-webkit-file-upload-button {
  margin-right: 10px;
  border: 0;
  border-radius: 12px;
  padding: 9px 13px;
  color: #fff;
  background: linear-gradient(135deg, #111827, #2f3645);
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(17,24,39,.18);
}
.reference-grid input[type="file"]:hover::file-selector-button {
  background: linear-gradient(135deg, #007aff, #5856d6);
}
.generate-form > textarea {
  min-height: 96px;
  resize: vertical;
}
.advanced-panel {
  grid-column: 1 / -1;
  border-radius: 18px;
  background: rgba(255,255,255,.46);
  border: 1px solid rgba(255,255,255,.72);
  padding: 10px 12px;
}
.advanced-panel summary {
  cursor: pointer;
  font-weight: 900;
  color: #20232a;
  list-style: none;
}
.advanced-panel summary::-webkit-details-marker {
  display: none;
}
.advanced-panel summary:after {
  content: "展开";
  float: right;
  color: var(--primary);
}
.advanced-panel[open] summary:after {
  content: "收起";
}
.records-page {
  padding: 24px;
}
.mini-pill {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--primary);
  font-weight: 800;
}
.plus { color: var(--success); font-weight: 800; }
.minus { color: var(--danger); font-weight: 800; }
.guide-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.guide-grid article {
  padding: 18px;
  border-radius: 16px;
  background: #f8f9fc;
  border: 1px solid var(--line);
}
.guide-grid p {
  color: var(--muted);
  line-height: 1.7;
}

@media (max-width: 1300px) {
  .masonry-grid { column-count: 4; }
}
@media (max-width: 1000px) {
  .studio, .wallet-layout, .detail-layout { grid-template-columns: 1fr; }
  .composer { position: static; }
  .template-grid, .template-grid.large, .image-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  body.template-surface .page { width: min(100% - 36px, 1440px); }
  .masonry-grid { column-count: 3; }
  .composer-dock {
    left: 14px;
    right: 14px;
    bottom: 14px;
    grid-template-columns: 1fr;
  }
  .composer-dock .generate-form { grid-template-columns: 1fr; }
  .quick-controls { justify-content: space-between; }
  .segmented {
    min-width: 0;
    width: 100%;
  }
  .settings-grid { grid-template-columns: 1fr; }
  .settings-actions { justify-content: stretch; }
  .settings-actions .send-btn { width: 100%; }
  .template-toolbar { align-items: flex-start; flex-direction: column; margin-bottom: 22px; }
  .template-toolbar h1 { white-space: nowrap; }
  .template-actions { justify-content: flex-start; }
}
@media (max-width: 760px) {
  .masonry-grid { column-count: 2; }
}
@media (max-width: 700px) {
  .topbar { padding: 0 16px; height: auto; min-height: 64px; flex-wrap: wrap; gap: 10px; }
  .nav { gap: 9px; flex-wrap: wrap; padding-bottom: 10px; }
  .page { width: min(100% - 22px, 1440px); margin-top: 16px; }
  .template-grid, .template-grid.large, .image-grid, .stat-grid { grid-template-columns: 1fr; }
  .admin-body { grid-template-columns: 1fr; }
  .admin-side { position: static; padding: 14px; }
  .admin-side { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-side .brand, .admin-nav-group { grid-column: 1 / -1; }
  .admin-main { padding: 16px; }
  body.template-surface .page { width: min(100% - 22px, 1440px); }
  .template-toolbar { margin-bottom: 18px; }
  .template-toolbar h1 { font-size: 29px; }
  .template-actions { justify-content: flex-start; }
  .tool-pill, .template-actions button { height: 36px; padding: 0 12px; font-size: 13px; }
  .masonry-grid { column-count: 1; }
  .masonry-card { border-radius: 22px; }
  .template-library-card .prompt-preview {
    min-height: 0;
    -webkit-line-clamp: 3;
  }
  .template-card-actions {
    flex-wrap: wrap;
  }
  .template-card-actions .mini-pill {
    flex: 1;
    justify-content: center;
  }
  .reference-grid, .guide-grid { grid-template-columns: 1fr; }
  .settings-inline { grid-template-columns: 1fr; }
  body.template-surface { padding-bottom: 118px; }
  .composer-dock {
    left: 8px;
    right: 8px;
    bottom: 8px;
    padding: 10px;
    border-radius: 22px;
    max-height: calc(100vh - 22px);
    grid-template-columns: 1fr;
    gap: 10px;
  }
  body.template-surface.composer-expanded,
  body.template-surface:has(.composer-dock.composer-open) {
    padding-bottom: 390px;
  }
  .composer-dock:not(.composer-open) .generate-form {
    display: none;
  }
  .composer-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
  }
  .composer-dock.composer-open .composer-toggle {
    background: rgba(17,24,39,.12);
    color: #111827;
  }
  .composer-title h2 { font-size: 18px; }
  .composer-title p { display: none; }
  .composer-orb {
    width: 38px;
    height: 38px;
    border-radius: 14px;
  }
  .quick-controls { flex-direction: column; }
  .quick-controls .send-btn, .send-btn { width: 100%; }
}
@media (max-width: 560px) {
  .masonry-grid { column-count: 1; }
}
