:root {
  --bg: #f4f3f0; --card: #fff; --text: #1d1d1b; --muted: #6b6a66; --line: #dddad4;
  --accent: #1f5fa8; --accent-text: #fff; --ok: #2e7d4f; --err: #b3261e;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #161615; --card: #22221f; --text: #ecebe7; --muted: #a09e98; --line: #3a3934; --accent: #6aa3e8; --accent-text: #0d1b2a; --ok: #6cc28f; --err: #f2867d; }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); }
header { display: flex; justify-content: space-between; align-items: center; padding: 12px 20px; border-bottom: 1px solid var(--line); background: var(--card); }
header strong { margin-right: 12px; }
.layout { display: grid; grid-template-columns: 240px 1fr; gap: 20px; padding: 20px; max-width: 1500px; margin: 0 auto; }
@media (max-width: 800px) { .layout { grid-template-columns: 1fr; padding: 16px; } aside { order: 2; } }
.layout > * { min-width: 0; }
aside h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 20px 0 8px; }
aside ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px; margin-bottom: 18px; }
h1, h2 { margin: 0 0 8px; } h2 { font-size: 18px; }
.muted { color: var(--muted); } .small { font-size: 13px; }
textarea, input { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); font: inherit; }
button, .button { display: inline-block; padding: 9px 16px; border-radius: 8px; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-text); font: inherit; cursor: pointer; text-decoration: none; }
button.secondary, .button.secondary { background: transparent; color: var(--accent); }
button.link { background: none; border: none; color: var(--accent); padding: 0; }
button:disabled { opacity: .5; cursor: wait; }
.wide { width: 100%; }
.row { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.row input { flex: 1; min-width: 0; flex-basis: 200px; }
#step-describe button { margin-top: 12px; }
/* 2D and 3D side by side once the 3D step is open (stacked on narrow screens). */
.work.two-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: stretch; }
.work.two-cols .card { display: flex; flex-direction: column; }
.work.two-cols .card { margin-bottom: 0; }
.work.two-cols .viewer { height: auto; aspect-ratio: 1; }
@media (max-width: 1100px) { .work.two-cols { grid-template-columns: minmax(0, 1fr); } }
.viewer { position: relative; background: #e9e7e3; border-radius: 8px; overflow: hidden; height: min(560px, 85vw); width: 100%; display: flex; align-items: center; justify-content: center; }
.viewer img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; }
.viewer img.preview { filter: blur(1px); opacity: .85; }
model-viewer { width: 100%; height: 100%; }
.viewer-msg { position: absolute; inset: auto 16px 16px; margin: 0; padding: 10px; border-radius: 6px; background: rgba(0,0,0,.7); color: #fff; font-size: 14px; text-align: center; }
.status { position: absolute; bottom: 10px; left: 10px; right: 10px; text-align: center; }
.status.active { background: rgba(0,0,0,.65); color: #fff; padding: 8px; border-radius: 6px; }
.status:empty { display: none; }
.progress-label { font-size: 14px; margin-bottom: 6px; }
.progress-bar { height: 8px; background: rgba(255,255,255,.25); border-radius: 4px; overflow: hidden; }
.progress-bar span { display: block; height: 100%; width: 0; background: #6aa3e8; border-radius: 4px; transition: width .25s linear; }
.recap { margin: 10px 0 0; }
.versions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.thumb { position: relative; padding: 0; width: 64px; height: 64px; border: 2px solid var(--line); background: none; border-radius: 6px; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb span { position: absolute; bottom: 0; left: 0; font-size: 11px; background: rgba(0,0,0,.6); color: #fff; padding: 0 4px; }
.thumb.selected { border-color: var(--accent); }
.thumb.validated { border-color: var(--ok); }
aside li { position: relative; }
.history-delete { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; padding: 0; border: none; border-radius: 50%; background: transparent; color: var(--muted); font-size: 18px; line-height: 24px; cursor: pointer; }
.history-delete:hover, .history-delete:focus-visible { background: var(--err); color: #fff; }
.history-item { padding-right: 32px !important; overflow: hidden; display: flex; gap: 8px; align-items: center; width: 100%; text-align: left; background: var(--card); color: var(--text); border: 1px solid var(--line); padding: 6px; }
.history-item img, .history-item .noimg { width: 36px; height: 36px; border-radius: 4px; object-fit: cover; background: var(--line); flex: none; }
.history-item span:last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.error { color: var(--err); }
.header-actions { display: flex; gap: 18px; align-items: center; }
#settings-dialog { border: 1px solid var(--line); border-radius: 10px; padding: 0; background: var(--card); color: var(--text); width: min(560px, calc(100vw - 32px)); }
#settings-dialog::backdrop { background: rgba(0,0,0,.45); }
.settings { padding: 18px 20px; display: grid; gap: 8px; }
.login-page { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login { width: 100%; max-width: 360px; display: grid; gap: 12px; }
.login label { display: grid; gap: 4px; font-size: 14px; }
