:root {
  --bg: #fff8fb;
  --bg-accent: radial-gradient(circle at top, #ffe1f0 0%, #fff8fb 42%, #fffdf7 100%);
  --panel: rgba(255, 255, 255, 0.88);
  --panel-strong: rgba(255, 255, 255, 0.96);
  --line: rgba(229, 165, 197, 0.36);
  --text: #5f4352;
  --muted: #9f7d8d;
  --primary: #ff7db0;
  --primary-strong: #ff5f98;
  --secondary: #8ccaff;
  --secondary-strong: #629eff;
  --danger: #ef6f86;
  --shadow: 0 24px 60px rgba(255, 126, 170, 0.12);
}

body[data-theme="night"] {
  --bg: #151925;
  --bg-accent: radial-gradient(circle at top, #263659 0%, #1b2031 52%, #151925 100%);
  --panel: rgba(25, 31, 47, 0.86);
  --panel-strong: rgba(18, 23, 36, 0.94);
  --line: rgba(124, 156, 224, 0.24);
  --text: #f7ebf3;
  --muted: #bbaec0;
  --primary: #ff8cb8;
  --primary-strong: #ff6c9c;
  --secondary: #7cb8ff;
  --secondary-strong: #5d98ff;
  --danger: #ff8396;
  --shadow: 0 24px 60px rgba(3, 6, 15, 0.42);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Noto Sans SC", "Hiragino Sans GB", sans-serif;
  background: var(--bg-accent);
}

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

button {
  border: none;
  cursor: pointer;
}

.shell {
  min-height: 100vh;
  padding: 20px;
}

.shell-single {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.panel {
  background: var(--panel);
  backdrop-filter: blur(18px);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.topbar,
.settings-grid,
.split-panel,
.grid,
.compact-grid,
.preview-strip,
.gallery,
.history-actions,
.thumb-actions,
.mode-tabs,
.thread-strip,
.settings-inline {
  display: grid;
  gap: 12px;
}

.topbar {
  padding: 12px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand h1,
h2,
h3 {
  margin: 0;
}

.brand p {
  margin: 8px 0 0;
  color: var(--muted);
}

.brand-inline {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.brand-compact h1 {
  font-size: 28px;
}

.brand-inline h1 {
  font-size: 24px;
}

.topbar-actions,
.row,
.thumb-actions,
.history-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.main,
.stack,
.history-list,
.settings-panel,
.composer-panel,
.workspace-main,
.gallery-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.main,
.workspace-main {
  gap: 18px;
}

.composer-panel,
.settings-panel,
.split-panel,
.panel {
  padding: 20px;
}

.asset-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.settings-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.split-panel {
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
}

.workspace-layout {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.compact-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

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

.gallery {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.sidebar-gallery {
  grid-template-columns: 1fr;
}

.gallery-pagination-footer {
  margin-top: auto;
  display: flex;
  justify-content: center;
  padding-top: 2px;
}

.gallery-pagination-anchor {
  position: relative;
  display: inline-flex;
  justify-content: center;
}

.gallery-page-dismiss-layer {
  position: fixed;
  inset: 0;
  z-index: 17;
  background: transparent;
  border: none;
  padding: 0;
}

.gallery-pagination-cluster {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

body[data-theme="night"] .gallery-pagination-cluster {
  box-shadow: none;
}

.pagination-icon-button {
  width: 46px;
  height: 46px;
  min-width: 46px;
  min-height: 46px;
  padding: 0;
  border-radius: 18px;
  flex: 0 0 46px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.42);
  box-shadow: 0 10px 22px rgba(255, 126, 170, 0.1);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

body[data-theme="night"] .pagination-icon-button {
  background: rgba(18, 23, 36, 0.72);
  border-color: rgba(124, 156, 224, 0.22);
  box-shadow: 0 10px 24px rgba(3, 6, 15, 0.24);
}

.pagination-page-button {
  min-width: 108px;
  height: 46px;
  padding: 0 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.42);
  box-shadow: 0 10px 22px rgba(255, 126, 170, 0.1);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  line-height: 1;
}

body[data-theme="night"] .pagination-page-button {
  background: rgba(18, 23, 36, 0.72);
  border-color: rgba(124, 156, 224, 0.22);
  box-shadow: 0 10px 24px rgba(3, 6, 15, 0.24);
}

.pagination-icon-button:disabled,
.pagination-page-button:disabled {
  opacity: 0.5;
  cursor: default;
  transform: none;
}

.pagination-icon-button .app-icon,
.pagination-page-button .app-icon {
  font-size: 22px;
}

.pagination-icon-button:not(:disabled):hover,
.pagination-page-button:hover {
  border-color: rgba(255, 125, 176, 0.42);
}

body[data-theme="night"] .pagination-icon-button:not(:disabled):hover,
body[data-theme="night"] .pagination-page-button:hover {
  border-color: rgba(124, 156, 224, 0.42);
}

.gallery-page-popover-layer {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 12px);
  transform: translateX(-50%);
  z-index: 18;
}

.gallery-page-popover {
  width: min(152px, calc(100vw - 72px));
  padding: 10px;
  border-radius: 20px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;
}

.gallery-page-popover::after {
  content: "";
  position: absolute;
  left: 50%;
  top: calc(100% - 2px);
  width: 14px;
  height: 14px;
  background: var(--panel-strong);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  transform: translateX(-50%) rotate(45deg);
}

.gallery-page-popover-body {
  display: flex;
  align-items: center;
  gap: 6px;
}

.gallery-page-wheel {
  width: 92px;
  min-width: 92px;
  min-height: 88px;
  padding: 4px 0;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.44);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  outline: none;
}

body[data-theme="night"] .gallery-page-wheel {
  background: rgba(18, 23, 36, 0.44);
}

.gallery-page-wheel-item {
  width: 100%;
  min-height: 18px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  font-weight: 600;
  transition:
    transform 0.18s ease,
    opacity 0.18s ease,
    color 0.18s ease;
}

.gallery-page-wheel-item.is-focused {
  color: var(--text);
  font-size: 24px;
  font-weight: 800;
  transform: scale(1);
}

.gallery-page-wheel-item.is-near {
  color: var(--text);
  opacity: 0.7;
  font-size: 15px;
  transform: scale(0.86);
}

.gallery-page-wheel-item.is-far {
  opacity: 0.38;
  font-size: 12px;
  transform: scale(0.72);
}

.gallery-page-confirm {
  width: 34px;
  min-width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.gallery-page-confirm .app-icon {
  font-size: 18px;
}

.mode-tabs {
  grid-template-columns: repeat(auto-fit, minmax(92px, max-content));
}

.thread-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
}

.thread-chip {
  position: relative;
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  padding-bottom: 2px;
}

.thread-chip::after {
  content: "";
  position: absolute;
  top: 100%;
  right: 0;
  width: 112px;
  height: 3px;
  pointer-events: auto;
}

.thread-chip-button {
  width: 100%;
  min-width: 138px;
  max-width: 188px;
  padding-right: 16px;
}

.thread-chip-label {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thread-chip-actions {
  position: absolute;
  right: 0;
  top: calc(100% + 1px);
  transform: translateY(-1px);
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.42);
  box-shadow: 0 10px 24px rgba(255, 126, 170, 0.12);
  backdrop-filter: blur(10px);
  opacity: 0;
  pointer-events: none;
  z-index: 12;
  transition:
    opacity 0.18s ease,
    transform 0.18s ease;
}

body[data-theme="night"] .thread-chip-actions {
  background: rgba(18, 23, 36, 0.78);
  border-color: rgba(124, 156, 224, 0.24);
  box-shadow: 0 10px 24px rgba(3, 6, 15, 0.32);
}

.thread-chip:hover .thread-chip-actions,
.thread-chip:focus-within .thread-chip-actions {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.thread-archive {
  position: relative;
  margin-left: auto;
  flex: 0 0 auto;
}

.thread-archive-button {
  width: 38px;
  min-width: 38px;
  height: 38px;
  min-height: 38px;
  padding: 0;
  border-radius: 14px;
}

.thread-archive-dismiss {
  position: fixed;
  inset: 0;
  z-index: 34;
  border: 0;
  background: transparent;
}

.thread-archive-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 35;
  width: min(280px, calc(100vw - 32px));
  max-height: min(360px, calc(100vh - 120px));
  overflow: auto;
  display: grid;
  gap: 6px;
  padding: 8px;
  border: 1px solid rgba(255, 125, 176, 0.26);
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(255, 125, 176, 0.12), rgba(140, 202, 255, 0.1)),
    var(--panel);
  box-shadow: 0 18px 42px rgba(32, 38, 64, 0.18);
}

.thread-archive-item {
  min-height: 38px;
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.thread-archive-item:hover {
  background: rgba(255, 125, 176, 0.13);
}

.thread-archive-item span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-inline {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: thin;
}

/* compact controls in settings line */
.settings-inline .resolution-button {
  flex: 0 0 150px;
  min-height: 34px;
  padding: 6px 10px;
  font-size: 0.85em;
  white-space: nowrap;
}
.settings-inline .resolution-button,
.settings-inline .compact-select,
.settings-inline .compact-stepper {
  border-color: rgba(255, 125, 176, 0.26);
  background:
    linear-gradient(135deg, rgba(255, 125, 176, 0.12), rgba(140, 202, 255, 0.12)),
    var(--panel-strong);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.settings-inline .resolution-button:hover,
.settings-inline .compact-select:hover,
.settings-inline .compact-stepper:hover {
  border-color: rgba(255, 125, 176, 0.42);
  box-shadow: 0 8px 18px rgba(255, 125, 176, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
.settings-inline .compact-select {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 6px 8px;
  font-size: 0.85em;
  width: auto;
  min-width: 88px;
  max-width: 128px;
}
.settings-inline .compact-field {
  flex: 0 0 52px;
  min-height: 34px;
  padding: 6px 8px;
  font-size: 0.85em;
  width: 52px;
  text-align: center;
}

.settings-inline .compact-stepper {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 34px;
  height: 34px;
  padding: 2px;
  border: 1px solid rgba(255, 125, 176, 0.26);
  border-radius: 17px;
  overflow: hidden;
}

.settings-inline .compression-stepper {
  width: 98px;
}

.settings-inline .count-stepper {
  width: 82px;
}

.settings-inline .stepper-button {
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
  min-width: 24px;
  min-height: 24px;
  aspect-ratio: 1 / 1;
  margin: 0;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(255, 125, 176, 0.22), rgba(140, 202, 255, 0.2));
  color: var(--text);
  cursor: pointer;
  font-size: 0.9em;
  font-weight: 800;
  line-height: 24px;
  text-align: center;
  transition: transform 0.16s ease, background 0.16s ease, color 0.16s ease;
}

.settings-inline .stepper-button:hover {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
  transform: translateY(-1px);
}

.settings-inline .stepper-button:active {
  transform: translateY(0);
}

.settings-inline .stepper-value {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  height: 28px;
  padding: 0 2px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 0.85em;
  font-weight: 700;
  text-align: center;
  outline: none;
}

.settings-inline .stepper-value::-webkit-inner-spin-button,
.settings-inline .stepper-value::-webkit-outer-spin-button {
  appearance: none;
  margin: 0;
}

.settings-inline .stepper-value[type="number"] {
  appearance: textfield;
}

.settings-inline .compact-stepper:focus-within {
  border-color: rgba(255, 125, 176, 0.55);
  box-shadow: 0 0 0 3px rgba(255, 125, 176, 0.12);
}

.settings-inline .compact-select:nth-of-type(1) {
  min-width: 82px;
}

.settings-inline .compact-select:nth-of-type(2) {
  min-width: 94px;
}

.settings-inline .compact-select:nth-of-type(4) {
  min-width: 116px;
}

.field,
.text-input,
.select-input,
.prompt-input {
  width: 100%;
  color: var(--text);
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
}

.field,
.text-input,
.select-input {
  padding: 10px 12px;
}

.prompt-input {
  min-height: 180px;
  padding: 16px;
  resize: vertical;
}

.button,
.chip-button {
  padding: 11px 16px;
  border-radius: 16px;
  transition: transform 0.2s ease;
}

.button {
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  color: #fff;
  font-weight: 700;
}

.button.secondary {
  background: linear-gradient(135deg, var(--secondary), var(--secondary-strong));
}

.button.save-success {
  background: linear-gradient(135deg, #79d9a2, #47b97b);
}

.button.ghost,
.chip-button {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}

.button.danger {
  color: var(--danger);
}

.resolution-button {
  min-height: 40px;
  padding: 10px 14px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(255, 125, 176, 0.18), rgba(140, 202, 255, 0.18));
  color: var(--text);
  border: 1px solid var(--line);
  text-align: left;
}

.compact-select,
.compact-field {
  min-width: 0;
}

.button:active,
.chip-button:active {
  transform: translateY(1px);
}

.active-chip {
  background: linear-gradient(135deg, rgba(255, 125, 176, 0.18), rgba(140, 202, 255, 0.18));
  border-color: rgba(255, 125, 176, 0.4);
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.18);
  color: var(--muted);
  font-size: 12px;
}

.composer-title-row {
  position: relative;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.config-switcher {
  position: relative;
  margin-left: auto;
}

.config-switcher-button {
  cursor: pointer;
  max-width: min(420px, 46vw);
  border-color: rgba(255, 125, 176, 0.26);
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

.config-switcher-button:hover {
  border-color: rgba(255, 125, 176, 0.46);
  background: rgba(255, 255, 255, 0.28);
}

.config-switcher-button span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.config-switcher-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 30;
  width: min(360px, calc(100vw - 48px));
  padding: 8px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 251, 253, 0.96);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.config-switcher-item {
  width: 100%;
  min-height: 42px;
  border: 0;
  border-radius: 12px;
  padding: 8px 10px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 24px;
  align-items: center;
  gap: 8px;
  color: var(--text);
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.config-switcher-item:hover,
.config-switcher-item.is-active {
  background: rgba(255, 125, 176, 0.13);
}

.config-switcher-name,
.config-switcher-model {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.config-switcher-model {
  color: var(--muted);
  font-size: 12px;
}

.muted,
.status {
  color: var(--muted);
}

.preset-block,
.mask-panel {
  padding: 16px;
  border-radius: 22px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
}

.dropzone {
  padding: 22px;
  border-radius: 22px;
  text-align: center;
  border: 2px dashed var(--line);
  color: var(--muted);
}

.resolution-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 18, 30, 0.34);
}

.settings-overlay {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: grid;
  place-items: start end;
  padding: 84px 20px 20px;
  background: rgba(15, 18, 30, 0.16);
}

.settings-popover {
  width: min(920px, calc(100vw - 40px));
  padding: 20px;
  border-radius: 28px;
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.settings-config-actions {
  justify-content: flex-end;
  align-items: center;
}

.settings-config-actions .select-input {
  flex: 1 1 0;
  min-width: 0;
}

.resolution-sheet {
  width: min(720px, 100%);
  min-height: 360px;
  padding: 22px;
  border-radius: 32px;
  border: 1px solid var(--line);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.9), rgba(255, 248, 251, 0.84));
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow: hidden;
  position: relative;
}

body[data-theme="night"] .resolution-sheet {
  background:
    linear-gradient(145deg, rgba(26, 31, 46, 0.94), rgba(18, 23, 36, 0.92));
}

.resolution-preview {
  display: flex;
  justify-content: center;
}

.resolution-close-button {
  position: absolute;
  top: 14px;
  right: 14px;
  min-width: 34px;
  min-height: 34px;
  width: 34px;
  height: 34px;
  padding: 0;
  z-index: 2;
}

.resolution-close-button:hover,
.resolution-close-button:focus-visible {
  background: rgba(255, 125, 176, 0.12);
}

.resolution-content {
  min-height: 210px;
  display: flex;
}

.custom-dimension-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.custom-dimension-separator {
  color: var(--muted);
  font-weight: 700;
  user-select: none;
}

.resolution-panel {
  width: 100%;
  min-height: 100%;
  justify-content: center;
}

.thumb-card,
.card {
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 22px;
  overflow: hidden;
}

.thumb-card.is-reference-selected {
  border-color: rgba(255, 125, 176, 0.58);
  box-shadow: 0 12px 28px rgba(255, 125, 176, 0.16);
}

.thumb-card.is-drag-placeholder {
  transform: translateY(-2px);
  border-color: rgba(98, 158, 255, 0.62);
  box-shadow: 0 0 0 2px rgba(98, 158, 255, 0.18);
}

.gallery .card .card-body {
  gap: 10px;
}

.gallery-card-compact {
  position: relative;
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  align-items: center;
  min-height: 112px;
  transform: translate3d(0, 0, 0);
  transform-origin: center;
  isolation: isolate;
  box-shadow:
    8px 10px 18px rgba(32, 38, 64, 0.12),
    14px 16px 28px rgba(255, 125, 176, 0.08),
    18px 20px 34px rgba(140, 202, 255, 0.06);
  transition:
    transform 0.24s cubic-bezier(0.2, 0.82, 0.2, 1),
    box-shadow 0.24s ease,
    border-color 0.24s ease;
  will-change: transform;
}

.gallery-card-compact::after {
  content: "";
  position: absolute;
  inset: auto 12px -9px 26px;
  height: 18px;
  z-index: -1;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255, 125, 176, 0.16), rgba(140, 202, 255, 0.12), transparent 82%);
  filter: blur(6px);
  opacity: 0.56;
  transform: translate3d(8px, 0, 0);
  pointer-events: none;
  transition: opacity 0.24s ease, transform 0.24s ease, filter 0.24s ease;
}

.gallery-card-compact:hover,
.gallery-card-compact:focus-within {
  z-index: 4;
  border-color: rgba(255, 125, 176, 0.42);
  transform: translate3d(4px, -4px, 0) scale(1.075);
  box-shadow:
    10px 14px 24px rgba(32, 38, 64, 0.16),
    18px 20px 34px rgba(255, 125, 176, 0.12),
    24px 26px 44px rgba(140, 202, 255, 0.09);
}

.gallery-card-compact:hover::after,
.gallery-card-compact:focus-within::after {
  opacity: 1;
  filter: blur(7px);
  transform: translate3d(12px, 3px, 0) scale(1.04);
}

body[data-theme="night"] .gallery-card-compact {
  box-shadow:
    8px 10px 20px rgba(0, 0, 0, 0.28),
    14px 16px 28px rgba(255, 125, 176, 0.08),
    18px 20px 34px rgba(140, 202, 255, 0.05);
}

body[data-theme="night"] .gallery-card-compact::after {
  background: linear-gradient(90deg, rgba(255, 125, 176, 0.12), rgba(140, 202, 255, 0.08), transparent 82%);
  opacity: 0.38;
}

body[data-theme="night"] .gallery-card-compact:hover,
body[data-theme="night"] .gallery-card-compact:focus-within {
  box-shadow:
    10px 14px 26px rgba(0, 0, 0, 0.34),
    18px 20px 34px rgba(255, 125, 176, 0.11),
    24px 26px 44px rgba(140, 202, 255, 0.07);
}

body[data-theme="night"] .gallery-card-compact:hover::after,
body[data-theme="night"] .gallery-card-compact:focus-within::after {
  opacity: 0.52;
}

@media (prefers-reduced-motion: reduce) {
  .gallery-card-compact {
    transition: box-shadow 0.18s ease, border-color 0.18s ease;
    will-change: auto;
  }

  .gallery-card-compact:hover,
  .gallery-card-compact:focus-within {
    transform: none;
  }
}

.image-button {
  display: block;
  width: 100%;
  padding: 0;
  background: transparent;
}

.thumb-card > .image-button {
  position: relative;
  overflow: hidden;
  border-top-left-radius: 22px;
  border-top-right-radius: 22px;
}

.thumb-card > .image-button {
  position: relative;
  overflow: hidden;
  border-top-left-radius: 22px;
  border-top-right-radius: 22px;
}

.thumb-card img,
.card img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
}

.compact-preview-button,
.compact-preview-fallback {
  position: relative;
  width: 112px;
  height: 100%;
  min-height: 112px;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  align-self: center;
  justify-self: start;
  overflow: hidden;
  border-radius: 18px;
}

.compact-preview-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  border-radius: 18px;
}

.compact-preview-fallback {
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
}

.gallery-image-overlay {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  max-width: calc(100% - 16px);
}

.gallery-image-overlay-right {
  left: auto;
  right: 8px;
  justify-content: flex-end;
}

.thumb-order-badge-slot {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 3;
  display: flex;
  justify-content: flex-end;
  pointer-events: none;
}

.gallery-corner-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(10, 12, 20, 0.72);
  color: #fff;
  font-size: 11px;
  line-height: 1;
  backdrop-filter: blur(6px);
}

.reference-order-badge {
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
}

.thumb-drag-handle {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 3;
  min-width: 28px;
  min-height: 28px;
  padding: 4px 6px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 12, 20, 0.62);
  color: #fff;
  font-size: 13px;
  line-height: 1;
  letter-spacing: -1px;
  backdrop-filter: blur(6px);
  cursor: grab;
  opacity: 1;
  visibility: visible;
}

.thumb-actions,
.card-body {
  padding: 12px;
}

.compact-card-body {
  justify-content: space-between;
  min-width: 0;
}

.gallery-card-title {
  margin: 0;
  font-size: 15px;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.gallery-meta {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
  justify-content: flex-end;
  min-width: 0;
  overflow: hidden;
}

.gallery-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  max-width: 100%;
  margin-left: auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compact-actions {
  gap: 6px;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  margin-left: auto;
}

.mini-action {
  min-height: 30px;
  min-width: 30px;
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 10px;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.compact-actions .mini-action,
.preview-sidebar .preview-copy-button,
.resolution-close-button {
  border: none;
  box-shadow: none;
  background: transparent;
}

.compact-actions .mini-action {
  padding: 0;
}

.compact-actions .mini-action:hover,
.compact-actions .mini-action:focus-visible {
  background: rgba(255, 125, 176, 0.12);
}

.compact-actions .danger:hover,
.compact-actions .danger:focus-visible {
  background: rgba(239, 111, 134, 0.14);
}

.gallery .mini-action {
  min-height: 30px;
  min-width: 30px;
  width: 30px;
  height: 30px;
}

.thumb-actions {
  justify-content: space-between;
  align-items: center;
  flex-wrap: nowrap;
}

.thumb-actions .mini-action {
  width: 30px;
  min-height: 30px;
  height: 30px;
}

.thumb-actions > .button.ghost:first-child {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 11px;
  min-height: 30px;
  padding: 6px 8px;
  white-space: nowrap;
}

.icon-action {
  font-weight: 700;
}

.material-symbols-rounded.app-icon {
  font-variation-settings:
    "FILL" 0,
    "wght" 500,
    "GRAD" 0,
    "opsz" 24;
  font-size: 18px;
  line-height: 1;
  width: 1em;
  height: 1em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  user-select: none;
}

.material-symbols-rounded.app-icon.is-filled {
  font-variation-settings:
    "FILL" 1,
    "wght" 500,
    "GRAD" 0,
    "opsz" 24;
  color: var(--primary-strong);
}

.favorite-top-button {
  width: 38px;
  min-width: 38px;
  height: 38px;
  min-height: 38px;
  padding: 0;
  border-radius: 14px;
}

.favorites-overlay {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: grid;
  place-items: start center;
  padding: 78px 18px 18px;
  background: rgba(20, 24, 36, 0.18);
}

.favorites-popover {
  width: min(1080px, calc(100vw - 28px));
  max-height: min(680px, calc(100vh - 96px));
  overflow: hidden;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 12px;
  padding: 16px;
  border: 1px solid rgba(255, 125, 176, 0.24);
  border-radius: 26px;
  background:
    linear-gradient(135deg, rgba(255, 125, 176, 0.12), rgba(140, 202, 255, 0.1)),
    var(--panel);
  box-shadow: 0 24px 60px rgba(32, 38, 64, 0.18);
}

.favorites-header,
.favorite-folder-tabs {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.favorite-folder-tabs {
  justify-content: flex-start;
  align-content: flex-start;
  flex-wrap: wrap;
  overflow: visible;
  padding-bottom: 4px;
}

.favorite-folder-tab,
.favorite-folder-add,
.folder-picker-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  cursor: pointer;
}

.favorite-folder-tab {
  min-height: 34px;
  padding: 0 4px 0 10px;
  border-radius: 999px;
  white-space: nowrap;
  overflow: hidden;
}

.favorite-folder-tab.is-active {
  border-color: rgba(255, 125, 176, 0.48);
  background: linear-gradient(135deg, rgba(255, 125, 176, 0.2), rgba(140, 202, 255, 0.16));
  color: var(--primary-strong);
}

.favorite-folder-tab-main,
.favorite-folder-rename {
  min-height: 30px;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.favorite-folder-tab-main {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 4px 0 0;
}

.favorite-folder-rename {
  width: 28px;
  min-width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  opacity: 0.66;
}

.favorite-folder-rename:hover {
  background: rgba(255, 125, 176, 0.14);
  opacity: 1;
}

.favorite-folder-rename.danger {
  color: var(--danger);
}

.favorite-folder-rename.danger:hover {
  background: rgba(239, 111, 134, 0.14);
}

.favorite-folder-add {
  width: 34px;
  min-width: 34px;
  height: 34px;
  justify-content: center;
  border-radius: 50%;
}

.favorite-gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  min-height: 0;
  overflow: auto;
  padding: 2px 2px 8px;
}

.favorite-gallery-card {
  grid-template-columns: 112px minmax(0, 1fr);
  min-height: 112px;
}

.favorite-gallery-card .compact-preview-button,
.favorite-gallery-card .compact-preview-fallback {
  width: 112px;
  min-height: 112px;
}

.favorite-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel-strong);
  box-shadow: 8px 10px 20px rgba(32, 38, 64, 0.1);
}

.favorite-card-image {
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
}

.favorite-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.favorite-card-info {
  display: grid;
  gap: 3px;
  padding: 8px;
  font-size: 12px;
}

.favorite-card-info span {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.favorite-empty {
  grid-column: 1 / -1;
  min-height: 220px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  color: var(--muted);
}

.favorite-empty-thumb {
  display: grid;
  place-items: center;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.08);
}

.gallery-count-tag {
  margin-left: auto;
}

.gallery-title-actions {
  margin-left: auto;
  justify-content: flex-end;
}

.folder-picker-dismiss {
  position: fixed;
  inset: 0;
  z-index: 55;
  border: 0;
  background: transparent;
}

.folder-picker-popover {
  position: fixed;
  z-index: 56;
  min-width: 172px;
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid rgba(255, 125, 176, 0.28);
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(255, 125, 176, 0.12), rgba(140, 202, 255, 0.1)),
    var(--panel);
  box-shadow: 0 18px 40px rgba(32, 38, 64, 0.16);
}

