/* ---------- FONT : DIN OFFC (TTF) ---------- */
@font-face {
  font-family: "DIN Offc";
  src: url("fonts/DINOffc-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "DIN Offc";
  src: url("fonts/DINOffc-Medium.ttf") format("truetype");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "DIN Offc";
  src: url("fonts/DINOffc-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ---------- THEME VARIABLES ---------- */
:root {
  --bg:     #efefef;
  --paper:  #ffffff;
  --panel:  #fafafa;
  --panel2: #f4f4f4;
  --well:   #ebebeb;
  --ink:    #111111;
  --muted:  #888888;
  --line:   #d0d0d0;
  --soft:   #e6e6e6;

  --font: "DIN Offc", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --transition: 160ms ease;
}

[data-theme="dark"] {
  --bg:     #141414;
  --paper:  #1c1c1c;
  --panel:  #222222;
  --panel2: #282828;
  --well:   #181818;
  --ink:    #f0f0f0;
  --muted:  #888888;
  --line:   #333333;
  --soft:   #2c2c2c;
}

/* ---------- GLOBAL RESET ---------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  border-radius: 0 !important;
}

html, body {
  height: 100%;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--ink);
  text-decoration: none;
}

img {
  display: block;
  max-width: 100%;
}

button {
  font-family: var(--font);
  cursor: pointer;
  border: none;
  background: none;
}

input, select, textarea {
  font-family: var(--font);
  font-size: 14px;
}

ul, ol {
  list-style: none;
}

/* ---------- SCREENS ---------- */
.screen {
  display: none;
}

.screen.active {
  display: block;
}

#refineScreen.active {
  display: flex !important;
  flex-direction: column;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--bg);
}

/* ---------- FRAME ---------- */
.frame {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  background: var(--paper);
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- LOGIN ---------- */
#loginScreen.active {
  display: flex;
  align-items: stretch;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}

.login-split {
  display: flex;
  width: 100%;
  max-width: 1100px;
  min-height: 100vh;
  margin: 0 auto;
}

.login-brand {
  flex: 1;
  background: #111;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-end;
  padding: 60px 60px 120px;
  gap: 16px;
  position: relative;
  overflow: hidden;
}

.login-oai {
  font-family: 'DIN Offc', Arial, sans-serif;
  font-size: clamp(120px, 18vw, 220px);
  font-weight: 700;
  color: #ffffff;
  line-height: 1;
  letter-spacing: -0.02em;
  position: absolute;
  top: 50%;
  left: 60px;
  transform: translateY(-50%);
  pointer-events: none;
  user-select: none;
  white-space: nowrap;
}

.login-logo {
  width: 220px;
  filter: brightness(0) invert(1);
  opacity: 0.92;
}

.login-tagline {
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.4);
  margin: 0;
}

.login-form-panel {
  width: 460px;
  background: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 48px;
  border-left: 1px solid var(--line);
}

.login-form-inner {
  width: 100%;
  max-width: 340px;
}

.login-title {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--ink);
  margin: 0 0 36px;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 20px;
}

.login-field label {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
}

.login-field input {
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}

.login-field input:focus {
  border-color: var(--ink);
}

.login-btn {
  width: 100%;
  height: 44px;
  margin-top: 12px;
  background: var(--ink);
  color: var(--paper);
  border: none;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.login-btn:hover {
  opacity: 0.82;
}

/* ---------- HEADER ---------- */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  height: 88px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.logoImg {
  height: 1cap;
  width: auto;
  display: block;
}

.header-brand {
  display: flex;
  align-items: baseline;
  font-size: 56px;
  gap: 20px;
  margin-left: 2px;
}

.header-oai {
  font-family: 'DIN Offc', Arial, sans-serif;
  font-size: 56px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 16px;
}

.user-info span {
  font-size: 13px;
  color: var(--muted);
  font-weight: 400;
}

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
  cursor: pointer;
  position: relative;
  transition: background var(--transition), border-color var(--transition);
}

.theme-toggle:hover {
  background: var(--well);
  border-color: var(--ink);
}

.theme-toggle .icon {
  position: absolute;
  opacity: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s ease;
}

html[data-theme="light"] .theme-toggle .moon { opacity: 1; }
html[data-theme="dark"]  .theme-toggle .sun  { opacity: 1; }

.admin-btn {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  padding: 6px 14px;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.admin-btn:hover {
  background: var(--well);
  color: var(--ink);
  border-color: var(--ink);
}

#logoutBtn {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  padding: 6px 14px;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}

#logoutBtn:hover {
  background: #111;
  color: #fff;
  border-color: #111;
}

/* ---------- TABS ---------- */
.tabs {
  display: flex;
  align-items: flex-end;
  gap: 0;
  border-bottom: 1px solid var(--line);
  padding: 0 32px;
  background: var(--paper);
  flex-shrink: 0;
}

.tab {
  position: relative;
  padding: 16px 20px 14px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
}

.tab:hover {
  color: var(--ink);
}

.tab.active {
  color: var(--ink);
  border-bottom-color: #111;
}

/* ---------- TAB CONTENT ---------- */
.tab-content {
  display: none;
  flex: 1;
}

.tab-content.active {
  display: block;
}

/* ---------- GENERATE SCREEN ---------- */
.generate-container {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 32px;
  gap: 24px;
}

.generate-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ---------- PROMPT BOX ---------- */
.prompt-box {
  border: 1px solid var(--line);
  background: var(--panel);
  display: flex;
  flex-direction: column;
}

.prompt-box textarea {
  border: none;
  background: transparent;
  padding: 16px;
  font-size: 14px;
  font-family: var(--font);
  color: var(--ink);
  resize: none;
  outline: none;
  min-height: 120px;
  line-height: 1.5;
}

.prompt-box textarea:focus {
  background: transparent;
  border: none;
}

.prompt-attachments {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  min-height: 48px;
}

.attach-card {
  display: flex;
  flex-direction: column;
  width: 200px;
  flex-shrink: 0;
  gap: 0;
  border: 1px solid var(--line);
}

.attach-card-img {
  position: relative;
  width: 100%;
  height: 140px;
  flex-shrink: 0;
}

.attach-card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.attach-thumb-remove {
  position: absolute;
  top: 0;
  right: 0;
  width: 24px;
  height: 24px;
  background: var(--ink);
  color: var(--paper);
  font-size: 13px;
  line-height: 24px;
  text-align: center;
  cursor: pointer;
  border: none;
  padding: 0;
  z-index: 2;
}

