:root {
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  background: #0b0b0c;
  color: #f7f7f8;
  -webkit-tap-highlight-color: transparent;
}

* { box-sizing: border-box; }
html { background: #0b0b0c; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: radial-gradient(circle at top, #222225 0%, #111113 40%, #080809 100%);
  overscroll-behavior-y: none;
}
button, input, select { font: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: not-allowed; opacity: .42; }

.app-shell {
  width: min(1380px, calc(100% - 28px));
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 0 max(46px, env(safe-area-inset-bottom));
}
.topbar { display: flex; gap: 20px; align-items: flex-start; justify-content: space-between; margin-bottom: 20px; }
.header-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.eyebrow-row { display: flex; align-items: center; gap: 10px; margin-bottom: 7px; }
.eyebrow { margin: 0; font-size: .7rem; font-weight: 700; letter-spacing: .15em; color: #9d9da3; }
.version-badge {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border: 1px solid #3d3d43;
  border-radius: 999px;
  background: #1e1e22;
  color: #c9c9ce;
  font-size: .68rem;
  font-weight: 750;
  letter-spacing: .02em;
}
h1 { margin: 0; font-size: clamp(2rem, 5vw, 3.2rem); line-height: .98; letter-spacing: -.045em; }
.subhead { margin: 10px 0 0; color: #b2b2b7; max-width: 660px; }

.control-card, .thumb-panel, .preview-panel {
  background: rgba(24,24,27,.94);
  border: 1px solid #34343a;
  border-radius: 22px;
  box-shadow: 0 18px 65px rgba(0,0,0,.24);
}
.control-card { padding: 17px; margin-bottom: 18px; }
.picker-row { display: flex; align-items: center; gap: 12px; padding-bottom: 16px; border-bottom: 1px solid #303036; }
.file-button, .primary-button, .secondary-button, .tertiary-button, .ghost-button {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 13px;
  padding: 11px 16px;
  border: 1px solid transparent;
  font-weight: 750;
}
.file-button, .primary-button { background: #f4f4f5; color: #111113; }
.secondary-button { background: #29292e; color: #fff; border-color: #47474e; }
.tertiary-button { background: transparent; color: #d5d5d8; border-color: #3c3c42; }
.ghost-button { min-height: 42px; background: transparent; color: #efeff1; border-color: #414148; }
.text-button { min-height: 44px; margin-left: auto; padding: 6px 8px; border: 0; background: transparent; color: #b9b9be; }
.file-count { color: #c8c8cc; }

.preset-section { padding-top: 16px; }
.control-label-row { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 10px; color: #d8d8dc; font-size: .92rem; }
.control-label-row strong { color: #fff; }
.preset-buttons { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; }
.preset-button {
  min-height: 48px;
  border-radius: 13px;
  border: 1px solid #414148;
  background: #222226;
  color: #d8d8dc;
  font-weight: 700;
}
.preset-button.active { background: #f3f3f4; color: #111113; border-color: #f3f3f4; }

.sliders-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; padding-top: 18px; }
.sliders-grid label { display: grid; gap: 9px; color: #d7d7db; font-size: .92rem; }
.sliders-grid strong { color: #fff; }
input[type="range"] { width: 100%; min-height: 30px; accent-color: #ededee; }
select { width: 100%; min-height: 46px; color: #f5f5f6; background: #222226; border: 1px solid #414148; border-radius: 12px; padding: 10px 12px; }

.workspace { display: grid; grid-template-columns: minmax(250px, 330px) 1fr; gap: 18px; min-height: 610px; }
.thumb-panel, .preview-panel { padding: 17px; }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-heading h2 { margin: 0; font-size: 1rem; }
.section-heading span { color: #9d9da3; font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thumb-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 9px; max-height: 560px; overflow: auto; padding: 2px 4px 2px 2px; -webkit-overflow-scrolling: touch; }
.thumb-grid.empty-state { display: grid; place-items: center; min-height: 300px; color: #898990; text-align: center; padding: 24px; }
.thumb { display: grid; padding: 0; overflow: hidden; text-align: left; background: #141416; border: 1px solid #333339; border-radius: 13px; color: #fff; }
.thumb.active { outline: 2px solid #f2f2f4; outline-offset: 1px; }
.thumb img { display: block; width: 100%; aspect-ratio: 1/1; object-fit: cover; background: #0d0d0f; }
.thumb-name { padding: 8px; font-size: .7rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.preview-panel { display: flex; flex-direction: column; }
.preview-heading { align-items: center; }
.status-pill { flex: 0 0 auto; border: 1px solid #3b3b42; border-radius: 999px; padding: 6px 10px; background: #202024; }
.preview-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; flex: 1; }
figure { margin: 0; min-width: 0; }
figcaption { color: #b9b9be; font-size: .76rem; margin-bottom: 7px; }
.canvas-frame { height: 100%; min-height: 410px; display: grid; place-items: center; overflow: hidden; background: #080809; border: 1px solid #2d2d32; border-radius: 14px; }
canvas { display: block; max-width: 100%; max-height: 560px; width: auto; height: auto; }
.action-row { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 9px; margin-top: 15px; }
.progress-wrap { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; margin-top: 14px; }
.progress-track { height: 8px; overflow: hidden; background: #2b2b30; border-radius: 99px; }
.progress-bar { width: 0%; height: 100%; background: #f4f4f5; transition: width .15s linear; }
.export-hint { color: #b4b4b9; font-size: .79rem; line-height: 1.45; margin: 13px 0 0; }
.privacy-note { color: #85858b; font-size: .76rem; line-height: 1.4; margin: 10px 0 0; text-align: right; }


@media (max-width: 900px) {
  .workspace, .preview-grid { grid-template-columns: 1fr; }
  .workspace { min-height: auto; }
  .thumb-grid { grid-template-columns: repeat(5, minmax(0,1fr)); max-height: 220px; }
  .canvas-frame { min-height: 300px; max-height: 55vh; }
}

@media (max-width: 620px) {
  .app-shell { width: calc(100% - 16px); padding-top: max(14px, env(safe-area-inset-top)); }
  .topbar { align-items: stretch; flex-direction: column; gap: 12px; margin-bottom: 14px; }
  .header-actions { justify-content: flex-start; }
  .eyebrow { font-size: .63rem; }
  h1 { font-size: 2rem; }
  .subhead { font-size: .9rem; }
  .control-card, .thumb-panel, .preview-panel { border-radius: 18px; }
  .control-card, .thumb-panel, .preview-panel { padding: 13px; }
  .picker-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
  .file-button { grid-column: 1 / -1; width: 100%; min-height: 52px; font-size: 1rem; }
  .file-count { align-self: center; font-size: .84rem; }
  .text-button { margin: 0; }
  .preset-buttons { grid-template-columns: 1fr 1fr; }
  .preset-button { min-height: 52px; font-size: .95rem; }
  .sliders-grid { grid-template-columns: 1fr; gap: 14px; }
  .workspace { gap: 12px; }
  .thumb-grid { grid-template-columns: repeat(4, minmax(0,1fr)); gap: 7px; max-height: 178px; }
  .thumb-name { display: none; }
  .preview-heading { align-items: flex-start; }
  .preview-heading > div span { display: none; }
  .preview-grid { gap: 10px; }
  .canvas-frame { min-height: 220px; max-height: 42vh; }
  .action-row { grid-template-columns: 1fr; }
  .action-row button { width: 100%; min-height: 52px; }
  .privacy-note { text-align: left; }
}

/* v0.6 framing controls */
.framing-section {
  margin-top: 18px;
  padding-top: 17px;
  border-top: 1px solid #303036;
}
.framing-heading-row { align-items: center; margin-bottom: 12px; }
.framing-heading-row > div { display: grid; gap: 4px; }
.framing-heading-row small { color: #919197; font-size: .75rem; line-height: 1.35; }
.framing-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  transition: opacity .15s ease;
}
.framing-controls label { display: grid; gap: 8px; color: #d7d7db; font-size: .9rem; }
.framing-controls.disabled { opacity: .42; pointer-events: none; }
.switch { position: relative; display: inline-flex; align-items: center; flex: 0 0 auto; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-track {
  width: 52px;
  height: 30px;
  padding: 3px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: #38383e;
  border: 1px solid #4b4b52;
  transition: background .16s ease, border-color .16s ease;
}
.switch-knob {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #f5f5f6;
  transform: translateX(0);
  transition: transform .16s ease;
  box-shadow: 0 2px 7px rgba(0,0,0,.35);
}
.switch input:checked + .switch-track { background: #f2f2f3; border-color: #f2f2f3; }
.switch input:checked + .switch-track .switch-knob { transform: translateX(22px); background: #111113; }
.switch input:focus-visible + .switch-track { outline: 2px solid #fff; outline-offset: 3px; }

@media (max-width: 620px) {
  .framing-controls { grid-template-columns: 1fr 1fr; gap: 8px; }
  .framing-controls select { font-size: .86rem; padding-left: 9px; padding-right: 9px; }
  .framing-heading-row small { max-width: 245px; }
}
