:root {
  --red: #a4161a;
  --green: #1b4332;
  --green-light: #2d6a4f;
  --gold: #e9c46a;
  --gold-bright: #ffd97d;
  --cream: #fff6e9;
  --ink: #241a12;
  --card: #ffffff;
  --line: #eadfce;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font-family: "Nunito", system-ui, sans-serif;
  background: #f4efe4;
  color: var(--ink);
  min-height: 100vh;
}

/* ---------- Login ---------- */
.login {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 1.2rem;
  background: radial-gradient(1000px 600px at 50% -10%, #2d6a4f, #1b4332 60%, #12301f);
}
.login-card {
  background: var(--card); border-radius: 26px; padding: 2.2rem 1.6rem;
  width: 100%; max-width: 420px; text-align: center;
  box-shadow: 0 24px 60px rgba(0,0,0,.3);
}
.logo { font-size: 3.2rem; }
.login-card h1 { font-family: "Fraunces", serif; font-weight: 900; margin: .4rem 0; color: var(--red); font-size: 1.9rem; }
.login-card p { color: #6b5d4d; margin: .3rem 0 1.3rem; }
#loginForm { display: flex; flex-direction: column; gap: .8rem; }
input[type=password], input[type=text] {
  font: inherit; font-size: 1.15rem; padding: 1rem 1.1rem;
  border: 2px solid var(--line); border-radius: 14px; width: 100%;
  background: #fff;
}
input:focus { outline: none; border-color: var(--green-light); }
button {
  font: inherit; font-weight: 800; font-size: 1.15rem; cursor: pointer;
  border: none; border-radius: 14px; padding: 1rem 1.2rem;
  background: var(--green-light); color: #fff;
}
button:active { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: default; }
.err { color: var(--red); font-weight: 700; min-height: 1.2em; margin: .6rem 0 0; }
.back { display: inline-block; margin-top: 1rem; color: var(--green-light); text-decoration: none; font-weight: 800; }

/* ---------- App ---------- */
.abar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.1rem; background: var(--green); color: var(--cream);
  position: sticky; top: 0; z-index: 10;
  box-shadow: 0 4px 16px rgba(0,0,0,.2);
}
.abar h1 { font-family: "Fraunces", serif; font-size: 1.4rem; margin: 0; }
.ghost {
  background: rgba(255,255,255,.15); color: inherit; padding: .6rem 1rem; font-size: 1rem;
}

.previewrow { padding: 1rem 1.1rem 0; max-width: 760px; margin: 0 auto; }
.switch { display: flex; align-items: center; gap: .7rem; cursor: pointer; font-weight: 700; }
.switch input { display: none; }
.track { width: 54px; height: 32px; border-radius: 999px; background: #cbbfaa; position: relative; flex: none; transition: background .2s; }
.knob { position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; transition: left .2s; box-shadow: 0 2px 4px rgba(0,0,0,.3); }
.switch input:checked + .track { background: var(--green-light); }
.switch input:checked + .track .knob { left: 25px; }
.switch .lbl { font-size: 1rem; }

/* ---------- Door grid ---------- */
.doorgrid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: .8rem;
  padding: 1rem 1.1rem 3rem; max-width: 760px; margin: 0 auto;
}
@media (max-width: 420px) { .doorgrid { grid-template-columns: repeat(3, 1fr); } }
.dbox {
  aspect-ratio: 1/1; border-radius: 16px; border: 2px solid var(--line);
  background: #fff; cursor: pointer; position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-family: "Fraunces", serif; font-weight: 900; color: var(--green);
  box-shadow: 0 3px 8px rgba(0,0,0,.06);
}
.dbox:active { transform: scale(.97); }
.dbox .d { font-size: 2rem; line-height: 1; }
.dbox .c {
  font-family: "Nunito"; font-weight: 800; font-size: .82rem; margin-top: .3rem;
  color: #fff; background: var(--gold); padding: .12rem .55rem; border-radius: 999px;
}
.dbox.empty { color: #b9ab96; border-style: dashed; }
.dbox.empty .c { background: #ddd2bf; color: #7a6c58; }
.dbox.filled { border-color: var(--green-light); background: linear-gradient(160deg,#fff,#eef6f0); }
.dbox .thumb { position:absolute; inset:0; border-radius:14px; object-fit:cover; width:100%; height:100%; opacity:.22; }
.dbox > * { position: relative; }

/* ---------- Sheet ---------- */
.sheet {
  position: fixed; inset: 0; z-index: 40; display: flex; align-items: flex-end; justify-content: center;
  background: rgba(20,15,8,.5);
}
.sheet-card {
  background: #fdf8ee; width: 100%; max-width: 620px; max-height: 92vh; overflow-y: auto;
  border-radius: 24px 24px 0 0; padding: 1.2rem 1.1rem 2rem;
  animation: up .25s ease;
}
@media (min-width: 640px){ .sheet{align-items:center} .sheet-card{border-radius:24px} }
@keyframes up { from { transform: translateY(100%) } to { transform: translateY(0) } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .8rem; }
.sheet-head h2 { font-family: "Fraunces", serif; color: var(--red); margin: 0; font-size: 1.5rem; }
.sheet-head .ghost { background: #eadfce; color: var(--ink); }

.items { display: flex; flex-direction: column; gap: .7rem; margin-bottom: 1.1rem; }
.item { display: flex; gap: .8rem; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: .6rem; }
.item .media { width: 64px; height: 64px; border-radius: 10px; object-fit: cover; flex: none; background: #000; }
.item .meta { flex: 1; min-width: 0; }
.item .meta .cap { font-weight: 700; }
.item .meta .sub { font-size: .82rem; color: #8a7b66; }
.item .del { background: #fbe8e8; color: var(--red); padding: .5rem .8rem; font-size: .95rem; flex: none; }
.empty-note { color: #8a7b66; text-align: center; padding: .6rem; font-weight: 700; }

/* ---------- Uploader ---------- */
.uploader { display: flex; flex-direction: column; gap: .7rem; border-top: 2px dashed var(--line); padding-top: 1rem; }
.drop { display: block; border: 3px dashed var(--green-light); border-radius: 16px; padding: 1.4rem; text-align: center; cursor: pointer; background: #fff; }
.drop:active { background: #f0f6f2; }
.drop-inner { display: flex; flex-direction: column; align-items: center; gap: .3rem; color: var(--green-light); font-weight: 800; }
.plus { font-size: 2.4rem; line-height: 1; }
.preview { border-radius: 14px; overflow: hidden; }
.preview img, .preview video { width: 100%; max-height: 240px; object-fit: contain; background:#000; display:block; border-radius: 14px; }
.bar { height: 10px; background: #e7dcc9; border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: var(--green-light); transition: width .15s; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 1.4rem; transform: translateX(-50%);
  background: var(--green); color: var(--cream); padding: .9rem 1.5rem; border-radius: 999px;
  font-weight: 800; z-index: 60; box-shadow: 0 10px 30px rgba(0,0,0,.3); max-width: 92vw; text-align:center;
}