.folder-picker-item {
  min-height: 32px;
  padding: 7px 10px;
  border-radius: 12px;
  justify-content: flex-start;
}

.folder-picker-item:hover {
  border-color: rgba(255, 125, 176, 0.45);
  background: rgba(255, 125, 176, 0.14);
}

.folder-picker-cancel {
  margin-top: 4px;
  border-color: rgba(239, 111, 134, 0.28);
  color: var(--danger);
}

.inline-popover-dismiss {
  position: fixed;
  inset: 0;
  z-index: 57;
  border: 0;
  background: transparent;
}

.inline-action-popover {
  position: fixed;
  z-index: 58;
  width: min(280px, calc(100vw - 24px));
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(255, 125, 176, 0.28);
  border-radius: 20px;
  background:
    linear-gradient(135deg, rgba(255, 125, 176, 0.14), rgba(140, 202, 255, 0.1)),
    var(--panel);
  box-shadow: 0 18px 42px rgba(32, 38, 64, 0.18);
}

.inline-popover-input {
  min-height: 38px;
  border-radius: 14px;
}

.inline-popover-actions {
  justify-content: flex-end;
  gap: 8px;
}

.inline-popover-actions .button {
  min-height: 34px;
  padding: 8px 12px;
}

.confirm-popover p {
  margin: 0;
  line-height: 1.5;
}

