/* /styles.css - Refactored for simplicity and maintainability */
:root {
  --bg: #FFFFFF;
  --surface: #F8F8F8;
  --border: #000000;
  --text: #000000;
  --muted: #666666;
  --accent: #000000;
  --ok: #27C93F;
  --warn: #FFBD2E;
  --danger: #FF5F56;
  
  /* Terminal colors */
  --terminal-bg: #1D1F21;
  --terminal-text: #00FF00;
  --terminal-text-alt: #FFFFFF;
  
  /* Pastel rainbow download buttons */
  --pastel-mint: #B4E7CE;
  --pastel-lavender: #DCD3FF;
  --pastel-coral: #FFB5B5;
  --pastel-yellow: #FFF4B5;
  --pastel-mint-hover: #9FDCBC;
  --pastel-lavender-hover: #C9BFEF;
  --pastel-coral-hover: #FFA0A0;
  --pastel-yellow-hover: #FFE99A;
  
  /* macOS window dots */
  --dot-red: #FF5F56;
  --dot-yellow: #FFBD2E;
  --dot-green: #27C93F;
  
  --space-1: 0.5rem;
  --space-2: 1rem;
  --space-3: 1.5rem;
  --space-4: 2rem;
  --focus: #000000;
}

* {
  box-sizing: border-box;
  border-radius: 0;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: clamp(1rem, 1.5vw, 1.125rem);
  line-height: 1.5;
}

:focus-visible {
  outline: 0.15rem solid var(--focus);
  outline-offset: 0.1rem;
}

header {
  padding: var(--space-3) var(--space-2) var(--space-2);
  text-align: center;
  border-bottom: 0.1rem solid var(--border);
}

.siteTitle {
  margin: 0;
  font-size: clamp(1.4rem, 3.6vw, 2.25rem);
  letter-spacing: 0.02em;
  font-weight: 700;
}

#magicWand {
  position: relative;
  display: inline-block;
  top: -1.15rem;
  left: 1.0rem;
  cursor: pointer;
  transition: transform 100ms cubic-bezier(0.13, 0.99, 0.66, 0.8);
  transform-origin: bottom left;
  margin-left: -0.5rem;
  -webkit-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

#magicWand.sparkling {
  transform: rotate(22.5deg);
}

.siteMotto {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: clamp(0.95rem, 2vw, 1.05rem);
}

main {
  max-width: 72rem;
  margin: 0 auto;
  padding: var(--space-3) var(--space-2);
}

/* WORKPANE & VIEW MANAGEMENT SYSTEM */
#workpane {
  position: relative;
  margin: 0 auto var(--space-3);
  /* min-height: clamp(14rem, 40vh, 32rem); */
}

/* All three views share consistent transitions */
#workpane > * {
  width: 100%;
  transition: opacity 600ms ease-in-out;
}

/* Terminal and hero have fixed heights only when active; stage is flexible based on content */
#workpane > :is(#terminal.view-active, #hero.view-active) {
  height: clamp(14rem, 40vh, 32rem);
}

/* Active view: visible, interactive, in document flow */
.view-active {
  position: relative;
  opacity: 1;
  pointer-events: auto;
  z-index: 2;
}

/* Inactive view: hidden, non-interactive, absolutely positioned (no layout impact) */
.view-inactive {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;       /* prevent any inner spill */
}

/* 1) hero padding must not reserve space when inactive */
#hero.view-inactive {
  padding: 0 !important;
  border: 0 !important;
}

/* 2) the specific offenders: don't let them keep their box sizes */
#hero.view-inactive #browseBtn,
#hero.view-inactive #browseTip {
  display: none !important;
  /* if you prefer to preserve fade timing on the container, use this instead of display:none:
     inline-size: 0; block-size: 0; padding: 0; margin: 0; visibility: hidden; */
}

/* (optional, clarity) only add hero padding when it’s the active view */
#hero.view-active { padding: var(--space-6); } /* replace with your token/value */

