:root {
  color-scheme: light;
  --page-max-width: 1360px;
  --page-gutter: clamp(48px, 7vw, 92px);
  --generate-page-max-width: 1040px;
  --generate-page-gutter: clamp(108px, 12vw, 180px);
  --bg: #f3efe8;
  --panel: rgba(248, 245, 240, 0.9);
  --panel-border: #e4ddd3;
  --text: #2d2923;
  --muted: #74685d;
  --accent: #8d7b67;
  --accent-soft: #eee5d8;
  --state-active-bg: #8f7a63;
  --state-active-border: #8f7a63;
  --state-active-hover: #816d57;
  --state-active-text: #fffdf9;
  --state-active-shadow: 0 12px 22px rgba(97, 78, 57, 0.16);
  --brand-primary-bg: #8b755f;
  --brand-primary-border: #8b755f;
  --brand-primary-hover: #7d6955;
  --brand-primary-text: #fffdf9;
  --brand-primary-shadow: 0 14px 24px rgba(99, 79, 58, 0.18);
  --danger: #b15f5f;
  --success: #6f8c68;
  --shadow: 0 14px 30px rgba(73, 60, 40, 0.045);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.92), rgba(245, 241, 234, 0.88) 42%, rgba(242, 238, 231, 1) 100%);
}

.app-shell {
  width: min(var(--generate-page-max-width), calc(100vw - (var(--generate-page-gutter) * 2)));
  margin: 12px auto 20px;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(320px, 410px) minmax(0, 1fr);
}

.panel {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 14px;
  min-height: 640px;
}

.panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 72px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.44), rgba(255, 255, 255, 0));
  pointer-events: none;
}

.panel > * {
  position: relative;
  z-index: 1;
}

.panel-title {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #766a5e;
}

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

.workspace-intro {
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(229, 223, 215, 0.5);
}

.workspace-title {
  margin: 0;
  font-size: 31px;
  line-height: 1.06;
  font-weight: 680;
  letter-spacing: -0.04em;
  color: #23201b;
}

.workspace-subtitle {
  margin: 6px 0 0;
  max-width: 600px;
  font-size: 13px;
  line-height: 1.6;
  color: #74695d;
}

.upload-container {
  display: block;
  position: relative;
  z-index: 100;
}

.upload-header {
  align-items: center;
}

.upload-title-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 0;
}

.reference-count {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: rgba(95, 84, 72, 0.72);
}

.upload-clear-button {
  padding: 0;
  border: 0;
  background: transparent;
  color: rgba(116, 104, 93, 0.72);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.2s ease, opacity 0.2s ease;
}

.upload-clear-button:hover:not(:disabled) {
  color: #5c5146;
}

.upload-clear-button:disabled {
  opacity: 0.45;
  cursor: default;
}

.upload-dropzone {
  display: grid;
  place-items: center;
  gap: 0;
  width: 100%;
  aspect-ratio: 1 / 1;
  border: 1px solid rgba(223, 214, 203, 0.9);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.2s, background-color 0.2s, box-shadow 0.2s;
  background: rgba(248, 245, 240, 0.92);
  position: relative;
  z-index: 101;
  padding: 3px;
  box-shadow: inset 0 0 0 1px rgba(189, 176, 157, 0.32);
}

.upload-dropzone-inline {
  border-style: solid;
}

.upload-dropzone:hover {
  border-color: var(--accent);
  background: rgba(247, 242, 235, 0.96);
  transform: translateY(-1px);
  box-shadow: 0 12px 22px rgba(69, 56, 36, 0.06), inset 0 0 0 1px rgba(184, 171, 152, 0.18);
}

.upload-icon {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(238, 229, 216, 0.74);
  border: 1px solid rgba(221, 211, 198, 0.78);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
  font-size: 17px;
  line-height: 1;
  color: #5a4d41;
}

.upload-dropzone > span {
  position: relative;
  z-index: 1;
}

