:root {
  --bg: #f7f3ee; --card: #ffffff; --ink: #2b2724; --muted: #7a716b; --line: #e8e1d9;
  --accent: #e9875f; --accent-ink: #fff; --soft: #fbe9df; --warn: #b4471f; --warn-bg: #fff1ea;
  --danger: #c0392b; --tile: #f3eee8; --checker: #ddd;
  --w1: #8fc7e8; --w2: #a9d8a0; --w3: #f0d27a; --w4: #f2a56b; --w5: #e06c6c;
  --radius: 16px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 14px rgba(60,40,20,.06);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #1c1917; --card: #28231f; --ink: #f3ede6; --muted: #a79c92; --line: #3a332d;
    --soft: #3d2d25; --warn: #f0a07a; --warn-bg: #3a2a22; --tile: #332c27; --checker: #444; --shadow: none; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif; font-size: 16px; line-height: 1.5; }
body.noscroll { overflow: hidden; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 17px; margin: 0 0 10px; }
small { font-size: 12px; }
.muted { color: var(--muted); }
.center { text-align: center; }

.topbar { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: calc(10px + env(safe-area-inset-top)) 16px 8px; }
main { padding: 4px 16px calc(96px + env(safe-area-inset-bottom)); max-width: 640px; margin: 0 auto; }

.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; background: var(--card);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabbar button { flex: 1; background: none; border: 0; padding: 8px 0 6px; font-size: 11px; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 2px; }
.tabbar button .ico { font-size: 22px; }
.tabbar button.active { color: var(--accent); font-weight: 600; }

.card { background: var(--card); border-radius: var(--radius); padding: 14px; margin: 12px 0; box-shadow: var(--shadow); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row > label { flex: 1; min-width: 130px; }
label { display: block; font-size: 13px; color: var(--muted); margin: 8px 0; }
label b { color: var(--ink); }
input[type=number], input[type=text], input[type=search], input[type=month], select {
  width: 100%; margin-top: 4px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--ink); font-size: 16px; }
.num { display: flex; align-items: center; gap: 6px; }
.num input { width: 110px; }
input[type=range] { width: 100%; margin: 8px 0 0; accent-color: var(--accent); }
.check { display: flex; align-items: center; gap: 8px; font-size: 15px; color: var(--ink); margin: 12px 0; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 6px 0; }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 8px 14px; white-space: nowrap; display: flex; gap: 6px; align-items: baseline; }
.chip small { color: var(--muted); }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip.on small { color: rgba(255,255,255,.85); }

.seg { display: flex; background: var(--tile); border-radius: 12px; padding: 3px; margin: 6px 0; }
.seg button { flex: 1; border: 0; background: none; padding: 9px; border-radius: 10px; color: var(--muted); font-weight: 600; }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.seg.small button { padding: 7px; font-size: 14px; }

