:root {
  --bg: #0c0d10;
  --panel: #15171c;
  --panel-2: #1b1e25;
  --line: rgba(255,255,255,0.07);
  --line-2: rgba(255,255,255,0.12);
  --text: #ece9e2;
  --muted: #8a8f99;
  --faint: #5b6783;
  --gold: #e7b54a;
  --gold-soft: rgba(231,181,74,0.14);
  --red: #c0392b;
  --green: #46d39a;
  --radius: 16px;
  --font: -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font); color: var(--text); background: var(--bg);
  min-height: 100vh; -webkit-font-smoothing: antialiased;
}

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top));
  background: rgba(12,13,16,0.92); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.icon-btn {
  width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--line-2);
  background: var(--panel-2); color: var(--text); font-size: 18px; cursor: pointer;
}
.brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.brand .paws { font-size: 22px; filter: drop-shadow(0 0 6px var(--gold-soft)); }
.brand-txt { line-height: 1.15; min-width: 0; }
.brand-txt b { font-size: 16px; letter-spacing: 1px; }
.brand-txt span { display: block; font-size: 12px; color: var(--gold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.save-dot { color: var(--muted); font-size: 12px; transition: color .3s; }
.save-dot.saving { color: var(--gold); }
.save-dot.saved { color: var(--green); }

/* Drawer */
.drawer {
  position: fixed; top: 0; left: 0; bottom: 0; width: 270px; z-index: 40;
  background: var(--panel); border-right: 1px solid var(--line);
  transform: translateX(-100%); transition: transform .25s ease;
  display: flex; flex-direction: column; padding-top: max(14px, env(safe-area-inset-top));
}
.drawer.open { transform: translateX(0); }
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 35; opacity: 0; pointer-events: none; transition: opacity .25s; }
.scrim.show { opacity: 1; pointer-events: auto; }
#nav { flex: 1; overflow-y: auto; padding: 8px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 13px 14px; border-radius: 12px; border: 0; background: transparent;
  color: var(--text); font-size: 15px; font-family: inherit; cursor: pointer; text-align: left;
}
.nav-item .nemoji { font-size: 18px; width: 24px; text-align: center; }
.nav-item.active { background: var(--gold-soft); color: var(--gold); border: 1px solid var(--gold-soft); }
.drawer-foot { padding: 14px; color: var(--muted); font-style: italic; font-size: 13px; border-top: 1px solid var(--line); text-align: center; }

/* Main */
.main { padding: 16px; padding-bottom: 60px; max-width: 760px; margin: 0 auto; }
.loading { color: var(--muted); text-align: center; padding: 60px 0; }
.section-title { display: flex; align-items: center; gap: 8px; color: var(--gold); font-weight: 700; letter-spacing: 1px; text-transform: uppercase; font-size: 14px; margin: 4px 0 14px; }
.hint { color: var(--muted); font-size: 12.5px; }

.banner {
  background: linear-gradient(180deg, #7a241c, #5e1c16); color: #ffe6e0;
  border: 1px solid rgba(255,255,255,0.12); border-radius: var(--radius);
  padding: 14px 16px; text-align: center; font-weight: 600; font-size: 13px; margin-bottom: 16px;
}

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.row { display: flex; align-items: center; gap: 12px; padding: 14px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 14px; margin-bottom: 10px; }
.row .r-emoji { width: 40px; height: 40px; display: grid; place-items: center; background: #0f1115; border-radius: 11px; font-size: 19px; border: 1px solid var(--line); }
.row .r-label { flex: 1; font-size: 15px; }
.row .r-sub { color: var(--muted); font-size: 12px; }

/* Switch */
.switch { position: relative; width: 52px; height: 30px; flex-shrink: 0; }
.switch input { display: none; }
.switch .track { position: absolute; inset: 0; background: #2a2d35; border-radius: 999px; transition: background .2s; }
.switch .thumb { position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: left .2s; }
.switch input:checked + .track { background: linear-gradient(180deg, #f0c662, var(--gold)); }
.switch input:checked + .track + .thumb { left: 25px; }

label.field { display: block; margin: 14px 0 6px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .6px; }
input.inp, textarea.inp, select.inp {
  width: 100%; background: #0f1115; color: var(--text); border: 1px solid var(--line-2);
  border-radius: 12px; padding: 12px 14px; font-family: inherit; font-size: 15px;
}
textarea.inp { min-height: 110px; resize: vertical; }
.num-row { display: flex; align-items: center; justify-content: space-between; }
.num-row input { width: 90px; text-align: center; }

.btn { border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text); border-radius: 12px; padding: 11px 16px; font-family: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.btn.gold { background: linear-gradient(180deg, #f0c662, var(--gold)); color: #2a200a; border: 0; }
.btn.red { color: #ff8a7a; border-color: rgba(192,57,43,.4); background: transparent; }
.btn.block { width: 100%; }

.trigger-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 12px; }
.trigger-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.trigger-head b { flex: 1; }

/* Log */
.logrow { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 11px 14px; margin-bottom: 8px; font-size: 14px; }
.logrow .logid { color: var(--muted); font-size: 12.5px; }
.logrow .logtime { color: var(--faint); font-size: 11.5px; margin-top: 3px; }
.section-title button { margin-left: auto; }

/* Photo upload */
.photo-box { display: flex; flex-direction: column; gap: 10px; }
.photo-prev { width: 100%; max-height: 200px; object-fit: cover; border-radius: 12px; border: 1px solid var(--line-2); background: #0f1115; }
.photo-actions { display: flex; gap: 10px; }
.photo-actions .btn { flex: 1; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #20242c; color: var(--text); border: 1px solid var(--line-2);
  padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 60;
}