.upload-text {
  font-size: 14px;
  font-weight: 700;
  color: #2f2922;
}

.upload-subtext {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.upload-hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

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

.preview-card {
  border: 1px solid rgba(223, 214, 203, 0.9);
  border-radius: 10px;
  overflow: hidden;
  background: rgba(248, 245, 240, 0.92);
  width: 100%;
  aspect-ratio: 1 / 1;
  position: relative;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
  padding: 3px;
  min-width: 0;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.36);
}

.preview-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 12px 22px rgba(69, 56, 36, 0.06);
}

.preview-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 7px;
}

.preview-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: 0;
  background: rgba(98, 88, 77, 0.62);
  color: rgba(255, 253, 249, 0.95);
  border-radius: 999px;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  position: absolute;
  top: 9px;
  right: 9px;
  z-index: 2;
  transition: background-color 0.2s, transform 0.2s;
}

.preview-remove:hover {
  background: var(--danger);
  color: #fff8f7;
  transform: scale(1.04);
}

.image-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(52, 44, 35, 0.36);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
  backdrop-filter: blur(20px);
}

.image-overlay.active {
  opacity: 1;
  visibility: visible;
}

.main-header {
  width: min(var(--page-max-width), calc(100vw - (var(--page-gutter) * 2)));
  margin: 0 auto;
  padding: 8px 0 6px;
}

.main-nav {
  display: grid;
  grid-template-columns: auto minmax(420px, 560px) auto;
  align-items: center;
  gap: 12px;
  padding: 2px 0;
  justify-content: space-between;
}

.nav-section {
  display: flex;
  align-items: center;
  min-width: 0;
}

.nav-left {
  justify-content: flex-start;
}

.nav-center {
  justify-content: center;
}

.nav-right {
  justify-content: flex-end;
}

.nav-brand {
  font-size: 12px;
  font-weight: 500;
  color: rgba(95, 84, 73, 0.72);
  text-decoration: none;
  transition: color 0.2s ease, opacity 0.2s ease;
  letter-spacing: 0.01em;
  white-space: nowrap;
  opacity: 0.82;
}

.nav-brand:hover {
  opacity: 1;
  color: rgba(74, 64, 54, 0.9);
}

.nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  width: 100%;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: #4f463c;
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  transition: background-color 0.18s ease, color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.nav-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: center;
  gap: 4px;
  width: min(100%, 560px);
  padding: 5px;
  border: 1px solid rgba(220, 212, 200, 0.84);
  border-radius: 999px;
  background: rgba(250, 247, 242, 0.98);
  box-shadow: 0 2px 10px rgba(86, 69, 47, 0.035);
}

.nav-tab.is-active {
  color: var(--brand-primary-text);
  font-weight: 800;
  background: #6d2d00;
  border-color: var(--brand-primary-border);
  box-shadow: 0 10px 18px rgba(92, 47, 19, 0.14);
}

.nav-link:hover {
  color: #3f372f;
  background: rgba(244, 237, 228, 0.86);
}

.nav-tab.is-active:hover {
  color: var(--brand-primary-text);
  background: #5f2600;
}