/* TERMINAL */
.terminalWindow {
  background: var(--terminal-bg);
  box-shadow: 0 0.5rem 2rem rgba(0, 0, 0, 0.15);
  overflow: hidden;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.terminalBar {
  background: #E8E8E8;
  border-bottom: 0.1rem solid var(--border);
  padding: 0.5rem 1rem;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.terminalDots { display: flex; gap: 0.5rem; }
.dot { width: 0.75rem; height: 0.75rem; border-radius: 50%; border: 0.05rem solid rgba(0,0,0,0.2); }
.dot.red { background: var(--dot-red); }
.dot.yellow { background: var(--dot-yellow); }
.dot.green { background: var(--dot-green); }
#terminalCloseBtn { cursor: pointer; }

.terminalTitle { font-size: 0.85rem; font-weight: 600; color: var(--muted); flex-grow: 1; text-align: center; }
.terminalSpacer { width: 3rem; }

.terminalBody {
  padding: 1rem;
  flex: 1;
  overflow-y: auto;
  font-family: "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", Consolas, "Courier New", monospace;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--terminal-text);
  scrollbar-width: thin;
  scrollbar-color: #444 var(--terminal-bg);
}

.terminalBody::-webkit-scrollbar { width: 0.5rem; }
.terminalBody::-webkit-scrollbar-track { background: var(--terminal-bg); }
.terminalBody::-webkit-scrollbar-thumb { background: #444; border-radius: 0.25rem; }

.terminalLine { margin-bottom: 0.25rem; word-wrap: break-word; }
.terminalLine.status { color: var(--terminal-text-alt); }
.terminalLine.success { color: var(--ok); font-weight: 600; }
.terminalLine.error { color: var(--danger); font-weight: 600; }

.terminalControls { display: none; justify-content: flex-end; gap: 0.5rem; padding: 0.75rem 1rem; border-top: 0.1rem solid rgba(255,255,255,0.1); background: rgba(0,0,0,0.2); }
.terminalBtn { padding: 0.4rem 0.8rem; background: rgba(255,255,255,0.1); color: var(--terminal-text-alt); border: 0.1rem solid rgba(255,255,255,0.2); font-size: 0.85rem; }
.terminalBtn:hover { background: rgba(255,255,255,0.15); border-color: rgba(255,255,255,0.3); }
.terminalBtn:active { transform: translateY(1px); }
#cancelBatch { color: var(--danger); border-color: var(--danger); }
#cancelBatch:hover { background: rgba(255, 95, 86, 0.2); }

/* HERO DROPPAD */
#hero { background: var(--bg); padding: var(--space-4); text-align: center; user-select: none; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; position: relative; }
#hero:hover, #hero.dragover { border-color: var(--muted); }
#browseBtn { margin-top: var(--space-1); padding: 0.6rem 1rem; background: transparent; color: var(--text); }
#browseBtn:hover { background: var(--surface); }
#browseBtn:disabled { opacity: 0.6; }
#hero.blocked { opacity: 0.7; pointer-events: none; }
#browseTip { margin-top: 0.4rem; color: var(--muted); }
.visually-hidden-file { position: absolute; width: 0.01rem; height: 0.01rem; opacity: 0; pointer-events: none; }
 
/* Unified hero message overlay for downloading, configuration, etc. */
.heroMessage {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: var(--space-4);
  z-index: 10;
  text-align: center;
  font-weight: 600;
  font-size: 1.1rem;
  line-height: 1.5;
}

.heroMessage.warn { background: #FFFFCC; border: 0.2rem solid #E6E600; color: #666600; }
.heroMessage.info { background: #E0E8FF; border: 0.2rem solid #88A8FF; color: #1B3C8F; }
.heroMessage p { margin: 0 0 0.5rem; }
.heroMessage .sublabel { font-size: 0.9rem; font-weight: normal; color: inherit; opacity: 0.8; }

/* STAGE, PROGRESS, & SLIDER */
#stage {
  background: var(--bg);
  padding: var(--space-2);
  /* No display: none or position overrides - managed by view classes */
}

.canvasStack { position: relative; display: block; max-width: 100%; max-height: 75vh; aspect-ratio: var(--ar, 16/9); margin: 0 auto; outline: 0.1rem solid var(--border); background: repeating-conic-gradient(#F0F0F0 0% 25%, white 0% 50%) 50% / 1rem 1rem; }
.canvasStack canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; object-fit: contain; border: none; }
#origCanvas { clip-path: inset(0 calc(100% - var(--split, 100%)) 0 0); will-change: clip-path; }
#cutCanvas { clip-path: inset(0 0 0 var(--split, 100%)); will-change: clip-path; }

.progressWrap { --p: 0; position: absolute; left: 5%; right: 5%; top: 50%; transform: translateY(-50%); z-index: 3; pointer-events: none; display: none; }
.progressBar { position: relative; height: 1.6rem; background: #FFFFFF; overflow: hidden; }
.progressFill { position: absolute; inset: 0; width: 0%; background: var(--accent); }

.miniLog { position: absolute; inset: 0; display: grid; place-items: center; font-size: 1.05rem; font-weight: 700; letter-spacing: 0.01em; pointer-events: none; }
.miniLog::before, .miniLog::after { content: attr(data-text); position: absolute; inset: 0; display: grid; place-items: center; text-shadow: 0 0 0.2rem rgba(0,0,0,0.1); }
.miniLog::before { color: #FFFFFF; clip-path: inset(0 calc((1 - var(--p, 0)) * 100%) 0 0); }
.miniLog::after { color: var(--accent); clip-path: inset(0 0 0 calc(var(--p, 0) * 100%)); }

#sliderLine { position: absolute; top: 0; bottom: 0; width: 0.2rem; background: var(--accent); z-index: 4; display: none; cursor: ew-resize; touch-action: none; }
#sliderHandle { position: absolute; width: 1.6rem; height: 1.6rem; top: 50%; transform: translate(-50%, -50%); background: var(--accent); box-shadow: 0 0 0.3rem rgba(0,0,0,0.3); z-index: 5; display: none; cursor: ew-resize; touch-action: none; }
#sliderHandle[role="separator"] { outline: none; }

/* ACTIONS & BUTTONS */
#actions { display: none; margin: var(--space-2) auto var(--space-3); text-align: center; }
.downloadGroup { display: flex; flex-direction: column; gap: var(--space-1); margin-bottom: var(--space-2); }
.downloadRow { display: flex; justify-content: space-between; gap: var(--space-1); }
.downloadRow button { flex: 1; }

button { cursor: pointer; font-family: inherit; font-size: inherit; transition: all 0.15s ease; font-weight: 600; }
button:disabled { cursor: not-allowed; opacity: 0.5; }

.pastel-mint { --hover-bg: var(--pastel-mint-hover); background: var(--pastel-mint); padding: 0.9rem 1.4rem; font-weight: 700; font-size: 1.1rem; }
:is(.pastel-lavender, .pastel-coral, .pastel-yellow) { padding: 0.7rem 1rem; }
.pastel-lavender { --hover-bg: var(--pastel-lavender-hover); background: var(--pastel-lavender); }
.pastel-coral { --hover-bg: var(--pastel-coral-hover); background: var(--pastel-coral); }
.pastel-yellow { --hover-bg: var(--pastel-yellow-hover); background: var(--pastel-yellow); }
:is(.pastel-mint, .pastel-lavender, .pastel-coral, .pastel-yellow) { color: var(--text); }
:is(.pastel-mint, .pastel-lavender, .pastel-coral, .pastel-yellow):hover:not(:disabled) { background: var(--hover-bg); transform: translateY(-1px); }

.stageIconBtn { position: absolute; top: 1rem; z-index: 10; width: 2.5rem; height: 2.5rem; padding: 0; display: flex; align-items: center; justify-content: center; background: rgba(255,255,255,0.95); color: var(--text); font-size: 1.4rem; transition: all 0.2s ease; box-shadow: 0 0.2rem 0.5rem rgba(0,0,0,0.1); }
.stageIconBtn-left { left: 1rem; color: var(--danger); }
.stageIconBtn-right { right: 1rem; color: var(--ok); display: none; }
.stageIconBtn:hover:not(:disabled) { background: var(--surface); transform: translateY(-2px); box-shadow: 0 0.3rem 0.8rem rgba(0,0,0,0.15); }
.stageIconBtn-left:hover:not(:disabled) { background: rgba(255,95,86,0.1); border-color: currentColor; }
.stageIconBtn-right:hover:not(:disabled) { background: rgba(39,201,63,0.1); border-color: currentColor; }
.stageIconBtn:disabled { opacity: 0.4; }

.quickButton { margin-bottom: var(--space-4); }
.quickButton button { width: 100%; padding: 0.9rem 1.2rem; display: flex; align-items: center; justify-content: center; gap: 0.6rem; font-size: 1.05rem; }
:is(.toggle, .preset) { background: var(--surface); color: var(--text); transition: all 0.2s ease; }
:is(.toggle, .preset):hover { background: #E8E8E8; }
:is(.toggle, .preset).active { background: var(--accent); color: #FFFFFF; border-color: var(--accent); font-weight: 700; }
:is(.toggle, .preset) i { font-size: 1.1em; }

/* SETTINGS PANELS */
details {
  background: var(--bg);
  padding: var(--space-2) var(--space-2) 0;
  margin-bottom: var(--space-2);
}

summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 1.15rem;
  padding: 0.5rem;
  user-select: none;
  margin: calc(var(--space-2) * -1) calc(var(--space-2) * -1) 0;
  padding-left: var(--space-2);
  padding-right: var(--space-2);
  background: var(--surface);
  position: relative;
  display: flex;
  align-items: center;
  list-style: none; /* For Firefox */
}

summary::-webkit-details-marker {
  display: none;
}

summary:hover {
  background: #E8E8E8;
}

details[open] {
  padding-bottom: var(--space-2);
}

details[open] > summary {
  margin-bottom: var(--space-2);
}

summary::before {
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  font-size: 0.9em;
  margin-right: 0.75rem;
  width: 1.2em;
  text-align: center;
  content: '\f067'; /* ALWAYS fa-plus */
  transition: transform 1s cubic-bezier(0, 0, 0, 1.65);
}

details[open] > summary::before {
  transform: rotate(405deg);
}

details > *:not(summary) { padding-left: var(--space-2); }

/* Smooth dropdown animation */
details:not([open]) > *:not(summary) {
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  transition: opacity 0.25s ease-out, max-height 0.3s ease-out, margin 0.3s ease-out, padding 0.3s ease-out;
  margin: 0;
  padding: 0;
}

details[open] > *:not(summary) {
  opacity: 1;
  max-height: 10000px;
  transition: opacity 0.3s ease-in 0.05s, max-height 0.5s ease-in;
}

/* NOTIFICATION STYLING */
.notification {
  background: #f9fae8;
  border: 0.15rem solid #a1a80f;
  margin-bottom: var(--space-2);
}

.notification > summary {
  background: #f4fa8c;
  color: #000000;
  cursor: pointer;
  font-weight: 700;
  font-size: 1.15rem;
  padding: 0.5rem var(--space-2);
  user-select: none;
  margin: calc(var(--space-2) * -1) calc(var(--space-2) * -1) 0;
  position: relative;
  display: flex;
  align-items: center;
  list-style: none;
}

.notification > summary::-webkit-details-marker {
  display: none;
}

.notification > summary:hover {
  background: #f0f480;
}

.notification[open] {
  padding-bottom: var(--space-2);
}

.notification[open] > summary {
  margin-bottom: var(--space-2);
}

.notification > summary::before {
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  font-size: 0.9em;
  margin-right: 0.75rem;
  width: 1.2em;
  text-align: center;
  content: '\f067';
  transition: transform 1s cubic-bezier(0, 0, 0, 1.65);
}

.notification[open] > summary::before {
  transform: rotate(405deg);
}

.notification > div {
  padding: var(--space-2);
}

/* Smooth animation for notification dropdown */
.notification:not([open]) > div {
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  transition: opacity 0.25s ease-out, max-height 0.3s ease-out, padding 0.3s ease-out;
  padding: 0;
}

.notification[open] > div {
  opacity: 1;
  max-height: 500px;
  transition: opacity 0.3s ease-in 0.05s, max-height 0.5s ease-in;
}

.notification p {
  margin: 0 0 var(--space-2) 0;
  color: var(--text);
}

.notification button {
  padding: 0.6rem 1.2rem;
  font-weight: 600;
  border: 0.1rem solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s ease;
}

.notification button:hover {
  background: #E8E8E8;
  transform: translateY(-1px);
}

.notification-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-1);
  margin-top: var(--space-2);
}

#shareNotificationBody {
  margin-bottom: var(--space-2);
  line-height: 1.6;
}

#shareNotificationBody strong {
  font-weight: 700;
}

.sectionIntro { margin-top: var(--space-3); margin-bottom: var(--space-2); }
.sectionIntro:first-of-type { margin-top: 0; }
.settingTitle { margin: 0 0 var(--space-1) 0; font-size: 1.15rem; font-weight: 700; color: var(--text); }
.quickExplain, .settingDesc, .sublabel, .tip, .shareSub, .recipeDescription, .recipeModelMeta, .recipesEmpty { color: var(--muted); line-height: 1.6; }
.quickExplain, .settingDesc, .sublabel, .tip, .shareSub { font-size: 0.95rem; }
.recipeDescription, .recipeModelMeta, .recipesEmpty { font-size: 0.85rem; }
.recipeDescription, .recipesEmpty { font-style: italic; }

.kv { display: flex; flex-direction: column; gap: 0.5rem; margin-top: var(--space-2); }
.row { display: flex; gap: var(--space-1); align-items: center; flex-wrap: wrap; }
.tip { margin-top: var(--space-1); margin-bottom: var(--space-2); }
.tip strong { color: var(--text); }
.tip code { background: var(--surface); padding: 0.1rem 0.3rem; border: 0.1rem solid var(--border); font-family: monospace; font-size: 0.9em; }

:is(input[type="range"], input[type="text"], select, input[type="number"]) { width: 100%; background: var(--bg); color: var(--text); padding: 0.6rem; }
input[type="range"] { cursor: pointer; }
:is(input[type="range"], input[type="text"], select, input[type="number"]):hover { border-color: var(--muted); }

.badge { display: inline-block; width: auto; padding: 0.3rem 0.6rem; background: var(--surface); font-size: 0.9rem; font-weight: 600; }
.threadsReadout { font-size: 2.5rem; font-weight: 700; color: var(--accent); text-align: center; margin: var(--space-1) 0; line-height: 1; }

/* --- CUSTOM FORM CONTROLS --- */
/* Target all checkboxes and the specific radio buttons */
input[type="checkbox"],
input[name="bgMode"][type="radio"] {
  /* Reset to a blank slate */
  -webkit-appearance: none;
  appearance: none;
  margin: 0; /* Remove browser default margins */
  
  /* Custom box styles */
  width: 1.2rem;
  height: 1.2rem;
  border: 0.1rem solid var(--border);
  border-radius: 0; /* Perfectly square */
  background-color: var(--bg);
  cursor: pointer;
  
  /* Positioning for the checkmark SVG */
  background-position: center;
  background-repeat: no-repeat;
  
  /* Smooth transitions */
  transition: background-color 0.15s ease-in-out;
}

/* Style the checked state */
input[type="checkbox"]:checked,
input[name="bgMode"][type="radio"]:checked {
  background-color: var(--accent);
  border-color: var(--accent);
  
  /* A white checkmark SVG, URL-encoded for CSS */
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 8'%3e%3cpath fill='none' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' stroke='%23fff' d='M1 4.2l3 3 5-6'/%3e%3c/svg%3e");
}

/* Style the disabled state */
input[type="checkbox"]:disabled,
input[name="bgMode"][type="radio"]:disabled {
  cursor: not-allowed;
  opacity: 0.6;
  background-color: var(--surface);
  border-color: var(--muted);
}
/* --- END CUSTOM FORM CONTROLS --- */


/* SHARING & FOOTER */
#shareSection { background: var(--bg); padding: var(--space-3); margin-bottom: var(--space-3); text-align: center; }
.shareCta { margin: 0 0 var(--space-2) 0; font-size: 1.15rem; font-weight: 700; color: var(--text); }
#shareUrl { width: 100%; padding: 0.8rem; margin-bottom: var(--space-2); background: var(--bg); color: var(--text); font-family: monospace; font-size: 0.95rem; cursor: pointer; transition: border-color 0.15s ease; }
#shareUrl:hover { border-color: var(--muted); }
#copyLink { width: 100%; padding: 0.9rem 1.2rem; margin-bottom: var(--space-2); background: var(--accent); color: #FFFFFF; border-color: var(--accent); display: flex; align-items: center; justify-content: center; gap: 0.6rem; font-size: 1.05rem; }
#copyLink:hover { background: #333333; transform: translateY(-1px); }
.shareSub { margin: var(--space-2) 0; }
.shareIcons { display: flex; gap: var(--space-2); justify-content: space-between; align-items: center; flex-wrap: wrap; }
.shareIcons button { display: flex; align-items: center; justify-content: center; width: 3.5rem; height: 3.5rem; background: var(--bg); color: var(--text); font-size: 1.8rem; transition: all 0.2s ease; text-decoration: none; }
.shareIcons button:hover { background: var(--accent); color: #FFFFFF; border-color: var(--accent); transform: translateY(-2px); }
#resetSection { margin-bottom: var(--space-3); text-align: center; }
.resetBtn { width: 100%; padding: 1.2rem 2rem; border: 0.2rem solid var(--accent); background: #FFFFFF; color: var(--accent); font-size: 1.1rem; text-align: center; transition: all 0.2s ease; }
.resetBtn:hover { background: var(--accent); color: #FFFFFF; transform: translateY(-2px); box-shadow: 0 0.25rem 0.5rem rgba(0,0,0,0.1); }
.resetBtn:active { transform: translateY(0); }
footer { margin-top: var(--space-4); padding-top: var(--space-2); font-size: 0.95rem; color: var(--muted); text-align: center; border-top: 0.1rem solid var(--border); display: flex; flex-direction: column; gap: var(--space-1); }

/* APP INFO IN FOOTER */
#appInfo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-size: 0.85rem;
}

#appVersion {
  color: var(--muted);
  transition: color 0.3s ease;
}

#appVersion.up-to-date {
  color: #27C93F;
  font-weight: 600;
}

#appVersion.update-available {
  color: #FFA500;
  font-weight: 600;
}

#checkForUpdateBtn {
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.15s ease;
}

#checkForUpdateBtn:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* MODEL & RECIPE UI */
.modelList, .recipesList { display: flex; flex-direction: column; gap: 0.5rem; }
.customModelInput { display: flex; gap: 0.5rem; margin-bottom: 0.5rem; flex-wrap: wrap; }
.customModelInput input { flex-grow: 1; min-width: 200px; }
.modelRow, .recipeRow { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.modelRow { padding: 0.5rem 0.6rem; background: var(--surface); }
.recipeRow {
  padding: 0.6rem 0.8rem;
  background: var(--bg);
  animation: recipeSlideIn 2s ease-out;
  transform-origin: top;
}

@keyframes recipeSlideIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.modelLeft, .recipeLeft { display: flex; align-items: flex-start; gap: 0.6rem; flex: 1; min-width: 0; }
.modelLeft { align-items: flex-start; }
.modelCheck { width: 1rem; height: 1rem; flex-shrink: 0; margin-top: 0.2rem; }
.modelContent { display: flex; flex-direction: column; gap: 0.3rem; flex: 1; min-width: 0; }
.modelName { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modelMeta { font-size: 0.85rem; color: var(--muted); }
.modelConfig { display: flex; gap: 0.4rem; align-items: center; }
.modelConfigInput { width: 120px; padding: 0.2rem 0.4rem; font-size: 0.85rem; }
.modelConfigBtn { padding: 0.2rem 0.4rem; font-size: 0.85rem; background: var(--surface); border: 1px solid var(--border); cursor: pointer; }
.modelConfigBtn:hover { background: var(--bg); }
.modelRight { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }
.status { padding: 0.15rem 0.4rem; font-size: 0.8rem; }
.status.unloaded { background: var(--surface); color: var(--muted); }
.status.downloading { background: #FFFFCC; border-color: #E6E600; color: #666600; }
.status.downloaded { background: #CCFFCC; border-color: var(--ok); color: #006600; }
.status.error { background: #FFCCCC; border-color: var(--danger); color: #660000; }
.deleteModel { border: 1px solid var(--danger); color: var(--danger); background: transparent; padding: 0.2rem 0.4rem; }
.deleteModel:disabled { opacity: 0.5; }

.recipeRow.unsaved {
  background: var(--surface);
  border-color: var(--muted);
  border-width: 0.1rem;
  animation: unsavedSlideIn 0.25s ease-out;
}

@keyframes unsavedSlideIn {
  from {
    opacity: 0;
    transform: translateY(-12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Recipe row compression/removal animation */
@keyframes recipeCompress {
  0% {
    opacity: 1;
    transform: scaleX(1);
    max-height: 200px;
    padding-top: 0.6rem;
    padding-bottom: 0.6rem;
    margin-bottom: 0.5rem;
  }
  60% {
    opacity: 0.4;
    transform: scaleX(0.3);
    max-height: 200px;
    padding-top: 0.6rem;
    padding-bottom: 0.6rem;
  }
  100% {
    opacity: 0;
    transform: scaleX(0);
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    margin-bottom: 0;
  }
}

.recipeRow.removing {
  animation: recipeCompress 0.4s cubic-bezier(0.4, 0.0, 0.2, 1) forwards;
  transform-origin: left center;
  overflow: hidden;
}

/* Smooth slide-up for remaining recipes */
.recipesList {
  transition: all 0.3s ease-out;
}

/* Model row compression/removal animation (reuse same keyframes) */
.modelRow.removing {
  animation: recipeCompress 0.4s cubic-bezier(0.4, 0.0, 0.2, 1) forwards;
  transform-origin: left center;
  overflow: hidden;
}

/* Smooth slide-up for remaining models */
.modelList {
  transition: all 0.3s ease-out;
}
.recipeCheck { flex-shrink: 0; width: 1.1rem; height: 1.1rem; margin-top: 0.2rem !important; }
.recipeCheck:disabled { cursor: default; }
.recipeSwatch { flex-shrink: 0; width: 1.2rem; height: 1.2rem; display: inline-block; margin-top: 0.2rem; }
.recipeContent { flex: 1; display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.recipeNameLine { display: flex; align-items: center; gap: 0.4rem; }
.recipeLabel { font-weight: 600; font-size: 0.95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recipeSettings { font-size: 0.8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: 'SF Mono', 'Monaco', 'Consolas', monospace; }
.recipeRight { display: flex; gap: 0.4rem; flex-shrink: 0; }
.recipeBtn { width: 2rem; height: 2rem; padding: 0; display: inline-flex; align-items: center; justify-content: center; background: var(--bg); font-size: 0.9rem; }
.recipeBtn:hover { transform: translateY(-1px); }
.recipeBtn.edit, .recipeBtn.copy { background: var(--surface); }
.recipeBtn.edit:hover, .recipeBtn.copy:hover { background: #E0E0E0; }
.recipeBtn.save, .recipeBtn.copy.copied { background: #CCFFCC; border-color: var(--ok); color: var(--ok); }
.recipeBtn.save:hover { background: #B3E6B3; }
.recipeBtn.cancel, .recipeBtn.delete { background: #FFCCCC; border-color: var(--danger); color: var(--danger); }
.recipeBtn.cancel:hover, .recipeBtn.delete:hover { background: #FFB3B3; }
.recipeRow.editing { background: #F0F8FF; }
:is(.recipeEditName, .recipeEditDesc) { width: 100%; padding: 0.4rem 0.6rem; font-family: inherit; font-size: 0.9rem; margin-bottom: 0.3rem; }
.recipeEditName { font-weight: 600; }
.recipeEditDesc { font-style: italic; color: var(--muted); }
:is(.recipeEditName, .recipeEditDesc):focus { outline: 0.15rem solid var(--focus); outline-offset: 0; }
.recipeColorPicker { flex-shrink: 0; width: 1.2rem; height: 1.2rem; display: inline-block; margin-top: 0.2rem; }
.recipeEditColor { width: 1.2rem; height: 1.2rem; padding: 0; background: none; }
.recipeEditColor::-webkit-color-swatch-wrapper { padding: 0; }
:is(.recipeEditColor::-webkit-color-swatch, .recipeEditColor::-moz-color-swatch) { border: none; border-radius: 0; }
.recipesEmpty { padding: var(--space-2); text-align: center; }
.recipesFooter { margin-top: var(--space-2); padding-top: var(--space-2); border-top: 0.1rem solid var(--border); }
.communityLink { display: inline-flex; align-items: center; gap: 0.5rem; color: var(--text); text-decoration: none; font-weight: 500; font-size: 0.95rem; padding: 0.5rem 0; }
.communityLink:hover { text-decoration: underline; color: #FF5700; }
.communityLink i { font-size: 1.2rem; color: #FF5700; }

/* CONSOLIDATED BORDER RULE */
:where(
  #hero, #stage, details, #shareSection, .terminalWindow, .progressBar, #sliderHandle,
  :is(.toggle, .preset), #browseBtn, :is(.pastel-mint, .pastel-lavender, .pastel-coral, .pastel-yellow),
  .stageIconBtn, .shareIcons button, .modelRow, .status, .recipeRow, .recipeSwatch, .recipeBtn,
  :is(input[type="range"], input[type="text"], select, input[type="number"]),
  .badge, #shareUrl, .recipeEditName, .recipeEditDesc, .recipeEditColor,
  /* Add custom checkboxes/radios to the border rule */
  input[type="checkbox"], input[name="bgMode"][type="radio"]
) {
  border: 0.1rem solid var(--border);
}

/* MEDIA QUERIES */
@media (prefers-reduced-motion: reduce) {
  :is(.progressFill, button, .toggle, .preset, .shareIcons button, #terminal, #hero, .stageIconBtn) {
    transition: none !important;
    transform: none !important;
  }
}

@media (max-width: 768px) {
  .shareIcons a {
    width: 3rem;
    height: 3rem;
    font-size: 1.5rem;
  }
}

/* Emoji Explosion for Re-happification */
.emoji-explosion-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  overflow: hidden;
}

.happy-emoji {
  position: absolute;
  left: var(--start-x);
  top: var(--start-y);
  font-size: 2.5rem;
  will-change: transform, opacity;
  animation: float-away cubic-bezier(0.5, 2.5, 0.5, 0) forwards;
  transform-origin: center center;
  text-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
}

@keyframes float-away {
  0% {
    transform: translate(-50%, -50%) scale(0) rotate(0deg);
    opacity: 1;
  }
  /*
  20% {
    transform: translate(calc(var(--tx) * 0.2 - 50%), calc(var(--ty) * 0.2 - 50%)) scale(3) rotate(calc(var(--rot) * 0.2));
    opacity: 1;
  }
  */
  80% {
    transform: translate(calc(var(--tx) - 50%), calc(var(--ty) - 50%)) scale(2.5) rotate(var(--rot));
    opacity: 1;
  }
  95% {
    transform: translate(calc(var(--tx) * 1.05 - 50%), calc(var(--ty) * 1.05 - 50%)) scale(4) rotate(calc(var(--rot) * 1.1));
    opacity: 1;
  }
  100% {
    transform: translate(calc(var(--tx) * 1.1 - 50%), calc(var(--ty) * 1.1 - 50%)) scale(0) rotate(calc(var(--rot) * 1.1));
    opacity: 0;
  }
}

/* Magic Wand Sparkle Effect */
.sparkle {
  position: absolute;
  font-size: 1.5rem;
  pointer-events: none;
  will-change: transform, opacity;
  animation: fall-and-fade forwards;
  z-index: 9999;
}

@keyframes fall-and-fade {
  0% {
    transform: translateY(0) translateX(0) rotate(0deg) scale(1);
    opacity: 1;
  }
  100% {
    transform: translateY(var(--fall-distance, 150px)) translateX(var(--drift, 0px)) rotate(var(--rotation, 360deg)) scale(0.3);
    opacity: 0;
  }
}




/* Additions for /app/styles.css */

/* Model Row Multi-line Layout */
.modelLeft {
  align-items: flex-start;
}
.modelCheck {
  margin-top: 0.2rem;
}
.modelContent {
  display: flex;
  flex-direction: column;
  gap: 0.1rem; /* Tighter spacing between name/meta/config */
  flex: 1;
  min-width: 0;
}
.modelName {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.modelMeta {
  font-size: 0.85rem;
  color: var(--muted);
  font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
}
.modelConfig {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  margin-top: 0.2rem; /* A bit of space above config controls */
}
.modelConfigInput {
  width: 120px;
  padding: 0.2rem 0.4rem;
  font-size: 0.85rem;
}
.modelConfigBtn {
  padding: 0.2rem 0.6rem;
  font-size: 0.8rem;
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}
.modelConfigBtn:hover {
  background: var(--bg);
}
.modelConfigBtn i {
  font-size: 0.9em;
}

/* Remove fixed width from status to allow flexbox to manage layout */
.status {
  min-width: auto;
  width: 130px; /* Use a fixed width for alignment */
}

/* Adjust delete button */
.deleteModel {
  width: 2.2rem;
  height: 2.2rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

/* Override input rule to make model config input smaller */
:is(input[type="range"], input[type="text"], select, input[type="number"]):not(.modelConfigInput) {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  padding: 0.6rem;
}