.attach-card-prompt {
  width: 100% !important;
  font-size: 13px !important;
  padding: 10px 12px !important;
  border: none !important;
  border-top: 1px solid var(--line) !important;
  background: var(--panel) !important;
  color: var(--ink) !important;
  outline: none !important;
  min-width: 0 !important;
  resize: none !important;
  min-height: 64px !important;
  line-height: 1.4 !important;
}

.attach-card-prompt:focus {
  background: var(--paper) !important;
}

.attach-add-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 140px;
  width: 80px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px dashed var(--line);
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
  user-select: none;
  align-self: flex-start;
}

.attach-add-btn:hover {
  color: var(--ink);
  border-color: var(--ink);
}

/* ---------- GENERATE OPTIONS TOOLBAR ---------- */
.generate-options {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
}

.gen-opt-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.gen-opt-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.generate-options select,
.generate-options input[type="number"] {
  width: auto;
  min-width: 72px;
  padding: 7px 10px;
  font-size: 13px;
}

.gen-opt-dims {
  flex-direction: row;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  padding-bottom: 7px;
}

.gen-opt-dims-source {
  flex-direction: row;
  align-items: center;
  gap: 6px;
  padding-bottom: 7px;
}

.gen-opt-dims-source select {
  font-size: 12px;
  padding: 4px 6px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  border-radius: 3px;
}

.gen-submit-btn {
  width: auto !important;
  min-width: 120px;
  margin-left: auto;
  padding: 9px 24px;
  align-self: flex-end;
}

/* ---------- FORM ELEMENTS ---------- */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.form-group input,
.form-group select,
.form-group textarea,
input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  background: #f7f7f7;
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 14px;
  font-family: var(--font);
  line-height: 1.4;
  outline: none;
  transition: border-color var(--transition), background var(--transition);
  appearance: none;
  -webkit-appearance: none;
}

[data-theme="dark"] .form-group input,
[data-theme="dark"] .form-group select,
[data-theme="dark"] .form-group textarea,
[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="password"],
[data-theme="dark"] input[type="email"],
[data-theme="dark"] input[type="number"],
[data-theme="dark"] select,
[data-theme="dark"] textarea {
  background: var(--well);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus,
input:focus,
select:focus,
textarea:focus {
  border-color: #111;
  background: var(--paper);
}

[data-theme="dark"] input:focus,
[data-theme="dark"] select:focus,
[data-theme="dark"] textarea:focus {
  border-color: var(--ink);
  background: var(--panel);
}

textarea {
  resize: vertical;
  min-height: 100px;
}

/* ---------- IMAGE PREVIEW ---------- */
#imagePreview {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--well);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

#imagePreview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#imagePreview .preview-placeholder {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.04em;
}

/* ---------- BUTTONS ---------- */
.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  background: #111;
  color: #fff;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid #111;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
  width: 100%;
}

.primary-btn:hover {
  background: #333;
  border-color: #333;
}

.primary-btn:disabled {
  background: var(--muted);
  border-color: var(--muted);
  cursor: not-allowed;
}

.secondary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid var(--line);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
  white-space: nowrap;
}

.secondary-btn:hover {
  background: #f0f0f0;
  border-color: #999;
}

[data-theme="dark"] .secondary-btn:hover {
  background: var(--panel2);
}

/* ---------- STYLE SELECTOR ---------- */
.style-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.style-btn {
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: var(--paper);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.style-btn:hover {
  background: var(--well);
  color: var(--ink);
  border-color: #999;
}

.style-btn.active {
  background: #111;
  color: #fff;
  border-color: #111;
}

/* ---------- QUEUE STATUS ---------- */
.queue-status {
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.queue-status h3 {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
}

#queueInfo {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--line);
}

.stat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.stat:last-child {
  border-bottom: none;
}

.stat .label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 400;
}

.stat span:last-child {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
}

/* ---------- STATUS MESSAGE ---------- */
.status-message {
  padding: 12px 16px;
  font-size: 13px;
  border: 1px solid var(--line);
  background: var(--well);
  color: var(--ink);
  display: none;
}

.status-message.success {
  background: #f0f0f0;
  border-color: #999;
  color: #111;
}

.status-message.error {
  background: #f5f0f0;
  border-color: #c04040;
  color: #aa2222;
}

.status-message.info {
  background: var(--well);
  border-color: var(--line);
  color: var(--ink);
}

.status-message.visible,
.status-message[style*="block"] {
  display: block;
}

/* ---------- GENERATION PROGRESS ---------- */
.generation-progress {
  padding: 24px 32px;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.progress-bar-container {
  width: 100%;
  height: 3px;
  background: var(--soft);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: #333;
  width: 0%;
  transition: width 400ms ease;
}

.progress-status {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.progress-percent {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
}

/* ---------- GENERATION RESULT ---------- */
.generation-result {
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.result-header h3 {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.result-image-container {
  width: 100%;
  background: var(--well);
  border: 1px solid var(--line);
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.result-image-container img {
  width: 100%;
  height: auto;
  display: block;
}

.result-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ---------- GALLERY TAB ---------- */
#galleryTab.active {
  padding: 0;
}

#historyTab.active {
  padding: 32px;
}

#galleryMainView,
#projectDetailView {
  padding: 32px;
}

/* ---------- GALLERY HEADER ---------- */
.gallery-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 32px;
  gap: 12px;
}


.gallery-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.gallery-search {
  flex: 1;
  max-width: 320px;
  padding: 8px 12px;
  font-size: 13px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  outline: none;
}

.gallery-search:focus {
  border-color: var(--ink);
  background: var(--paper);
}

.section-title {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 12px;
  margin-top: 28px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

.checkbox-label input[type="checkbox"] {
  width: 14px;
  height: 14px;
  border: 1px solid var(--line);
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
}

.checkbox-label input[type="checkbox"]:checked {
  background: #111;
  border-color: #111;
}

.checkbox-label input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 1px;
  width: 5px;
  height: 8px;
  border: 2px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(45deg);
}

/* ---------- PROJECTS GRID ---------- */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 8px;
}

.project-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  padding: 24px 20px;
  background: var(--paper);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: transform 150ms ease, box-shadow 150ms ease, border-color 150ms ease, background 150ms ease;
  position: relative;
  overflow: hidden;
}

