:root {
  --bg: #121110; --card: #1b1a18; --card2: #232120; --line: #2c2a27;
  --tx: #efe9df; --mu: #8d877d; --ac: #e8dcc4; --warn: #d8a46a;
  --r: 22px; --sat: env(safe-area-inset-top); --sab: env(safe-area-inset-bottom);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--tx); font: 15px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", Inter, system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
body { min-height: 100dvh; overscroll-behavior-y: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, textarea { font: inherit; color: var(--tx); }
svg { display: block; }
main { padding: calc(var(--sat) + 18px) 18px calc(var(--sab) + 96px); max-width: 520px; margin: 0 auto; }
.serif { font-family: ui-serif, "New York", Georgia, serif; }

/* header */
.hd { display: flex; align-items: flex-end; justify-content: space-between; margin: 4px 2px 14px; gap: 12px; }
.hd .k { color: var(--mu); font-size: 13px; letter-spacing: .02em; }
.hd h1 { margin: 2px 0 0; font: 500 32px/1.05 ui-serif, "New York", Georgia, serif; letter-spacing: -.01em; }
.wx { display: flex; align-items: center; gap: 8px; color: var(--tx); font-size: 22px; font-weight: 300; }
.wx svg { width: 30px; height: 30px; stroke: var(--ac); fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.wx small { display: block; color: var(--mu); font-size: 12px; font-weight: 400; text-align: right; }
.hbtns { display: flex; gap: 8px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 12px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px; border-radius: 99px; background: var(--card); border: 1px solid var(--line); font-size: 13px; color: var(--tx); white-space: nowrap; }
.chip.mu { color: var(--mu); }
.chip.on { background: var(--ac); color: #1a1714; border-color: var(--ac); }
.chip.warn { color: var(--warn); border-color: #4a3a28; }

/* flatlay */
.lay { position: relative; border-radius: var(--r); overflow: hidden; background: #6f6a62; box-shadow: 0 10px 40px rgba(0,0,0,.35); aspect-ratio: 3 / 4; }
.lay > svg { width: 100%; height: 100%; }
.lay .pc { cursor: pointer; transition: opacity .3s; }
.lay .pc.dirty { opacity: .35; }
.lay.small { border-radius: 18px; }
.lay .empty { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; gap: 14px; padding: 30px; color: #f3eee6; text-shadow: 0 1px 8px rgba(0,0,0,.3); }
.lay .shade { position: absolute; inset: 0; background: rgba(18,17,16,.35); display: grid; place-items: center; }
.acts { display: flex; justify-content: center; gap: 14px; margin: 16px 0 4px; }
.rb { width: 54px; height: 54px; border-radius: 50%; background: var(--card); border: 1px solid var(--line); display: grid; place-items: center; transition: transform .15s; }
.rb:active { transform: scale(.92); }
.rb svg { width: 22px; height: 22px; fill: none; stroke: var(--tx); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.rb.on svg { fill: #e57c6b; stroke: #e57c6b; }
.rb.sm { width: 40px; height: 40px; }
.rb.sm svg { width: 19px; height: 19px; }
.rb.pri { background: var(--ac); border-color: var(--ac); }
.rb.pri svg { stroke: #1a1714; }
.spin { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* sections */
.sec { margin: 22px 2px 10px; color: var(--mu); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; display: flex; justify-content: space-between; align-items: center; }
.row { display: flex; gap: 10px; overflow-x: auto; padding: 2px 2px 8px; margin: 0 -18px; padding-left: 18px; padding-right: 18px; scrollbar-width: none; }
.row::-webkit-scrollbar { display: none; }

/* tiles */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tile { position: relative; aspect-ratio: 1; border-radius: 18px; background: var(--card); border: 1px solid var(--line); display: grid; place-items: center; padding: 12%; overflow: hidden; transition: transform .15s, opacity .3s; }
.tile:active { transform: scale(.96); }
.tile > img, .tile > svg { position: absolute; left: 13%; top: 13%; width: 74%; height: 74%; object-fit: contain; filter: drop-shadow(0 4px 6px rgba(0,0,0,.35)); }
.tile.off { opacity: .38; border-style: dashed; }
.tile.lau { opacity: .45; }
.tile .b { position: absolute; top: 7px; right: 7px; width: 20px; height: 20px; border-radius: 50%; background: var(--bg); display: grid; place-items: center; }
.tile .b svg { position: static; width: 12px; height: 12px; fill: none; stroke: var(--ac); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; filter: none; }
.tile.pin { border-color: var(--ac); box-shadow: inset 0 0 0 1px var(--ac); }
.row .tile { flex: 0 0 82px; width: 82px; height: 82px; }
.tile.add { border-style: dashed; color: var(--mu); }

/* tabs */
#tabs { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--sab) + 12px); display: flex; gap: 2px; padding: 6px; background: rgba(30,28,26,.86); backdrop-filter: blur(20px) saturate(1.4); -webkit-backdrop-filter: blur(20px) saturate(1.4); border: 1px solid var(--line); border-radius: 99px; z-index: 5; }
#tabs button { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; width: 72px; padding: 7px 0 5px; border-radius: 99px; color: var(--mu); font-size: 10.5px; }
#tabs button.on { color: var(--tx); background: rgba(255,255,255,.07); }
#tabs svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
#lbadge { position: absolute; top: 3px; right: 17px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--ac); color: #1a1714; font: 600 10px/16px system-ui; font-style: normal; }
#lbadge:empty { display: none; }

/* sheet */
#sheet { position: fixed; inset: 0; z-index: 10; }
#sheet .scrim { position: absolute; inset: 0; background: rgba(0,0,0,.5); opacity: 0; transition: opacity .25s; }
#sheet .panel { position: absolute; left: 0; right: 0; bottom: 0; max-height: 92dvh; overflow-y: auto; background: #1a1917; border-radius: 26px 26px 0 0; padding: 8px 20px calc(var(--sab) + 22px); transform: translateY(100%); transition: transform .3s cubic-bezier(.2,.8,.2,1); max-width: 560px; margin: 0 auto; }
#sheet.open .scrim { opacity: 1; }
#sheet.open .panel { transform: none; }
.grip { width: 38px; height: 5px; border-radius: 3px; background: #3a3734; margin: 4px auto 14px; }
.sheet-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.sheet-h h2 { margin: 0; font: 500 22px ui-serif, "New York", Georgia, serif; }

.pv { display: block; width: 62%; margin: 0 auto 16px; aspect-ratio: 1; border-radius: 22px; background: #77716a url(/concrete.jpg) center/cover; display: grid; place-items: center; padding: 10%; position: relative; }
.pv > img, .pv > svg { position: absolute; left: 12%; top: 12%; width: 76%; height: 76%; object-fit: contain; filter: drop-shadow(0 6px 10px rgba(0,0,0,.35)); }
.field { margin: 0 0 14px; }
.field > label { display: block; color: var(--mu); font-size: 12px; margin: 0 0 7px 2px; letter-spacing: .04em; }
.in { width: 100%; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); outline: none; }
.in:focus { border-color: #4a4640; }
textarea.in { resize: none; min-height: 88px; font-size: 14px; }
.seg { display: flex; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 3px; }
.seg button { flex: 1; padding: 9px 0; border-radius: 11px; color: var(--mu); font-size: 14px; }
.seg button.on { background: var(--card2); color: var(--tx); box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.sw { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; }
.sw button { width: 30px; height: 30px; border-radius: 50%; border: 2px solid transparent; box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); }
.sw button.on { border-color: var(--ac); }
.sw label { position: relative; width: 30px; height: 30px; border-radius: 50%; background: conic-gradient(#e66, #ec6, #6c6, #6ce, #66e, #c6e, #e66); overflow: hidden; }
.sw input { position: absolute; inset: 0; opacity: 0; }
.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 15px; border-radius: 16px; background: var(--ac); color: #1a1714; font-weight: 600; font-size: 16px; }
.btn.ghost { background: var(--card); color: var(--tx); border: 1px solid var(--line); font-weight: 500; }
.btn.red { background: transparent; color: #d77a6a; font-weight: 500; }
.btns { display: flex; gap: 10px; margin-top: 8px; }
.btns .btn { flex: 1; }
.big2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.big { aspect-ratio: 1; border-radius: 22px; background: var(--card); border: 1px solid var(--line); display: grid; place-content: center; justify-items: center; gap: 10px; font-size: 15px; }
.big svg { width: 34px; height: 34px; fill: none; stroke: var(--ac); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.line { display: flex; align-items: center; justify-content: space-between; padding: 14px 2px; border-bottom: 1px solid var(--line); gap: 12px; }
.line:last-child { border-bottom: 0; }
.line .t { color: var(--mu); font-size: 13px; }
.ok { color: #9cc79a; }
.mu { color: var(--mu); }
.center { text-align: center; }
.emptyw { display: grid; place-items: center; gap: 10px; padding: 70px 0 40px; color: var(--mu); }
.emptyw svg { width: 46px; height: 46px; fill: none; stroke: var(--mu); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }

#toast { position: fixed; left: 50%; bottom: calc(var(--sab) + 92px); transform: translate(-50%, 20px); background: #2a2826; color: var(--tx); padding: 10px 16px; border-radius: 99px; font-size: 14px; opacity: 0; transition: .25s; pointer-events: none; z-index: 20; white-space: nowrap; }
#toast.on { opacity: 1; transform: translate(-50%, 0); }

.login { min-height: 80dvh; display: grid; place-content: center; gap: 14px; width: min(320px, 86vw); margin: 0 auto; text-align: center; }
.login h1 { font: 500 34px ui-serif, "New York", Georgia, serif; margin: 0 0 8px; }
.fade { animation: fade .35s ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } }
.pvcam { white-space: nowrap; position: absolute; right: 10px; bottom: 10px; display: flex; align-items: center; gap: 6px; padding: 7px 10px; border-radius: 99px; background: rgba(18,17,16,.72); color: var(--tx); font-size: 13px; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.pvcam svg { width: 17px; height: 17px; fill: none; stroke: var(--tx); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; position: static !important; filter: none !important; }
.pvcam b { font-weight: 500; }
.noph { position: absolute; inset: 0; display: grid; place-items: center; }
.noph i { position: absolute; width: 34%; aspect-ratio: 1; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); opacity: .9; }
.noph svg { position: relative; width: 22%; height: 22%; fill: none; stroke: rgba(255,255,255,.85); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; mix-blend-mode: difference; }
.pv .noph i { width: 26%; }
.pv.empty .pvcam { left: 50%; right: auto; bottom: 50%; transform: translate(-50%, 50%); padding: 12px 16px; font-size: 15px; }
input[type=range] { width: 100%; accent-color: var(--ac); }
.big3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.big3 .big { font-size: 14px; }
