:root {
  --bg: #eef3f8; --card: #ffffff; --text: #1d2733; --sub: #5d6b7a; --line: #dde4ec;
  --accent: #1f6fd1; --hi: #d9480f; --lo: #1c7ed6; --band: rgba(31, 111, 209, .14);
  --rain: #3b82c4; --ok: #2b8a3e; --warn: #b7791f; --err: #c92a2a;
  --A: #2b8a3e; --B: #c08a00; --C: #c92a2a;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1620; --card: #18222e; --text: #e6edf3; --sub: #95a3b3; --line: #2a3644;
    --accent: #5aa2f0; --hi: #ff8a5b; --lo: #6cb4ff; --band: rgba(90, 162, 240, .18);
    --rain: #5ea9e6; --A: #51cf66; --B: #f2c94c; --C: #ff6b6b; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1620; --card: #18222e; --text: #e6edf3; --sub: #95a3b3; --line: #2a3644;
  --accent: #5aa2f0; --hi: #ff8a5b; --lo: #6cb4ff; --band: rgba(90, 162, 240, .18);
  --rain: #5ea9e6; --A: #51cf66; --B: #f2c94c; --C: #ff6b6b; color-scheme: dark;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.55 system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", sans-serif;
}
a { color: var(--accent); }
header, main, footer { max-width: 900px; margin: 0 auto; padding: 0 16px; }
header { padding-top: 12px; }
.bar { display: flex; align-items: center; justify-content: space-between; }
h1 { font-size: 20px; margin: 4px 0 10px; }
h2 { font-size: 22px; margin: 0; }
h3 { font-size: 16px; margin: 0 0 10px; }
.search { position: relative; display: flex; gap: 8px; }
.search input {
  flex: 1; min-width: 0; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font-size: 16px;
}
.btn, .icon-btn {
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  border-radius: 10px; padding: 0 12px; font-size: 14px; cursor: pointer; white-space: nowrap;
}
.icon-btn { font-size: 20px; width: 40px; height: 40px; padding: 0; }
.results {
  position: absolute; top: 46px; left: 0; right: 0; z-index: 5; list-style: none; margin: 0; padding: 0;
  background: var(--card); border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.18); overflow: hidden;
}
.results button { width: 100%; text-align: left; padding: 10px 14px; border: 0; background: none; color: var(--text); font-size: 15px; cursor: pointer; }
.results button:hover { background: var(--bg); }
.results .none { padding: 10px 14px; color: var(--sub); }
main { padding-top: 12px; }
.card { background: var(--card); border-radius: 14px; padding: 16px; margin-bottom: 12px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.status { margin: 2px 0 10px; font-size: 13px; color: var(--sub); }
.status.ok::before { content: "● "; color: var(--ok); }
.status.warn::before { content: "● "; color: var(--warn); }
.status.error { color: var(--err); }
.meta, .hint { font-size: 12.5px; color: var(--sub); margin: 8px 0 0; }
.hint { color: var(--accent); }
.now-main { display: flex; align-items: center; gap: 14px; }
.now-icon { font-size: 56px; line-height: 1; }
.now-temp { font-size: 44px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.now-sub { color: var(--sub); font-size: 13px; }
.now-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 14px; }
.now-grid div { background: var(--bg); border-radius: 10px; padding: 8px 10px; }
.now-grid span { display: block; font-size: 12px; color: var(--sub); }
.now-grid b { font-variant-numeric: tabular-nums; }
@media (max-width: 520px) { .now-grid { grid-template-columns: repeat(2, 1fr); } }
.hi { color: var(--hi); } .lo { color: var(--lo); }

.chart { width: 100%; overflow: hidden; }
.chart svg { display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .grid.day { stroke: var(--sub); stroke-dasharray: 3 3; opacity: .6; }
.chart .axis { fill: var(--sub); font-size: 11px; }
.chart .band { fill: var(--band); }
.chart .tline { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; }
.chart .mline { fill: none; stroke-width: 1.2; opacity: .75; }
.chart .obs { fill: var(--hi); stroke: var(--card); stroke-width: 1; }
.chart .pbar { fill: var(--rain); }
.chart .now { stroke: var(--hi); stroke-width: 1.5; stroke-dasharray: 4 3; }
.chart .now-l { fill: var(--hi); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--sub); margin-top: 6px; }
.lg::before { content: ""; display: inline-block; width: 14px; height: 3px; margin-right: 5px; vertical-align: middle; background: var(--c, var(--sub)); }
.lg.tl::before { background: var(--accent); }
.lg.bd::before { background: var(--band); height: 10px; }
.lg.ob::before { background: var(--hi); width: 7px; height: 7px; border-radius: 50%; }
.lg.pb::before { background: var(--rain); width: 6px; height: 10px; }
.switch, .area-sel { font-size: 13px; color: var(--sub); }
.area-sel select { font-size: 13px; padding: 3px; border-radius: 6px; background: var(--card); color: var(--text); border: 1px solid var(--line); }

.hourly { display: flex; overflow-x: auto; gap: 0; padding-bottom: 6px; scroll-snap-type: x proximity; }
.hcell { flex: 0 0 52px; text-align: center; padding: 22px 0 4px; position: relative; border-left: 1px solid transparent; font-variant-numeric: tabular-nums; scroll-snap-align: start; }
.hcell.newday { border-left-color: var(--line); }
.hday { position: absolute; top: 0; left: 4px; font-size: 11px; color: var(--sub); white-space: nowrap; }
.hh { font-size: 12px; color: var(--sub); }
.hi-ic { font-size: 22px; margin: 2px 0; }
.ht { font-weight: 700; }
.hp { font-size: 12px; color: var(--sub); }
.hp.wet { color: var(--rain); font-weight: 700; }
.hmm { font-size: 11px; color: var(--rain); }
.hw { font-size: 10.5px; color: var(--sub); line-height: 1.25; margin-top: 2px; }

.pop6 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
@media (max-width: 520px) { .pop6 { grid-template-columns: repeat(2, 1fr); } }
.p6 { background: var(--bg); border-radius: 10px; padding: 8px 10px; }
.p6t { font-size: 12px; color: var(--sub); }
.p6v { font-size: 22px; font-weight: 700; color: var(--rain); }
.p6s { font-size: 11px; color: var(--sub); }

.daily { display: flex; flex-direction: column; }
.drow {
  display: grid; grid-template-columns: 64px 36px 1fr 46px 96px 28px; align-items: center; gap: 4px 8px;
  padding: 8px 0; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums;
}
.drow:last-child { border-bottom: 0; }
.dd { font-weight: 600; }
.wd { font-size: 12px; margin-left: 3px; color: var(--sub); }
.wd.w0 { color: var(--C); } .wd.w6 { color: var(--lo); }
.di { font-size: 24px; text-align: center; }
.dtx { font-size: 13px; color: var(--sub); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dp { color: var(--rain); text-align: right; }
.dt { text-align: right; } .dt b { display: inline-block; min-width: 40px; }
.dc { text-align: center; font-weight: 700; border-radius: 6px; font-size: 13px; }
.confA { color: var(--A); } .confB { color: var(--B); } .confC { color: var(--C); }
.dsrc { grid-column: 3 / -1; font-size: 11px; color: var(--sub); margin-top: -4px; }
@media (max-width: 520px) {
  .drow { grid-template-columns: 52px 32px 1fr 40px 84px 22px; }
  .dsrc { grid-column: 1 / -1; }
}

.jd { padding: 8px 0; border-bottom: 1px solid var(--line); }
.jd:last-of-type { border-bottom: 0; }
.ji { font-size: 20px; margin-right: 6px; }
.jd small { color: var(--sub); }
details { margin-top: 10px; }
summary { cursor: pointer; color: var(--accent); font-size: 14px; }
.ovtext { font-size: 13.5px; white-space: normal; }
.how { padding-left: 20px; font-size: 13.5px; }
.how li { margin: 6px 0; }
table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 8px; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--line); }
th { color: var(--sub); font-weight: 500; }
td i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }
footer { font-size: 12px; color: var(--sub); padding-bottom: 32px; }