.project-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.10);
  border-color: var(--ink);
  z-index: 1;
}

.project-card-icon {
  width: 36px;
  height: 36px;
  background: var(--well);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.project-card-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.3;
}

.project-card-count {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.04em;
}

/* ---------- GALLERY GRID ---------- */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 40px;
  align-items: center;
}

.gallery-item {
  position: relative;
  background: var(--paper);
  cursor: pointer;
  transition: transform 450ms cubic-bezier(0.25, 0.46, 0.45, 0.94), box-shadow 450ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
  box-shadow: 0 2px 8px rgba(0,0,0,0.07), 0 8px 24px rgba(0,0,0,0.06);
}

.gallery-item:hover {
  transform: scale(1.06) translateY(-4px);
  box-shadow: 0 16px 40px rgba(0,0,0,0.16), 0 32px 64px rgba(0,0,0,0.12);
  z-index: 10;
  transition: transform 220ms cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 220ms ease;
}

/* Stacked cards (image + upscale grouped) */
.gallery-item.stacked {
  margin-bottom: 10px; /* room for pseudo-element cards below */
}
.gallery-item.stacked::before,
.gallery-item.stacked::after {
  content: '';
  position: absolute;
  left: 0; right: 0;
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  transition: transform 450ms cubic-bezier(0.25, 0.46, 0.45, 0.94),
              opacity   450ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.gallery-item.stacked::before {
  top: 6px;
  bottom: -6px;
  transform: rotate(1.5deg);
  z-index: -1;
}
.gallery-item.stacked::after {
  top: 11px;
  bottom: -11px;
  transform: rotate(3deg);
  z-index: -2;
  opacity: 0.7;
}
.gallery-item.stacked:hover::before {
  transform: rotate(2.5deg) translateY(3px);
  transition: transform 200ms cubic-bezier(0.34, 1.56, 0.64, 1),
              opacity   200ms ease;
}
.gallery-item.stacked:hover::after {
  transform: rotate(5deg) translateY(6px);
  opacity: 0.5;
  transition: transform 200ms cubic-bezier(0.34, 1.56, 0.64, 1),
              opacity   200ms ease;
}

.gallery-item.dragging {
  opacity: 0.35;
  transform: scale(0.96);
  transition: opacity 150ms ease, transform 150ms ease;
  cursor: grabbing;
}

.gallery-item.reorder-dragging {
  opacity: 0.35;
  cursor: grabbing;
}

.gallery-item.reorder-drop-before {
  box-shadow: -4px 0 0 0 var(--primary-color, #2563eb);
}

.gallery-item.reorder-drop-after {
  box-shadow: 4px 0 0 0 var(--primary-color, #2563eb);
}

.gallery-item {
  cursor: grab;
}

.project-card.drag-over {
  transform: scale(1.03);
  box-shadow: 0 0 0 2px var(--ink), 0 8px 32px rgba(0,0,0,0.18);
  border-color: var(--ink);
  background: var(--soft);
}

/* Drop zone label that appears on drag-over */
.project-card.drag-over::after {
  content: 'Drop here';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
  background: rgba(0,0,0,0.04);
  border-radius: inherit;
  pointer-events: none;
}

[data-theme="dark"] .project-card.drag-over::after {
  background: rgba(255,255,255,0.04);
}

.stack-badge {
  position: absolute;
  bottom: 8px;
  left: 8px;
  background: var(--ink);
  color: var(--paper);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 3px 8px;
  z-index: 3;
}

.gallery-item img {
  width: 100%;
  height: auto;
  display: block;
}

img.img-error {
  opacity: 0.15;
  filter: grayscale(1);
  min-height: 80px;
  background: var(--soft);
}

.gallery-item-info {
  padding: 10px 2px 2px;
}

.gallery-item-info .date {
  font-size: 11px;
  color: #888;
  letter-spacing: 0.03em;
}

.favorite-badge {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 22px;
  height: 22px;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  z-index: 3;
  color: #f0c040;
}

/* ---------- BACK BUTTON ---------- */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 6px 0;
  transition: color var(--transition);
}

.back-btn:hover {
  color: var(--ink);
}

/* ---------- PROJECT NAME INPUT ---------- */
.project-name-input {
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 4px 0;
  outline: none;
  width: 100%;
  transition: border-color var(--transition);
}

.project-name-input:focus {
  border-bottom-color: #111;
}

/* ---------- PROJECT CHAINS ---------- */
.project-chains {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding-top: 8px;
}

.chain-row {
  display: flex;
  align-items: center;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.chain-thumb {
  position: relative;
  flex-shrink: 0;
  cursor: pointer;
}

.chain-thumb img {
  max-width: 320px;
  max-height: 200px;
  width: auto;
  height: auto;
  display: block;
}

.chain-thumb:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}

.chain-version {
  position: absolute;
  bottom: 0;
  left: 0;
  background: rgba(0,0,0,0.65);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.chain-arrow {
  color: var(--muted);
  font-size: 18px;
  flex-shrink: 0;
  user-select: none;
}

/* ---------- HISTORY LIST ---------- */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.history-item {
  border-bottom: 1px solid var(--line);
  padding: 20px 32px;
  transition: background var(--transition);
}

.history-item:hover {
  background: var(--panel);
}

.history-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.history-item-type {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- STATUS BADGES ---------- */
.status-badge {
  display: inline-block;
  padding: 3px 8px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.status-badge.pending {
  background: var(--well);
  color: var(--muted);
  border: 1px solid var(--line);
}

.status-badge.processing {
  background: #111;
  color: #fff;
  border: 1px solid #111;
}

.status-badge.completed {
  background: var(--soft);
  color: #333;
  border: 1px solid var(--line);
}

[data-theme="dark"] .status-badge.completed {
  background: var(--panel2);
  color: var(--ink);
}

.status-badge.failed {
  background: #f5f0f0;
  color: #aa2222;
  border: 1px solid #d08080;
}

[data-theme="dark"] .status-badge.failed {
  background: #2a1a1a;
  color: #e06060;
  border-color: #5a2a2a;
}

.history-item-prompt {
  font-size: 13px;
  color: var(--ink);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.history-item-date {
  font-size: 11px;
  color: var(--muted);
  margin-top: 6px;
}

/* ---------- MODALS ---------- */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0,0,0,0.55);
  align-items: center;
  justify-content: center;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--paper);
  border: 1px solid var(--line);
  width: 90%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.wide-modal {
  max-width: 960px !important;
}

.small-modal {
  max-width: 420px !important;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.modal-header h2,
.modal-header h3 {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.2px;
  color: var(--ink);
}

.close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  font-size: 20px;
  line-height: 1;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.close-btn:hover {
  background: #111;
  color: #fff;
  border-color: #111;
}

/* ---------- STACK STRIP ---------- */
.stack-strip {
  display: flex;
  justify-content: center;
  gap: 16px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  overflow-y: visible;
  background: var(--well);
}

.stack-thumb-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  flex-shrink: 0;
  opacity: 0.45;
  transition: opacity 180ms ease;
}

.stack-thumb-wrap.active {
  opacity: 1;
}

.stack-thumb-wrap:hover {
  opacity: 0.75;
}

.stack-thumb-wrap.active:hover {
  opacity: 1;
}

.stack-thumb-wrap img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  display: block;
  border: 2px solid transparent;
}

.stack-thumb-wrap.active img {
  border-color: var(--ink);
}

.stack-thumb-label {
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
}

.stack-thumb-wrap.active .stack-thumb-label {
  color: var(--ink);
  font-weight: 700;
}

/* stack strip compare mode */
.stack-thumb-wrap { position: relative; }

.stack-thumb-wrap.compare-selected {
  opacity: 1;
}
.stack-thumb-wrap.compare-selected img {
  border-color: var(--ink);
}
.stack-thumb-wrap.compare-selected .compare-sel-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  pointer-events: none;
}

.compare-strip-hint {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--well);
  border-bottom: 1px solid var(--line);
  text-align: center;
  padding: 8px 24px;
}

.compare-btn.compare-active {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
  font-weight: 600;
}

/* ---------- IMAGE MODAL ---------- */
.image-modal-content {
  background: var(--paper);
  border: 1px solid var(--line);
  width: 90%;
  max-width: 880px;
  max-height: 92vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.image-modal-content {
  position: relative;
}

.image-modal-content > .close-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 10;
}

#modalImage {
  width: 100%;
  max-height: 55vh;
  object-fit: contain;
  display: block;
  background: var(--well);
}