.confirm-popover .button.danger {
  color: #fff;
}

@media (max-width: 980px) {
  .favorite-gallery-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .favorite-gallery-grid {
    grid-template-columns: 1fr;
  }
}

.gallery .mini-action .app-icon {
  font-size: 17px;
}

.thumb-actions .mini-action .app-icon {
  font-size: 16px;
}

.gallery-sidebar {
  position: sticky;
  top: 20px;
  max-height: calc(100vh - 40px);
  overflow: auto;
}

.continuation-banner {
  padding: 14px 16px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: linear-gradient(135deg, rgba(255, 125, 176, 0.12), rgba(140, 202, 255, 0.14));
}

.continuation-thumb {
  width: 72px;
  height: 72px;
  border-radius: 18px;
  object-fit: cover;
  border: 1px solid var(--line);
}

.mask-stage {
  position: relative;
  width: 100%;
  min-height: min(72vh, 820px);
  border-radius: 22px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.18);
}

.mask-base-image,
.mask-overlay {
  display: block;
  width: 100%;
}

.mask-base-image {
  position: relative;
  z-index: 1;
}

.mask-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}

.canvas-wrap {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mask-data-canvas {
  display: none;
}

.mask-toolbar {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mask-toolbar-main,
.mask-toolbar-actions,
.reference-menu-actions {
  justify-content: space-between;
}

.mask-size-control {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 280px;
}

.mask-size-range {
  width: min(280px, 100%);
}

.reference-toggle-button {
  font-size: 12px;
  padding-inline: 10px;
}

.reference-menu-shell,
.mask-modal-shell {
  width: min(920px, calc(100vw - 40px));
  max-height: calc(100vh - 40px);
  padding: 22px;
  border-radius: 32px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  box-shadow: var(--shadow);
  overflow: auto;
}

.mask-modal-shell {
  width: min(1100px, calc(100vw - 40px));
}

.reference-menu-top {
  align-items: flex-start;
  justify-content: space-between;
}

.reference-menu-preview {
  margin: 12px 0 16px;
  border-radius: 24px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.18);
}

.reference-menu-preview img {
  display: block;
  width: 100%;
  max-height: 62vh;
  object-fit: contain;
}

.preview-overlay,
.context-menu-layer {
  position: fixed;
  inset: 0;
  z-index: 60;
}

.preview-overlay {
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(6, 8, 15, 0.72);
  backdrop-filter: blur(14px);
}

.preview-shell {
  position: relative;
  width: min(1240px, 100%);
  max-height: calc(100vh - 40px);
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(360px, 0.8fr);
  gap: 0;
  overflow: hidden;
  border-radius: 32px;
  border: 1px solid var(--line);
  background: rgba(255, 251, 253, 0.96);
  box-shadow: var(--shadow);
}

.failure-log-shell {
  width: min(920px, 100%);
}

.failure-log-text {
  margin: 4px 0 0;
  padding: 14px;
  max-height: min(56vh, 620px);
  overflow: auto;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.06);
  white-space: pre-wrap;
  word-break: break-word;
}