/* タブ */
.tabs { display: flex; gap: 6px; margin-top: 10px; }
.tabs button { flex: 1; padding: 9px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--sub); font-size: 15px; cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }

/* 稲作ビュー */
.small { font-size: 13px; }
h4 { font-size: 15px; margin: 18px 0 8px; }
.rice-form { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
@media (max-width: 620px) { .rice-form { grid-template-columns: repeat(2, 1fr); } }
.rice-form label { display: flex; flex-direction: column; font-size: 12px; color: var(--sub); gap: 3px; min-width: 0; }
.rice-form select, .rice-form input { font-size: 15px; padding: 6px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--text); min-width: 0; }
.rice-sum { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 12px; }
@media (max-width: 620px) { .rice-sum { grid-template-columns: repeat(2, 1fr); } }
.rice-sum div { background: var(--bg); border-radius: 10px; padding: 8px 10px; }
.rice-sum span { display: block; font-size: 12px; color: var(--sub); }
.rice-sum b { font-size: 17px; }
.rice-sum b.small { font-size: 13px; }
.stagebar { position: relative; display: flex; height: 28px; border-radius: 8px; overflow: hidden; margin-top: 12px; }
.seg { display: flex; align-items: center; justify-content: center; font-size: 10.5px; color: #fff; overflow: hidden; white-space: nowrap; border-right: 1px solid rgba(255,255,255,.5); }
.seg span { overflow: hidden; text-overflow: ellipsis; padding: 0 2px; }
.seg-rooting { background: #8aa36a; } .seg-tiller { background: #5c9a4a; } .seg-panicle { background: #3f8a6b; }
.seg-meiosis { background: #2f7a8a; } .seg-heading { background: #d9a400; } .seg-filling { background: #c9862b; } .seg-harvest { background: #9b5d2a; }
.now-mark { position: absolute; top: -3px; bottom: -3px; width: 3px; background: var(--hi); border-radius: 2px; box-shadow: 0 0 0 2px var(--card); }
.stagedates { display: flex; flex-wrap: wrap; gap: 2px 10px; font-size: 11.5px; color: var(--sub); margin-top: 4px; }
.risks { display: grid; gap: 10px; }
.risk { border: 1px solid var(--line); border-left: 6px solid var(--lvc, var(--line)); border-radius: 10px; padding: 10px 12px; }
.risk-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.badge { font-size: 12px; font-weight: 700; padding: 2px 10px; border-radius: 99px; background: var(--lvc, var(--line)); color: #fff; white-space: nowrap; }
.lvref .badge { color: var(--text); }
.risk-val { font-variant-numeric: tabular-nums; margin-top: 4px; font-weight: 600; }
.risk-basis { font-size: 12.5px; color: var(--sub); margin: 6px 0 0; }
.measures { margin: 8px 0 0; padding-left: 18px; font-size: 13.5px; }
.measures li { margin: 4px 0; }
.lv0 { --lvc: #4f9d5d; } .lv1 { --lvc: #c9a227; } .lv2 { --lvc: #e07b28; } .lv3 { --lvc: #d64545; }
table.yt td.lv1, table.yt td.lv2, table.yt td.lv3 { background: color-mix(in srgb, var(--lvc) 22%, transparent); font-weight: 600; }
table.yt td, table.yt th { text-align: center; }
table.yt { overflow-x: auto; display: block; }
@media (min-width: 560px) { table.yt { display: table; } }

/* 圃場・カレンダー・記録 */
.fieldcard { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--bg); border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; }
.fc-main span { display: block; font-size: 12px; color: var(--sub); }
.fc-main b { font-size: 17px; margin-right: 8px; }
.fc-main small { color: var(--sub); }
.fc-btns { display: flex; gap: 6px; }
.fc-btns .btn, .f-actions .btn, .logform .btn, #r-future { height: 36px; }
.f-form { margin-bottom: 12px; }
.f-actions { grid-column: 1 / -1; display: flex; gap: 6px; flex-wrap: wrap; }
.alerts { display: grid; gap: 6px; }
.alert { border-left: 5px solid var(--lvc); background: color-mix(in srgb, var(--lvc) 12%, transparent); border-radius: 8px; padding: 6px 10px; font-size: 14px; }
.plan { list-style: none; padding: 0; margin: 0; }
.plan li { display: grid; grid-template-columns: 96px 1fr; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.plan li.done { opacity: .55; }
.plan li.now { background: color-mix(in srgb, var(--accent) 10%, transparent); border-radius: 8px; }
.pdate { font-variant-numeric: tabular-nums; font-weight: 600; padding-left: 4px; }
.ptext { font-size: 13.5px; }
.plan small { color: var(--sub); }
.pill { font-size: 11px; background: var(--accent); color: #fff; border-radius: 99px; padding: 1px 8px; vertical-align: 1px; }
.pill.nx { background: var(--sub); }
.logform { display: grid; grid-template-columns: 140px 130px 1fr auto; gap: 6px; }
@media (max-width: 620px) { .logform { grid-template-columns: 1fr 1fr; } .logform #l-val { grid-column: 1 / -1; } }
.logform input, .logform select { font-size: 15px; padding: 6px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--text); min-width: 0; }
.loglist { list-style: none; padding: 0; margin: 8px 0 0; }
.loglist li { display: grid; grid-template-columns: 52px 90px 1fr 28px; gap: 6px; align-items: center; padding: 5px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.loglist .x { border: 0; background: none; color: var(--sub); font-size: 18px; cursor: pointer; }
.tscroll { overflow-x: auto; }
.tscroll table.yt { display: table; }
[hidden] { display: none !important; }
details.fold > summary { font-size: 15px; font-weight: 700; color: var(--text); margin: 18px 0 8px; }

/* 雷 */
.hth { font-size: 10.5px; color: #b8860b; font-weight: 700; min-height: 13px; }
#thunder-card summary { font-weight: 700; }
#thunder-alert .alert { margin-bottom: 4px; }
.tm-wrap { overflow: hidden; display: flex; justify-content: center; margin-top: 10px; }
.tm { position: relative; flex: none; border-radius: 10px; overflow: hidden; background: #ddd; }
.tm img { position: absolute; display: block; }
.tm-thns img { opacity: .85; }
.tm-pin { position: absolute; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; background: #d64545; border: 3px solid #fff; box-shadow: 0 0 0 1px #0006; }
.tm-steps { display: flex; gap: 6px; justify-content: center; margin-top: 6px; flex-wrap: wrap; }
.tm-steps button { height: 32px; font-size: 13px; }
.tm-steps button[aria-pressed="true"] { background: var(--accent); color: #fff; border-color: var(--accent); }