.nav-status {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.nav-user-chip,
.nav-auth-link,
.nav-auth-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.nav-user-chip {
  color: #5d5144;
  background: rgba(246, 240, 231, 0.82);
  border: 1px solid rgba(224, 216, 205, 0.88);
}

.nav-auth-link,
.nav-auth-button {
  color: #6b5f52;
  background: transparent;
  border: 1px solid rgba(223, 214, 203, 0.9);
  transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.nav-auth-link:hover,
.nav-auth-button:hover {
  background: rgba(245, 238, 229, 0.92);
  color: #443a31;
  border-color: rgba(199, 188, 173, 0.96);
}

.nav-auth-link.is-active {
  color: var(--brand-primary-text);
  background: var(--brand-primary-bg);
  border-color: var(--brand-primary-border);
}

.nav-auth-form {
  margin: 0;
}

.nav-auth-button {
  cursor: pointer;
}

.nav-node-label {
  color: rgba(138, 126, 113, 0.82);
  font-size: 10px;
}

.nav-node-value {
  color: #564b40;
}

.nav-node-caret {
  color: #8d7f71;
  font-size: 10px;
  line-height: 1;
}

.nav-icon {
  font-size: 16px;
}

.auth-shell {
  width: min(480px, calc(100vw - 32px));
  margin: 44px auto 28px;
}

.auth-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: auto;
}

.auth-title {
  margin: 0;
  font-size: 26px;
  line-height: 1.1;
  letter-spacing: -0.03em;
  color: #26211b;
}

.auth-subtitle {
  margin: 6px 0 0;
  font-size: 13px;
  line-height: 1.7;
  color: #74695d;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-error {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(220, 171, 162, 0.56);
  background: rgba(253, 244, 242, 0.92);
  color: #9f4f4f;
  font-size: 13px;
}

.auth-footer {
  margin: 0;
  font-size: 13px;
  color: #74695d;
}

.auth-footer a {
  color: #5b4e42;
  font-weight: 700;
}

.admin-shell {
  width: min(var(--page-max-width), calc(100vw - (var(--page-gutter) * 2)));
  margin: 16px auto 24px;
}

.admin-card {
  min-height: auto;
}

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

.admin-table th,
.admin-table td {
  padding: 12px 10px;
  border-bottom: 1px solid rgba(229, 223, 215, 0.62);
  text-align: left;
  font-size: 13px;
}

.admin-table th {
  color: #766a5e;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.admin-table td form {
  margin: 0;
}

.admin-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(246, 240, 231, 0.92);
  border: 1px solid rgba(224, 216, 205, 0.88);
  color: #5d5144;
  font-size: 12px;
  font-weight: 700;
}

.admin-badge.is-danger {
  background: rgba(253, 244, 242, 0.92);
  border-color: rgba(220, 171, 162, 0.56);
  color: #9f4f4f;
}

.image-overlay-content {
  max-width: 90vw;
  max-height: 90vh;
  position: relative;
  animation: zoomIn 0.3s ease;
}

@keyframes zoomIn {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.image-overlay-img {
  max-width: 100%;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 10px;
  box-shadow: 0 24px 72px rgba(48, 40, 30, 0.18);
}

.image-overlay-close {
  position: absolute;
  top: -40px;
  right: 0;
  width: 36px;
  height: 36px;
  background: rgba(255, 252, 247, 0.88);
  border: 1px solid rgba(214, 203, 190, 0.82);
  border-radius: 50%;
  color: #564c40;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, border-color 0.2s;
}

.image-overlay-close:hover {
  background: #fff;
  border-color: rgba(151, 135, 114, 0.6);
}

.control-section {
  margin-top: 10px;
  padding-top: 0;
}

.parameter-panel {
  margin-top: 10px;
  border: 1px solid rgba(223, 214, 203, 0.88);
  border-radius: 10px;
  background: rgba(248, 245, 240, 0.9);
  padding: 10px 12px 12px;
}

.parameter-toggle {
  width: 100%;
  border: 0;
  background: transparent;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  text-align: left;
}

.parameter-toggle-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.parameter-summary {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.45;
}

.parameter-toggle-arrow {
  flex: 0 0 auto;
  color: #74685d;
  font-size: 14px;
  transition: transform 0.2s ease;
}

.parameter-toggle[aria-expanded="true"] .parameter-toggle-arrow {
  transform: rotate(180deg);
}

.parameter-content {
  margin-top: 10px;
  padding-top: 0;
  border-top: 1px solid rgba(226, 220, 212, 0.58);
}

.parameter-content .control-section:first-child {
  margin-top: 10px;
}

.field-label {
  display: block;
  margin-bottom: 8px;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #5f5448;
  font-weight: 800;
}

.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.checkbox-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
}