.failure-log-top {
  padding-right: 56px;
}

.preview-shell-close {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 3;
  background: rgba(255, 255, 255, 0.86);
  border-color: rgba(24, 26, 38, 0.08);
}

.preview-stage {
  position: relative;
  min-height: 560px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  background:
    radial-gradient(circle at center, rgba(255, 255, 255, 0.88), transparent 48%),
    linear-gradient(180deg, rgba(255, 239, 247, 0.92), rgba(247, 250, 255, 0.94));
}

.preview-stage.is-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 80;
  padding: 40px;
}

.preview-stage-meta {
  position: absolute;
  top: 18px;
  left: 18px;
  display: flex;
  gap: 10px;
  z-index: 2;
}

.preview-fullscreen-toolbar {
  position: absolute;
  top: 18px;
  right: 18px;
  display: flex;
  gap: 10px;
  z-index: 2;
}

.preview-toolbar-button {
  background: rgba(255, 255, 255, 0.82);
  border-color: rgba(24, 26, 38, 0.08);
}

.preview-image-button {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: 100%;
  overflow: hidden;
  cursor: zoom-in;
}

.preview-image-button.is-pan-enabled {
  cursor: grab;
}

.preview-image {
  max-width: 100%;
  max-height: calc(100vh - 180px);
  border-radius: 20px;
  object-fit: contain;
  transition: transform 0.12s ease, border-radius 0.18s ease;
  transform-origin: center center;
  will-change: transform;
  user-select: none;
  pointer-events: none;
}