.modal-prompt {
  font-size: 13px;
  color: var(--ink);
  line-height: 1.6;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  max-height: 160px;
  overflow-y: auto;
  background: var(--well);
}

.image-actions {
  display: flex;
  gap: 0;
  border-top: 1px solid var(--line);
}

.image-actions .action-btn {
  flex: 1;
}

.image-project-section {
  padding: 20px 24px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ---------- ACTION BUTTONS ---------- */
.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 20px;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink);
  background: var(--paper);
  border: none;
  border-right: 1px solid var(--line);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}

.action-btn:last-child {
  border-right: none;
}

.action-btn:hover {
  background: #f4f4f4;
}

[data-theme="dark"] .action-btn:hover {
  background: var(--panel2);
}

.action-btn.delete-btn {
  color: var(--muted);
}

.action-btn.delete-btn:hover {
  background: #aa2222;
  color: #fff;
}

/* ---------- ADMIN TABS ---------- */
.admin-tabs {
  display: flex;
  align-items: flex-end;
  gap: 0;
  border-bottom: 1px solid var(--line);
  padding: 0 32px;
  background: var(--panel);
}

.admin-tab {
  padding: 14px 18px 12px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
}

.admin-tab:hover {
  color: var(--ink);
}

.admin-tab.active {
  color: var(--ink);
  border-bottom-color: #111;
}

.admin-tab-content {
  display: none;
  padding: 32px;
}

.admin-tab-content.active {
  display: block;
}

/* ---------- ADMIN ACTIONS ---------- */
.admin-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

/* ---------- DATA TABLE ---------- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  text-align: left;
  padding: 12px 20px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.data-table td {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  vertical-align: middle;
  font-size: 14px;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tr:hover td {
  background: var(--panel);
}

/* ---------- DATA TABLE BUTTONS ---------- */
.data-table button {
  padding: 7px 14px;
  margin-right: 6px;
  background: var(--panel2);
  color: var(--ink);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  font-family: var(--font);
  transition: background var(--transition);
}

.data-table button:hover {
  background: var(--soft);
}

.data-table button.delete-btn {
  color: #aa2222;
}

.data-table button.delete-btn:hover {
  background: #aa2222;
  color: white;
  border-color: #aa2222;
}

/* ---------- STATS GRID ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1px;
  background: var(--line);
  margin-bottom: 32px;
}

.stat-card {
  background: var(--paper);
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stat-card .stat-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.stat-card .stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.1;
}

/* ---------- REFINE SCREEN ---------- */
.refine-screen {
  width: 100%;
  min-height: 100vh;
  background: var(--bg);
}

#refineScreen.active {
  display: flex !important;
  flex-direction: column;
  align-items: stretch;
  height: 100vh;
  overflow: hidden;
}

.refine-frame {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  background: var(--paper);
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.refine-view-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 32px;
  height: 56px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.refine-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 6px 0;
  transition: color var(--transition);
  flex-shrink: 0;
}

.refine-back-btn:hover {
  color: var(--ink);
}

.refine-view-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.refine-view-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.refine-view-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* ---------- REFINE HISTORY PANEL ---------- */
.refine-history-panel {
  width: 220px;
  flex-shrink: 0;
  background: var(--paper);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.refine-history-label {
  padding: 14px 16px 10px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.refine-history-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.refine-history-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--line);
  border-left: 2px solid transparent;
  transition: background var(--transition), border-color var(--transition);
}

.refine-history-item:hover {
  background: var(--soft);
}

.refine-history-item.active {
  background: var(--well);
  border-left-color: var(--ink);
}

.refine-history-thumb-container {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  background: var(--well);
  border: 1px solid var(--line);
  overflow: hidden;
}

.refine-history-thumb-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.refine-history-version {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0.04em;
  display: block;
}

.refine-history-prompt {
  font-size: 11px;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
  margin-top: 2px;
}

/* ---------- REFINE MAIN PANEL ---------- */
.refine-main-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  overflow: hidden;
  min-width: 0;
}

.refine-image-container {
  flex: 1;
  min-height: 0;
  background: var(--well);
  overflow: hidden;
  position: relative;
}