.checkbox-row input {
  accent-color: var(--accent);
}

.text-input,
.prompt-input {
  width: 100%;
  border: 1px solid rgba(220, 211, 199, 0.94);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--text);
  padding: 12px 14px;
  font: inherit;
  box-shadow: inset 0 1px 2px rgba(71, 56, 34, 0.02);
}

.text-input {
  min-height: 48px;
}

.prompt-input {
  resize: vertical;
  min-height: 112px;
}

.text-input:focus,
.prompt-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(217, 207, 194, 0.22);
  outline: none;
}

.option-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.option-chip {
  border: 1px solid rgba(220, 211, 199, 0.9);
  background: rgba(251, 248, 243, 0.82);
  color: #554b40;
  border-radius: 999px;
  padding: 9px 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  transition: background-color 0.2s, border-color 0.2s, transform 0.2s, box-shadow 0.2s;
}

.option-chip:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 8px 14px rgba(73, 60, 40, 0.045);
}

.option-chip.is-active {
  background: var(--state-active-bg);
  border-color: var(--state-active-border);
  color: var(--state-active-text);
  box-shadow: var(--state-active-shadow);
}

.action-row {
  margin-top: 10px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.ghost-button,
.primary-button {
  border-radius: 10px;
  padding: 12px 18px;
  font: inherit;
  cursor: pointer;
  font-weight: 700;
  transition: opacity 0.2s, transform 0.2s, border-color 0.2s, background-color 0.2s, box-shadow 0.2s;
}

.ghost-button {
  border: 1px solid #ddd3c6;
  background: #fbf8f3;
  color: #53493f;
}

.primary-button {
  flex: 1;
  border: 0;
  color: var(--brand-primary-text);
  background: var(--brand-primary-bg);
  font-weight: 700;
  box-shadow: var(--brand-primary-shadow);
}

.ghost-button:hover,
.primary-button:hover {
  transform: translateY(-1px);
}

.ghost-button:hover {
  background: #f5efe6;
}

.primary-button:hover {
  background: var(--brand-primary-hover);
  box-shadow: 0 16px 28px rgba(99, 79, 58, 0.22);
}

.ghost-button:disabled,
.primary-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid rgba(220, 211, 199, 0.9);
  color: #675c50;
  background: rgba(251, 248, 243, 0.82);
  font-size: 12px;
}

.status-badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #b7ab9d;
}

.status-badge.is-running {
  border-color: #b9aa96;
  color: #453c33;
}

.status-badge.is-running::before {
  background: #a38d74;
}

.status-badge.is-success {
  border-color: #b7c8b1;
  color: #486246;
}

.status-badge.is-success::before {
  background: #6f8c68;
}

.status-badge.is-error {
  border-color: var(--danger);
  color: #9b4f4f;
}

.status-badge.is-error::before {
  background: var(--danger);
}

.panel-right {
  display: flex;
  flex-direction: column;
}

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

.result-link {
  color: #6d6256;
  text-decoration: none;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid #ddd3c6;
  background: #fbf8f3;
  transition: all 0.2s ease;
}

.result-link:hover {
  color: #2f2922;
  border-color: var(--accent);
  background: #f5efe6;
  transform: translateY(-1px);
}

.empty-state {
  flex: 1;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
  padding: 36px 18px;
  border: 1px dashed rgba(214, 203, 189, 0.9);
  border-radius: 12px;
  background: rgba(248, 245, 240, 0.9);
}

.result-history {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  padding-right: 2px;
}

.result-error {
  margin-top: 12px;
  border: 1px solid rgba(177, 95, 95, 0.24);
  border-radius: 10px;
  background: rgba(248, 236, 236, 0.82);
  color: #8e5050;
  padding: 12px 14px;
  font-size: 14px;
}

