/* Phones (loaded with media="(max-width: 700px)", see templates/_head.html): calm and simple - flat cards, normal text
   instead of the control-room look, one column, details folded away (common.js: foldPanels), a tab bar at the bottom
   (templates/_nav.html), touch targets of 44 px. Every rule starts with "html", so it wins over the page styles no
   matter in which order they are loaded. */

/* ---------- plain surfaces: no grid, glow, blur or corner brackets ---------- */
html:root { --gap: 8px; --card-bg: #10171e; --inset-bg: rgb(var(--hi) / 0.04); --font-mono: var(--font-ui); }
html body { padding: max(6px, env(safe-area-inset-top)) 8px calc(74px + env(safe-area-inset-bottom)); font-size: 15px; background: var(--bg-color); }
html body::before { display: none; }
html .glass-panel { padding: 12px; margin-bottom: 8px; border-radius: 12px; box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none; }
html .glass-panel::before, html .glass-panel::after { display: none; }
html .plant-dot { box-shadow: none; }
html .grid-2, html .grid-3 { gap: 0; }

/* ---------- room for the tab bar; messages and toasts appear above it ---------- */
html .toast-region { bottom: calc(74px + env(safe-area-inset-bottom)); }
html .sysmsgs { left: 8px; right: 8px; bottom: calc(74px + env(safe-area-inset-bottom)); max-width: none; }
html body.menu-open { overflow: hidden; }
html .tab { min-height: 50px; font-size: 11.5px; }
html .tab svg { width: 24px; height: 24px; }

/* ---------- text: normal letters instead of capitals and monospace ---------- */
html p, html .muted { font-size: 14px; line-height: 1.45; margin: 6px 0; }
html small, html .small, html .hint { font-size: 12.5px; }
html h3, html .panel-title { margin: 0 0 8px; padding: 0; border: 0; font: 600 16px var(--font-ui); color: var(--text-strong); text-transform: none; letter-spacing: 0; }
html h3::before, html .panel-title::before { display: none; }
html h3.bar > .h-note { font-size: 12.5px; flex-basis: 100%; }
html h4 { font-size: 15.5px; }
html label { font-size: 14.5px; }
html label, html .toggles label { white-space: normal; }
html th { font: 600 12px var(--font-ui); text-transform: none; letter-spacing: 0; padding: 6px; }
html td { padding: 8px 6px; }
html table { font-size: 13.5px; }
html .field-label { font: 600 12.5px var(--font-ui); text-transform: none; letter-spacing: 0; }
html .modal-box h2 { font: 700 18px var(--font-ui); text-transform: none; letter-spacing: 0; }
html .msg { font: 13.5px var(--font-ui); }
html .hide-phone { display: none; }

/* ---------- folding panels: the heading is the switch ---------- */
html .glass-panel.foldable { padding-top: 0; padding-bottom: 12px; }
html .glass-panel.foldable.folded { padding-bottom: 0; }
html .foldable > h3 { position: relative; min-height: 48px; margin: 0; padding: 14px 40px 12px 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
html .foldable > h3.bar { padding-right: 0; gap: 8px; }
html .foldable > h3.bar > span:first-child { flex-basis: 100%; margin: 0; padding-right: 40px; }
html .folded > h3.bar > :not(:first-child):not(.fold-toggle) { display: none; }
html .folded > :not(h3) { display: none !important; }
html .fold-toggle { display: block; position: absolute; top: 0; right: -12px; width: 52px; height: 48px; padding: 0; background: none; border: 0; cursor: pointer; }
html .fold-toggle::after {
    content: ''; position: absolute; top: 18px; left: 20px; width: 9px; height: 9px; transform: rotate(225deg); transition: transform 0.15s;
    border-right: 2px solid var(--text-muted); border-bottom: 2px solid var(--text-muted);
}
html .fold-toggle[aria-expanded="false"]::after { transform: rotate(45deg); top: 14px; }
html .more-phone { margin-top: 8px; }
html .more-phone > summary { display: list-item; min-height: 36px; padding: 8px 0; color: var(--text-muted); font-size: 14px; cursor: pointer; }

/* ---------- page header: one plain line ---------- */
html .page-header { padding: 4px 4px 6px; gap: 6px 8px; flex-wrap: wrap; align-items: center; margin-bottom: 4px; background: none; border: 0; }
html .ph-kicker { display: none; }
html .page-header h1 { font: 700 20px var(--font-ui); letter-spacing: 0; text-transform: none; text-shadow: none; }
html .ph-sub { font-size: 12.5px; }
html .ph-actions { width: auto; flex-wrap: nowrap; gap: 6px; margin-left: auto; }
html .ph-actions .btn { min-height: 38px; padding: 6px 10px; white-space: nowrap; }
html .ph-actions .muted { margin: 0; font-size: 12.5px; }

/* login (guests): title, connection state, then the form below each other */
html .page-header:has(.login-form) { flex-direction: column; align-items: stretch; gap: 10px; }
html .page-header:has(.login-form) .ph-actions { width: 100%; margin-left: 0; flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: 10px; }
html .page-header:has(.login-form) .status-badge { align-self: flex-start; font-size: 11px; padding: 4px 10px; white-space: nowrap; }
html .login-form { flex-direction: column; align-items: stretch; gap: 8px; }
html .login-inputs { flex-direction: column; gap: 8px; width: 100%; }
html .login-inputs input, html .login-form input[name="code"] { width: 100% !important; flex: none; }
html .login-form .btn { width: 100%; flex: none; }
html .login-links { flex-direction: row; justify-content: space-between; gap: 12px; width: 100%; }
html .login-sub { flex-direction: column; align-items: stretch; gap: 4px; }
html .login-remember { font-size: 15px; padding: 6px 0; }
html .login-alt { flex-direction: column; align-items: stretch; }
html .login-or { text-align: center; }
html .guest-prefs { top: 10px; right: 10px; }
html .pl-photo-time { font-size: 10.5px; left: auto; right: 6px; bottom: 6px; }

/* ---------- controls ---------- */
html .btn { min-height: 44px; font: 600 14px var(--font-ui); text-transform: none; letter-spacing: 0; padding: 9px 13px; border-radius: 10px; box-shadow: none; }
html .btn-small { min-height: 38px; font-size: 13px; padding: 6px 11px; }
html .btn:hover { box-shadow: none; }
html .link-btn { font: 600 14px var(--font-ui); text-transform: none; letter-spacing: 0; padding: 8px 0; }
html .seg > button { min-height: 40px; font: 600 14px var(--font-ui); padding: 8px 11px; }
html input, html select, html textarea { font-size: 16px; min-height: 44px; border-radius: 9px; }   /* 16 px: no zoom on iOS */
html input[type="checkbox"], html input[type="radio"] { width: 20px; height: 20px; min-height: 0; }
html input[type="range"] { min-height: 32px; }
html .row { gap: 8px; }

/* ---------- data ---------- */
html .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
html .kpi { padding: 8px 10px; border-radius: 9px; }
html .kpi::before { display: none; }
html .kpi .v { font: 700 17px var(--font-ui); line-height: 1.2; overflow-wrap: break-word; }
html .kpi .l { font-size: 12px; text-transform: none; letter-spacing: 0; line-height: 1.25; margin-top: 3px; }
html .pill { font: 600 12px var(--font-ui); text-transform: none; letter-spacing: 0; padding: 3px 9px; }
html .msg, html .note, html .note-warn { font-size: 14px; }
html .note, html .note-warn { margin-top: 8px; padding: 8px 10px; }
html .chart-box { height: 220px; }
html .chart-tall { height: 270px; }
html .legend-note { font-size: 13px; }

/* ---------- navigation ---------- */
html .topnav { margin-bottom: 6px; padding: 5px 8px; border-radius: 12px; background: var(--card-bg); box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none; }
html .topnav.open .tn-menu { max-height: calc(100vh - 150px); }
html .tn-top, html .tn-group > summary { font-size: 15px; padding: 12px 10px; text-transform: none; letter-spacing: 0; }
html .tn-item { padding: 10px 12px; }
html .tn-item span { font-size: 15.5px; }
html .tn-item small { display: none; }
html .tn-plants { grid-template-columns: 1fr 1fr; }
html .tn-plant { font-size: 15px; padding: 10px; }
html .tn-health, html .tn-power { font: 500 13px var(--font-ui); padding: 6px 10px; box-shadow: none; }
html .tn-avatar { width: 32px; height: 32px; font-size: 15px; box-shadow: none; }

/* ---------- dashboard: the schematic is the whole overview, everything else folds away ---------- */
html .topnav ~ .container #dash-header { display: none; }       /* logged in: the bar on top already says "all OK" or "controller offline" */
/* system: three chips in one row */
html .telemetry-widget { flex-direction: row !important; padding: 6px; gap: 6px; margin-bottom: 8px !important; }
html .topo-link { display: none !important; }
html .topo-node { flex: 1 1 0; min-width: 0; width: auto; padding: 6px 4px; font-size: 10.5px; line-height: 1.3; }
html .topo-title { font-size: 9px; letter-spacing: 0.5px; }
html .main-grid { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
html .schematic-panel { padding-bottom: 8px; }
html .schematic-panel > h3 { margin-bottom: 4px; }
html .schematic-wrapper { gap: 6px; }
/* below the schematic: the mode, and a button for the slider and the switches */
html .overlay-stats { order: 2; padding: 6px 0 2px; gap: 8px 12px; background: none; border: 0; border-radius: 0; box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none; border-top: 1px solid var(--glass-border); }
html .stat-line { font: 600 14px var(--font-ui); gap: 8px; }
html .stat-line:not(.stat-mode) { display: none; }
html .ctl-toggle { display: inline-flex; margin-left: auto; }
html .overlay-stats:not(.open) > .speed-line, html .overlay-stats:not(.open) > .action-btns { display: none; }
html .speed-line { flex-basis: 100%; max-width: none; font: 600 14px var(--font-ui); }
html .speed-line b { font-family: var(--font-ui); }
html .action-btns { margin-left: 0; width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
html .action-btns .btn { min-height: 44px; white-space: normal; }
html .action-hint { grid-column: 1 / -1; font: 13px var(--font-ui); text-align: left; }
/* event log: plain list without the timeline */
html .log-content, html .log-panel .log-content { flex: none; height: auto; min-height: 0; max-height: 50vh; padding: 8px 10px; background: var(--inset-bg); box-shadow: none; font: 13px var(--font-ui); }
html .log-content::before, html .log-entry::before { display: none; }
html .log-entry { padding-left: 0; margin-bottom: 8px; font-size: 13px; line-height: 1.4; }
html .log-tools { flex-basis: 100%; }
html .log-tools input { flex: 1; width: auto; font-size: 16px; min-height: 40px; }
/* moisture chart: time range, then plants as a legend you can tap, then the chart */
html .chart-panel:not(.folded) { display: flex; flex-direction: column; }
html .chart-toolbar { flex-basis: 100%; gap: 8px 14px; }
html .chart-toolbar .seg { display: grid; grid-template-columns: repeat(4, 1fr); width: 100%; }
html .chart-opt { font: 14px var(--font-ui); gap: 7px; }
html .chart-legend-note { display: none; font: 12.5px var(--font-ui); gap: 10px; margin-bottom: 6px; }
html .chart-panel:has(#opt-events:checked) .chart-legend-note { display: flex; }
html .chart-summary { order: 1; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin: 2px 0 8px; }
html .chart-container, html .chart-status { order: 2; }
html .chart-container { height: 260px; }
html .chart-export { order: 3; justify-content: flex-start; margin-top: 8px; }
html .chart-export select { flex: 1; min-width: 0; font-size: 16px; min-height: 40px; }
html .sum-card { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 7px 9px; font: 13px var(--font-ui); border-radius: 8px; }
html .sum-card b { font: 600 13.5px var(--font-ui); margin: 0; min-width: 0; }
html .sum-card b > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
html .sum-card .plant-dot { display: none; }
html .sum-card .v { font: 700 14.5px var(--font-ui); white-space: nowrap; }
html .sum-val [class^="trend-"], html .sum-meta { display: none; }
/* setup: two pots per row */
html .admin-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
html .cfg-pot { padding: 8px; gap: 4px; }
html .cfg-pot input, html .cfg-pot select { font-size: 15px; min-height: 40px; padding: 6px 8px; }
html .config-panel { border-color: var(--glass-border); }
html .muted-hint { display: none; }

/* ---------- statistics: period in one row ---------- */
html .period-bar { flex-direction: column; align-items: stretch; gap: 6px; }
html .period-kind { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
html .period-nav { display: grid; grid-template-columns: 46px 1fr 46px; gap: 6px; align-items: center; }
html #period-label { min-width: 0; font: 600 14px var(--font-ui); line-height: 1.3; }
html .period-nav .btn { padding: 0; font-size: 20px; }

/* ---------- plants overview: photo left, details right ---------- */
html .pl-grid { grid-template-columns: minmax(0, 1fr); gap: 8px; }
html .pl-card { flex-direction: row; border-radius: 12px; box-shadow: none; }
html .pl-photo { flex: 0 0 104px; aspect-ratio: auto; min-height: 100%; }
html .pl-verdict { top: auto; bottom: 6px; left: 6px; right: auto; font-size: 9.5px; padding: 2px 6px; }
html .pl-verdict.collecting { display: none; }
html .pl-body { padding: 9px 10px; gap: 5px; min-width: 0; flex: 1 1 auto; }
html .pl-head h4 { font-size: 15.5px; }
html .pl-head .muted { font-size: 11.5px; margin: 0; }
html .pl-now { gap: 8px; }
html .pl-num { font-size: 22px; }
html .pl-lines { font-size: 12.5px; gap: 1px; }
html .pl-lines > :nth-child(n+2) { display: none; }     /* next watering only; the rest is on the plant page */
html .pl-trend { display: none; }

/* ---------- plant page, status, forecast, diary ---------- */
html .pp-hero { gap: 0; }
html .pp-photo-panel .photo { max-height: 240px; }
html .pp-care-item, html .pp-reasons, html .pp-cal-steps { font-size: 14px; }
html .pp-care-form { grid-template-columns: minmax(0, 1fr); gap: 6px; }
html .pp-care-form > * { grid-column: auto; width: 100%; min-width: 0; }
html .st-grid { gap: 6px; }
html .st-card { padding: 9px 10px; gap: 4px; box-shadow: none; }
html .st-name { font-size: 15px; }
html .st-summary { font-size: 13.5px; }
html .st-details { font-size: 12.5px; }
html .st-list { font-size: 13.5px; gap: 4px; }
html .st-banner { padding: 10px 12px; gap: 12px; }
html .st-banner-icon { width: 36px; height: 36px; font-size: 18px; box-shadow: none; }
html .st-banner-title { font-size: 17px; }
html .plant-card { padding: 10px; }
html .plant-card h4 { font: 600 15.5px var(--font-ui); }
html .plant-card ul { font-size: 13px; }
html .source-list { font-size: 13px; margin-top: 4px; }
html #plant-tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; width: 100%; }
html #plant-tabs .btn { min-height: 40px; padding: 6px 8px; justify-content: flex-start; overflow: hidden; }
html .toast { font-size: 14.5px; padding: 11px 13px; }
html .timeline { font-size: 12.5px; }