#maskZoomWrapper {
  position: absolute;
  inset: 0;
  overflow: visible;
  transform-origin: 0 0;
}

.refine-image-container img {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
  cursor: zoom-in;
}

/* ---------- MASK CANVAS ---------- */
.mask-canvas {
  position: absolute;
  top: 0; left: 0;
  cursor: crosshair;
  opacity: 0.75;
  pointer-events: none;
}

.mask-canvas.active {
  pointer-events: all;
}

.refine-image-container.mask-mode img {
  cursor: crosshair;
}

/* Mask toolbar */
.mask-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: #1a1a1a;
  color: #f0f0f0;
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 20;
}

.mask-toolbar-modes {
  display: flex;
  gap: 3px;
  margin-right: 6px;
}

.mask-mode-btn {
  padding: 5px 11px;
  font-size: 11px;
  letter-spacing: 0.05em;
  border: 1px solid rgba(255,255,255,0.25);
  background: transparent;
  color: rgba(255,255,255,0.65);
  border-radius: 3px;
  cursor: pointer;
  transition: background 150ms, color 150ms;
  white-space: nowrap;
}

.mask-mode-btn.active {
  background: rgba(255,255,255,0.18);
  border-color: rgba(255,255,255,0.5);
  color: #f0f0f0;
}

.mask-brush-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.mask-poly-controls {
  display: flex;
  align-items: center;
}

.mask-poly-hint {
  font-size: 11px;
  opacity: 0.6;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.mask-toolbar-spacer {
  flex: 1;
}

.mask-zoom-label {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  opacity: 0.55;
  min-width: 36px;
  text-align: right;
  letter-spacing: 0.04em;
}

.mask-toolbar-tools {
  display: flex;
  gap: 4px;
}

.mask-tool-btn {
  width: 28px;
  height: 28px;
  border: 1px solid rgba(255,255,255,0.2);
  background: transparent;
  color: #f0f0f0;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 150ms;
}

.mask-tool-btn.active {
  background: rgba(255,255,255,0.2);
  border-color: rgba(255,255,255,0.5);
}

.mask-size-slider {
  width: 100px;
  accent-color: white;
  cursor: pointer;
}

.mask-action-btn {
  padding: 5px 12px;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid rgba(255,255,255,0.3);
  background: transparent;
  color: #f0f0f0;
  cursor: pointer;
  border-radius: 3px;
  transition: background 150ms;
}

.mask-action-btn:hover {
  background: rgba(255,255,255,0.12);
}

/* Paint region button in style bar */
.paint-region-btn {
  color: var(--muted);
}

.paint-region-btn.mask-active {
  background: var(--ink) !important;
  color: var(--paper) !important;
}

/* Fullscreen image overlay */
#refineImageFullscreen {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(0,0,0,0.92);
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
}

#refineImageFullscreen.active {
  display: flex;
}

#refineImageFullscreen img {
  max-width: 92vw;
  max-height: 92vh;
  object-fit: contain;
  display: block;
  cursor: zoom-out;
}

.refine-loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.88);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 10;
}

[data-theme="dark"] .refine-loading-overlay {
  background: rgba(28,28,28,0.88);
}

.refine-loading-text {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- REFINE PROMPT SIDEBAR ---------- */
.refine-prompt-sidebar {
  width: 300px;
  flex-shrink: 0;
  border-left: 1px solid var(--line);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

/* Style toggle */
.refine-sidebar-style {
  display: flex;
  flex-shrink: 0;
  border-bottom: 1px solid var(--line);
}

.refine-sidebar-style .style-btn {
  flex: 1;
  padding: 12px 8px;
  font-size: 11px;
  letter-spacing: 0.06em;
  border: none;
  border-right: 1px solid var(--line);
}

.refine-sidebar-style .style-btn:last-child {
  border-right: none;
}

/* Prompt textarea */
.refine-sidebar-textarea {
  flex: 1;
  min-height: 120px;
  padding: 16px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  font-size: 14px;
  font-family: var(--font);
  line-height: 1.6;
  resize: none;
  outline: none;
  overflow-y: auto;
}

.refine-sidebar-textarea:focus {
  background: var(--paper);
}

/* Attachments zone */
.refine-sidebar-attachments {
  flex-shrink: 0;
  height: 400px;
  border-bottom: 1px solid var(--line);
  overflow-y: auto;
}

.refine-sidebar-attachments .prompt-attachments {
  border-top: none;
  padding: 10px 12px;
  align-items: flex-start;
}

/* Options */
.refine-sidebar-opts {
  display: flex;
  gap: 0;
  flex-shrink: 0;
  border-bottom: 1px solid var(--line);
}

.refine-sidebar-opt {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  border-right: 1px solid var(--line);
}

.refine-sidebar-opt:last-child {
  border-right: none;
}

.refine-opt-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.refine-sidebar-opt select {
  width: 100%;
  padding: 6px 8px;
  font-size: 13px;
  border: 1px solid var(--line);
  background: var(--paper);
}

/* Generate button */
.refine-sidebar-generate {
  flex-shrink: 0;
  margin: 16px;
  width: auto !important;
  padding: 14px !important;
  font-size: 13px;
  letter-spacing: 0.08em;
}

/* ---------- UPSCALE MODAL ---------- */
.upscale-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.upscale-body {
  padding: 20px 24px 24px;
}

.upscale-section-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 12px;
}

.upscale-cat-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.upscale-cat-btn {
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-family: var(--font);
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.upscale-cat-btn:hover {
  border-color: var(--ink);
  color: var(--ink);
}

.upscale-cat-btn.active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
  font-weight: 600;
}

.upscale-option-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 32px 24px;
  background: var(--paper);
  border: none;
  border-right: 1px solid var(--line);
  cursor: pointer;
  transition: background var(--transition);
  font-family: var(--font);
}

.upscale-option-btn:last-child {
  border-right: none;
}

.upscale-option-btn:hover {
  background: var(--ink);
  color: var(--paper);
}

.upscale-option-btn:hover .upscale-desc {
  color: #aaa;
}

.upscale-factor {
  font-size: 36px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.02em;
  line-height: 1;
}

.upscale-option-btn:hover .upscale-factor {
  color: #fff;
}

/* ── Compare mode ─────────────────────────────────────────────── */
.compare-btn { font-weight: 600; }
.compare-btn.compare-active { background: var(--ink); color: var(--paper); border-color: var(--ink); }

