:root {
  --bg: #f5f7f5;
  --surface: #ffffff;
  --ink: #202124;
  --muted: #77716c;
  --line: #dfe5df;
  --primary: #e64f3d;
  --primary-strong: #c83d2d;
  --accent: #177866;
  --accent-strong: #123f37;
  --soft: #eef3ef;
  --cream: #f9fbf7;
  --warn: #9c3d2f;
  --shadow: 0 18px 45px rgba(46, 32, 22, .08);
  --soft-shadow: 0 12px 30px rgba(46, 32, 22, .06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    linear-gradient(180deg, #fbfcfa 0%, var(--bg) 42%, #eef3ef 100%);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

button, input, textarea, select {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell, .admin-shell {
  width: min(1440px, calc(100% - 40px));
  margin: 0 auto;
  padding: 22px 0 42px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

h1, h2, h3, p { margin: 0; }

h1 {
  font-size: 26px;
  line-height: 1.25;
}

h2 {
  font-size: 20px;
  line-height: 1.35;
}

.eyebrow {
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  margin-bottom: 6px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pill {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 11px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  color: var(--accent);
  font-weight: 700;
  box-shadow: var(--soft-shadow);
}

.ghost-link, .text-btn {
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
}

.text-btn {
  color: var(--muted);
}

.primary, .secondary {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  font-weight: 700;
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}

.primary {
  background: linear-gradient(135deg, var(--primary), #f17856);
  color: white;
  box-shadow: 0 12px 22px rgba(230, 79, 61, .2);
}

.primary:hover {
  background: linear-gradient(135deg, var(--primary-strong), #e95f45);
  transform: translateY(-1px);
}

.secondary {
  background: var(--accent-strong);
  color: white;
}

.hidden { display: none !important; }

.auth-grid {
  min-height: calc(100vh - 56px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 0;
  align-items: center;
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}

body:has(#authView:not(.hidden)) #mainTopbar {
  display: none;
}

body:has(#authView:not(.hidden)) .shell {
  width: min(1180px, calc(100% - 40px));
  padding-top: 28px;
}

.category-panel, .generator-panel, .result-panel, .admin-panel, .admin-login .auth-panel, .student-sidebar, .account-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.intro-panel {
  grid-column: 1 / -1;
  grid-row: 1;
  min-height: 620px;
  padding: 0;
  display: block;
  overflow: hidden;
}

.intro-copy {
  position: relative;
  z-index: 1;
}

.intro-panel h2 {
  max-width: 620px;
  font-size: 38px;
  line-height: 1.18;
}

.intro-panel p {
  max-width: 590px;
  color: var(--muted);
  line-height: 1.8;
  margin-top: 14px;
}

.hero-visual {
  position: relative;
  min-height: 620px;
  height: 100%;
  border-radius: 0;
  overflow: hidden;
  border: 0;
  background: var(--surface);
}

.hero-visual::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(255,255,255,.16) 0%, rgba(255,255,255,.08) 48%, rgba(255,255,255,.66) 72%, rgba(255,255,255,.9) 100%);
  pointer-events: none;
}

.hero-visual img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 620px;
  object-fit: cover;
  transform: scaleX(-1);
}

.flow-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  max-width: 780px;
}

.auth-benefits {
  grid-column: 1 / -1;
  max-width: none;
}

.flow-list span {
  padding: 12px;
  border-radius: 8px;
  background: var(--soft);
  font-weight: 700;
  text-align: center;
}

.auth-panel {
  grid-column: 2;
  grid-row: 1;
  z-index: 2;
  margin-right: 28px;
  padding: 24px;
  align-self: center;
  background: rgba(255, 255, 255, .82);
  border: 1px solid rgba(255, 255, 255, .72);
  border-radius: 8px;
  box-shadow: 0 20px 50px rgba(39, 35, 29, .14);
  backdrop-filter: blur(18px);
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  background: var(--soft);
  border-radius: 8px;
  margin-bottom: 18px;
}

.tab, .nav-btn {
  border: 0;
  background: transparent;
  min-height: 36px;
  border-radius: 6px;
  color: var(--muted);
  font-weight: 700;
}

.tab.active, .nav-btn.active {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
}

.form-stack, .settings-form {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 12px 13px;
  outline: none;
}

textarea {
  min-height: 118px;
  resize: vertical;
  line-height: 1.6;
}

.compact-textarea {
  min-height: 72px;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(36, 124, 112, .12);
}

.workspace {
  display: grid;
  grid-template-columns: 290px minmax(360px, 1fr) minmax(360px, .9fr);
  gap: 16px;
  align-items: start;
}

.student-dashboard {
  display: grid;
  grid-template-columns: 228px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.student-sidebar {
  padding: 14px;
  position: sticky;
  top: 16px;
  min-height: calc(100vh - 88px);
  background:
    linear-gradient(180deg, #143d35 0%, #19372f 48%, #2d3029 100%);
  border-color: rgba(255, 255, 255, .14);
  color: #fff;
  box-shadow: 0 18px 45px rgba(30, 34, 28, .13);
}

.student-card {
  padding: 10px 8px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, .15);
}

.student-card h2 {
  margin-bottom: 4px;
  color: #fff;
  font-size: 22px;
}

.student-sidebar .eyebrow {
  color: #a9e6d9;
}

.student-sidebar .muted {
  color: rgba(255, 255, 255, .68);
}

.credit-number {
  display: block;
  margin-top: 14px;
  padding: 14px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .11);
  color: #fff2e9;
  font-size: 28px;
  line-height: 1;
}

.student-nav {
  display: grid;
  gap: 7px;
  padding: 16px 0;
}

.student-nav-btn {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: rgba(255, 255, 255, .72);
  font-weight: 700;
  text-align: left;
  padding: 0 12px;
}

.student-nav-btn.active {
  background: #fbfcfa;
  border-color: rgba(255, 255, 255, .8);
  color: var(--accent-strong);
  box-shadow: 0 10px 22px rgba(0, 0, 0, .12);
}

.side-stats {
  display: grid;
  gap: 4px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, .15);
  color: rgba(255, 255, 255, .66);
  font-size: 12px;
}

.side-stats div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 30px;
  padding: 0 3px;
}

.side-stats strong {
  color: #fff;
  font-size: 13px;
}

.student-main {
  display: grid;
  gap: 12px;
}

.student-panel {
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.student-panel .workspace {
  grid-template-columns: minmax(340px, .82fr) minmax(520px, 1.18fr);
  gap: 16px;
}

.category-panel, .generator-panel, .result-panel {
  padding: 18px;
  box-shadow: var(--soft-shadow);
}

.result-panel {
  min-width: 0;
}

.result-panel .content-box {
  font-size: 15px;
}

.result-panel .image-grid {
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.category-panel {
  grid-column: 1 / -1;
  padding: 12px 14px;
  background: rgba(255, 255, 255, .82);
  backdrop-filter: blur(10px);
}

.category-panel .section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.category-panel .section-title h2 {
  font-size: 16px;
}

.compact-title .eyebrow {
  margin-bottom: 0;
}

.section-title {
  margin-bottom: 14px;
}

.category-list {
  display: block;
}

.category-select {
  min-height: 40px;
  font-weight: 700;
}

.muted {
  color: var(--muted);
  line-height: 1.6;
}

.badge {
  display: inline-flex;
  margin-top: 10px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #e8f2ef;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.generator-head {
  border-bottom: 1px solid var(--line);
  padding: 0 0 10px;
  margin-bottom: 12px;
}

.generator-head h2 {
  font-size: 21px;
}

.rule-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.rule-list span {
  padding: 6px 9px;
  border-radius: 6px;
  background: #eef7f4;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 15px;
}

.field-grid label:has(textarea) {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

#generateBtn {
  min-width: 160px;
}

.empty-state {
  min-height: 260px;
  border: 1px dashed #dacfc4;
  border-radius: 8px;
  color: var(--muted);
  display: grid;
  place-items: center;
  text-align: center;
  padding: 18px;
  background: #fbfcfa;
}

.result-stack {
  display: grid;
  gap: 12px;
}

.result-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.result-block h3 {
  font-size: 15px;
  margin-bottom: 10px;
  color: var(--accent-strong);
}

.title-options {
  display: grid;
  gap: 8px;
}

.copy-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 11px;
  border-radius: 6px;
  background: #f8f0e8;
}

.copy-row button, .small-btn {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 6px 10px;
  white-space: nowrap;
  color: var(--accent-strong);
  font-weight: 700;
}

.danger-btn {
  min-height: 36px;
  border: 0;
  border-radius: 8px;
  background: #b42318;
  color: #fff;
  padding: 0 12px;
  font-weight: 700;
  text-align: center;
}

.content-box {
  white-space: pre-wrap;
  line-height: 1.75;
  font-size: 14px;
  color: #37322e;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-list span {
  padding: 6px 9px;
  border-radius: 999px;
  background: #fff0eb;
  color: var(--primary-strong);
  font-weight: 700;
  font-size: 13px;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.image-plan {
  min-height: 128px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: linear-gradient(135deg, #fff, #f5faf6);
}

.image-plan strong {
  display: block;
  margin-bottom: 8px;
}

.image-plan p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.image-plan img {
  display: block;
  width: 100%;
  border-radius: 6px;
  margin-bottom: 8px;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  background: var(--soft);
}

.history-section {
  margin-top: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.account-grid {
  display: grid;
  grid-template-columns: minmax(0, .8fr) minmax(320px, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}

.account-card {
  padding: 18px;
  box-shadow: var(--soft-shadow);
  background: rgba(255, 255, 255, .9);
}

.account-card h2 {
  font-size: 30px;
  color: var(--accent-strong);
}

.cost-list {
  display: grid;
  gap: 8px;
}

.cost-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.cost-row strong {
  color: var(--primary);
  white-space: nowrap;
}

.history-list {
  display: grid;
  gap: 10px;
}

.history-item, .admin-item {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  background: #fff;
  box-shadow: var(--soft-shadow);
}

.history-meta, .admin-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.admin-login {
  display: grid;
  place-items: center;
  min-height: 480px;
}

.admin-login .auth-panel {
  width: min(420px, 100%);
}

.admin-grid {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 16px;
}

.admin-nav {
  display: grid;
  align-content: start;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.nav-btn {
  text-align: left;
  padding: 0 12px;
}

.admin-panel {
  padding: 18px;
  min-height: 520px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.stat-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: var(--soft);
}

.stat-card strong {
  display: block;
  font-size: 28px;
  margin-top: 8px;
}

.admin-list {
  display: grid;
  gap: 10px;
}

.admin-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.admin-edit-grid, .inline-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}

.admin-edit-grid label:nth-child(5),
.admin-edit-grid label:nth-child(6) {
  grid-column: span 2;
}

.admin-edit-grid label:has(textarea) {
  grid-column: span 2;
}

.admin-edit-grid textarea {
  min-height: 92px;
}

.category-config-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(380px, .9fr);
  gap: 18px;
  align-items: start;
  margin-top: 4px;
}

.category-config-main {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.category-basic-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}

.category-basic-grid .wide-field {
  grid-column: 1 / -1;
}

.category-text-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px;
  gap: 12px;
  align-items: end;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.category-json-field {
  min-width: 0;
}

.category-json-field textarea {
  min-height: 372px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.5;
  tab-size: 2;
}

@media (max-width: 1180px) {
  .category-config-layout {
    grid-template-columns: 1fr;
  }

  .category-json-field textarea {
    min-height: 300px;
  }
}

@media (max-width: 760px) {
  .category-basic-grid,
  .category-text-row {
    grid-template-columns: 1fr;
  }

  .category-basic-grid .wide-field {
    grid-column: auto;
  }
}

.copy-box {
  width: 100%;
  min-height: 130px;
  margin: 12px 0;
}

.record-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.record-actions select {
  width: auto;
  min-width: 120px;
  min-height: 36px;
  padding: 7px 10px;
}

.admin-table {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.admin-table table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
}

.admin-table th,
.admin-table td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  vertical-align: middle;
  font-size: 13px;
}

.admin-table th {
  background: var(--soft);
  color: var(--muted);
  font-weight: 700;
}

.admin-table tr:last-child td {
  border-bottom: 0;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
  color: var(--muted);
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(31, 36, 40, .28);
  z-index: 50;
  padding: 20px;
}

.modal-card {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.task-modal-card {
  width: min(1180px, 100%);
  max-height: min(780px, calc(100vh - 40px));
  overflow: auto;
}

.task-image-comparison {
  display: grid;
  gap: 10px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.task-image-comparison h3 {
  font-size: 15px;
}

.image-comparison-list {
  display: grid;
  gap: 8px;
}

.image-comparison-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 38px;
}

.image-comparison-meta,
.image-comparison-links {
  display: flex;
  align-items: center;
  gap: 12px;
}

.image-comparison-meta span {
  color: var(--muted);
  font-size: 13px;
}

.image-comparison-links a {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.image-comparison-links a:hover {
  text-decoration: underline;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.detail-grid h3 {
  margin-bottom: 8px;
  font-size: 15px;
}

.detail-grid .test-output {
  min-height: 240px;
  margin-top: 0;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.agent-generate-grid {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.settings-form {
  max-width: 820px;
  gap: 0;
}

.settings-section {
  display: grid;
  gap: 14px;
  padding: 4px 0 22px;
}

.settings-section + .settings-section {
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.settings-kicker {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
}

.setting-switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.setting-switch-row > div {
  display: grid;
  gap: 7px;
}

.setting-switch-row h3 {
  font-size: 17px;
}

.toggle-control {
  display: inline-flex;
  grid-template-columns: none;
  flex: 0 0 auto;
  align-items: center;
  gap: 10px;
  min-width: 112px;
  cursor: pointer;
  color: var(--ink);
}

.toggle-control input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.toggle-track {
  width: 46px;
  height: 26px;
  padding: 3px;
  border: 1px solid #cfd7d1;
  border-radius: 999px;
  background: #e7ebe8;
  transition: background .16s ease, border-color .16s ease;
}

.toggle-track span {
  display: block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 5px rgba(31, 47, 41, .2);
  transition: transform .16s ease;
}

.toggle-control input:checked + .toggle-track {
  border-color: var(--accent);
  background: var(--accent);
}

.toggle-control input:checked + .toggle-track span {
  transform: translateX(20px);
}

.toggle-control input:focus-visible + .toggle-track {
  box-shadow: 0 0 0 3px rgba(36, 124, 112, .15);
}

.toggle-control strong {
  min-width: 46px;
  font-size: 13px;
}

.retention-setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.retention-label {
  gap: 4px;
  color: var(--ink);
  cursor: pointer;
}

.retention-label strong {
  font-size: 14px;
}

.retention-label span {
  color: var(--muted);
  font-weight: 500;
}

.retention-input {
  display: grid;
  grid-template-columns: 84px 20px;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  color: var(--muted);
  font-weight: 700;
}

.retention-input input {
  min-height: 38px;
  padding: 7px 9px;
  text-align: center;
}

.service-status-row {
  display: grid;
  grid-template-columns: 9px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  color: var(--muted);
  font-size: 13px;
}

.service-status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #9aa39e;
}

.service-status-dot.ready { background: #1d9877; }
.service-status-dot.error { background: var(--primary); }
.service-status-dot.checking {
  background: #d7982d;
  animation: status-pulse 1s ease-in-out infinite;
}

@keyframes status-pulse {
  50% { opacity: .35; }
}

.settings-form .form-actions {
  margin-top: 0;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.test-output {
  max-width: 720px;
  min-height: 120px;
  margin-top: 14px;
  padding: 12px;
  overflow: auto;
  white-space: pre-wrap;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111f1b;
  color: #dff7ec;
  font-size: 12px;
  line-height: 1.6;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100% - 36px));
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow);
  z-index: 20;
}

@media (max-width: 1080px) {
  .student-dashboard {
    grid-template-columns: 1fr;
  }
  .student-sidebar {
    position: static;
    min-height: auto;
  }
  .student-nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .student-nav-btn {
    text-align: center;
  }
  .student-panel .workspace {
    grid-template-columns: minmax(0, 1fr);
  }
  .workspace {
    grid-template-columns: 260px minmax(0, 1fr);
  }
  .result-panel {
    grid-column: auto;
  }
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .setting-switch-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
  }

  .service-status-row {
    grid-template-columns: 9px minmax(0, 1fr);
  }

  .service-status-row .small-btn {
    grid-column: 1 / -1;
    width: 100%;
  }

  .retention-setting-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }
}

@media (max-width: 760px) {
  .shell, .admin-shell {
    width: min(100% - 22px, 1440px);
    padding-top: 14px;
  }
  .topbar, .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }
  .auth-grid, .workspace, .admin-grid, .field-grid, .flow-list, .admin-edit-grid, .inline-form, .stats-grid, .student-panel .workspace, .account-grid, .agent-generate-grid {
    grid-template-columns: 1fr;
  }
  .auth-grid {
    min-height: auto;
    display: grid;
    grid-template-columns: 1fr;
  }
  .intro-panel {
    grid-column: 1;
    grid-row: 1;
    grid-template-columns: 1fr;
    min-height: auto;
    padding: 0;
  }
  .hero-visual,
  .hero-visual img {
    min-height: 560px;
  }
  .hero-visual::after {
    background: linear-gradient(180deg, rgba(255,255,255,.08) 0%, rgba(255,255,255,.62) 42%, rgba(255,255,255,.92) 100%);
  }
  .auth-panel {
    grid-column: 1;
    grid-row: 1;
    width: min(100% - 28px, 390px);
    margin: 220px auto 18px;
  }
  .student-nav {
    grid-template-columns: 1fr;
  }
  .student-sidebar {
    padding: 12px;
  }
  .student-card {
    padding-bottom: 12px;
  }
  .credit-number {
    font-size: 24px;
    padding: 12px;
  }
  .category-panel,
  .generator-panel,
  .result-panel {
    padding: 14px;
  }
  .generator-head h2 {
    font-size: 21px;
  }
  .intro-panel h2 {
    font-size: 26px;
  }
  .admin-edit-grid label:nth-child(5),
  .admin-edit-grid label:nth-child(6) {
    grid-column: auto;
  }
  .image-grid {
    grid-template-columns: 1fr;
  }
  .detail-grid {
    grid-template-columns: 1fr;
  }
}

/* 2026-07 visual refresh: compact publishing workspace */
:root {
  --bg: #f4f5f2;
  --surface: #ffffff;
  --surface-soft: #f8f8f6;
  --ink: #202422;
  --muted: #707772;
  --line: #dfe3de;
  --line-strong: #cfd5cf;
  --primary: #e64b3c;
  --primary-strong: #c93b2f;
  --primary-soft: #fff0ed;
  --accent: #197565;
  --accent-strong: #125547;
  --soft: #eef2ee;
  --cream: #f8f8f6;
  --warn: #a52d25;
  --shadow: 0 14px 38px rgba(31, 40, 35, .09);
  --soft-shadow: 0 5px 18px rgba(31, 40, 35, .055);
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  letter-spacing: 0;
}

button,
input,
textarea,
select {
  letter-spacing: 0;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(25, 117, 101, .18);
  outline-offset: 2px;
}

.shell,
.admin-shell {
  width: min(1560px, calc(100% - 32px));
  padding: 16px 0 32px;
}

.topbar {
  min-height: 56px;
  margin-bottom: 12px;
  padding: 0 2px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 11px;
}

.brand-mark {
  position: relative;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--primary);
  box-shadow: inset 0 -8px 16px rgba(133, 27, 20, .12);
}

.brand-mark::before,
.brand-mark::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  height: 3px;
  border-radius: 2px;
  background: #fff;
  transform: rotate(-8deg);
}

.brand-mark::before { top: 11px; }
.brand-mark::after { top: 20px; width: 12px; right: auto; }

h1 {
  font-size: 23px;
  font-weight: 760;
}

h2 {
  font-size: 18px;
  font-weight: 740;
}

.eyebrow {
  margin-bottom: 3px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 760;
}

.pill {
  height: 34px;
  gap: 8px;
  border-color: var(--line);
  background: var(--surface);
  box-shadow: none;
  color: var(--accent-strong);
  font-size: 13px;
}

.credit-user {
  padding-right: 8px;
  border-right: 1px solid var(--line);
}

.ghost-link,
.text-btn {
  height: 34px;
  border-color: var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 13px;
}

.ghost-link:hover,
.text-btn:hover {
  border-color: var(--line-strong);
  background: var(--surface);
  color: var(--ink);
}

.primary,
.secondary {
  min-height: 40px;
  border-radius: 7px;
  box-shadow: none;
  transition: background .16s ease, border-color .16s ease, transform .16s ease;
}

.primary {
  background: var(--primary);
  color: #fff;
}

.primary:hover {
  background: var(--primary-strong);
  box-shadow: 0 8px 18px rgba(201, 59, 47, .18);
}

.primary:disabled {
  cursor: wait;
  opacity: .62;
  transform: none;
}

.secondary {
  background: var(--accent-strong);
  color: #fff;
}

input,
textarea,
select {
  min-height: 42px;
  border-color: var(--line-strong);
  border-radius: 7px;
  padding: 10px 12px;
  background: #fff;
  transition: border-color .16s ease, box-shadow .16s ease;
}

textarea {
  min-height: 104px;
}

.compact-textarea {
  min-height: 66px;
}

label {
  gap: 6px;
  color: #555d58;
  font-size: 12px;
  font-weight: 680;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(25, 117, 101, .1);
}

/* Login stays image-led and the form remains part of the image composition. */
.auth-grid {
  min-height: min(720px, calc(100vh - 56px));
  grid-template-columns: minmax(0, 1fr) 380px;
  border-color: #d9ddd8;
  background: #f4f1ec;
  box-shadow: 0 22px 60px rgba(44, 39, 34, .12);
}

body:has(#authView:not(.hidden)) .shell {
  width: min(1240px, calc(100% - 32px));
  padding-top: 24px;
}

.intro-panel,
.hero-visual,
.hero-visual img {
  min-height: min(720px, calc(100vh - 56px));
}

.hero-visual::after {
  background: linear-gradient(90deg, rgba(255,255,255,.03) 0%, rgba(255,255,255,.03) 54%, rgba(250,248,244,.62) 73%, rgba(250,248,244,.95) 100%);
}

.auth-panel {
  margin-right: 32px;
  padding: 22px;
  border: 1px solid rgba(255,255,255,.76);
  background: rgba(255, 255, 255, .76);
  box-shadow: 0 18px 50px rgba(44, 39, 34, .12);
  backdrop-filter: blur(22px) saturate(115%);
}

.tabs {
  margin-bottom: 16px;
  background: rgba(233, 237, 233, .82);
}

.tab {
  min-height: 38px;
}

.tab.active {
  border-color: #d9ded9;
  box-shadow: 0 2px 7px rgba(42, 50, 45, .06);
}

.auth-panel .primary {
  width: 100%;
  min-height: 44px;
  margin-top: 2px;
}

/* Student workspace */
.student-dashboard {
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}

.student-sidebar {
  position: static;
  display: grid;
  grid-template-columns: minmax(190px, .72fr) minmax(320px, 1fr) minmax(460px, 1.45fr);
  align-items: center;
  min-height: auto;
  padding: 9px 12px;
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--soft-shadow);
}

.student-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 10px;
  min-width: 0;
  padding: 0 14px 0 2px;
  border-right: 1px solid var(--line);
  border-bottom: 0;
}

.student-card h2 {
  grid-column: 1;
  color: var(--ink);
  font-size: 16px;
}

.student-card .eyebrow,
.student-card .muted {
  grid-column: 1;
}

.student-card .muted {
  overflow: hidden;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.student-sidebar .eyebrow { color: var(--primary); }
.student-sidebar .muted { color: var(--muted); }

.credit-number {
  grid-column: 2;
  grid-row: 1 / span 3;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid #f2d5d0;
  background: var(--primary-soft);
  color: var(--primary-strong);
  font-size: 17px;
  white-space: nowrap;
}

.student-nav {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  padding: 0 12px;
  border-right: 1px solid var(--line);
}

.student-nav-btn {
  position: relative;
  min-height: 38px;
  padding: 0 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 680;
  text-align: center;
}

.student-nav-btn:hover {
  background: var(--surface-soft);
  color: var(--ink);
}

.student-nav-btn.active {
  border-color: #f1d2cc;
  background: var(--primary-soft);
  color: var(--primary-strong);
  box-shadow: none;
}

.student-nav-btn.active::before {
  display: none;
}

.side-stats {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  padding: 0 0 0 12px;
  border-top: 0;
  color: var(--muted);
  font-size: 11px;
}

.side-stats div {
  justify-content: center;
  flex-direction: column;
  gap: 2px;
  min-height: 42px;
  padding: 0 7px;
  border-left: 1px solid var(--line);
}

.side-stats div:first-child { border-left: 0; }

.side-stats strong {
  max-width: 90px;
  overflow: hidden;
  color: var(--ink);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body:has(#appView:not(.hidden)) #creditPill {
  display: none !important;
}

.student-panel .workspace {
  grid-template-columns: minmax(320px, .64fr) minmax(620px, 1.36fr);
  gap: 14px;
}

.category-panel,
.generator-panel,
.result-panel,
.account-card,
.admin-panel,
.student-sidebar {
  border-radius: 8px;
}

.category-panel,
.generator-panel,
.result-panel {
  padding: 16px;
  border-color: var(--line);
  box-shadow: var(--soft-shadow);
}

.category-panel {
  display: grid;
  grid-template-columns: auto minmax(220px, 420px);
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 10px 12px;
  background: var(--surface);
  backdrop-filter: none;
}

.category-panel .section-title {
  display: flex;
  align-items: baseline;
  justify-content: flex-start;
  gap: 8px;
  margin: 0;
}

.category-panel .section-title h2 {
  font-size: 14px;
}

.category-select {
  min-height: 38px;
  padding-top: 8px;
  padding-bottom: 8px;
  font-size: 13px;
}

.generator-panel {
  align-self: start;
  background: var(--surface);
}

.generator-head {
  margin-bottom: 14px;
  padding-bottom: 11px;
}

.generator-head h2 {
  font-size: 18px;
}

.field-grid {
  grid-template-columns: 1fr;
  gap: 12px;
}

.form-actions {
  align-items: flex-start;
  flex-direction: column;
  gap: 7px;
  margin-top: 14px;
  padding-top: 14px;
}

#generateBtn {
  width: 100%;
  min-height: 44px;
}

#statusText {
  width: 100%;
  text-align: center;
  font-size: 12px;
}

.result-panel {
  min-height: 520px;
  background: var(--surface);
}

.result-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 13px;
}

.result-ready {
  padding: 5px 8px;
  border: 1px solid #cde0da;
  border-radius: 6px;
  background: #f1f8f5;
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 720;
}

.empty-state {
  min-height: 420px;
  align-content: center;
  gap: 7px;
  border-color: #d4dad4;
  background: var(--surface-soft);
}

.empty-state strong {
  color: #3c443f;
  font-size: 15px;
}

.empty-state small {
  color: var(--muted);
  font-size: 12px;
}

.empty-state-mark {
  position: relative;
  display: block;
  width: 42px;
  height: 52px;
  margin-bottom: 6px;
  border: 1px solid #bfc8c1;
  border-radius: 7px;
  background: #fff;
}

.empty-state-mark::before,
.empty-state-mark::after {
  content: "";
  position: absolute;
  left: 9px;
  height: 2px;
  border-radius: 2px;
  background: #c8d0ca;
}

.empty-state-mark::before { top: 17px; width: 22px; }
.empty-state-mark::after { top: 26px; width: 15px; }

.result-stack {
  gap: 0;
  border-top: 1px solid var(--line);
}

.result-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.result-toolbar button,
.copy-row button,
.image-actions button {
  min-height: 30px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 0 9px;
  background: #fff;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
}

.result-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.result-toolbar-actions [data-download-all],
.image-actions [data-image-download] {
  border-color: #c8ddd6;
  background: #f1f8f5;
  color: var(--accent-strong);
}

.result-toolbar button:hover,
.copy-row button:hover,
.image-actions button:hover {
  border-color: #a8c5bc;
  background: #f1f8f5;
}

.result-block {
  padding: 15px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
}

.result-block:last-child { border-bottom: 0; }

.result-block h3 {
  margin: 0;
  color: var(--ink);
  font-size: 13px;
}

.copy-row {
  padding: 0 0 9px;
  border-radius: 0;
  background: transparent;
}

.copy-row > span {
  color: var(--muted);
  font-size: 12px;
}

.content-box {
  padding: 12px 14px;
  border: 1px solid #e1e5e0;
  border-radius: 7px;
  background: #fafbf9;
  color: #363c38;
  font-size: 14px;
  line-height: 1.8;
}

.title-content {
  border-color: #efd6d1;
  background: #fff7f5;
  color: #3a2926;
  font-size: 17px;
  font-weight: 720;
  line-height: 1.55;
}

.result-panel .image-grid {
  grid-template-columns: repeat(auto-fill, minmax(140px, 170px));
  gap: 10px;
  justify-content: start;
}

.image-plan {
  min-height: 0;
  overflow: hidden;
  padding: 0;
  border-color: var(--line);
  background: #fff;
}

.image-plan img {
  margin: 0;
  border-radius: 0;
  background: var(--soft);
}

.image-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px;
}

.image-actions strong {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.tag-list {
  gap: 6px;
}

.tag-list span {
  padding: 5px 8px;
  border: 1px solid #f2d4ce;
  border-radius: 6px;
  background: var(--primary-soft);
  color: var(--primary-strong);
  font-size: 12px;
}

/* History and account views */
.panel-head {
  margin-bottom: 12px;
  padding: 2px 0 12px;
  border-bottom: 1px solid var(--line);
}

.history-list {
  gap: 8px;
}

.history-item,
.admin-item {
  padding: 12px 14px;
  border-color: var(--line);
  box-shadow: none;
}

.history-item:hover,
.admin-item:hover {
  border-color: var(--line-strong);
  background: #fdfdfc;
}

.account-grid {
  grid-template-columns: minmax(240px, .65fr) minmax(340px, 1.35fr);
  gap: 12px;
  margin-bottom: 12px;
}

.account-card {
  padding: 16px;
  border-color: var(--line);
  box-shadow: var(--soft-shadow);
}

.account-card h2 {
  font-size: 26px;
  color: var(--primary-strong);
}

.cost-row {
  padding: 9px 11px;
  border-color: var(--line);
}

/* Admin and agent surfaces share the same quiet operational system. */
.admin-grid {
  grid-template-columns: 196px minmax(0, 1fr);
  gap: 14px;
}

.admin-nav {
  position: sticky;
  top: 12px;
  gap: 3px;
  padding: 8px;
  border-color: var(--line);
  box-shadow: var(--soft-shadow);
}

.nav-btn {
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid transparent;
  color: var(--muted);
  font-size: 13px;
}

.nav-btn:hover {
  background: var(--surface-soft);
  color: var(--ink);
}

.nav-btn.active {
  border-color: #f1d2cc;
  background: var(--primary-soft);
  color: var(--primary-strong);
}

.admin-panel {
  min-height: 560px;
  padding: 16px;
  border-color: var(--line);
  box-shadow: var(--soft-shadow);
}

.stats-grid {
  gap: 10px;
}

.stat-card {
  padding: 14px;
  border-color: var(--line);
  background: var(--surface-soft);
}

.stat-card strong {
  margin-top: 6px;
  color: var(--ink);
  font-size: 25px;
}

.admin-edit-grid,
.inline-form {
  gap: 10px;
}

.admin-table {
  border-color: var(--line);
}

.admin-table th,
.admin-table td {
  padding: 9px 10px;
  border-bottom-color: var(--line);
}

.admin-table th {
  background: #f1f3f0;
  color: #59615c;
}

.admin-table tbody tr:hover {
  background: #fafbf9;
}

.small-btn,
.danger-btn {
  border-radius: 6px;
}

.modal {
  background: rgba(26, 31, 28, .42);
  backdrop-filter: blur(3px);
}

.modal-card {
  border-color: var(--line);
  box-shadow: 0 24px 70px rgba(24, 30, 26, .18);
}

.error-modal-card {
  width: min(390px, 100%);
  gap: 18px;
  padding: 22px;
}

.error-modal-head {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.error-modal-head .eyebrow {
  color: var(--primary);
}

.error-modal-head h2 {
  font-size: 20px;
}

.error-modal-message {
  min-height: 52px;
  color: #414844;
  font-size: 15px;
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-word;
}

.error-modal-card .modal-actions {
  padding-top: 2px;
}

.error-modal-card .primary {
  min-width: 112px;
}

.test-output {
  border-color: #233b33;
  background: #14221d;
  color: #d8f1e7;
}

.toast {
  right: 16px;
  bottom: 16px;
  border: 1px solid rgba(255,255,255,.12);
  background: #202824;
  box-shadow: 0 12px 34px rgba(24, 30, 26, .2);
}

@media (max-width: 1180px) {
  .student-sidebar {
    grid-template-columns: minmax(190px, .72fr) minmax(300px, 1fr);
  }

  .side-stats {
    grid-column: 1 / -1;
    margin-top: 8px;
    padding: 8px 0 0;
    border-top: 1px solid var(--line);
  }

  .student-panel .workspace {
    grid-template-columns: minmax(300px, .7fr) minmax(520px, 1.3fr);
  }
}

@media (max-width: 980px) {
  .student-dashboard {
    grid-template-columns: 1fr;
  }

  .student-sidebar {
    position: static;
    grid-template-columns: minmax(190px, .72fr) minmax(0, 1fr);
    min-height: auto;
  }

  .student-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    column-gap: 12px;
    padding-bottom: 0;
  }

  .student-card .eyebrow,
  .student-card .muted {
    grid-column: 1;
  }

  .student-card h2 { grid-column: 1; }

  .credit-number {
    grid-column: 2;
    grid-row: 1 / span 3;
    margin: 0;
  }

  .student-nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    border-right: 0;
  }

  .student-nav-btn { text-align: center; }

  .student-nav-btn.active::before { display: none; }

  .side-stats {
    grid-column: 1 / -1;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    border-top: 1px solid var(--line);
  }

  .side-stats div {
    justify-content: center;
    flex-direction: column;
    gap: 2px;
    min-height: 48px;
  }

  .student-panel .workspace {
    grid-template-columns: 1fr;
  }

  .result-panel { min-height: 440px; }
  .empty-state { min-height: 330px; }
}

@media (max-width: 760px) {
  .shell,
  .admin-shell {
    width: min(100% - 20px, 1560px);
    padding-top: 10px;
  }

  .topbar {
    min-height: 48px;
    align-items: center;
    flex-direction: row;
  }

  .topbar h1 { font-size: 19px; }
  .topbar .eyebrow { display: none; }
  .brand-mark { width: 30px; height: 30px; }
  .top-actions { gap: 6px; }
  .pill { max-width: none; white-space: nowrap; }
  .credit-user { display: none; }
  .credit-label { display: none; }

  body:has(#authView:not(.hidden)) .shell {
    width: 100%;
    padding: 0;
  }

  .auth-grid {
    min-height: 100svh;
    grid-template-columns: minmax(0, 1fr);
    border: 0;
    border-radius: 0;
  }

  .intro-panel,
  .hero-visual,
  .hero-visual img {
    min-height: 100svh;
  }

  .intro-panel {
    grid-column: 1;
    grid-row: 1;
  }

  .hero-visual img {
    object-position: 42% center;
  }

  .hero-visual::after {
    background: linear-gradient(180deg, rgba(255,255,255,.02) 0%, rgba(248,246,242,.32) 34%, rgba(248,246,242,.9) 67%, rgba(248,246,242,.98) 100%);
  }

  .auth-panel {
    grid-column: 1;
    grid-row: 1;
    width: min(100% - 24px, 390px);
    margin: auto auto 14px;
    align-self: end;
    padding: 18px;
  }

  .student-sidebar {
    grid-template-columns: 1fr;
    padding: 10px;
  }

  .student-card {
    grid-template-columns: minmax(0, 1fr) auto;
    padding: 4px 4px 9px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .credit-number {
    padding: 9px 10px;
    font-size: 19px;
  }

  .student-nav {
    gap: 4px;
    padding: 8px 0;
    border-bottom: 1px solid var(--line);
  }
  .student-nav-btn { min-height: 36px; padding: 0 6px; font-size: 12px; }
  .side-stats {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin: 0;
    padding: 8px 0 0;
    border-top: 0;
  }

  .side-stats div {
    min-height: 38px;
    padding: 0 3px;
  }

  .category-panel {
    grid-template-columns: 1fr;
    gap: 7px;
  }

  .category-panel .section-title { justify-content: space-between; }

  .category-panel,
  .generator-panel,
  .result-panel,
  .account-card,
  .admin-panel {
    padding: 13px;
  }

  .result-title { align-items: flex-end; }
  .empty-state { min-height: 290px; }
  .result-panel .image-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 170px)); }
  .image-actions { align-items: flex-start; flex-direction: column; }
  .image-actions button { width: 100%; }
  .account-grid { grid-template-columns: 1fr; }

  .admin-grid { grid-template-columns: 1fr; }
  .admin-nav {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .nav-btn { text-align: center; }
  .image-comparison-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }
  .image-comparison-links {
    flex-wrap: wrap;
  }
}

@media (max-width: 420px) {
  .pill { max-width: none; }
  .result-panel .image-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 160px)); }
  .result-toolbar { align-items: flex-start; flex-direction: column; }
  .result-toolbar button { width: 100%; }
  .result-toolbar-actions { width: 100%; }
  .result-toolbar-actions button { flex: 1; }
}
