:root{
  --bg:#faf8fb;
  --surface:#ffffff;
  --surface-2:#f3eef5;
  --border:#e6dfe9;
  --ink:#18141d;
  --muted:#6c6270;
  --accent:#501659;
  --accent-ink:#ffffff;
  --danger:#b3261e;
  --shadow:0 1px 2px rgba(24,20,29,0.04), 0 8px 24px rgba(24,20,29,0.06);
}

@media (prefers-color-scheme: dark){
  :root{
    --bg:#141019;
    --surface:#1c1721;
    --surface-2:#26202c;
    --border:#332b3a;
    --ink:#f1ecf4;
    --muted:#a99dae;
    --accent:#c98fda;
    --accent-ink:#1c1721;
    --shadow:0 1px 2px rgba(0,0,0,0.2), 0 8px 24px rgba(0,0,0,0.3);
  }
}

*{ box-sizing:border-box; }
[hidden]{ display:none !important; }

body{
  margin:0;
  background:var(--bg);
  color:var(--ink);
  font-family:'Inter',Arial,Helvetica,sans-serif;
  font-size:14.5px;
  line-height:1.5;
}

.shell{
  max-width:1080px;
  margin:0 auto;
  padding:32px 24px 64px;
}

.gate{
  position:fixed;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:24px;
  background:var(--bg);
  z-index:100;
}
.gate-card{
  width:100%;
  max-width:320px;
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:14px;
  box-shadow:var(--shadow);
  padding:28px 24px;
  text-align:center;
}
.gate-logo{
  height:30px;
  width:auto;
  margin:0 auto 18px;
  display:block;
}
@media (prefers-color-scheme: dark){
  .gate-logo{ filter:invert(1); }
}
.gate-card h2{
  font-family:'Parkinsans',Arial,sans-serif;
  font-size:18px;
  margin:0 0 8px;
}
.gate-card p{
  margin:0 0 18px;
  color:var(--muted);
  font-size:13px;
  line-height:1.5;
}
#gate-form{
  display:flex;
  flex-direction:column;
  gap:10px;
}
#gateCode{
  font:inherit;
  font-size:14px;
  padding:10px 12px;
  border:1px solid var(--border);
  border-radius:8px;
  background:var(--bg);
  color:var(--ink);
  text-align:center;
}
#gateCode:focus{
  outline:2px solid var(--accent);
  outline-offset:1px;
}
.gate-error{
  margin:12px 0 0;
  color:var(--danger);
  font-size:12.5px;
}

.topbar{
  display:flex;
  align-items:center;
  gap:20px;
  margin-bottom:32px;
}
.brand-logo{
  height:34px;
  width:auto;
  display:block;
}
@media (prefers-color-scheme: dark){
  .brand-logo{ filter:invert(1); }
}
.topbar-text h1{
  font-family:'Parkinsans',Arial,sans-serif;
  font-weight:700;
  font-size:22px;
  margin:0 0 2px;
}
.topbar-text p{
  margin:0;
  color:var(--muted);
  font-size:13.5px;
}

.layout{
  display:grid;
  grid-template-columns:minmax(0,380px) minmax(0,1fr);
  gap:24px;
  align-items:start;
}
@media (max-width:820px){
  .layout{ grid-template-columns:1fr; }
}

.panel{
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:14px;
  box-shadow:var(--shadow);
}

.form-panel{
  padding:22px;
  display:flex;
  flex-direction:column;
  gap:16px;
}

.field{
  display:flex;
  flex-direction:column;
  gap:6px;
}
.field label{
  font-size:12.5px;
  font-weight:600;
  color:var(--ink);
}
.field input{
  font:inherit;
  font-size:14px;
  padding:9px 11px;
  border:1px solid var(--border);
  border-radius:8px;
  background:var(--bg);
  color:var(--ink);
}
.field input:focus{
  outline:2px solid var(--accent);
  outline-offset:1px;
}

.field-group{
  border:1px solid var(--border);
  border-radius:10px;
  padding:14px 14px 4px;
  display:flex;
  flex-direction:column;
  gap:12px;
  margin:0;
}
.field-group legend{
  font-size:12.5px;
  font-weight:600;
  padding:0 4px;
}
.optional{
  font-weight:400;
  color:var(--muted);
}

.photo-picker{
  display:flex;
  gap:14px;
  align-items:flex-start;
}
.photo-preview{
  flex:none;
  width:72px;
  height:72px;
  border-radius:50%;
  background:var(--surface-2);
  border:2px solid var(--accent);
  display:flex;
  align-items:center;
  justify-content:center;
  overflow:hidden;
  font-family:'Parkinsans',Arial,sans-serif;
  font-weight:600;
  font-size:20px;
  color:var(--accent);
}
.photo-preview img{
  width:100%;
  height:100%;
  object-fit:cover;
  display:block;
}
.photo-picker-actions{
  flex:1;
  min-width:0;
}
.photo-picker-actions input[type="file"]{
  font-size:13px;
  max-width:100%;
}
.hint{
  margin:6px 0 0;
  font-size:11.5px;
  color:var(--muted);
}
.upload-status{
  margin:6px 0 0;
  font-size:12px;
  min-height:1.2em;
}
.upload-status.error{ color:var(--danger); }
.upload-status.ok{ color:#2a7a3b; }

.primary-btn{
  margin-top:4px;
  font:inherit;
  font-weight:600;
  font-size:14px;
  color:var(--accent-ink);
  background:var(--accent);
  border:none;
  border-radius:9px;
  padding:11px 16px;
  cursor:pointer;
}
.primary-btn:hover{ filter:brightness(1.06); }
.primary-btn:focus-visible{ outline:2px solid var(--accent); outline-offset:2px; }
.primary-btn:disabled{ opacity:0.6; cursor:not-allowed; }

.preview-panel{
  padding:0;
  overflow:hidden;
  display:flex;
  flex-direction:column;
}
.preview-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:12px 16px;
  border-bottom:1px solid var(--border);
  background:var(--surface-2);
  font-size:12px;
  letter-spacing:0.04em;
  text-transform:uppercase;
  color:var(--muted);
}
.copy-btn{
  font-family:'Inter',Arial,sans-serif;
  font-size:12.5px;
  font-weight:600;
  color:var(--accent);
  background:transparent;
  border:1px solid var(--accent);
  border-radius:7px;
  padding:6px 12px;
  cursor:pointer;
  text-transform:none;
  letter-spacing:0;
}
.copy-btn:hover:not(:disabled){ background:var(--accent); color:var(--accent-ink); }
.copy-btn:disabled{ opacity:0.4; cursor:not-allowed; }

.preview-frame-wrap{
  position:relative;
}
#previewFrame{
  width:100%;
  height:520px;
  border:0;
  display:block;
  background:var(--surface);
}
.preview-empty{
  display:none;
  position:absolute;
  inset:0 24px 24px;
  margin:0;
  color:var(--muted);
  font-size:13.5px;
  text-align:center;
  align-items:center;
  justify-content:center;
  pointer-events:none;
}
.preview-empty:not([hidden]){
  display:flex;
}