.compare-select-hint {
  display: block;
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.04em;
  text-transform: none;
  color: var(--accent, #0066cc);
  margin-top: 4px;
  min-height: 14px;
}

.refine-history-list.compare-mode .refine-history-item {
  cursor: crosshair;
  position: relative;
}
.refine-history-list.compare-mode .refine-history-item::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 6px;
  border: 2px solid transparent;
  pointer-events: none;
  transition: border-color 0.15s;
}
.refine-history-list.compare-mode .refine-history-item:hover::after {
  border-color: var(--ink);
}
.refine-history-list.compare-mode .refine-history-item.compare-selected::after {
  border-color: var(--accent, #0066cc);
  background: rgba(0,102,204,0.06);
}
.compare-sel-badge {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent, #0066cc);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  pointer-events: none;
}

/* ── Compare slider modal ─────────────────────────────────────── */
.compare-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0,0,0,0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.compare-modal-header {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 10;
}
.compare-modal-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.6);
}
.compare-close-btn {
  background: none;
  border: 1px solid rgba(255,255,255,0.2);
  color: rgba(255,255,255,0.7);
  border-radius: 6px;
  width: 32px;
  height: 32px;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.compare-close-btn:hover { background: rgba(255,255,255,0.12); color: #fff; }

.compare-slider-wrap {
  position: relative;
  max-width: 90vw;
  max-height: calc(100vh - 72px);
  margin-top: 52px;
  overflow: hidden;
  border-radius: 4px;
  user-select: none;
}
.compare-img-a {
  display: block;
  max-width: 90vw;
  max-height: calc(100vh - 72px);
  width: auto;
  height: auto;
}
.compare-img-b {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  clip-path: inset(0 0 0 50%);
}
.compare-handle {
  position: absolute;
  top: 0;
  left: 50%;
  width: 2px;
  height: 100%;
  transform: translateX(-50%);
  cursor: ew-resize;
  z-index: 5;
}
.compare-handle-line {
  width: 2px;
  height: 100%;
  background: rgba(255,255,255,0.85);
  box-shadow: 0 0 6px rgba(0,0,0,0.5);
}
.compare-handle-knob {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 12px rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 10px;
  color: #333;
  pointer-events: none;
}
.compare-handle-arrow { line-height: 1; }

.compare-label-a,
.compare-label-b {
  position: absolute;
  bottom: 14px;
  padding: 4px 10px;
  border-radius: 4px;
  background: rgba(0,0,0,0.55);
  color: rgba(255,255,255,0.9);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  pointer-events: none;
}
.compare-label-a { left: 14px; }
.compare-label-b { right: 14px; }

.upscale-desc {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

#upscaleStatus {
  margin: 16px 20px;
}

/* ---------- LOADING SPINNER ---------- */
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--line);
  border-top-color: var(--ink);
  animation: spin 600ms linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--line);
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ---------- SCROLLBARS ---------- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: var(--line);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

/* ---------- GEN HOME ---------- */
.gen-home {
  padding: 48px 40px;
}

.gen-home-tiles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.gen-tile {
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 36px 32px;
  cursor: pointer;
  transition: border-color 0.18s, box-shadow 0.18s, transform 0.18s;
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: relative;
}

.gen-tile:hover {
  border-color: var(--ink);
  box-shadow: 0 8px 32px rgba(0,0,0,0.07);
  transform: translateY(-2px);
}

.gen-tile-icon {
  color: var(--ink);
  opacity: 0.7;
  line-height: 1;
}

.gen-tile-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.gen-tile-title {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin: 0;
  line-height: 1.1;
}

.gen-tile-desc {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.65;
  margin: 0;
}


/* Time of the Day tile — spans remaining column on row 2 */
.gen-tile--tod {
  grid-column: 2 / 3;
}

/* Locked tile (Coming Soon) */
.gen-tile--locked {
  cursor: default;
  pointer-events: none;
  position: relative;
}

.gen-tile--locked::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.58);
  pointer-events: none;
  z-index: 1;
}

.gen-tile--locked:hover {
  transform: none;
  box-shadow: none;
  border-color: var(--line);
}

.gen-tile-soon {
  position: absolute;
  top: 14px;
  right: 14px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: #000;
  color: #fff;
  padding: 4px 10px;
  z-index: 2;
}

/* Small tile (Refining) — full width, horizontal layout */
.gen-tile--sm {
  grid-column: 1 / -1;
  flex-direction: row;
  align-items: center;
  padding: 26px 32px;
  gap: 24px;
}

.gen-tile--sm .gen-tile-body {
  flex-direction: row;
  align-items: center;
  gap: 0;
}

.gen-tile--sm .gen-tile-title {
  font-size: 20px;
  min-width: 110px;
}

.gen-tile--sm .gen-tile-desc {
  margin-left: 20px;
  font-size: 13px;
}


/* ---------- GEN SECTION NAV ---------- */
.gen-section-nav {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 32px;
  height: 52px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.gen-back-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 12px;
  font-family: var(--font);
  letter-spacing: 0.05em;
  cursor: pointer;
  padding: 0;
  transition: color 0.15s;
}

.gen-back-btn:hover {
  color: var(--ink);
}

.gen-section-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink);
}

/* ---------- MODELING MATERIAL TILES ---------- */
.gen-model-tiles {
  grid-template-columns: 1fr 1fr 1fr;
}

.gen-tile-swatch {
  height: 6px;
  width: 48px;
  border-radius: 3px;
  margin-bottom: 4px;
}

.gen-tile-swatch--cork {
  background: linear-gradient(90deg, #c8a97a, #e2c99a);
}

.gen-tile-swatch--concrete {
  background: linear-gradient(90deg, #8a8a8a, #b8b8b8);
}

.gen-tile-swatch--wood {
  background: linear-gradient(90deg, #8b5e3c, #c4874e);
}

/* ---------- MODELING FORM ---------- */
.modeling-form-wrap {
  padding: 32px 40px;
  max-width: 860px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.modeling-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modeling-block-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}

.modeling-toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.modeling-toggle-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent, #fff);
  cursor: pointer;
  flex-shrink: 0;
}

.modeling-toggle-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.modeling-toggle-hint {
  font-size: 11px;
  color: var(--muted);
}

.modeling-upload-zone {
  border: 1.5px dashed var(--line);
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: border-color 0.18s, background 0.18s;
  overflow: hidden;
}

.modeling-upload-zone:hover,
.modeling-upload-zone.drag-over {
  border-color: var(--ink);
  background: var(--panel);
}

.modeling-upload-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  pointer-events: none;
}

.modeling-upload-icon {
  opacity: 0.5;
}

.modeling-upload-text {
  font-size: 14px;
  color: var(--ink);
  margin: 0;
}

.modeling-upload-sub {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
}

.modeling-upload-preview {
  width: 100%;
  height: 100%;
  object-fit: contain;
  max-height: 280px;
}

.modeling-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

#todPresets {
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  flex-shrink: 0;
}
#todPresets::-webkit-scrollbar { display: none; }
#todPresets .modeling-preset {
  flex-shrink: 0;
}

