/*
 * BatteryPro: the tool's own components, styled in the site's design language (7 Oct 2026, on the UltraCompress Pro
 * template, after EmailSignature). Base: /libs/site-pages.css (tokens, Inter and Space Grotesk, buttons, theme toggle, focus
 * rings) and /libs/shared-nav.css (the site's header and footer). This file holds only what the tool itself needs: the
 * toolbar with its source badge, the dashboard grid (three cards per row on desktops, two on tablets, one on phones, with
 * the analytics card two columns wide and the suggestions card full width, so no slot is empty), the battery ring card,
 * the profile cards, the sliders whose fill follows the value, the switches, the fact and insight lists, the analytics
 * tabs and chart boxes, the carbon box, the profile bars, the suggestion cards, the alert notice, the windows, the toasts
 * and the information sections. Light is the default; dark applies when <html> has no data-theme.
 */

/* ----- Tokens the tool adds ----- */
:root {
    --surface: #ffffff;                 /* cards are true white in the light theme */
    --surface-2: #f3f4f8;               /* a quiet inset inside a card */
    --ring: rgba(139, 92, 246, 0.18);
    --app-max: 1600px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --ok: #166534;
    --ok-soft: rgba(22, 163, 74, 0.12);
    --warn: #92400e;
    --warn-soft: rgba(217, 119, 6, 0.12);
    --bad: #b91c1c;
    --bad-soft: rgba(220, 38, 38, 0.12);
}
:root:not([data-theme="light"]) {
    --surface: #14141f;
    --surface-2: rgba(255, 255, 255, 0.05);
    --ok: #4ade80;
    --warn: #fbbf24;
    --bad: #f87171;
}

/* ----- Page: full width, the page provides the side space ----- */
.container.app-container {
    max-width: calc(var(--app-max) + 2 * var(--content-gutter));
    margin-top: 16px;
}
@media (min-width: 640px) { .container.app-container { margin-top: 24px; } }

/* ----- Tools back link above the header, as on every other tool: the bar scrolls away under the sticky header ----- */
body { padding-top: 0; }
.back-bar { height: 48px; display: flex; align-items: center; padding: 0 var(--zdu-gutter, 24px); }
body > header { position: sticky; top: 0; z-index: 50; }
header .site-nav { position: relative; top: auto; }
.theme-toggle { top: calc(90px + var(--bar-offset, 48px)); }
@media (max-width: 768px) { .theme-toggle { top: calc(75px + var(--bar-offset, 48px)); } }

.visually-hidden, .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.hidden-input { display: none; }
.mb-0 { margin-bottom: 0 !important; }
.mb-sm { margin-bottom: 10px !important; }
.mt-sm { margin-top: 10px; }

/* ----- Hero: brand row, headline, tagline ----- */
.app-hero { margin: 0 0 2rem; text-align: center; }
.app-brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 1.25rem;
    font-family: 'Space Grotesk', 'Inter', sans-serif;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-strong);
}
.app-brand img { width: 44px; height: 44px; border-radius: 12px; display: block; }
.app-hero h1 { margin-bottom: 0.75rem; }
.app-tagline { color: var(--text-2); font-size: 1.125rem; line-height: 1.6; max-width: 46rem; margin: 0 auto; }