.result-meta {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.result-meta::-webkit-scrollbar {
  display: none;
}

.result-meta-item {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 26px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 0;
  background: rgba(255, 252, 247, 0.72);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.3);
  white-space: nowrap;
}

.result-meta-label {
  color: rgba(120, 108, 95, 0.82);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.result-meta-value {
  color: #443a31;
  font-size: 11px;
  font-weight: 700;
}

.result-meta-item-status {
  position: relative;
  gap: 6px;
  padding-left: 10px;
  box-shadow: none;
}

.result-meta-item-status .result-meta-label {
  display: none;
}

.result-meta-item-status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: rgba(185, 170, 150, 0.95);
}

.result-meta-item-status.is-running {
  background: rgba(248, 243, 235, 0.92);
}

.result-meta-item-status.is-running::before {
  background: rgba(185, 170, 150, 0.95);
}

.result-meta-item-status.is-success {
  background: rgba(241, 247, 239, 0.92);
}

.result-meta-item-status.is-success::before {
  background: rgba(111, 140, 104, 0.95);
}

.result-meta-item-status.is-error {
  background: rgba(248, 236, 236, 0.9);
}

.result-meta-item-status.is-error::before {
  background: rgba(177, 95, 95, 0.9);
}

.result-stage {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
  border: 1px solid rgba(223, 214, 203, 0.22);
  border-radius: 12px;
  background: rgba(248, 245, 240, 0.92);
  box-shadow: 0 10px 24px rgba(73, 60, 40, 0.03);
}

.result-stage-note {
  position: relative;
  margin: 0;
  padding: 10px 12px 10px 16px;
  border-radius: 10px;
  border: 0;
  background: rgba(251, 248, 243, 0.72);
  color: #675c50;
  font-size: 12px;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.result-stage-note::before {
  content: "";
  position: absolute;
  top: 10px;
  bottom: 10px;
  left: 0;
  width: 3px;
  border-radius: 999px;
  background: rgba(196, 181, 163, 0.9);
}

.result-stage-note.is-running {
  color: #5a4e42;
  background: rgba(248, 243, 235, 0.82);
}

.result-stage-note.is-running::before {
  background: rgba(185, 170, 150, 0.95);
}

.result-stage-note.is-success {
  color: #486246;
  background: rgba(241, 247, 239, 0.82);
}

.result-stage-note.is-success::before {
  background: rgba(111, 140, 104, 0.95);
}

.result-stage-note.is-error {
  color: #8e5050;
  background: rgba(248, 236, 236, 0.82);
}

.result-stage-note.is-error::before {
  background: rgba(177, 95, 95, 0.9);
}

.result-stage-media {
  display: flex;
  min-height: 0;
}

.result-stage-media-card {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: rgba(244, 239, 232, 0.84);
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s, background-color 0.2s;
}

.result-stage-media-card:hover {
  transform: translateY(-1px);
  background: rgba(242, 236, 228, 0.9);
  box-shadow: 0 12px 22px rgba(69, 56, 36, 0.05);
}

.result-stage-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 10px;
}

.result-stage-image-hint {
  position: absolute;
  right: 14px;
  bottom: 14px;
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(249, 245, 239, 0.86);
  border: 0;
  color: #5d5145;
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 6px 14px rgba(69, 56, 36, 0.05);
}

.result-stage-skeleton {
  width: 100%;
  aspect-ratio: 1 / 1;
  border: 0;
  border-radius: 10px;
  background: rgba(244, 239, 232, 0.84);
  position: relative;
  overflow: hidden;
}

.result-stage-skeleton::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.72) 50%,
    rgba(255, 255, 255, 0) 100%
  );
  animation: loading 1.5s infinite;
}

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

.result-stage-actions .ghost-button {
  flex: 0 0 auto;
}

.result-stage-actions .ghost-button.is-danger {
  flex: 1;
  color: #a04040;
  border-color: rgba(160, 64, 64, 0.24);
}