.preview-image.is-zoomed {
  border-radius: 16px;
}

.preview-sidebar {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(255, 250, 252, 0.96), rgba(255, 246, 250, 0.96));
  overflow: auto;
}

.preview-sidebar .status,
.preview-sidebar .tag {
  color: var(--muted);
}

.preview-sidebar-top {
  align-items: flex-start;
  justify-content: space-between;
}

.preview-prompt-head {
  align-items: center;
  gap: 4px;
}

.preview-copy-button {
  min-width: 20px;
  min-height: 20px;
  width: 20px;
  height: 20px;
  padding: 0;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
  border-radius: 0;
  align-self: baseline;
  margin-top: -1px;
  margin-left: -2px;
}

.preview-copy-button .app-icon {
  font-size: 13px;
}

.preview-prompt {
  margin: 0;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}

.preview-prompt-box {
  margin-top: 2px;
  padding: 12px 14px;
  max-height: min(28vh, 240px);
  overflow: auto;
  border-radius: 18px;
  border: 1px solid rgba(24, 26, 38, 0.08);
  background: rgba(255, 255, 255, 0.5);
  scrollbar-gutter: stable;
}

.icon-button {
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  font-size: 24px;
  line-height: 1;
}

.preview-copy-button:hover,
.preview-copy-button:focus-visible {
  color: var(--primary-strong);
  background: transparent;
  border: none;
}