/* ----- Buttons: the site's pills in the tool's sizes ----- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 0;
    border-radius: 9999px;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.95rem;
    line-height: 1.2;
    padding: 12px 24px;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.btn-primary { background: var(--gradient-brand); color: #fff; box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3); }
.btn-primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 8px 25px rgba(139, 92, 246, 0.4); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--text-strong); border: 1px solid var(--surface-border); padding: 11px 23px; }
.btn-secondary:hover:not(:disabled) { border-color: var(--brand); color: var(--link); transform: translateY(-2px); }
.btn-danger { background: var(--surface); color: var(--danger); border: 1px solid rgba(185, 28, 28, 0.35); padding: 11px 23px; }
.btn-danger:hover:not(:disabled) { background: var(--danger-strong); color: #fff; border-color: transparent; transform: translateY(-2px); }
.btn-sm { font-size: 0.85rem; padding: 9px 16px; }
.btn-sm svg { width: 15px; height: 15px; }
.btn-secondary.btn-sm, .btn-danger.btn-sm { padding: 8px 15px; }
.btn-icon.btn-sm { width: 38px; height: 38px; padding: 0; }
.btn-icon.btn-sm svg { width: 17px; height: 17px; }
.btn.is-ok { color: var(--ok); border-color: var(--ok); opacity: 1; }
.btn.is-blocked { color: var(--bad); border-color: var(--bad); opacity: 1; }
.btn.is-busy svg { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ----- The app: the toolbar above the dashboard ----- */
.app-shell { margin: 0 0 3rem; scroll-margin-top: 90px; }
.app-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 24px; margin: 0 0 1.25rem; }
.app-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.toolbar-status { display: inline-flex; align-items: center; gap: 10px; }
.source-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    border-radius: 9999px;
    border: 1px solid var(--chip-border);
    background: var(--chip);
    color: var(--text-2);
    font-size: 0.82rem;
    font-weight: 600;
}
.source-badge::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); }
.source-badge.is-live { color: var(--ok); border-color: var(--ok); background: var(--ok-soft); }
.source-badge.is-live::before { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.source-badge.is-demo { color: var(--warn); border-color: var(--warn); background: var(--warn-soft); }
.source-badge.is-demo::before { background: var(--warn); }

.demo-notice {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 14px 18px;
    margin: 0 0 1.25rem;
    border-radius: 14px;
    border: 1px solid var(--warn);
    background: var(--warn-soft);
    color: var(--text);
}
.demo-notice[hidden] { display: none; }
.demo-notice p { margin: 0; font-size: 0.92rem; line-height: 1.5; }
.demo-notice-icon { font-size: 1.2rem; line-height: 1.3; }

/* ----- Dashboard grid: three per row, analytics two wide, suggestions full width ----- */
.dashboard-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; align-items: stretch; }
.analytics-card { grid-column: span 2; }
.suggestions-card { grid-column: 1 / -1; }