.result-stage-actions .ghost-button.is-danger:hover {
  background: rgba(160, 64, 64, 0.08);
  border-color: rgba(160, 64, 64, 0.38);
}

.result-stage-actions .primary-button {
  flex: 1;
}

.result-prompt-card {
  padding: 12px;
  border: 0;
  border-radius: 10px;
  background: rgba(252, 249, 244, 0.74);
}

.result-prompt-label {
  display: inline-block;
  margin-bottom: 8px;
  color: rgba(120, 108, 95, 0.82);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.result-prompt {
  margin: 0;
  color: #352f28;
  line-height: 1.6;
  display: -webkit-box;
  line-clamp: 2;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.3s ease;
}

.result-prompt.expanded {
  line-clamp: unset;
  -webkit-line-clamp: unset;
  display: block;
}

.prompt-toggle {
  margin-top: 8px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}

.prompt-toggle:hover {
  text-decoration: underline;
}

.loading-state {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}

.loading-skeleton {
  border: 1px solid rgba(223, 214, 203, 0.9);
  border-radius: 10px;
  overflow: hidden;
  background: rgba(247, 242, 235, 0.82);
  height: 200px;
  position: relative;
  overflow: hidden;
}

.loading-skeleton::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, 
    rgba(255, 255, 255, 0) 0%, 
    rgba(255, 255, 255, 0.7) 50%, 
    rgba(255, 255, 255, 0) 100%);
  animation: loading 1.5s infinite;
}

/* Share group dialog */
.mockup-confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 900;
}

.mockup-confirm {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  min-width: 340px;
  max-width: 440px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.12);
}

.mockup-confirm-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
}

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

.mockup-confirm-actions .primary-button,
.mockup-confirm-actions .ghost-button {
  flex: none;
  padding: 8px 18px;
  font-size: 14px;
}

.error-status {
  color: #a04040;
  font-size: 13px;
  margin-top: 4px;
}

.success-status {
  color: #2a7a3b;
  font-size: 13px;
  margin-top: 4px;
}