.preview-copy-button:disabled,
.preview-copy-button:disabled:hover,
.preview-copy-button:disabled:focus-visible {
  color: color-mix(in srgb, var(--muted) 72%, transparent);
  background: transparent;
  border: none;
  opacity: 0.42;
  cursor: not-allowed;
  pointer-events: none;
}

.preview-ref-strip {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.preview-ref-card {
  width: 90px;
  height: 90px;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.32);
}

.floating-tip {
  position: fixed;
  z-index: 120;
  max-width: min(220px, calc(100vw - 24px));
  padding: 6px 10px;
  border-radius: 12px;
  background: rgba(28, 26, 38, 0.82);
  color: #fff7fb;
  font-size: 12px;
  line-height: 1.3;
  letter-spacing: 0.01em;
  box-shadow: 0 14px 30px rgba(24, 18, 32, 0.2);
  backdrop-filter: blur(10px);
  pointer-events: none;
  transform: translate(0, calc(-100% - 4px));
  white-space: nowrap;
}

body[data-theme="day"] .floating-tip {
  background: rgba(255, 247, 252, 0.96);
  color: #5f4566;
  border: 1px solid rgba(255, 125, 176, 0.16);
  box-shadow: 0 14px 30px rgba(255, 125, 176, 0.16);
}

