:root {
  --bg: #0f0e0d; --panel: #161412; --line: #26231f; --line-2: #332e29;
  --ink: #f2ead9; --ink-2: #a89f90; --ink-3: #6e675d;
  --accent: #ff9a3c; --accent-ink: #1a0f04;
  --radius: 14px; --font: 'Inter', system-ui, -apple-system, sans-serif; --serif: 'Instrument Serif', Georgia, serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; overflow: hidden; }
button, select, input { font: inherit; color: inherit; }
h1, h2, p { margin: 0; }
[hidden] { display: none !important; }

.top { height: 56px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 0 20px; border-bottom: 1px solid var(--line); background: var(--bg); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: .01em; white-space: nowrap; }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 14px var(--accent); }
.top-status { color: var(--ink-2); font-size: 13px; text-align: center; white-space: nowrap; }
.top-actions { display: flex; gap: 8px; justify-content: flex-end; }

.btn { border: 1px solid var(--line-2); background: transparent; color: var(--ink); padding: 8px 14px; border-radius: 10px; cursor: pointer; transition: background .15s, transform .1s, opacity .15s; }
.btn:hover { background: #1f1c18; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; }
.btn.primary:hover { background: #ffa958; }
.btn:disabled { opacity: .4; cursor: default; }
.btn.full { width: 100%; }

.app { display: grid; grid-template-columns: 280px 1fr 250px; height: calc(100% - 56px); }
.panel { overflow-y: auto; padding: 18px 16px; border-right: 1px solid var(--line); background: var(--panel); scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
.panel.right { border-right: 0; border-left: 1px solid var(--line); }
.block + .block { margin-top: 24px; }
.h { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--ink-2); font-weight: 600; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: baseline; }
.h .hint { text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--ink-3); font-size: 11px; }

.dropzone { border: 1px dashed var(--line-2); border-radius: var(--radius); cursor: pointer; transition: border-color .15s, background .15s; outline: none; }
.dropzone:hover, .dropzone:focus, .dropzone.over { border-color: var(--accent); background: rgba(255, 154, 60, .05); }
.dropzone.small .dz-inner { display: flex; gap: 10px; align-items: center; padding: 14px; color: var(--ink-2); font-size: 12.5px; }
.dropzone.big { margin: 24px; min-height: calc(100% - 48px); display: flex; align-items: center; justify-content: center; text-align: center; }
.dropzone.big .dz-inner { display: flex; flex-direction: column; align-items: center; gap: 16px; max-width: 460px; color: var(--ink-2); }
.display { font-family: var(--serif); font-weight: 400; font-size: 56px; line-height: 1; color: var(--ink); letter-spacing: -.01em; }
.display em { font-style: italic; color: var(--accent); }
.fine { font-size: 12px; color: var(--ink-3); }

.ref-strip { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.ref-strip img { width: 48px; height: 48px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line-2); }
.ref-strip .x { position: relative; }
.ref-strip .x button { position: absolute; top: -5px; right: -5px; width: 16px; height: 16px; border-radius: 50%; border: 0; background: var(--ink); color: var(--bg); font-size: 10px; line-height: 16px; padding: 0; cursor: pointer; }
.ref-card { margin-top: 12px; padding: 12px; border: 1px solid var(--line-2); border-radius: 12px; background: #1b1815; }
.palette { display: flex; height: 16px; border-radius: 6px; overflow: hidden; }
.palette span { flex: 1; }
.mood { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.mood span { font-size: 11px; padding: 3px 8px; border-radius: 999px; background: #262220; color: var(--ink-2); }

.looks { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.look { border: 1px solid var(--line-2); background: #1b1815; border-radius: 12px; overflow: hidden; cursor: pointer; text-align: left; padding: 0; transition: border-color .15s, transform .15s; }
.look:hover { transform: translateY(-1px); }
.look.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.look .thumb { aspect-ratio: 1; background: #221f1b; width: 100%; display: block; object-fit: cover; }
.look .meta { padding: 8px 10px 9px; }
.look .name { font-weight: 600; font-size: 12.5px; }
.look .tag { color: var(--ink-3); font-size: 10.5px; line-height: 1.3; margin-top: 2px; }
.look.ref .name::before { content: '★ '; color: var(--accent); }
.look.flagship { background: linear-gradient(180deg, #221c15, #1b1815); }
.look.flagship .name::after { content: 'FLAGSHIP'; font-size: 8.5px; letter-spacing: .1em; color: var(--accent); margin-left: 6px; vertical-align: 1px; }
.look-info { font-size: 12.5px; color: var(--ink-2); line-height: 1.45; }
.look-info .li-name { color: var(--ink); font-weight: 600; margin-bottom: 4px; }
.look-info p { margin-top: 6px; }
.look-info .li-cal b { color: var(--ink); }
.look-info a { color: var(--accent); }
.pill { font-size: 9px; letter-spacing: .1em; padding: 2px 6px; border-radius: 999px; border: 1px solid var(--accent); color: var(--accent); margin-left: 4px; vertical-align: 2px; }

.stage { overflow-y: auto; position: relative; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
.stage.over::after { content: 'Drop to add'; position: absolute; inset: 12px; border: 2px dashed var(--accent); border-radius: var(--radius); display: grid; place-items: center; font-family: var(--serif); font-size: 32px; color: var(--accent); background: rgba(15, 14, 13, .7); pointer-events: none; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; padding: 20px; }
.cell { position: relative; border-radius: 12px; overflow: hidden; background: transparent; cursor: zoom-in; aspect-ratio: 1; display: grid; place-items: center; }
.cell canvas { width: 100%; height: 100%; object-fit: contain; display: block; opacity: 0; transition: opacity .25s; }
.cell.ready canvas { opacity: 1; }
.cell .spin { position: absolute; width: 18px; height: 18px; border: 2px solid var(--line-2); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
.cell.ready .spin { display: none; }
.cell .badge { position: absolute; left: 8px; top: 8px; font-size: 10px; font-weight: 700; letter-spacing: .08em; padding: 2px 6px; border-radius: 6px; background: var(--accent); color: var(--accent-ink); }
.cell .ai-busy { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; background: rgba(8, 7, 6, .55); backdrop-filter: blur(2px); font-size: 11.5px; color: var(--ink); text-align: center; padding: 10px; }
.cell .ai-busy i { width: 22px; height: 22px; border: 2px solid var(--line-2); border-top-color: var(--accent); border-radius: 50%; animation: spin .9s linear infinite; }
.cell .rm { position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .55); color: #fff; cursor: pointer; opacity: 0; transition: opacity .15s; font-size: 12px; }
.cell:hover .rm { opacity: 1; }
@keyframes spin { to { transform: rotate(360deg); } }

.sliders { display: flex; flex-direction: column; gap: 12px; }
.sl label { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-2); margin-bottom: 4px; }
.sl label b { color: var(--ink); font-weight: 500; font-variant-numeric: tabular-nums; }
.sl input[type=range] { width: 100%; -webkit-appearance: none; appearance: none; height: 4px; background: var(--line-2); border-radius: 2px; margin: 6px 0; outline: none; }
.sl input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: var(--ink); border: 2px solid var(--panel); box-shadow: 0 0 0 1px var(--line-2); cursor: grab; }
.sl input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--ink); border: 2px solid var(--panel); cursor: grab; }
.seg { display: grid; grid-template-columns: repeat(5, 1fr); border: 1px solid var(--line-2); border-radius: 10px; overflow: hidden; margin-bottom: 12px; }
.seg button { border: 0; background: transparent; padding: 8px 0; font-size: 12px; cursor: pointer; color: var(--ink-2); }
.seg button.on { background: #262220; color: var(--ink); font-weight: 500; }
.row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; font-size: 13px; color: var(--ink-2); border-top: 1px solid var(--line); }
.row select { background: #1b1815; border: 1px solid var(--line-2); border-radius: 8px; padding: 5px 8px; font-size: 12px; }
.row input[type=checkbox] { accent-color: var(--accent); width: 16px; height: 16px; }
#btn-reset { margin-top: 10px; }

.lightbox { position: fixed; inset: 0; background: rgba(8, 7, 6, .94); z-index: 20; display: flex; align-items: center; justify-content: center; gap: 22px; padding: 0 24px; backdrop-filter: blur(6px); }
.ai-studio { width: 300px; flex: 0 0 300px; max-height: 92vh; overflow-y: auto; background: var(--panel); border: 1px solid var(--line-2); border-radius: var(--radius); padding: 16px; scrollbar-width: thin; }
.ai-studio .h { margin-bottom: 12px; flex-direction: column; align-items: flex-start; gap: 2px; }
.ai-group { margin-bottom: 12px; }
.ai-group > label { display: block; font-size: 11.5px; color: var(--ink-2); margin-bottom: 5px; }
.ai-seg { grid-template-columns: repeat(3, 1fr); margin-bottom: 0; }
.ai-seg.three { grid-template-columns: repeat(3, 1fr); }
.ai-seg.four { grid-template-columns: repeat(4, 1fr); }
.ai-seg.four button { font-size: 11px; }
.ai-seg button { padding: 7px 0; font-size: 11.5px; }
.ai-seg button.on { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
#ai-edit-text { width: 100%; margin-top: 8px; background: #1b1815; border: 1px solid var(--line-2); border-radius: 8px; padding: 8px 10px; font-size: 12.5px; outline: none; }
#ai-edit-text:focus { border-color: var(--accent); }
.ai-row { display: flex; gap: 8px; align-items: center; justify-content: space-between; margin: 10px 0; }
.ai-row select { background: #1b1815; border: 1px solid var(--line-2); border-radius: 8px; padding: 6px 8px; font-size: 12px; flex: 1; }
.btn.small { padding: 6px 10px; font-size: 12px; }
.ai-summary { font-size: 12.5px; color: var(--ink); min-height: 18px; margin: 8px 0 10px; font-family: var(--serif); font-size: 17px; }
.ai-actions { display: flex; flex-direction: column; gap: 8px; }
.ai-photo-state { font-size: 12px; color: var(--ink-2); margin-top: 12px; min-height: 16px; }
.ai-progress { height: 4px; border-radius: 2px; background: var(--line-2); margin-top: 6px; overflow: hidden; }
.ai-progress i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 2px; transition: width .9s linear; }
.ai-row.summary-row { align-items: flex-start; justify-content: space-between; gap: 8px; margin: 8px 0 10px; }
.ai-row.summary-row .ai-summary { margin: 0; flex: 1; }
.ai-photo-state .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent); animation: pulse 1.2s ease-in-out infinite; margin-right: 4px; }
.ai-off { font-size: 12px; color: #e0a24a; background: rgba(224, 162, 74, .1); border: 1px solid rgba(224, 162, 74, .3); padding: 8px 10px; border-radius: 8px; margin-bottom: 12px; }
@keyframes pulse { 50% { opacity: .3; } }
.lb-close { position: absolute; top: 16px; right: 20px; background: transparent; border: 0; color: var(--ink-2); font-size: 20px; cursor: pointer; }
.lb-body { display: flex; flex-direction: column; gap: 14px; align-items: center; max-width: min(calc(92vw - 340px), 1100px); min-width: 0; }
.compare { position: relative; max-height: 78vh; user-select: none; cursor: ew-resize; border-radius: 10px; overflow: hidden; }
.compare canvas { display: block; max-height: 78vh; max-width: calc(92vw - 340px); }
.compare #lb-after { position: absolute; inset: 0; width: 100%; height: 100%; clip-path: inset(0 0 0 50%); }
.handle { position: absolute; top: 0; bottom: 0; left: 50%; width: 2px; background: var(--ink); pointer-events: none; }
.handle span { position: absolute; top: 12px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink); background: rgba(0, 0, 0, .5); padding: 3px 7px; border-radius: 6px; }
.handle span:first-child { right: 10px; }
.handle span:last-child { left: 10px; }
.lb-bar { display: flex; gap: 10px; align-items: center; color: var(--ink-2); font-size: 13px; }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 13px; z-index: 30; box-shadow: 0 10px 30px rgba(0, 0, 0, .4); }
.progress { position: fixed; top: 56px; left: 0; height: 2px; background: var(--accent); z-index: 25; transition: width .2s; box-shadow: 0 0 10px var(--accent); }

@media (max-width: 980px) {
  body { overflow: auto; }
  .app { display: block; height: auto; }
  .panel { border: 0; border-bottom: 1px solid var(--line); }
  .panel.right { border-top: 1px solid var(--line); }
  .dropzone.big { min-height: 50vh; }
  .display { font-size: 40px; }
  .top { grid-template-columns: auto 1fr auto; }
  .top-status { text-align: right; padding-right: 12px; font-size: 12px; }
  .top { padding: 0 14px; }
  .btn { padding: 7px 11px; white-space: nowrap; }
  .looks { display: flex; overflow-x: auto; gap: 8px; margin: 0 -16px; padding: 0 16px 6px; scroll-snap-type: x mandatory; scrollbar-width: none; }
  .looks .look { flex: 0 0 128px; scroll-snap-align: start; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; padding: 12px; }
  .lightbox { flex-direction: column; align-items: stretch; justify-content: flex-start; overflow-y: auto; padding: 48px 12px 24px; gap: 14px; }
  .lb-body { max-width: none; }
  .compare { max-height: 52vh; align-self: center; }
  .compare canvas { max-height: 52vh; max-width: calc(100vw - 24px); }
  .ai-studio { width: auto; flex: none; max-height: none; }
  .seg button { font-size: 11px; }
}