@keyframes loading {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

.history-container {
  width: min(var(--page-max-width), calc(100vw - (var(--page-gutter) * 2)));
  margin: 12px auto 20px;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.history-title {
  margin: 0;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.back-button {
  padding: 8px 16px;
  border: 1px solid #ddd3c6;
  border-radius: 14px;
  background: #fbf8f3;
  color: #64594d;
  text-decoration: none;
  font-size: 14px;
  transition: background-color 0.2s, border-color 0.2s, transform 0.2s;
}

.back-button:hover {
  border-color: var(--accent);
  background: #f5efe6;
  transform: translateY(-1px);
}

.history-filters {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  background: rgba(248, 245, 240, 0.92);
  box-shadow: var(--shadow);
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.filter-label {
  font-size: 14px;
  color: #5f5448;
}

.filter-select {
  padding: 10px 14px;
  border: 1px solid #ddd3c6;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.95);
  color: var(--text);
  font: inherit;
  min-width: 180px;
}

.filter-select:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 4px rgba(217, 207, 194, 0.28);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.history-item {
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  background: rgba(248, 245, 240, 0.92);
  box-shadow: var(--shadow);
  padding: 16px;
}

.history-item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
}

.history-date,
.history-model,
.history-quality,
.history-ratio,
.history-references {
  padding: 6px 12px;
  border: 1px solid #ddd3c6;
  border-radius: 999px;
  color: #675c50;
  background: #fbf8f3;
  font-size: 13px;
}

.history-item-prompt {
  margin: 0 0 12px;
  color: #352f28;
  line-height: 1.6;
  font-size: 15px;
}

.history-item-images {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  margin-bottom: 12px;
}

.history-image-card {
  border: 1px solid #e2d9cd;
  border-radius: 12px;
  overflow: hidden;
  background: #faf7f2;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.2s;
}

.history-image-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 16px 28px rgba(69, 56, 36, 0.08);
}

.history-image {
  display: block;
  width: 100%;
  height: 160px;
  object-fit: cover;
}

.history-image-label {
  display: block;
  padding: 12px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

.history-no-images {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--muted);
  padding: 40px 20px;
  border: 1px dashed #d7cbbb;
  border-radius: 22px;
  background: #f8f4ee;
}

.history-item-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.action-button {
  padding: 8px 16px;
  border: 1px solid #ddd3c6;
  border-radius: 14px;
  background: #fbf8f3;
  color: #64594d;
  font-size: 14px;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s;
}

.delete-button {
  border-color: rgba(177, 95, 95, 0.24);
  color: #a15a5a;
}

.delete-button:hover {
  border-color: var(--danger);
  background: rgba(250, 239, 239, 0.98);
}

.empty-history {
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
  padding: 80px 20px;
  border: 1px dashed #d7cbbb;
  border-radius: 16px;
  background: #f6f2ec;
}

.empty-history p {
  font-size: 18px;
  margin: 0 0 8px;
  color: #322c25;
}

.empty-history small {
  font-size: 14px;
  opacity: 0.7;
  margin-bottom: 12px;
  display: block;
}

.empty-state {
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
  padding: 42px 18px;
  border: 1px dashed rgba(214, 203, 189, 0.9);
  border-radius: 12px;
  background: rgba(248, 245, 240, 0.92);
  min-height: 280px;
}

.empty-state p {
  font-size: 17px;
  margin: 0 0 8px;
  color: #322c25;
}

.empty-state small {
  font-size: 14px;
  opacity: 0.7;
}

.loading-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid #ddd3c6;
  color: #675c50;
  background: #fbf8f3;
  font-size: 13px;
  position: relative;
  overflow: hidden;
}

.loading-badge::after {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #a38d74;
  animation: loadingDots 1.5s infinite;
}

@keyframes loadingDots {
  0%, 100% {
    opacity: 0.4;
    transform: scale(0.9);
  }
  50% {
    opacity: 1;
    transform: scale(1.15);
  }
}

@media (max-width: 1024px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .panel {
    min-height: auto;
  }

  .action-row {
    flex-direction: column;
  }

  .history-item-images {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }

}

@media (max-width: 768px) {
  .main-nav {
    grid-template-columns: 1fr;
    gap: 8px;
    justify-items: stretch;
  }

  .nav-section {
    justify-content: center;
  }

  .nav-left,
  .nav-right {
    justify-content: center;
  }

  .nav-tabs {
    width: 100%;
  }

  .nav-link {
    min-width: 0;
    padding: 0 10px;
  }

  .workspace-title {
    font-size: 28px;
  }

  .result-toolbar,
  .history-header,
  .history-filters {
    flex-direction: column;
    align-items: flex-start;
  }

  .history-header {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }

  .history-filters {
    flex-direction: column;
  }

  .history-item-meta {
    flex-direction: column;
    align-items: flex-start;
  }

  .history-date,
  .history-model,
  .history-quality,
  .history-ratio,
  .history-references {
    width: fit-content;
  }

  .history-item-images {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }

  .preview-row {
    gap: 8px;
  }

  .result-stage-actions {
    flex-direction: column;
  }

  .result-stage-actions .ghost-button,
  .result-stage-actions .primary-button {
    width: 100%;
  }

}

@media (max-width: 640px) {
  .main-header,
  .app-shell,
  .history-container {
    width: min(var(--page-max-width), calc(100vw - 24px));
  }

  .history-item-images {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }

  .preview-row {
    gap: 8px;
  }

  .result-stage {
    padding: 10px;
  }

}

@media (max-width: 480px) {
  .main-header {
    padding: 10px 0 8px;
  }
  
  .panel {
    padding: 16px;
  }
  
  .history-item {
    padding: 16px;
  }
}
