:root {
  --bg: #f4f2f7; --card: #ffffff; --ink: #2c2b33; --muted: #7c7a86;
  --line: #e7e4ee; --accent: #9AA3CC; --good: #4a9d6b; --close: #c99a3a; --off: #c0616b;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { width: 100%; max-width: 100%; overflow-x: hidden; margin: 0; }
main, header, .tabbar { max-width: 100%; }
input, select, button, img { max-width: 100%; }
body { margin: 0; font: 15px/1.4 -apple-system, system-ui, sans-serif; color: var(--ink); background: var(--bg);
       padding-bottom: calc(64px + var(--safe-b)); }
header { position: sticky; top: 0; z-index: 5; display: flex; align-items: baseline; gap: 10px;
         padding: calc(12px + var(--safe-t)) 16px 12px; background: var(--accent); color: #fff; }
header h1 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: .5px; }
.season { font-size: 12px; opacity: .9; font-weight: 600; text-transform: uppercase; letter-spacing: .8px; }
main { padding: 16px; }
.tab { display: none; } .tab.active { display: block; }
.card { background: var(--card); border-radius: 16px; padding: 16px; box-shadow: 0 1px 3px rgba(0,0,0,.06); width: 100%; overflow: hidden; }
.swatch { height: 170px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
          color: rgba(0,0,0,.45); font-size: 13px; text-align: center; padding: 10px; border: 1px solid var(--line);
          background: #e9e9ee; transition: background .2s; }
.row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; align-items: center; }
.row input[type=color] { flex: none; width: 46px; height: 40px; padding: 0; border: 1px solid var(--line); border-radius: 10px; background: none; }
.row input[type=text] { flex: 1; width: auto; min-width: 0; }
input[type=text], select { font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
                           background: #fff; color: var(--ink); width: 100%; }
.row > * { flex-shrink: 1; }
.row input[type=text] { flex: 1 1 120px; }
button { font: inherit; font-weight: 600; border: none; border-radius: 10px; padding: 11px 14px; background: var(--accent);
         color: #fff; cursor: pointer; }
button.ghost { background: #eef0f7; color: var(--accent); white-space: nowrap; }
.verdict { margin-top: 14px; padding: 12px 14px; border-radius: 12px; font-weight: 700; font-size: 17px; text-align: center; }
.verdict.good { background: #e8f5ee; color: var(--good); }
.verdict.close { background: #fbf3e0; color: var(--close); }
.verdict.off { background: #fbe9eb; color: var(--off); }
.details { margin-top: 10px; font-size: 13px; color: var(--muted); }
.details .metric { display: inline-block; margin-right: 12px; }
.details ul { margin: 8px 0 0; padding-left: 18px; }
.details .near { display: inline-flex; align-items: center; gap: 6px; margin-top: 6px; }
.details .chip { width: 16px; height: 16px; border-radius: 4px; border: 1px solid var(--line); }
.save-box { margin-top: 14px; display: grid; gap: 8px; }
.filters { display: flex; gap: 8px; margin-bottom: 14px; }
.filters select { flex: 1; width: auto; min-width: 0; }
.list { display: grid; gap: 10px; }
.item { background: var(--card); border-radius: 14px; padding: 12px; display: flex; gap: 12px; align-items: center;
        box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.item .sw { width: 46px; height: 46px; border-radius: 10px; border: 1px solid var(--line); flex: none; }
.item .meta { flex: 1; min-width: 0; }
.item .meta .nm { font-weight: 600; }
.item .meta .sub { font-size: 12px; color: var(--muted); }
.badge { flex: none; white-space: nowrap; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; }
.badge.good { background: #e8f5ee; color: var(--good); } .badge.close { background: #fbf3e0; color: var(--close); }
.badge.off { background: #fbe9eb; color: var(--off); }
.item .del { background: none; color: var(--muted); font-size: 20px; padding: 4px 8px; }
.palette-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 10px; }
.palette-grid .p { border-radius: 12px; overflow: hidden; background: var(--card); box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.palette-grid .p .c { height: 64px; } .palette-grid .p .n { font-size: 11px; padding: 6px 8px; color: var(--muted); }
.hint { color: var(--muted); font-size: 13px; }
.empty { color: var(--muted); text-align: center; margin-top: 40px; }
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: #fff; border-top: 1px solid var(--line);
          padding-bottom: var(--safe-b); z-index: 5; }
.tabbar button { flex: 1; background: none; color: var(--muted); border-radius: 0; padding: 14px 0; font-size: 13px; }
.tabbar button.active { color: var(--accent); }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(78px + var(--safe-b));
         background: #2c2b33; color: #fff; padding: 10px 16px; border-radius: 999px; font-size: 13px; opacity: 0;
         transition: opacity .2s; pointer-events: none; z-index: 10; }
.toast.show { opacity: .95; }

.hexhint { margin: 10px 2px 0; font-size: 12px; color: var(--muted); }
.primary-wide { width: 100%; padding: 14px; font-size: 16px; margin-bottom: 12px; }
.connect-status { text-align: center; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.sensor-state { text-align: center; font-weight: 700; padding: 9px; border-radius: 10px; margin-bottom: 10px; font-size: 14px; }
.sensor-state.off  { background: #eef0f3; color: #7c7a86; }
.sensor-state.warn { background: #fbf3e0; color: #c99a3a; }
.sensor-state.on   { background: #e8f5ee; color: #4a9d6b; }
.sensor-state.busy { background: #e6effb; color: #3b6fb0; }
.linkbtn { background: none; color: var(--muted); font-weight: 600; padding: 6px; width: 100%; margin-top: 4px; }
.manual { margin-top: 6px; }
.manual summary { cursor: pointer; color: var(--accent); font-size: 13px; font-weight: 600; padding: 6px 2px; }
.manual .row { margin-top: 8px; }
.swatch-cap { text-align: center; font-size: 12px; color: var(--muted); margin: 8px 0 2px; font-weight: 600; }
.closelist { margin-top: 12px; }
.closehead { font-size: 12px; font-weight: 700; color: var(--ink); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .3px; }
.closerow { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.closerow:last-child { border-bottom: none; }
.closerow .chip { width: 26px; height: 26px; border-radius: 7px; border: 1px solid var(--line); flex: none; }
.closerow .cname { flex: 1; font-size: 14px; color: var(--ink); }
.closerow .cde { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.reasons { margin: 12px 0 0; padding-left: 18px; }
.build { margin-left: auto; font-size: 11px; opacity: .7; font-weight: 700; }