.btn { border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 12px; padding: 11px 14px; font-weight: 600; font-size: 15px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn.small { padding: 7px 10px; font-size: 13px; }
.btn.on { background: var(--soft); border-color: var(--accent); }
.btn:disabled { opacity: .45; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.btns .btn { flex: 1; }
.btns.col { flex-direction: column; }
.fab { position: fixed; right: 18px; bottom: calc(76px + env(safe-area-inset-bottom)); width: 56px; height: 56px; border-radius: 50%;
  border: 0; background: var(--accent); color: #fff; font-size: 30px; line-height: 1; box-shadow: 0 6px 18px rgba(233,135,95,.45); z-index: 4; }

.weather .status { font-size: 12px; color: var(--muted); margin-top: 6px; }
.result .feels { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.result .feels b { font-size: 34px; margin: 0 2px; }
.result .feels small { display: block; font-size: 12px; color: var(--muted); }
.band { background: var(--soft); color: var(--warn); border-radius: 999px; padding: 4px 12px; font-weight: 700; }
.tag { font-size: 12px; background: var(--tile); border-radius: 999px; padding: 3px 10px; color: var(--muted); }
.targets { font-size: 13px; margin: 6px 0 10px; }

.tiles { display: flex; gap: 10px; flex-wrap: wrap; }
.tiles.grid { display: grid; grid-template-columns: repeat(3, 1fr); }
.tile { width: calc(33.33% - 7px); min-width: 96px; background: var(--tile); border-radius: 14px; padding: 8px; text-align: center; position: relative; }
.tiles.grid .tile { width: auto; min-width: 0; }
.tile .icon { position: relative; aspect-ratio: 1; border-radius: 10px; background: var(--card); display: flex; align-items: center; justify-content: center; overflow: hidden; margin-bottom: 6px; }
.tile .icon img { width: 100%; height: 100%; object-fit: contain; }
.tile .icon .emoji { font-size: 40px; }
.tile .name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .sub { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .warmth { font-size: 11px; margin-top: 4px; border-radius: 6px; padding: 2px 4px; color: #3a2a1a; }
.tile .warmth small { font-size: 10px; }
.w1 { background: var(--w1); } .w2 { background: var(--w2); } .w3 { background: var(--w3); } .w4 { background: var(--w4); } .w5 { background: var(--w5); }
.tile.laundry .icon img, .tile.laundry .icon .emoji { opacity: .35; }
.tile.archived { opacity: .55; }
.badge { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); background: rgba(40,30,20,.75); color: #fff; font-size: 11px; padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.cath { font-size: 15px; margin: 18px 0 8px; display: flex; gap: 6px; align-items: baseline; }
.cath small { color: var(--muted); }
.empty { color: var(--muted); text-align: center; padding: 28px 10px; }

ul.warn, ul.tips { margin: 10px 0 0; padding: 10px 12px 10px 28px; border-radius: 12px; font-size: 13px; }
ul.warn { background: var(--warn-bg); color: var(--warn); }
ul.tips { background: var(--tile); }
.feedback { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line); font-size: 14px; }
.feedback .btns { margin-top: 8px; }

.kidrow { display: flex; align-items: center; gap: 10px; padding: 12px 4px; border-bottom: 1px solid var(--line); }
.kidrow > div:first-child { flex: 1; }
.kidrow .chev { color: var(--muted); font-size: 22px; }
.loglist { font-size: 13px; }
.loglist div { padding: 6px 0; border-bottom: 1px solid var(--line); display: flex; gap: 8px; }
.loglist .d { color: var(--muted); min-width: 56px; }
.placeres button { display: block; width: 100%; text-align: left; margin-top: 6px; }
.linkbox { font-size: 12px; word-break: break-all; background: var(--tile); padding: 8px 10px; border-radius: 10px; font-family: ui-monospace, Menlo, monospace; }
.hint { border: 1px dashed var(--accent); }
.hint p { margin: 4px 0 8px; font-size: 13px; }
.rulerow { border-top: 1px solid var(--line); padding: 10px 0 6px; }
.rulehead { display: flex; justify-content: space-between; align-items: center; font-size: 14px; }
.rulehead input { width: 72px; margin: 0; padding: 6px 8px; }
.rulegrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px 8px; margin-top: 6px; }
.rulegrid label { margin: 0; font-size: 12px; }
.rulegrid select { padding: 7px 8px; font-size: 14px; margin-top: 2px; }

.sheet { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.4); display: flex; align-items: flex-end; }
.sheet.hidden, .toast.hidden { display: none; }
.sheet-panel { position: relative; background: var(--card); width: 100%; max-width: 640px; margin: 0 auto; max-height: 92vh; overflow-y: auto;
  border-radius: 20px 20px 0 0; padding: 18px 16px calc(24px + env(safe-area-inset-bottom)); }
.sheet .close { position: absolute; right: 10px; top: 8px; width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--tile); font-size: 20px; color: var(--muted); }
.canvaswrap { width: min(100%, 360px); aspect-ratio: 1; margin: 10px auto; border-radius: 14px; overflow: hidden; background: var(--tile); border: 1px solid var(--line); }
.canvaswrap.checker { background: repeating-conic-gradient(var(--checker) 0 25%, transparent 0 50%) 0 0 / 20px 20px; }
.canvaswrap canvas { width: 100%; height: 100%; display: block; touch-action: none; -webkit-user-select: none; user-select: none; }
.preview { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; }
.preview img, .preview .emoji { width: 84px; height: 84px; border-radius: 14px; background: var(--tile); object-fit: contain; display: flex; align-items: center; justify-content: center; font-size: 44px; }

.toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: rgba(40,30,20,.9); color: #fff;
  padding: 10px 16px; border-radius: 999px; font-size: 14px; z-index: 30; max-width: 90vw; text-align: center; }