.preview-ref-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

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

.preview-time-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 14px;
}

.detail-card {
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.4);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.detail-card.is-inline {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
}

.detail-label {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
  flex: 0 0 auto;
}

.detail-value {
  font-size: 13px;
  line-height: 1.35;
  color: var(--text);
  margin: 0;
  min-width: 0;
}

.detail-card.is-inline .detail-value {
  white-space: nowrap;
}

.detail-value-wrap {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.preview-actions {
  gap: 10px;
}

.preview-actions .button {
  flex: 1 1 0;
  justify-content: center;
}

.context-menu {
  position: fixed;
  min-width: 160px;
  padding: 8px;
  border-radius: 18px;
  background: rgba(255, 251, 253, 0.96);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.context-item {
  width: 100%;
  text-align: left;
}

body[data-theme="night"] .preview-shell {
  border-color: rgba(255, 255, 255, 0.08);
  background: rgba(17, 19, 28, 0.94);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.34);
}

body[data-theme="night"] .failure-log-text {
  background: rgba(255, 255, 255, 0.04);
}

body[data-theme="night"] .preview-stage {
  background:
    radial-gradient(circle at center, rgba(255, 255, 255, 0.08), transparent 45%),
    rgba(12, 13, 18, 0.96);
}

body[data-theme="night"] .preview-shell-close {
  background: rgba(22, 24, 34, 0.88);
  border-color: rgba(255, 255, 255, 0.08);
}

body[data-theme="night"] .preview-toolbar-button {
  background: rgba(22, 24, 34, 0.88);
  border-color: rgba(255, 255, 255, 0.08);
}

body[data-theme="night"] .preview-sidebar {
  color: #f4ecf2;
  background:
    linear-gradient(180deg, rgba(26, 28, 36, 0.96), rgba(17, 19, 28, 0.96));
}

body[data-theme="night"] .preview-sidebar .status,
body[data-theme="night"] .preview-sidebar .tag {
  color: rgba(255, 255, 255, 0.72);
}

body[data-theme="night"] .preview-ref-card {
  border-color: rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
}

body[data-theme="night"] .detail-card {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.06);
}