.modeling-preset {
  padding: 8px 18px;
  border: 1px solid var(--line);
  font-size: 13px;
  font-family: var(--font);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  background: var(--paper);
  color: var(--ink);
  user-select: none;
}

.modeling-preset:hover {
  border-color: var(--ink);
}

.modeling-preset.active {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

/* Image preset grid */
.modeling-img-grid {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}

.modeling-img-grid > .modeling-img-card {
  flex: 1 0 0;
  min-width: 0;
}

.modeling-img-grid--sm {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 8px;
  overflow-x: unset;
}

.modeling-img-grid--sm > .modeling-img-card {
  flex: unset;
  min-width: unset;
}

.modeling-img-card {
  border: 2px solid var(--line);
  cursor: pointer;
  transition: border-color 0.15s;
  aspect-ratio: 1;
  overflow: hidden;
  position: relative;
  background: var(--panel);
}

.modeling-img-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity 0.15s;
}

.modeling-img-card:hover {
  border-color: var(--muted);
}

.modeling-img-card.active {
  border-color: var(--ink);
}

.modeling-img-card.active::after {
  content: '✓';
  position: absolute;
  top: 5px;
  right: 5px;
  background: var(--ink);
  color: var(--paper);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  line-height: 18px;
  text-align: center;
}

.modeling-img-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.58);
  color: #fff;
  font-size: 10px;
  line-height: 1.3;
  padding: 4px 5px;
  text-align: center;
  white-space: normal;
  word-break: break-word;
  pointer-events: none;
}

.modeling-block-hint {
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.04em;
  text-transform: none;
  color: var(--muted);
}

.modeling-prompt-textarea {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font-size: 13px;
  font-family: var(--font);
  line-height: 1.6;
  resize: vertical;
  outline: none;
  transition: border-color 0.15s;
  box-sizing: border-box;
}

.modeling-prompt-textarea:focus {
  border-color: var(--ink);
}

.modeling-options-row {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
}

.ratio-control {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ratio-auto-pill {
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: var(--paper);
  border: 1px solid var(--line);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  -webkit-user-select: none;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.ratio-auto-pill input[type="checkbox"] { display: none; }
.ratio-auto-pill:hover { background: var(--well); color: var(--ink); border-color: #999; }
.ratio-auto-pill:has(input:checked) {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

/* ---------- STANDALONE REFINING ---------- */
/* ---------- TIME OF THE DAY ---------- */
#genTimeOfDay .refining-container {
  align-items: flex-start;
  padding: 32px 40px 48px;
}

#genTimeOfDay .refining-upload-zone {
  max-width: 100%;
}

.tod-controls {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.tod-options {
  flex-wrap: wrap;
}

.tod-mood-grid {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tod-mood-grid::-webkit-scrollbar { display: none; }

.tod-mood-card {
  flex: 0 0 180px;
  height: 220px;
  cursor: pointer;
  border: 2px solid transparent;
  position: relative;
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.tod-mood-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 30%;
  display: block;
  transition: transform 0.2s;
}
.tod-mood-card:hover img {
  transform: scale(1.04);
}
.tod-mood-card.active {
  border-color: var(--ink);
  box-shadow: 0 0 0 1px var(--ink);
}
.tod-mood-card.active::after {
  content: '✓';
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--ink);
  color: var(--paper);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
}

.refining-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 56px 40px 40px;
  gap: 24px;
}

.refining-upload-zone {
  width: 100%;
  max-width: 640px;
  min-height: 320px;
  border: 1.5px dashed var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.18s, background 0.18s;
  position: relative;
  overflow: hidden;
}

.refining-upload-zone:hover,
.refining-upload-zone.drag-over {
  border-color: var(--ink);
  background: var(--panel);
}

.refining-upload-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  pointer-events: none;
}

.refining-upload-icon {
  opacity: 0.45;
  margin-bottom: 4px;
}

.refining-upload-text {
  font-size: 15px;
  color: var(--ink);
  margin: 0;
}

.refining-upload-sub {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
}

.refining-preview {
  width: 100%;
  height: 100%;
  object-fit: contain;
  max-height: 400px;
}

.refining-start-btn {
  min-width: 220px;
}

/* ── Generate — slot system ─────────────────────────────────────────────── */

.gen-type-row {
  display: flex;
  gap: 0;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--line);
}
.gen-type-btn {
  padding: 8px 20px 9px;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-family: "DIN Offc", sans-serif;
  letter-spacing: 0.04em;
  cursor: pointer;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
  text-align: left;
}
.gen-type-btn.active { color: var(--ink); border-bottom-color: var(--ink); }
.gen-type-btn:hover:not(.active) { color: var(--ink); }

.gen-slots-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-start;
  border: 1px solid var(--line);
  padding: 20px;
  margin-bottom: 16px;
}
#genCustomSlotsContainer { display: contents; }

