:root {
  --bg: #eef5f1;
  --surface: #ffffff;
  --surface-soft: #f8fbfa;
  --ink: #13202c;
  --muted: #657582;
  --line: rgba(19, 32, 44, .12);
  --brand: #0f7d5c;
  --brand-dark: #0a5c45;
  --accent: #d9b66f;
  --danger: #b63a3a;
  --shadow: 0 24px 80px rgba(13, 38, 54, .14);
  --radius-xl: 30px;
  --radius-lg: 22px;
  --radius-md: 16px;
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 0%, rgba(217, 182, 111, .28), transparent 30rem),
    radial-gradient(circle at 84% 4%, rgba(15, 125, 92, .18), transparent 34rem),
    linear-gradient(135deg, #edf6f2, #ffffff 48%, #edf6f2);
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; touch-action: manipulation; }
img { max-width: 100%; display: block; }
a.btn { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.app-shell { width: min(1540px, calc(100% - 28px)); margin: 18px auto 34px; }
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 18px 20px; margin-bottom: 16px;
  border: 1px solid var(--line); border-radius: var(--radius-xl);
  background: rgba(255,255,255,.78); backdrop-filter: blur(18px);
  box-shadow: 0 12px 34px rgba(15, 38, 52, .08);
}
.brand-mark {
  width: 56px; height: 56px; display: grid; place-items: center; flex: 0 0 auto;
  border-radius: 18px; color: #fff; font-weight: 950; letter-spacing: .04em;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  box-shadow: inset 0 -10px 18px rgba(0,0,0,.12), 0 14px 24px rgba(15,125,92,.20);
}
.brand-mark.big { width: 72px; height: 72px; border-radius: 24px; margin: 0 auto 14px; font-size: 1.25rem; }
.topbar h1 { margin: 0; line-height: 1.05; font-size: clamp(1.35rem, 2.2vw, 2.1rem); }
.eyebrow { margin: 0 0 4px; color: var(--brand); font-size: .75rem; letter-spacing: .13em; text-transform: uppercase; font-weight: 850; }
.top-actions { margin-left: auto; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.ghost-link {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); color: var(--ink); background: rgba(255,255,255,.82);
  text-decoration: none; padding: 10px 13px; border-radius: 999px; font-weight: 850;
}
.ghost-link:hover { border-color: rgba(15,125,92,.35); color: var(--brand); }
.notice {
  margin: 0 0 16px; padding: 13px 16px;
  border: 1px solid rgba(15,125,92,.18); border-radius: 20px;
  background: rgba(255,255,255,.72); color: var(--muted);
  box-shadow: 0 10px 28px rgba(15,38,52,.06);
}
.notice strong { color: var(--ink); }
.workspace { display: grid; grid-template-columns: minmax(360px,.95fr) minmax(330px,.7fr) minmax(360px,.95fr); gap: 16px; align-items: start; }
.panel { border: 1px solid var(--line); border-radius: var(--radius-xl); background: rgba(255,255,255,.84); box-shadow: var(--shadow); overflow: hidden; }
.camera-card, .settings-card, .result-card, .admin-form, .admin-preview-panel { padding: 18px; }
.panel-title, .camera-header, .row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.panel-title h2, .camera-header h2 { margin: 0; font-size: 1.15rem; }
.status-pill { display: inline-flex; align-items: center; white-space: nowrap; padding: 7px 11px; border-radius: 999px; color: var(--brand); background: rgba(15,125,92,.10); border: 1px solid rgba(15,125,92,.16); font-weight: 850; font-size: .78rem; }
.status-pill.bad { color: var(--danger); background: rgba(182,58,58,.10); border-color: rgba(182,58,58,.16); }
.camera-stage { position: relative; min-height: 420px; border-radius: 26px; overflow: hidden; background: linear-gradient(135deg, #112b37, #0c171f); border: 1px solid rgba(255,255,255,.16); display: grid; place-items: center; }
.camera-stage video { width: 100%; height: 100%; min-height: 420px; object-fit: cover; display: block; }
.camera-stage video.mirror { transform: scaleX(-1); }
.stage-empty, .result-empty { position: absolute; inset: 0; display: grid; place-items: center; align-content: center; gap: 10px; padding: 30px; text-align: center; color: rgba(255,255,255,.88); background: radial-gradient(circle at center, rgba(255,255,255,.08), transparent 22rem); }
.stage-empty span, .result-empty span { color: rgba(255,255,255,.62); max-width: 28rem; }
.result-empty.light { position: static; min-height: 280px; color: var(--ink); background: #f5faf8; border-radius: 20px; }
.result-empty.light span { color: var(--muted); }
.camera-icon { font-size: 3rem; }
.countdown { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; color: #fff; background: rgba(5,12,18,.52); font-size: clamp(5rem, 12vw, 10rem); font-weight: 950; text-shadow: 0 18px 40px rgba(0,0,0,.35); }
.shot-tracker { min-height: 34px; display: flex; gap: 8px; justify-content: center; align-items: center; padding: 10px 0 4px; }
.shot-dot { width: 12px; height: 12px; border-radius: 999px; background: rgba(19,32,44,.18); box-shadow: inset 0 0 0 1px rgba(19,32,44,.09); }
.shot-dot.done { background: var(--brand); }
.shot-dot.active { background: var(--accent); transform: scale(1.18); }
.primary-actions, .admin-actions { display: flex; gap: 10px; margin-top: 14px; }
.wrap { flex-wrap: wrap; }
.center { justify-content: center; }
.btn { border: 0; border-radius: 16px; padding: 12px 15px; font-weight: 900; color: var(--ink); background: #e9efec; box-shadow: 0 8px 18px rgba(13,38,54,.08); }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn.primary { color: #fff; background: linear-gradient(135deg, var(--brand), var(--brand-dark)); }
.btn.accent { color: #241c0a; background: linear-gradient(135deg, #f0d28b, var(--accent)); }
.btn.muted { background: #eef3f1; }
.btn.danger { color: #fff; background: var(--danger); }
.btn.full { width: 100%; justify-content: center; }
.helper-note { margin-top: 12px; padding: 12px 13px; color: var(--muted); background: rgba(15,125,92,.07); border: 1px dashed rgba(15,125,92,.25); border-radius: 18px; font-size: .92rem; line-height: 1.45; }
.helper-note strong { color: var(--ink); }
.field, .admin-field { display: grid; gap: 7px; margin-bottom: 12px; }
.field span, .admin-field span, .upload-card span { color: var(--muted); font-size: .84rem; font-weight: 850; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 15px; padding: 11px 12px; color: var(--ink); background: rgba(255,255,255,.86); outline: none; }
textarea { resize: vertical; min-height: 86px; }
input[type="color"] { height: 46px; padding: 5px; }
input:focus, select:focus, textarea:focus { border-color: rgba(15,125,92,.42); box-shadow: 0 0 0 4px rgba(15,125,92,.10); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.upload-card { display: grid; gap: 8px; padding: 12px; border: 1px dashed rgba(19,32,44,.22); border-radius: 18px; background: var(--surface-soft); }
.upload-card input { padding: 8px; background: #fff; }
.switch-row { display: flex; flex-wrap: wrap; gap: 10px 16px; margin: 6px 0 12px; color: var(--muted); font-weight: 800; }
.switch-row input { width: auto; margin-right: 6px; }
.result-stage { position: relative; min-height: 420px; border-radius: 26px; overflow: hidden; background: linear-gradient(135deg, #101b24, #071016); display: grid; place-items: center; padding: 14px; }
.result-stage img { max-height: 650px; width: auto; border-radius: 18px; box-shadow: 0 18px 50px rgba(0,0,0,.28); }
.result-empty { color: rgba(255,255,255,.88); }
.result-empty span { color: rgba(255,255,255,.62); }
.share-box { display: flex; align-items: center; gap: 12px; margin-top: 14px; padding: 12px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface-soft); }
.share-box p { margin: 3px 0 8px; color: var(--muted); }
.share-content { min-width: 0; flex: 1; }
.qr-preview { flex: 0 0 auto; padding: 8px; background: #fff; border: 1px solid var(--line); border-radius: 18px; }
.qr-preview canvas { display: block; width: 148px; height: 148px; }
.gallery-dialog { width: min(1120px, calc(100% - 24px)); border: 0; border-radius: 28px; padding: 0; background: #fff; box-shadow: 0 28px 90px rgba(0,0,0,.25); }
.gallery-dialog::backdrop { background: rgba(5,13,18,.55); backdrop-filter: blur(8px); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.dialog-head h2 { margin: 0; }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 999px; background: #fff; font-size: 1.6rem; line-height: 1; }
.gallery-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; max-height: min(72vh, 780px); overflow: auto; padding: 18px; }
.gallery-card { border: 1px solid var(--line); border-radius: 20px; overflow: hidden; background: var(--surface-soft); }
.gallery-card img { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; background: #101820; }
.gallery-meta { padding: 12px; }
.gallery-meta strong { display: block; margin-bottom: 3px; }
.gallery-meta span { color: var(--muted); font-size: .86rem; overflow-wrap: anywhere; }
.gallery-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.gallery-actions .btn { flex: 1; padding: 9px 10px; border-radius: 13px; font-size: .86rem; }
.empty-gallery { grid-column: 1 / -1; padding: 44px 20px; color: var(--muted); text-align: center; }
.admin-layout { display: grid; grid-template-columns: minmax(340px, 1fr) minmax(340px, 1fr); gap: 16px; align-items: start; }
.span-2 { grid-column: 1 / -1; }
.admin-preview { min-height: 440px; border-radius: 24px; background: linear-gradient(135deg, #102a36, #0c171f); display: grid; place-items: center; padding: 18px; }
.admin-preview img { max-height: 650px; border-radius: 18px; box-shadow: 0 18px 45px rgba(0,0,0,.24); }
.template-list { display: grid; gap: 10px; }
.template-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 17px; background: var(--surface-soft); }
.template-swatch { width: 28px; height: 28px; border-radius: 10px; flex: 0 0 auto; background: linear-gradient(135deg, var(--brand), var(--accent)); }
.template-info { display: flex; align-items: center; gap: 10px; min-width: 0; }
.template-info strong { display: block; }
.template-info span { display: block; color: var(--muted); font-size: .86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.download-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.download-card { width: min(740px, 100%); padding: 24px; text-align: center; }
.download-card h1 { margin: 0 0 8px; font-size: clamp(1.7rem, 5vw, 3rem); }
.download-copy { margin: 0 auto 18px; color: var(--muted); max-width: 34rem; line-height: 1.55; }
.download-image-wrap { min-height: 320px; display: grid; place-items: center; border-radius: 24px; background: #102a36; padding: 14px; margin-bottom: 12px; }
.download-image-wrap img { max-height: 70vh; border-radius: 18px; box-shadow: 0 18px 50px rgba(0,0,0,.28); }
.toast { position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; z-index: 80; max-width: min(520px, calc(100% - 24px)); padding: 12px 15px; border-radius: 999px; color: #fff; background: rgba(12, 28, 38, .92); box-shadow: 0 16px 45px rgba(0,0,0,.24); transition: .25s ease; font-weight: 750; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (max-width: 1200px) { .workspace { grid-template-columns: 1fr 1fr; } .settings-card { grid-column: 1 / -1; order: 3; } }
@media (max-width: 840px) {
  .app-shell { width: min(100% - 18px, 1540px); margin-top: 9px; }
  .topbar { align-items: flex-start; flex-wrap: wrap; border-radius: 22px; }
  .top-actions { width: 100%; margin-left: 0; justify-content: flex-start; }
  .workspace, .admin-layout { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .grid-2, .gallery-grid { grid-template-columns: 1fr; }
  .camera-stage, .camera-stage video, .result-stage { min-height: 330px; }
  .primary-actions { flex-wrap: wrap; }
  .btn { flex: 1 1 auto; }
  .share-box { flex-direction: column; align-items: stretch; }
  .qr-preview { align-self: center; }
}