body[data-theme="night"] .context-menu {
  background: rgba(18, 23, 36, 0.96);
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

body[data-theme="night"] .config-switcher-menu {
  background: rgba(18, 23, 36, 0.96);
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

@media (max-width: 1100px) {
  .settings-grid,
  .split-panel,
  .compact-grid,
  .grid,
  .workspace-layout {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .gallery-sidebar {
    position: static;
    max-height: none;
  }

  .preview-shell {
    grid-template-columns: 1fr;
  }

  .preview-stage {
    min-height: 380px;
  }
}

@media (max-width: 720px) {
  .shell {
    padding: 12px;
  }

  .composer-title-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .config-switcher,
  .config-switcher-button {
    width: 100%;
    max-width: 100%;
  }

  .config-switcher-menu {
    left: 0;
    right: auto;
    width: 100%;
  }

  .settings-inline {
    grid-template-columns: repeat(auto-fill, minmax(68px, max-content));
    gap: 4px;
  }

  .resolution-sheet,
  .preview-overlay {
    padding: 14px;
  }

  .preview-details-grid {
    grid-template-columns: 1fr;
  }

  .gallery-card-compact {
    grid-template-columns: 88px minmax(0, 1fr);
    min-height: 88px;
  }

  .compact-preview-button,
  .compact-preview-fallback {
    width: 88px;
    min-height: 88px;
  }

  .compact-preview-image {
    width: 76px;
    height: 76px;
  }
}
