:root {
  color-scheme: light; --bg:#faf8f6; --panel:#fffdfa; --ink:#211b19; --muted:#655d58;
  --border:#ddd5ce; --orange:#ac4608; --orange-wash:#fff0df; --green:#26673b;
  font: 16px/1.5 -apple-system,BlinkMacSystemFont,"PingFang SC","Noto Sans CJK SC",sans-serif;
}
* { box-sizing:border-box; }
body { margin:0; background:var(--bg); color:var(--ink); }
[hidden] { display:none !important; }
main { max-width:640px; margin:auto; padding:22px 16px 36px; }
.page-header { display:flex; gap:14px; align-items:center; margin-bottom:24px; }
h1,h2,p { margin:0; }
h1 { font-size:26px; letter-spacing:-.025em; line-height:1.2; }
h2 { font-size:22px; line-height:1.25; overflow-wrap:anywhere; }
#connection { font-size:14px; color:var(--muted); margin-top:5px; }
#connection b { display:inline-block; width:8px; height:8px; border-radius:50%; margin-right:7px; background:#95867d; }
#connection.online b { background:#2f9b54; }
.brand-icon { width:48px; height:48px; border-radius:15px; background:#ca641e; display:grid; place-items:center; }
.brand-icon i { display:block; width:19px; height:32px; border-radius:7px; border:2px solid white; position:relative; }
.brand-icon i::before,.brand-icon i::after { content:""; position:absolute; left:50%; transform:translateX(-50%); border-radius:50%; }
.brand-icon i::before { top:4px; width:4px; height:4px; background:white; }
.brand-icon i::after { bottom:5px; width:9px; height:9px; border:1px dashed white; }
button,input { font:inherit; color:inherit; }
button { cursor:pointer; }
button:disabled { cursor:default; }
button:focus-visible,input:focus-visible { outline:2px solid #984315; outline-offset:2px; }
.segments { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:8px; }
.segments button,.day { border:1px solid var(--border); background:transparent; border-radius:10px; min-height:42px; padding:4px; font-weight:650; }
.segments button[aria-pressed="true"],.day[aria-pressed="true"],.primary { border-color:var(--orange); background:var(--orange); color:white; }
.search { margin:14px 0; display:flex; align-items:center; gap:11px; min-height:44px; border:1px solid var(--border); border-radius:13px; padding:0 14px; }
.search i { border:2px solid var(--muted); border-radius:50%; height:13px; width:13px; flex:none; position:relative; }
.search i::after { content:""; position:absolute; height:2px; width:7px; bottom:-3px; right:-6px; transform:rotate(45deg); background:var(--muted); }
.search input { width:100%; border:0; background:none; min-height:42px; padding:0; }
.app-row { width:100%; display:flex; align-items:center; text-align:left; gap:12px; background:var(--panel); border:1px solid var(--border); padding:11px 12px; border-radius:13px; min-height:67px; margin-bottom:8px; }
.app-row:not(:disabled):hover { border-color:#dc9267; }
.app-icon { display:grid; flex:0 0 41px; height:41px; place-items:center; border-radius:11px; background:#ece9e6; font-size:18px; font-weight:750; }
.app-row[data-variant=pending] .app-icon,.app-row[data-variant=schedule] .app-icon { color:#87370f; background:#ffe8d4; }
.app-text { display:flex; flex:1; min-width:0; flex-direction:column; }
.app-text strong { font-size:15px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.app-text small,#editor-package,.small { color:var(--muted); font-size:12px; overflow-wrap:anywhere; }
.app-text small { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.badge { padding:3px 8px; background:#eeeae6; color:#514742; border-radius:20px; font-weight:650; font-size:12px; white-space:nowrap; }
.badge[data-color=warm] { color:#8c3507; background:var(--orange-wash); }
.badge[data-color=green] { color:var(--green); background:#e5f3e4; }
.chevron { width:8px; height:8px; border-right:1.5px solid var(--muted); border-top:1.5px solid var(--muted); transform:rotate(45deg); flex:none; }
.app-row:disabled .chevron { visibility:hidden; }
.message { font-size:13px; color:#8c3507; margin:6px 0; }
.message:empty { display:none; }
dialog { width:min(100%,560px); padding:0; margin:auto auto 0; border:1px solid var(--border); border-radius:22px 22px 0 0; background:var(--panel); color:var(--ink); max-width:100%; max-height:90dvh; }
dialog::backdrop { background:rgba(42,30,23,.26); }
#editor-form { padding:12px 17px max(19px,env(safe-area-inset-bottom)); }
.grabber { height:4px; width:32px; border-radius:10px; background:#cec8c4; margin:0 auto 12px; }
.editor-header { display:flex; justify-content:space-between; gap:12px; align-items:start; }
.close,.text-button { background:none; border:0; color:var(--orange); }
.close { font-size:27px; line-height:1; min-height:40px; min-width:40px; color:var(--muted); }
.editor-segments { grid-template-columns:repeat(3,minmax(0,1fr)); margin:15px 0; }
.window { padding:10px 0 12px; border-bottom:1px solid var(--border); }
.times { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
.times label { display:grid; gap:5px; font-size:13px; font-weight:650; }
.times input { width:100%; border:1px solid var(--border); border-radius:9px; background:white; padding:7px; min-height:42px; font-size:16px; }
.days { display:grid; grid-template-columns:repeat(7,minmax(0,1fr)); gap:5px; margin-top:7px; }
.day { min-height:36px; font-size:12px; padding:0; }
.day-label { font-size:13px; font-weight:650; margin-top:10px; }
.text-button { padding:9px 0; font-size:13px; font-weight:650; }
.remove { display:block; margin-left:auto; }
.primary { display:block; width:100%; min-height:46px; border:1px solid var(--orange); border-radius:11px; font-weight:700; margin-top:15px; }
.primary:disabled { opacity:.65; }
main:has(.login:not([hidden])) { max-width:440px; }
.login { border:1px solid var(--border); border-radius:18px; background:var(--panel); padding:24px 18px 18px; text-align:center; }
.login-hint { font-size:14px; color:var(--muted); margin-top:6px; }
.pin-progress { display:flex; justify-content:center; gap:14px; margin:18px 0 3px; }
.pin-progress i { width:16px; height:16px; border:1.5px solid #aa9281; border-radius:50%; }
.pin-progress i.filled { background:var(--orange); border-color:var(--orange); }
.login-message,.login-message:empty { display:block; min-height:24px; margin:5px 0; }
.keypad { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:9px; }
.keypad button { min-height:52px; background:var(--bg); border:1px solid var(--border); border-radius:12px; font-size:22px; font-weight:650; line-height:1; touch-action:manipulation; }
.keypad button:not(:disabled):hover { border-color:#dc9267; }
.keypad button:not(:disabled):active { background:var(--orange-wash); color:var(--orange); }
.keypad button[data-delete] { background:transparent; border-color:transparent; color:var(--orange); }
.keypad[aria-busy="true"] { opacity:.65; }

.overview { display:grid; gap:10px; grid-template-columns:1fr; align-items:start; margin-bottom:10px; }
.quick-panel { background:#f5efe8; border:1px solid var(--border); border-radius:14px; padding:12px; min-width:0; }
.quick-panel h2,.quick-panel summary { font-size:16px; font-weight:720; }
.quick-panel summary { cursor:pointer; }
#active-apps { list-style:none; margin:7px 0 0; padding:0; font-size:13px; overflow-wrap:anywhere; }
#active-apps li { padding:4px 0; }
#active-apps small { display:block; color:var(--muted); }
#active-apps .playing { color:var(--green); }
.favorites-panel { margin-bottom:14px; }
#favorites { display:grid; grid-template-columns:repeat(auto-fit,minmax(min(100%,255px),1fr)); gap:8px; margin-top:8px; }
.favorite-card,.app-entry { background:var(--panel); border:1px solid var(--border); border-radius:12px; min-width:0; }
.favorite-card { padding:7px 9px 10px; }
.favorite-card header { display:flex; align-items:center; gap:5px; }
.favorite-card strong { overflow-wrap:anywhere; font-size:14px; }
.star { border:0; background:none; color:var(--orange); font-size:22px; padding:0; min-width:38px; height:40px; }
.app-entry { display:grid; grid-template-columns:minmax(0,1fr) 42px; align-items:center; margin-bottom:8px; }
.app-row { border:0; margin:0; }
.rule-choices { display:grid; grid-template-columns:1fr 1fr 1.65fr; gap:5px; }
.rule-choices button,.editor-segments button { min-height:38px; border-radius:8px; font-weight:650; font-size:13px; }
[data-choice=allow],[data-kind=allow] { --choice:#356320; --wash:#edf3e8; }
[data-choice=block],[data-kind=block] { --choice:#8d3023; --wash:#f7edeb; }
[data-choice=schedule],[data-kind=schedule] { --choice:#9b420b; --wash:#faf0e6; }
.rule-choices button,.editor-segments button { color:var(--choice); background:var(--wash); border:1px solid var(--choice); }
.rule-choices button[aria-pressed=true],.editor-segments button[aria-pressed=true] { background:var(--choice); border-color:var(--choice); color:white; }
.remote-controls { display:grid; gap:8px; margin-top:10px; }
#tv-frame { display:block; width:100%; border-radius:8px; }
.remote-controls button { border:1px solid var(--border); border-radius:8px; background:var(--panel); min-height:40px; }
.remote-controls button:disabled { opacity:.7; }
.remote-keys { display:grid; grid-template-columns:repeat(3,1fr); gap:6px; }
[data-key=down] { grid-column:2; }
@media (min-width:530px) { .overview { grid-template-columns:1.4fr 1fr; } }
