:root {
  color-scheme: dark;
  --bg: #080908;
  --paper: #f2f1ec;
  --ink: #171715;
  --white: #f8f6f0;
  --muted: #8e8c85;
  --gold: #d7a355;
  --danger: #ff6b62;
  --safe-top: max(16px, env(safe-area-inset-top));
  --safe-bottom: max(18px, env(safe-area-inset-bottom));
}

* { box-sizing: border-box; }
html, body, #app { width: 100%; height: 100%; margin: 0; }
body { position: fixed; inset: 0; overflow: hidden; background: #050605; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", sans-serif; letter-spacing: 0; }
button, input { font: inherit; letter-spacing: 0; }
button { -webkit-tap-highlight-color: transparent; cursor: pointer; touch-action: manipulation; }
button:not(.work-card, .edit-dismiss, :disabled):active { transform: scale(.96); transition: transform 90ms ease-out; }
button:disabled { cursor: default; opacity: .42; }
button:focus-visible, input:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }

.app-shell { position: relative; width: min(100vw, 520px); height: 100dvh; min-height: 0; margin: 0 auto; overflow: hidden; color: var(--white); background: var(--bg); box-shadow: 0 0 80px rgba(0,0,0,.5); }
.screen { position: absolute; inset: 0; overflow: hidden; }
.photo-fill { width: 100%; height: 100%; object-fit: cover; user-select: none; -webkit-user-drag: none; }
.glass { border: 1px solid rgba(255,255,255,.17); background: rgba(20,20,19,.54); backdrop-filter: blur(20px) saturate(135%); }
.icon-button { width: 44px; height: 44px; display: grid; flex: 0 0 44px; place-items: center; padding: 0; border: 0; border-radius: 50%; color: inherit; background: rgba(18,18,17,.46); backdrop-filter: blur(18px); }
.icon-button svg { width: 20px; height: 20px; stroke-width: 1.8; }
.icon-button.gold { color: #17120a; background: var(--gold); }
.topbar { position: absolute; z-index: 7; top: 0; right: 0; left: 0; min-height: 64px; display: flex; align-items: center; justify-content: space-between; padding: calc(var(--safe-top) + 4px) 16px 8px; }
.topbar-spacer { width: 44px; height: 44px; }
.wordmark { font-family: "Songti SC", "Noto Serif SC", serif; font-size: 18px; font-weight: 600; letter-spacing: 0; }

.boot-screen { display: grid; place-items: center; background: #080908; }
.boot-mark { font-family: "Songti SC", serif; font-size: 24px; font-weight: 600; animation: boot-breathe 1.2s ease-in-out infinite alternate; }
@keyframes boot-breathe { to { opacity: .48; transform: scale(.985); } }

.camera-screen { background: #050505; }
.camera-screen::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to bottom, rgba(0,0,0,.38), transparent 25%, transparent 62%, rgba(0,0,0,.74)); pointer-events: none; }
.camera-screen video, .camera-preview { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.camera-empty { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 14px; padding: 32px; color: rgba(255,255,255,.72); text-align: center; }
.camera-empty svg { width: 36px; height: 36px; stroke-width: 1.4; }
.camera-empty p { margin: 0; font-size: 13px; }
.capture-system { min-height: 44px; display: flex; align-items: center; gap: 8px; padding: 0 16px; border: 1px solid rgba(255,255,255,.3); border-radius: 22px; color: white; background: transparent; }
.capture-system svg { width: 18px; height: 18px; }
.focus-mark { position: absolute; z-index: 4; width: 56px; height: 56px; border: 1px solid rgba(255,255,255,.8); transform: translate(-50%, -50%) scale(1.08); opacity: 0; transition: opacity 160ms ease, transform 220ms cubic-bezier(.2,.8,.2,1); pointer-events: none; }
.focus-mark.visible { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.ai-strength { position: absolute; z-index: 8; bottom: calc(var(--safe-bottom) + 136px); left: 50%; width: 194px; overflow: hidden; border-radius: 22px; color: white; transform: translateX(-50%); transition: width 260ms cubic-bezier(.2,.8,.2,1), border-radius 260ms ease; }
.ai-strength.expanded { width: min(84vw, 326px); border-radius: 18px; }
.ai-strength-summary { width: 100%; min-height: 44px; display: grid; grid-template-columns: 20px auto 1fr 20px; gap: 7px; align-items: center; padding: 0 12px; border: 0; color: white; background: transparent; text-align: left; font-size: 11px; }
.ai-strength-summary svg { width: 16px; height: 16px; stroke-width: 1.8; }
.ai-strength-summary span { font-weight: 700; white-space: nowrap; }
.ai-strength-summary b { overflow: hidden; color: rgba(255,255,255,.7); font-size: 10px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.ai-strength-controls { display: grid; grid-template-columns: 32px 1fr 32px; gap: 8px; align-items: center; height: 42px; padding: 0 12px 8px; color: rgba(255,255,255,.66); font-size: 10px; }
.ai-strength-controls input { --strength: 52%; width: 100%; height: 28px; margin: 0; appearance: none; background: transparent; touch-action: pan-x; }
.ai-strength-controls input::-webkit-slider-runnable-track { height: 3px; border-radius: 2px; background: linear-gradient(to right, var(--gold) 0 var(--strength), rgba(255,255,255,.24) var(--strength) 100%); }
.ai-strength-controls input::-webkit-slider-thumb { width: 22px; height: 22px; margin-top: -9.5px; appearance: none; border: 1px solid rgba(255,255,255,.7); border-radius: 50%; background: white; box-shadow: 0 2px 8px rgba(0,0,0,.3); }
.ai-strength-controls input::-moz-range-track { height: 3px; border: 0; border-radius: 2px; background: rgba(255,255,255,.24); }
.ai-strength-controls input::-moz-range-progress { height: 3px; border-radius: 2px; background: var(--gold); }
.ai-strength-controls input::-moz-range-thumb { width: 22px; height: 22px; border: 1px solid rgba(255,255,255,.7); border-radius: 50%; background: white; }
.camera-actions { position: absolute; z-index: 7; right: 0; bottom: 0; left: 0; min-height: 154px; display: grid; grid-template-columns: 1fr 100px 1fr; align-items: center; padding: 26px 24px calc(var(--safe-bottom) + 18px); }
.library-thumb { width: 48px; height: 48px; overflow: hidden; padding: 0; border: 1px solid rgba(255,255,255,.7); border-radius: 8px; background: #222; }
.library-thumb img { width: 100%; height: 100%; object-fit: cover; }
.library-placeholder { display: grid; place-items: center; }
.library-placeholder svg { width: 19px; height: 19px; }
.camera-action-spacer { width: 44px; height: 44px; justify-self: end; }
.shutter { position: relative; width: 78px; height: 78px; justify-self: center; padding: 0; border: 2px solid white; border-radius: 50%; background: rgba(255,255,255,.12); }
.shutter::after { content: ""; position: absolute; inset: 6px; border-radius: 50%; background: rgba(255,255,255,.92); transition: transform 100ms ease-out; }
.shutter:active::after { transform: scale(.84); }
.switch-camera { justify-self: end; }
.capture-flash { position: absolute; z-index: 20; inset: 0; background: white; opacity: 0; pointer-events: none; }
.capture-flash.active { animation: camera-flash 180ms ease-out; }
@keyframes camera-flash { 0% { opacity: .75; } 100% { opacity: 0; } }

.processing-screen { background: #111; }
.processing-photo { position: absolute; inset: 0; overflow: hidden; background: #111; }
.processing-screen .photo-fill { position: absolute; inset: 0; filter: blur(10px) brightness(.42) saturate(.72); transform: scale(1.045); animation: develop-photo 4.2s cubic-bezier(.22,.7,.2,1) forwards; will-change: filter, transform; }
@keyframes develop-photo { 45% { filter: blur(4px) brightness(.58) saturate(.88); transform: scale(1.025); } 100% { filter: blur(1px) brightness(.72) saturate(1.04); transform: scale(1); } }
.processing-photo::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to bottom, rgba(5,6,5,.2), transparent 32%, transparent 64%, rgba(5,6,5,.42)); pointer-events: none; }
.exposure-sweep { position: absolute; z-index: 2; top: -25%; right: -15%; left: -15%; height: 34%; background: linear-gradient(to bottom, transparent, rgba(255,237,205,.14), transparent); animation: exposure-sweep 2.1s cubic-bezier(.4,0,.2,1) infinite; pointer-events: none; will-change: transform, opacity; }
@keyframes exposure-sweep { 0% { transform: translateY(0); opacity: 0; } 18% { opacity: 1; } 82% { opacity: .65; } 100% { transform: translateY(430%); opacity: 0; } }
.focus-frame { position: absolute; z-index: 3; top: 50%; left: 50%; width: min(70vw, 310px); aspect-ratio: 4 / 5; transform: translate(-50%,-50%) scale(1.06); animation: settle-frame 4.2s cubic-bezier(.2,.8,.2,1) forwards, focus-breathe 2.4s 4.2s ease-in-out infinite alternate; opacity: .64; }
.focus-frame i { position: absolute; width: 24px; height: 24px; border-color: rgba(255,255,255,.78); border-style: solid; }
.focus-frame i:nth-child(1) { top: 0; left: 0; border-width: 1px 0 0 1px; }
.focus-frame i:nth-child(2) { top: 0; right: 0; border-width: 1px 1px 0 0; }
.focus-frame i:nth-child(3) { right: 0; bottom: 0; border-width: 0 1px 1px 0; }
.focus-frame i:nth-child(4) { bottom: 0; left: 0; border-width: 0 0 1px 1px; }
@keyframes settle-frame { to { transform: translate(-50%,-50%) scale(.94); opacity: .28; } }
@keyframes focus-breathe { from { transform: translate(-50%,-50%) scale(.94); opacity: .28; } to { transform: translate(-50%,-50%) scale(.955); opacity: .42; } }
.processing-center { position: absolute; z-index: 4; inset: 0; display: grid; place-content: center; justify-items: center; padding: 32px; text-align: center; }
.processing-mark { width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.24); border-radius: 50%; color: var(--gold); background: rgba(10,10,9,.32); backdrop-filter: blur(12px); animation: processing-breathe 1.8s ease-in-out infinite; }
.processing-mark svg { width: 19px; height: 19px; stroke-width: 1.7; }
@keyframes processing-breathe { 50% { transform: scale(1.08); border-color: rgba(215,163,85,.5); } }
.processing-center h1 { margin: 22px 0 7px; font-family: "Songti SC", serif; font-size: 21px; font-weight: 600; }
.processing-center p { margin: 0; color: rgba(255,255,255,.68); font-size: 12px; }
.processing-footer { position: absolute; z-index: 5; right: 18px; bottom: calc(var(--safe-bottom) + 8px); left: 18px; display: flex; justify-content: space-between; padding-top: 14px; color: rgba(255,255,255,.72); font-size: 11px; }
.processing-footer::before, .processing-footer i { content: ""; position: absolute; top: 0; left: 0; height: 1px; border-radius: 1px; }
.processing-footer::before { width: 100%; background: rgba(255,255,255,.2); }
.processing-footer i { width: var(--progress); overflow: hidden; background: var(--gold); transition: width 420ms cubic-bezier(.2,.8,.2,1); }
.processing-footer i::after { content: ""; position: absolute; inset: -1px -24px -1px auto; width: 24px; background: rgba(255,255,255,.78); filter: blur(5px); animation: progress-glow 1.1s ease-in-out infinite alternate; }
@keyframes progress-glow { to { opacity: .28; transform: translateX(-9px); } }
.processing-footer b { color: var(--gold); font-variant-numeric: tabular-nums; }

.result-screen { color: var(--ink); background: var(--paper); }
.result-screen .topbar { color: var(--ink); background: rgba(242,241,236,.82); backdrop-filter: blur(18px); }
.result-screen .icon-button { background: rgba(255,255,255,.72); }
.version-count { font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
.result-stage { position: absolute; top: calc(var(--safe-top) + 58px); right: 12px; bottom: 105px; left: 12px; overflow: hidden; padding: 8px 8px 52px; background: white; box-shadow: 0 10px 32px rgba(40,36,28,.11); touch-action: pan-y; }
.result-screen:not(.editing) .result-stage { animation: result-arrive 420ms cubic-bezier(.2,.8,.2,1) both; }
@keyframes result-arrive { from { opacity: 0; transform: scale(.985); } }
.result-photo { position: absolute; top: 8px; right: 8px; bottom: 52px; left: 8px; overflow: hidden; background: #121312; transform-origin: center; will-change: transform; }
.result-photo img { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; user-select: none; -webkit-user-drag: none; }
.result-photo-backdrop { z-index: 0; object-fit: cover; filter: blur(24px) brightness(.56) saturate(.76); transform: scale(1.12); }
#result-original, #result-image { z-index: 1; object-fit: contain; }
#result-image { z-index: 2; opacity: 1; transition: opacity 140ms ease-out; }
.result-stage.show-original #result-image { opacity: 0; }
.result-caption { position: absolute; right: 12px; bottom: 13px; left: 12px; display: flex; align-items: end; justify-content: space-between; gap: 10px; }
.result-caption strong { font-family: "Songti SC", serif; font-size: 17px; }
.result-caption small { max-width: 55%; overflow: hidden; color: #65625d; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.compare-hint { position: absolute; z-index: 4; left: 50%; bottom: 64px; min-width: 68px; min-height: 44px; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 0 13px; border: 1px solid rgba(255,255,255,.18); border-radius: 22px; color: white; background: rgba(15,15,14,.68); backdrop-filter: blur(16px); transform: translateX(-50%); font-size: 11px; white-space: nowrap; }
.compare-hint:active { transform: translateX(-50%) scale(.96) !important; }
.compare-hint svg { width: 15px; height: 15px; }
.compare-hint[aria-pressed="true"] { color: #18130c; background: var(--gold); }
.edit-dock { position: absolute; z-index: 7; right: 0; bottom: 0; left: 0; display: grid; grid-template-columns: 1fr 50px; gap: 8px; align-items: center; padding: 12px 14px calc(var(--safe-bottom) + 8px); border-top: 1px solid #d2cfc6; background: rgba(242,241,236,.92); backdrop-filter: blur(20px); }
.edit-dock > button:first-child { height: 48px; padding: 0 16px; overflow: hidden; border: 0; border-radius: 24px; color: #68645e; background: #e3e1da; text-align: left; text-overflow: ellipsis; white-space: nowrap; }
.edit-dock .icon-button { width: 50px; height: 50px; color: #17120a; background: var(--gold); }
.edit-dismiss { position: absolute; z-index: 9; inset: 0; padding: 0; border: 0; background: transparent; }
.edit-panel { position: absolute; z-index: 10; right: 10px; bottom: calc(var(--safe-bottom) + 8px); left: 10px; padding: 8px 9px 10px; border-radius: 22px; color: white; box-shadow: 0 16px 48px rgba(0,0,0,.34); transform-origin: center bottom; animation: panel-arrive 260ms cubic-bezier(.2,.8,.2,1) both; }
@keyframes panel-arrive { from { opacity: 0; transform: translateY(10px) scale(.985); backdrop-filter: blur(8px); } }
.edit-handle { width: 28px; height: 3px; margin: 0 auto 7px; border-radius: 2px; background: rgba(255,255,255,.34); }
.suggestions { display: flex; gap: 8px; margin-bottom: 7px; overflow-x: auto; scrollbar-width: none; }
.suggestions::-webkit-scrollbar { display: none; }
.suggestions button { flex: 0 0 auto; min-height: 44px; padding: 0 13px; border: 1px solid rgba(255,255,255,.2); border-radius: 22px; color: rgba(255,255,255,.82); background: rgba(255,255,255,.06); font-size: 11px; }
.suggestions button.selected { color: #17120a; border-color: var(--gold); background: var(--gold); }
.edit-row { display: grid; grid-template-columns: 1fr 44px 44px; gap: 6px; align-items: center; padding: 3px 3px 3px 14px; border: 1px solid rgba(255,255,255,.22); border-radius: 26px; background: rgba(0,0,0,.24); }
.edit-row input { min-width: 0; height: 44px; padding: 0; border: 0; outline: 0; color: white; background: transparent; font-size: 16px; }
.edit-row input::placeholder { color: rgba(255,255,255,.5); }
.edit-row .icon-button { width: 44px; height: 44px; }
.mic-button.listening::after { content: ""; position: absolute; inset: -5px; border: 1px solid var(--gold); border-radius: 50%; animation: pulse 1s ease-out infinite; }
.mic-button.transcribing svg, [data-action="submit-edit"] svg[data-lucide="loader-circle"], .delete-sheet .danger svg[data-lucide="loader-circle"] { animation: spin 900ms linear infinite; }
@keyframes pulse { to { transform: scale(1.22); opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }

.library-screen { background: #111; }
.library-backdrop { position: absolute; inset: -35px; width: calc(100% + 70px); height: calc(100% + 70px); object-fit: cover; filter: blur(30px) brightness(.32) saturate(.8); transform: scale(1.08); }
.library-screen::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to bottom, rgba(0,0,0,.18), transparent 38%, rgba(0,0,0,.5)); pointer-events: none; }
.library-title { position: absolute; z-index: 5; top: var(--safe-top); right: 17px; left: 17px; display: flex; align-items: center; justify-content: space-between; }
.library-title h1 { margin: 0; font-family: "Songti SC", serif; font-size: 24px; font-weight: 600; }
.library-title span { color: rgba(255,255,255,.66); font-size: 10px; font-variant-numeric: tabular-nums; }
.task-toast { position: absolute; z-index: 8; top: calc(var(--safe-top) + 42px); left: 50%; min-height: 44px; display: flex; align-items: center; gap: 8px; padding: 0 14px; border-radius: 22px; color: white; transform: translateX(-50%); white-space: nowrap; font-size: 11px; }
.task-toast:active { transform: translateX(-50%) scale(.96) !important; }
.task-toast i { width: 7px; height: 7px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 3px rgba(215,163,85,.17); }
.library-stack { position: absolute; z-index: 4; top: calc(var(--safe-top) + 62px); right: 0; bottom: calc(var(--safe-bottom) + 68px); left: 0; perspective: 1200px; touch-action: pan-y; }
.library-stack.has-task { top: calc(var(--safe-top) + 96px); }
.work-card { position: absolute; top: 0; left: 50%; width: min(72vw, 310px); height: min(66dvh, 560px); overflow: hidden; padding: 0; border: 1px solid rgba(255,255,255,.28); border-radius: 22px; background: #242321; box-shadow: 0 24px 60px rgba(0,0,0,.42); transform-origin: center bottom; will-change: transform, opacity, filter; }
.work-card > img { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.work-card-backdrop { object-fit: cover; filter: blur(22px) brightness(.62) saturate(.78); transform: scale(1.12); }
.work-card-photo { object-fit: contain; }
.work-card footer { position: absolute; right: 0; bottom: 0; left: 0; display: flex; align-items: end; justify-content: space-between; min-height: 84px; padding: 28px 16px 15px; background: linear-gradient(to bottom, transparent, rgba(0,0,0,.76)); }
.work-card footer strong { font-family: "Songti SC", serif; font-size: 16px; }
.work-card footer small { color: rgba(255,255,255,.72); font-size: 10px; }
.library-dots { position: absolute; z-index: 6; bottom: calc(var(--safe-bottom) + 58px); left: 50%; min-height: 20px; display: flex; align-items: center; gap: 5px; transform: translateX(-50%); }
.library-dots i { width: 5px; height: 5px; border-radius: 50%; background: rgba(255,255,255,.28); }
.library-dots i.active { background: white; transform: scale(1.35); }
.library-dots span { color: rgba(255,255,255,.7); font-size: 10px; font-variant-numeric: tabular-nums; }
.bottom-nav { position: absolute; z-index: 7; bottom: var(--safe-bottom); left: 50%; width: 72px; min-height: 58px; display: grid; place-items: center; padding: 5px; border-radius: 29px; transform: translateX(-50%); }
.bottom-nav:active { transform: translateX(-50%) !important; }
.mini-shutter { width: 46px; height: 46px; display: grid; place-items: center; padding: 0; border: 2px solid white; border-radius: 50%; background: transparent; }
.mini-shutter::after { content: ""; width: 32px; height: 32px; border-radius: 50%; background: white; }
.empty-library { position: absolute; z-index: 4; inset: 0; display: grid; place-content: center; justify-items: center; gap: 10px; color: rgba(255,255,255,.64); }
.empty-library svg { width: 32px; height: 32px; }
.empty-library p { margin: 0; font-size: 12px; }

.fullscreen { position: absolute; z-index: 20; inset: 0; display: grid; place-items: center; overflow: hidden; background: #030303; touch-action: none; }
.fullscreen > img { width: 100%; height: 100%; object-fit: contain; transform-origin: center; pointer-events: none; will-change: transform; }
.fullscreen-bar { position: absolute; z-index: 2; top: 0; right: 0; left: 0; display: grid; grid-template-columns: 96px 1fr 96px; align-items: center; padding: calc(var(--safe-top) + 2px) 16px 16px; background: linear-gradient(to bottom, rgba(0,0,0,.68), transparent); }
.fullscreen-bar > strong { justify-self: center; font-size: 12px; }
.fullscreen-actions { display: flex; justify-content: flex-end; gap: 8px; }
.delete-confirm { position: absolute; z-index: 4; inset: 0; display: flex; align-items: flex-end; justify-content: center; padding: 16px 12px calc(var(--safe-bottom) + 8px); background: rgba(0,0,0,.5); touch-action: manipulation; }
.delete-sheet { width: min(100%, 420px); padding: 20px; border-radius: 22px; color: white; box-shadow: 0 24px 72px rgba(0,0,0,.5); animation: delete-arrive 280ms cubic-bezier(.2,.8,.2,1) both; }
@keyframes delete-arrive { from { opacity: 0; transform: translateY(18px) scale(.98); } }
.delete-sheet h2 { margin: 0 0 6px; font-size: 17px; }
.delete-sheet p { margin: 0 0 18px; color: rgba(255,255,255,.7); font-size: 13px; line-height: 1.5; }
.delete-sheet > div { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.delete-sheet button { min-height: 48px; display: flex; align-items: center; justify-content: center; gap: 7px; border: 0; border-radius: 24px; color: white; background: rgba(255,255,255,.1); }
.delete-sheet button svg { width: 17px; height: 17px; }
.delete-sheet button.danger { color: white; background: #b83d38; }

.error-banner { position: absolute; z-index: 30; top: calc(var(--safe-top) + 50px); right: 14px; left: 14px; min-height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 8px 8px 14px; border: 1px solid rgba(255,255,255,.2); border-radius: 12px; color: white; background: rgba(94,34,28,.9); backdrop-filter: blur(18px); font-size: 12px; }
.error-banner button { border: 0; color: white; background: transparent; }
.mode-badge { position: absolute; z-index: 30; top: calc(var(--safe-top) + 10px); left: 68px; padding: 5px 7px; border-radius: 6px; color: rgba(255,255,255,.68); background: rgba(0,0,0,.42); font-size: 9px; pointer-events: none; }

@media (max-height: 600px) {
  .camera-actions { min-height: 132px; padding-top: 16px; }
  .ai-strength { bottom: calc(var(--safe-bottom) + 116px); }
  .result-stage { top: calc(var(--safe-top) + 52px); bottom: 92px; }
  .edit-dock { padding-top: 8px; }
  .library-stack { top: calc(var(--safe-top) + 54px); bottom: calc(var(--safe-bottom) + 62px); }
  .library-stack.has-task { top: calc(var(--safe-top) + 88px); }
  .work-card { height: min(64dvh, 430px); }
}

@media (min-width: 700px) and (min-height: 560px) {
  body { background: #11110f; }
  .app-shell { width: 430px; height: min(920px, 96dvh); margin-top: 2dvh; border: 1px solid #30302d; border-radius: 36px; }
}

@media (orientation: landscape) and (max-height: 500px) {
  :root { --safe-top: max(8px, env(safe-area-inset-top)); --safe-bottom: max(8px, env(safe-area-inset-bottom)); }
  .app-shell { width: 100vw; height: 100dvh; margin: 0; border: 0; border-radius: 0; }
  .topbar { min-height: 54px; padding-top: var(--safe-top); }
  .camera-actions { min-height: 118px; padding: 12px 24px calc(var(--safe-bottom) + 10px); }
  .ai-strength { bottom: calc(var(--safe-bottom) + 102px); }
  .result-stage { top: calc(var(--safe-top) + 50px); right: 88px; bottom: 12px; left: 88px; }
  .edit-dock { top: 50%; right: 12px; bottom: auto; left: auto; width: 64px; display: grid; grid-template-columns: 1fr; gap: 8px; padding: 8px; border: 1px solid rgba(0,0,0,.08); border-radius: 32px; transform: translateY(-50%); }
  .edit-dock > button:first-child { display: none; }
  .edit-panel { right: auto; bottom: calc(var(--safe-bottom) + 6px); left: 50%; width: min(560px, calc(100vw - 24px)); transform: translateX(-50%); }
  @keyframes panel-arrive { from { opacity: 0; transform: translateX(-50%) translateY(10px) scale(.985); backdrop-filter: blur(8px); } }
  .library-title { top: var(--safe-top); }
  .task-toast { top: calc(var(--safe-top) + 34px); }
  .library-stack { top: calc(var(--safe-top) + 48px); bottom: calc(var(--safe-bottom) + 54px); }
  .library-stack.has-task { top: calc(var(--safe-top) + 76px); }
  .work-card { width: min(46vw, 380px); height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 104px); }
  .library-dots { bottom: calc(var(--safe-bottom) + 50px); }
  .bottom-nav { bottom: var(--safe-bottom); width: 64px; min-height: 54px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}

@media (prefers-reduced-transparency: reduce) {
  .glass, .icon-button, .edit-dock, .compare-hint, .task-toast, .bottom-nav { backdrop-filter: none; }
  .glass, .bottom-nav { background: #232321; }
  .edit-dock { background: var(--paper); }
}

@media (prefers-contrast: more) {
  .glass, .icon-button, .compare-hint, .bottom-nav { border-color: rgba(255,255,255,.62); background-color: rgba(8,8,8,.9); }
  .result-caption small, .library-title span, .work-card footer small { color: currentColor; opacity: .82; }
}