/* ----- Cards ----- */
.card {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--surface-shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.card-header { padding: 14px 20px; border-bottom: 1px solid var(--surface-border); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.card-title { margin: 0; font-size: 1.05rem; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.card-note { font-size: 0.8125rem; color: var(--text-3); }
.card-header-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.card-body { padding: 16px 20px 20px; flex: 1; }
.form-hint { font-size: 0.78rem; color: var(--text-3); margin: 10px 0 0; line-height: 1.5; }
.form-hint:first-child { margin-top: 0; }

/* ----- Battery card: the ring and the three readings ----- */
.battery-body { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.battery-visual { position: relative; width: 200px; height: 200px; }
.battery-ring-svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.battery-ring-bg { fill: none; stroke: var(--surface-2); stroke-width: 14; }
.battery-ring { fill: none; stroke: url(#batteryGradient); stroke-width: 14; stroke-linecap: round; transition: stroke-dashoffset 0.8s ease; }
.battery-card.is-low .battery-ring { stroke: var(--bad); }
.battery-percentage {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    font-family: 'Space Grotesk', 'Inter', sans-serif;
    font-size: 2.8rem; font-weight: 700; color: var(--text-strong);
    font-variant-numeric: tabular-nums;
}
.battery-percentage small { font-size: 1.2rem; margin-left: 2px; color: var(--text-2); }
.battery-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; width: 100%; }
.stat { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 6px; border-radius: 12px; background: var(--surface-2); text-align: center; }
.stat-icon { width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center; background: var(--tint-brand); color: var(--link); }
.stat-icon svg { width: 18px; height: 18px; }
.stat-icon.is-charging { background: var(--ok-soft); color: var(--ok); }
.stat-label { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-3); }
.stat-value { font-weight: 700; color: var(--text-strong); font-size: 0.95rem; font-variant-numeric: tabular-nums; }
.stat-value[data-grade="excellent"], .stat-value[data-grade="good"] { color: var(--ok); }
.stat-value[data-grade="fair"] { color: var(--warn); }
.stat-value[data-grade="poor"] { color: var(--bad); }

/* ----- Profiles ----- */
.profile-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.profile-card-wrap { position: relative; }
.profile-card {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 14px 8px 12px;
    border: 1px solid var(--chip-border);
    border-radius: 14px;
    background: var(--chip);
    font-family: inherit;
    color: var(--text);
    cursor: pointer;
    text-align: center;
    transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}
.profile-card:hover { border-color: var(--brand); transform: translateY(-2px); box-shadow: var(--surface-hover-shadow); }
.profile-card.active { background: var(--tint-brand); border-color: var(--brand); box-shadow: 0 0 0 3px var(--ring); }
.profile-card:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.profile-icon { font-size: 1.5rem; line-height: 1; }
.profile-name { font-weight: 600; font-size: 0.85rem; color: var(--text-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.profile-limit { font-size: 0.75rem; color: var(--text-3); font-variant-numeric: tabular-nums; }
.profile-delete {
    position: absolute; top: -8px; right: -8px;
    width: 24px; height: 24px; border-radius: 50%;
    border: 1px solid var(--chip-border); background: var(--surface); color: var(--text-2);
    display: flex; align-items: center; justify-content: center; cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    transition: color 0.2s ease, border-color 0.2s ease;
}
.profile-delete:hover { color: var(--danger); border-color: var(--danger); }
.icon-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.icon-option {
    width: 44px; height: 44px; border-radius: 12px;
    border: 1px solid var(--chip-border); background: var(--chip);
    font-size: 1.3rem; cursor: pointer; font-family: inherit;
    transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}
.icon-option:hover { border-color: var(--brand); transform: translateY(-2px); }
.icon-option.active { background: var(--tint-brand); border-color: var(--brand); box-shadow: 0 0 0 3px var(--ring); }

/* ----- Forms ----- */
.form-group { margin-bottom: 14px; }
.form-group:last-child { margin-bottom: 0; }
.form-label { display: block; margin-bottom: 6px; font-size: 0.85rem; font-weight: 600; color: var(--text-strong); }
.form-input {
    width: 100%;
    min-width: 0;
    padding: 10px 14px;
    background: var(--field);
    border: 1px solid var(--field-border);
    border-radius: 12px;
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text);
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.form-input::placeholder { color: var(--placeholder); }
.form-input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--ring); }
.form-error { margin-top: 4px; font-size: 0.8rem; color: var(--danger); }
.form-error:empty { display: none; }
.check-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.check-row input { width: 18px; height: 18px; accent-color: #8B5CF6; cursor: pointer; }
.check-row label { font-size: 0.95rem; color: var(--text); cursor: pointer; }

/* Sliders: brand fill that follows the value */
.range-label { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.range-value { font-weight: 700; color: var(--link); font-variant-numeric: tabular-nums; }
.range-input {
    --fill: 50%;
    width: 100%;
    height: 6px;
    margin: 8px 0 4px;
    appearance: none;
    -webkit-appearance: none;
    border-radius: 3px;
    background: linear-gradient(90deg, #8B5CF6 0%, #EC4899 var(--fill), var(--surface-2) var(--fill), var(--surface-2) 100%);
    outline: none;
    cursor: pointer;
}
.range-input::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 20px; height: 20px; border-radius: 50%; background: #fff; border: 2px solid #8B5CF6; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2); cursor: pointer; transition: transform 0.15s ease; }
.range-input::-moz-range-thumb { width: 20px; height: 20px; border-radius: 50%; background: #fff; border: 2px solid #8B5CF6; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2); cursor: pointer; }
.range-input::-webkit-slider-thumb:hover { transform: scale(1.1); }
.range-input:focus-visible { box-shadow: 0 0 0 3px var(--ring); }
.range-ends { display: flex; justify-content: space-between; font-size: 0.72rem; color: var(--text-3); font-variant-numeric: tabular-nums; }

/* Switch rows */
.switch-list { display: flex; flex-direction: column; gap: 12px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.switch-row > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.switch-label { font-weight: 600; font-size: 0.92rem; color: var(--text-strong); }
.switch-hint { font-size: 0.78rem; color: var(--text-3); line-height: 1.4; }
.toggle {
    position: relative;
    width: 46px;
    height: 26px;
    flex-shrink: 0;
    border-radius: 9999px;
    border: 0;
    padding: 0;
    background: var(--chip-border);
    cursor: pointer;
    transition: background 0.2s ease;
}
.toggle .toggle-knob { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); transition: transform 0.2s ease; }
.toggle[aria-checked="true"] { background: var(--gradient-brand); }
.toggle[aria-checked="true"] .toggle-knob { transform: translateX(20px); }
.toggle:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ----- Assistant facts ----- */
.fact-list { display: flex; flex-direction: column; gap: 10px; }
.fact-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); }
.fact-row > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.fact-label { font-weight: 600; font-size: 0.9rem; color: var(--text-strong); }
.fact-hint { font-size: 0.75rem; color: var(--text-3); line-height: 1.4; }
.fact-value { font-weight: 700; font-size: 0.95rem; text-align: right; flex-shrink: 0; max-width: 46%; color: var(--text-strong); font-variant-numeric: tabular-nums; }
.fact-value.accent { color: var(--link); }
.fact-value.good { color: var(--ok); }
.fact-value.warn { color: var(--warn); }

/* ----- Analytics ----- */
.analytics-tabs { display: inline-flex; gap: 4px; padding: 4px; border-radius: 9999px; background: var(--surface-2); margin-bottom: 14px; max-width: 100%; }
.analytics-tab {
    padding: 7px 14px;
    border: 0;
    border-radius: 9999px;
    background: transparent;
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-2);
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}
.analytics-tab:hover { color: var(--link); }
.analytics-tab.active { background: var(--gradient-brand); color: #fff; box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3); }
.analytics-tab:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.analytics-panel[hidden] { display: none; }
.chart-box { position: relative; height: 260px; width: 100%; }
.chart-missing { color: var(--text-3); text-align: center; padding: 2rem 0; }
.insight-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.insight { display: flex; flex-direction: column; gap: 2px; padding: 12px; border-radius: 12px; background: var(--surface-2); }
.insight-label { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-3); }
.insight-value { font-family: 'Space Grotesk', 'Inter', sans-serif; font-size: 1.5rem; font-weight: 700; color: var(--text-strong); font-variant-numeric: tabular-nums; }
.insight-value.accent { color: var(--link); }
.insight-value.good { color: var(--ok); }
.insight-hint { font-size: 0.72rem; color: var(--text-3); }
.carbon-widget { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: 14px; background: var(--ok-soft); border: 1px solid rgba(22, 163, 74, 0.3); }
.carbon-icon { font-size: 1.8rem; line-height: 1; }
.carbon-title { font-weight: 600; font-size: 0.9rem; color: var(--text-strong); }
.carbon-value { font-family: 'Space Grotesk', 'Inter', sans-serif; font-size: 1.5rem; font-weight: 700; color: var(--ok); margin: 2px 0; }

/* ----- Battery profile bars ----- */
.profile-bars { display: flex; flex-direction: column; gap: 12px; }
.profile-bar-label { display: flex; justify-content: space-between; gap: 10px; font-size: 0.85rem; color: var(--text-2); margin-bottom: 5px; }
.profile-bar-value { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.profile-bar-track { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.profile-bar-fill { height: 100%; border-radius: 4px; width: 0; transition: width 0.8s ease; }
.grade-good { color: var(--ok); }
.grade-fair { color: var(--warn); }
.grade-poor { color: var(--bad); }
.profile-bar-fill.grade-good { background: linear-gradient(90deg, #16a34a, #4ade80); }
.profile-bar-fill.grade-fair { background: linear-gradient(90deg, #d97706, #fbbf24); }
.profile-bar-fill.grade-poor { background: linear-gradient(90deg, #dc2626, #f87171); }

/* ----- Suggestions ----- */
.suggestion-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.suggestion-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid var(--surface-border);
    background: var(--surface-2);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.suggestion-card:hover { transform: translateY(-2px); box-shadow: var(--surface-hover-shadow); border-color: var(--brand); }
.suggestion-card.type-urgent, .suggestion-card.type-overlimit { border-color: var(--bad); background: var(--bad-soft); }
.suggestion-head { display: flex; align-items: center; gap: 8px; }
.suggestion-icon { font-size: 1.2rem; line-height: 1; }
.suggestion-title { margin: 0; font-size: 0.98rem; font-weight: 700; color: var(--text-strong); }
.suggestion-text { margin: 0; font-size: 0.88rem; color: var(--text-2); line-height: 1.5; }
.suggestion-action { align-self: flex-start; margin-top: auto; }
.grid-status { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; color: var(--text-3); }
.grid-status-dot { width: 9px; height: 9px; border-radius: 50%; }
.grid-status-dot.is-low { background: var(--ok); }
.grid-status-dot.is-normal { background: var(--warn); }
.grid-status-dot.is-peak { background: var(--bad); }

/* ----- Tone presets ----- */
.tone-presets { display: flex; flex-wrap: wrap; gap: 8px; }
.tone-btn {
    padding: 8px 14px;
    border-radius: 9999px;
    border: 1px solid var(--chip-border);
    background: var(--chip);
    color: var(--text-2);
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}
.tone-btn:hover { border-color: var(--brand); color: var(--link); }
.tone-btn.active { background: var(--gradient-brand); color: #fff; border-color: transparent; }

/* ----- The alert notice ----- */
.alert-overlay {
    position: fixed;
    inset: auto 24px 24px auto;
    z-index: 2500;
    max-width: 380px;
    animation: slideIn 0.35s ease;
}
.alert-box {
    background: var(--surface);
    border: 2px solid var(--bad);
    border-radius: 18px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
    padding: 16px 18px;
    animation: pulseBorder 1.2s ease-in-out infinite;
}
@keyframes pulseBorder { 0%, 100% { box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35), 0 0 0 0 rgba(220, 38, 38, 0.4); } 50% { box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35), 0 0 0 10px rgba(220, 38, 38, 0); } }
.alert-box-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.alert-box-emoji { font-size: 1.4rem; line-height: 1; }
.alert-box-title { font-size: 1.05rem; color: var(--text-strong); }
.alert-box-body { margin: 0 0 12px; color: var(--text-2); font-size: 0.92rem; line-height: 1.5; }
.alert-box-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ----- Windows ----- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 20, 0.6);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}
.modal-overlay.active { opacity: 1; visibility: visible; }
.modal {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: 20px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
    width: 100%;
    max-width: 520px;
    max-height: 92vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: translateY(12px);
    transition: transform 0.25s ease;
}
.modal--narrow { max-width: 420px; }
.modal-overlay.active .modal { transform: translateY(0); }
.modal-header { padding: 18px 20px; border-bottom: 1px solid var(--surface-border); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.modal-title { margin: 0; font-size: 1.15rem; }
.modal-close {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border-radius: 50%;
    border: 1px solid var(--chip-border);
    background: var(--chip);
    color: var(--text-strong);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.2s ease, color 0.2s ease;
}
.modal-close:hover { border-color: var(--brand); color: var(--link); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--surface-border); display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.modal-hint { margin-top: 14px; }
.modal-section-title { margin: 0 0 10px; font-size: 0.95rem; }
.modal-section-title + .switch-row { margin-bottom: 6px; }
.modal-body .form-hint + .modal-section-title { margin-top: 20px; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.confirm-message { margin: 0; color: var(--text); }
.shortcuts-list { display: grid; gap: 10px; }
.shortcut-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.shortcut-keys { display: flex; gap: 4px; }
.shortcut-key {
    background: var(--surface-2);
    border: 1px solid var(--surface-border);
    border-radius: 6px;
    padding: 2px 8px;
    font-size: 0.75rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-weight: 600;
    color: var(--text-2);
}
.shortcut-description { font-size: 0.875rem; color: var(--text-2); }

/* ----- Toasts ----- */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 3000; display: flex; flex-direction: column; gap: 10px; max-width: calc(100vw - 32px); }
.toast {
    background: #0a0a14;
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-left: 4px solid var(--brand);
    border-radius: 14px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3);
    min-width: 260px;
    max-width: 400px;
    font-size: 0.875rem;
    font-weight: 500;
    overflow-wrap: anywhere;
    animation: slideIn 0.3s ease;
    transition: opacity 0.3s ease, transform 0.3s ease;
}
.toast-icon { font-size: 1.1rem; line-height: 1; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.toast.success { border-left-color: #4ade80; }
.toast.error { border-left-color: #f87171; }
.toast.warning { border-left-color: #fbbf24; }
.toast.info { border-left-color: #38bdf8; }
.toast.leaving { opacity: 0; transform: translateX(40px); }

/* ----- Information sections below the tool ----- */
.info-section { margin: 0 0 2.5rem; }
.info-section h2 { font-size: 1.75rem; margin: 0 0 1.25rem; }
.info-section > p { max-width: 70ch; }
.info-section .info-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.info-three { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin: 1rem 0 1.5rem; }
.info-stack { display: grid; gap: 12px; }
.info-card {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: 16px;
    box-shadow: var(--surface-shadow);
    padding: 20px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.info-card:hover { transform: translateY(-4px); box-shadow: var(--surface-hover-shadow); }
.info-card--small { padding: 16px; box-shadow: none; }
.info-card h3 { margin: 0 0 0.75rem; font-size: 1.15rem; }
.info-card p { color: var(--text-2); margin-bottom: 0.75rem; }
.info-card p:last-child { margin-bottom: 0; }
.info-section article:not(.info-card) p { color: var(--text-2); max-width: 70ch; }
.step-card { position: relative; padding-top: 24px; }
.step-num {
    position: absolute;
    top: -16px;
    left: 20px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--gradient-brand);
    color: #fff;
    font-weight: 700;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}
.step-head { display: flex; align-items: center; gap: 12px; margin-bottom: 0.75rem; }
.step-head h3 { margin: 0; }
.step-emoji { font-size: 1.6rem; line-height: 1; }
.info-section details.info-card { padding: 0; }
.info-section details.info-card summary {
    cursor: pointer;
    padding: 16px 20px;
    font-weight: 600;
    color: var(--text-strong);
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}
.info-section details.info-card summary::-webkit-details-marker { display: none; }
.info-section details.info-card summary::after { content: '+'; color: var(--link); font-weight: 700; font-size: 1.2rem; line-height: 1; flex-shrink: 0; }
.info-section details.info-card[open] summary::after { content: '\2212'; }
.info-section details.info-card p { padding: 0 20px 16px; margin: 0; color: var(--text-2); }

/* ----- Tablets ----- */
@media (max-width: 1023px) {
    .dashboard-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .battery-card { grid-column: span 2; }
    .analytics-card { grid-column: span 2; }
    .battery-body { flex-direction: row; justify-content: center; gap: 28px; }
    .battery-stats { width: auto; flex: 1; max-width: 420px; }
    .insight-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .info-section .info-grid, .info-three { grid-template-columns: repeat(2, 1fr); }
}

/* ----- Phones ----- */
@media (max-width: 639px) {
    .app-hero { margin-bottom: 1.5rem; }
    .app-tagline { font-size: 1rem; }
    .app-toolbar { gap: 10px; }
    .app-actions { width: 100%; }
    .app-actions .btn { flex: 1 1 auto; padding-left: 12px; padding-right: 12px; }
    .dashboard-grid { grid-template-columns: 1fr; gap: 16px; }
    .battery-card, .analytics-card { grid-column: auto; }
    .battery-body { flex-direction: column; gap: 14px; }
    .battery-visual { width: 170px; height: 170px; }
    .battery-percentage { font-size: 2.3rem; }
    .battery-stats { width: 100%; max-width: none; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
    .stat { padding: 8px 4px; }
    .stat-label { font-size: 0.66rem; }
    .stat-value { font-size: 0.85rem; }
    .card-header { padding-left: 16px; padding-right: 16px; }
    .card-body { padding: 14px 16px 16px; }
    .profile-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
    .profile-card { padding: 10px 4px 8px; }
    .analytics-tabs { width: 100%; overflow-x: auto; }
    .analytics-tab { flex: 1; padding-left: 10px; padding-right: 10px; }
    .chart-box { height: 220px; }
    .insight-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .insight-value { font-size: 1.25rem; }
    .fact-value { max-width: 50%; font-size: 0.88rem; }
    .alert-overlay { inset: auto 16px 16px 16px; max-width: none; }
    .modal-overlay { padding: 8px; }
    .modal-body, .modal-header, .modal-footer { padding-left: 16px; padding-right: 16px; }
    .toast-container { bottom: 16px; right: 16px; left: 16px; align-items: flex-end; }
    .toast { min-width: 0; }
    .info-section h2 { font-size: 1.4rem; }
    .info-section .info-grid, .info-three { grid-template-columns: 1fr; }
    .info-card { padding: 16px; }
    .step-num { left: 16px; }
}

@media (prefers-reduced-motion: reduce) {
    .btn, .info-card, .modal, .toast, .toggle .toggle-knob, .profile-card, .suggestion-card, .battery-ring, .profile-bar-fill, .alert-overlay, .alert-box, .btn.is-busy svg { transition: none; animation: none; }
}

/* Phones: 16 px text, 44 px tap targets (AdSense audit H-04, 8 Oct 2026) */
@media (max-width: 639.98px) {
    main button, main select, main summary, main [role="button"],
    main input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]) { min-height: 44px; }
    article.suggestion-card.type-grid > p.suggestion-text,
    article.suggestion-card.type-optimize > p.suggestion-text,
    article.suggestion-card.type-overlimit > p.suggestion-text,
    div#usage-tab.analytics-panel > p.form-hint,
    div.alert-box > p.alert-box-body,
    div.card-body > p.form-hint { font-size: 1rem; }
    main button#addProfileBtn, main button#notificationSettingsBtn { min-width: 44px; }
}