.gen-slot {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 200px;
}
.gen-slot-label {
  font-size: 10px;
  font-family: "DIN Offc", sans-serif;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: left;
  display: flex;
  align-items: center;
  gap: 6px;
}
.gen-slot-dup-btn {
  background: none;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  line-height: 1;
  padding: 1px 5px;
  cursor: pointer;
  font-family: "DIN Offc", sans-serif;
  transition: color 0.15s, border-color 0.15s;
}
.gen-slot-dup-btn:hover { color: var(--ink); border-color: var(--ink); }
.gen-slot-body {
  position: relative;
  width: 200px;
  height: 190px;
  border: 1px solid var(--line);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.gen-slot-body:hover { border-color: var(--ink); }
.gen-slot-body.filled { border: none; }

.gen-slot-empty {
  font-size: 20px;
  color: var(--line);
  line-height: 1;
  pointer-events: none;
}
.gen-slot-preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.gen-slot-clear {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  border: none;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

/* Custom slot */
.gen-slot--custom .gen-slot-name-input {
  width: 100%;
  border: none;
  border-bottom: 1px solid var(--line);
  background: transparent;
  font-size: 10px;
  font-family: "DIN Offc", sans-serif;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 0 4px;
  outline: none;
  box-sizing: border-box;
  text-align: left;
}
.gen-slot--custom .gen-slot-name-input:focus {
  border-bottom-color: var(--ink);
  color: var(--ink);
}
.gen-slot-remove-btn {
  width: 100%;
  padding: 5px 8px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-family: "DIN Offc", sans-serif;
  letter-spacing: 0.06em;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, color 0.15s;
}
.gen-slot-remove-btn:hover { border-color: #c0392b; color: #c0392b; }

.gen-slot--addwrap { width: 60px; }
.gen-slot-add-btn {
  border: none;
  background: var(--ink);
  color: var(--paper);
  font-size: 26px;
  font-weight: 300;
  line-height: 1;
  cursor: pointer;
  height: 190px;
  width: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s;
}
.gen-slot-add-btn:hover { opacity: 0.7; }

/* Prompt area */
.gen-prompt-area {
  border: 1px solid var(--line);
  padding: 16px 20px;
  margin-bottom: 16px;
}
.gen-prompt-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.gen-prompt-label {
  font-size: 10px;
  font-family: "DIN Offc", sans-serif;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: left;
}
.gen-prompt-reset-btn {
  font-size: 11px;
  font-family: "DIN Offc", sans-serif;
  letter-spacing: 0.06em;
  color: var(--muted);
  background: none;
  border: 1px solid var(--line);
  cursor: pointer;
  padding: 3px 10px;
  transition: color 0.15s, border-color 0.15s;
  text-transform: uppercase;
}
.gen-prompt-reset-btn:hover { color: var(--ink); border-color: var(--ink); }
#genPromptInput {
  width: 100%;
  min-height: 90px;
  padding: 12px 0 0;
  border: none;
  border-top: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  font-family: "DIN Offc", sans-serif;
  line-height: 1.6;
  resize: none;
  box-sizing: border-box;
  outline: none;
  text-align: left;
}
#genPromptInput:focus { border-top-color: var(--ink); }
.gen-prompt-slot-instructions {
  font-size: 12px;
  font-family: "DIN Offc", sans-serif;
  color: var(--muted);
  line-height: 1.6;
  padding: 10px 0 8px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 2px;
  min-height: 16px;
  text-align: left;
  white-space: pre-line;
}

/* ---------- RESPONSIVE ---------- */
@media (max-width: 768px) {
  header {
    padding: 0 16px;
    height: 48px;
  }

  .tabs {
    padding: 0 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .tab {
    padding: 12px 14px 10px;
    white-space: nowrap;
    font-size: 11px;
  }

  .generate-container {
    grid-template-columns: 1fr;
  }

  .generate-options {
    flex-wrap: wrap;
  }

  .gen-submit-btn {
    margin-left: 0;
    width: 100% !important;
  }

  .gallery-header {
    padding: 16px;
    flex-wrap: wrap;
    gap: 12px;
  }

  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }

  .projects-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    padding: 16px;
    gap: 1px;
  }

  .history-item {
    padding: 16px;
  }

  .queue-status {
    padding: 12px 16px;
    gap: 16px;
    flex-wrap: wrap;
  }

  .generation-result {
    padding: 16px;
  }

  .admin-tab-content {
    padding: 16px;
  }

  .modal-content {
    width: 96%;
  }

  .image-modal-content {
    width: 96%;
  }

  .refine-view-body {
    flex-direction: column;
  }

  .refine-history-panel {
    width: 100%;
    height: 180px;
  }

  .refine-history-list {
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .refine-history-item {
    flex-direction: column;
    align-items: center;
    text-align: center;
    min-width: 80px;
    padding: 10px 8px;
    border-left: none;
    border-bottom: 3px solid transparent;
  }

  .refine-history-item.active {
    border-left-color: transparent;
    border-bottom-color: #fff;
  }

  .refine-prompt-bar {
    flex-wrap: wrap;
  }

  .refine-prompt-bar textarea {
    min-height: 56px;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .refine-prompt-bar .primary-btn {
    width: 100%;
    padding: 14px;
    align-self: auto;
  }

  .refine-view-header {
    padding: 0 16px;
  }

  .chain-row {
    padding: 12px 16px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .data-table {
    font-size: 12px;
  }

  .data-table th,
  .data-table td {
    padding: 8px 10px;
  }
}

/* ---------- TOAST NOTIFICATIONS ---------- */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  pointer-events: all;
  padding: 12px 18px;
  border-radius: 6px;
  font-size: 13px;
  font-family: var(--font);
  color: #fff;
  max-width: 340px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  animation: toastIn 200ms ease forwards;
  opacity: 1;
  transition: opacity 300ms ease;
}

.toast.toast-error   { background: #c0392b; }
.toast.toast-success { background: #27ae60; }
.toast.toast-info    { background: #2c3e50; }
.toast.toast-warning { background: #e67e22; }
.toast.toast-fade    { opacity: 0; }

/* ---------- CANCEL BUTTON STATE ---------- */
.btn--cancelling {
  background: #c0392b !important;
  color: #fff !important;
  border-color: #c0392b !important;
}
.btn--cancelling:hover {
  background: #a93226 !important;
}

/* ---------- CLEANUP WARNING BANNER ---------- */
.cleanup-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 10px 18px;
  background: #e67e22;
  color: #fff;
  font-size: 13px;
  font-family: var(--font);
  text-align: center;
}

.cleanup-banner-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
  opacity: 0.8;
}

.cleanup-banner-close:hover {
  opacity: 1;
}

@keyframes toastIn {
  from { transform: translateY(12px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ---------- GALLERY SKELETON LOADER ---------- */
.gallery-skeleton {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 40px;
}

.skeleton-item {
  border-radius: 2px;
  overflow: hidden;
}

.skeleton-thumb {
  width: 100%;
  aspect-ratio: 16/9;
  background: linear-gradient(90deg, var(--soft) 25%, var(--well) 50%, var(--soft) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

