:root {
    color-scheme: light dark;
    --bg: #f4f7fb;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --surface-raised: #ffffff;
    --text: #172033;
    --muted: #64748b;
    --line: #dbe3ee;
    --line-strong: #c5d0df;
    --primary: #2457a7;
    --primary-dark: #193f7d;
    --primary-soft: #e9f0fb;
    --success: #177245;
    --success-soft: #e9f7ef;
    --warning: #9a5b00;
    --warning-soft: #fff5db;
    --danger: #a62d2d;
    --danger-soft: #fdecec;
    --shadow: 0 12px 34px rgba(31, 49, 78, 0.08);
    --shadow-strong: 0 18px 50px rgba(31, 49, 78, 0.16);
    --header-bg: rgba(255, 255, 255, 0.94);
    --nav-bg: rgba(255, 255, 255, 0.97);
    --focus: rgba(36, 87, 167, 0.32);
    --radius: 16px;
    --radius-small: 10px;
    --content: 1500px;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--bg);
}

body {
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0;
    background:
        radial-gradient(circle at top right, rgba(36, 87, 167, 0.08), transparent 30rem),
        var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 16px;
    line-height: 1.55;
}

[hidden] {
    display: none !important;
}

svg {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.skip-link {
    position: fixed;
    z-index: 200;
    top: calc(0.5rem + env(safe-area-inset-top));
    left: calc(0.5rem + env(safe-area-inset-left));
    padding: 0.7rem 0.9rem;
    border-radius: 10px;
    background: var(--text);
    box-shadow: var(--shadow-strong);
    color: var(--surface);
    font-weight: 800;
    transform: translateY(-180%);
    transition: transform 150ms ease;
}

.skip-link:focus {
    color: var(--surface);
    transform: translateY(0);
}

button,
input,
select,
textarea {
    font: inherit;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    color: var(--primary-dark);
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 0.45rem;
    font-size: clamp(1.8rem, 2.7vw, 2.65rem);
    line-height: 1.12;
    letter-spacing: -0.035em;
}

h2 {
    margin-bottom: 0.25rem;
    font-size: 1.2rem;
    line-height: 1.25;
}

h3 {
    font-size: 1rem;
}

small,
.muted {
    color: var(--muted);
}

code,
pre {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

pre {
    max-width: 100%;
    margin: 0;
    overflow: auto;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.site-header {
    position: sticky;
    z-index: 50;
    top: 0;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 1.25rem;
    min-height: 74px;
    padding: 0.75rem max(1.1rem, calc((100vw - var(--content)) / 2));
    border-bottom: 1px solid rgba(197, 208, 223, 0.85);
    background: var(--header-bg);
    box-shadow: 0 4px 20px rgba(31, 49, 78, 0.05);
    backdrop-filter: blur(14px);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text);
}

.brand:hover {
    color: var(--text);
}

.brand > span:last-child {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.brand-icon {
    display: block;
    width: 42px;
    height: 42px;
    flex: 0 0 auto;
    border-radius: 13px;
    box-shadow: 0 8px 18px rgba(36, 87, 167, 0.2);
}

.brand small {
    margin-top: 0.2rem;
    font-size: 0.72rem;
    letter-spacing: 0.055em;
    text-transform: uppercase;
}

.brand-mark {
    display: inline-grid;
    width: 42px;
    height: 42px;
    place-items: center;
    flex: 0 0 auto;
    border-radius: 13px;
    background: linear-gradient(145deg, var(--primary), var(--primary-dark));
    box-shadow: 0 8px 18px rgba(36, 87, 167, 0.22);
    color: #fff;
    font-weight: 800;
    letter-spacing: -0.05em;
}

.brand-mark-large {
    width: 64px;
    height: 64px;
    border-radius: 20px;
    font-size: 1.65rem;
}

.primary-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
}

.primary-nav a {
    display: inline-flex;
    min-height: 44px;
    padding: 0.55rem 0.68rem;
    border-radius: 9px;
    color: #344155;
    font-size: 0.9rem;
    font-weight: 650;
    align-items: center;
    gap: 0.45rem;
}

.primary-nav a svg {
    width: 19px;
    height: 19px;
}

.primary-nav a:hover,
.primary-nav a[aria-current="page"] {
    background: var(--primary-soft);
    color: var(--primary-dark);
}

.nav-toggle {
    display: none;
    min-height: 44px;
    padding: 0.55rem 0.8rem;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    align-items: center;
    gap: 0.4rem;
}

.nav-toggle svg {
    width: 20px;
    height: 20px;
}

.logout-form {
    margin: 0;
}

.page-shell {
    width: min(calc(100% - 2rem), var(--content));
    min-height: calc(100vh - 145px);
    margin: 0 auto;
    padding: 2rem 0 3rem;
}

.page-shell:focus {
    outline: none;
}

.page-shell-login {
    display: grid;
    width: min(calc(100% - 2rem), 520px);
    min-height: 100vh;
    place-items: center;
    padding: 2rem 0;
}

.site-footer {
    display: flex;
    width: min(calc(100% - 2rem), var(--content));
    margin: 0 auto;
    padding: 0 0 2rem;
    justify-content: space-between;
    gap: 1rem;
    color: var(--muted);
    font-size: 0.83rem;
}

.page-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.page-heading > div:first-child {
    max-width: 850px;
}

.page-heading p:not(.eyebrow) {
    margin-bottom: 0;
    color: var(--muted);
    font-size: 1.02rem;
}

.eyebrow {
    margin-bottom: 0.45rem;
    color: var(--primary);
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.notice {
    margin-bottom: 1.25rem;
    padding: 0.9rem 1rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-small);
    background: var(--surface);
    box-shadow: 0 5px 18px rgba(31, 49, 78, 0.04);
}

.notice-success {
    border-color: #b9ddc9;
    background: var(--success-soft);
    color: #0f5b36;
}

.notice-warning {
    border-color: #ecd392;
    background: var(--warning-soft);
    color: #754500;
}

.notice-error,
.notice-danger {
    border-color: #efb8b8;
    background: var(--danger-soft);
    color: #812020;
}

.notice-info {
    border-color: #bfd0eb;
    background: var(--primary-soft);
    color: #173f7c;
}

.button {
    display: inline-flex;
    min-height: 42px;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.62rem 0.92rem;
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    background: var(--surface);
    box-shadow: 0 2px 6px rgba(31, 49, 78, 0.05);
    color: #28364a;
    font-weight: 700;
    line-height: 1.15;
    cursor: pointer;
    transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease, background 120ms ease;
}

.button:hover {
    border-color: #9eacc0;
    box-shadow: 0 5px 14px rgba(31, 49, 78, 0.1);
    color: #192638;
    transform: translateY(-1px);
}

.button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible,
summary:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}

.button:disabled {
    opacity: 0.6;
    cursor: wait;
    transform: none;
}

.button-primary {
    border-color: var(--primary);
    background: var(--primary);
    color: #fff;
}

.button-primary:hover {
    border-color: var(--primary-dark);
    background: var(--primary-dark);
    color: #fff;
}

.button-warning {
    border-color: #d9a43f;
    background: var(--warning-soft);
    color: #754500;
}

.button-danger {
    border-color: var(--danger);
    background: var(--danger);
    color: #fff;
}

.button-danger:hover {
    border-color: #7f1f1f;
    background: #7f1f1f;
    color: #fff;
}

.button-quiet {
    border-color: transparent;
    background: transparent;
    box-shadow: none;
}

.button-wide {
    width: 100%;
}

.button-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.65rem;
}

.button-row form {
    margin: 0;
}

.text-link {
    flex: 0 0 auto;
    font-size: 0.9rem;
    font-weight: 700;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.metric-card {
    display: flex;
    min-height: 128px;
    padding: 1.2rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    flex-direction: column;
    justify-content: center;
    color: var(--text);
}

.metric-card:hover {
    border-color: #b9c7d8;
    color: var(--text);
    transform: translateY(-1px);
}

.metric-alert {
    border-color: #e6aaaa;
    background: linear-gradient(135deg, var(--surface), var(--danger-soft));
}

.metric-warning {
    border-color: #e6c16f;
    background: linear-gradient(135deg, var(--surface), var(--warning-soft));
}

.metric-value {
    font-size: 2.15rem;
    font-weight: 820;
    line-height: 1;
    letter-spacing: -0.045em;
}

.metric-label {
    margin-top: 0.55rem;
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 650;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.panel {
    min-width: 0;
    margin-bottom: 1rem;
    padding: 1.25rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.panel-span-2 {
    grid-column: span 2;
}

.panel-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.panel-heading h2 {
    margin-bottom: 0.2rem;
}

.panel-heading p {
    margin-bottom: 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.empty-state,
.good-state {
    display: flex;
    min-height: 150px;
    padding: 1.5rem;
    border: 1px dashed var(--line-strong);
    border-radius: 12px;
    background: var(--surface-soft);
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 0.45rem;
    color: var(--muted);
}

.good-state {
    border-color: #b9ddc9;
    background: var(--success-soft);
    color: #155f3b;
}

.agenda-list {
    display: grid;
    gap: 0.25rem;
}

.agenda-day {
    margin: 1.05rem 0 0.3rem;
    padding-bottom: 0.45rem;
    border-bottom: 1px solid var(--line);
    color: #41506a;
}

.agenda-day:first-child {
    margin-top: 0;
}

.agenda-item {
    display: grid;
    grid-template-columns: 100px minmax(0, 1fr) auto;
    gap: 1rem;
    padding: 0.8rem 0.4rem;
    border-bottom: 1px solid #edf1f6;
}

.agenda-time {
    color: #44536b;
    font-size: 0.88rem;
    font-weight: 720;
}

.agenda-body {
    display: flex;
    min-width: 0;
    flex-direction: column;
}

.agenda-body strong {
    overflow-wrap: anywhere;
}

.agenda-body span {
    color: var(--muted);
    font-size: 0.85rem;
    overflow-wrap: anywhere;
}

.agenda-status {
    display: flex;
    align-items: flex-start;
    gap: 0.35rem;
}

.badge {
    display: inline-flex;
    max-width: 100%;
    align-items: center;
    padding: 0.24rem 0.48rem;
    border: 1px solid #ccd6e4;
    border-radius: 999px;
    background: #f4f7fb;
    color: #44536b;
    font-size: 0.7rem;
    font-weight: 780;
    letter-spacing: 0.025em;
    line-height: 1.2;
    text-transform: uppercase;
}

.badge-warning,
.badge-medium {
    border-color: #e7c46f;
    background: var(--warning-soft);
    color: #754500;
}

.badge-critical,
.badge-error {
    border-color: #edaaaa;
    background: var(--danger-soft);
    color: #8d2525;
}

.badge-high {
    border-color: #e9b58a;
    background: #fff0e4;
    color: #884417;
}

.badge-low,
.badge-info,
.badge-success {
    border-color: #b8d7c6;
    background: var(--success-soft);
    color: #155f3b;
}

.compact-list {
    display: grid;
    gap: 0.5rem;
}

.compact-item {
    display: flex;
    padding: 0.75rem;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: var(--surface-soft);
    flex-direction: column;
    gap: 0.16rem;
    color: var(--text);
}

.compact-item:hover {
    border-color: #b4c1d2;
    background: #fff;
    color: var(--text);
}

.compact-item-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.75rem;
}

.compact-item-row > span:nth-child(2) {
    display: flex;
    flex-direction: column;
}

.health-dot {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: #b5bfcc;
    box-shadow: 0 0 0 4px rgba(181, 191, 204, 0.16);
}

.health-good {
    background: #2e9b62;
    box-shadow: 0 0 0 4px rgba(46, 155, 98, 0.14);
}

.health-bad {
    background: #c44242;
    box-shadow: 0 0 0 4px rgba(196, 66, 66, 0.14);
}

.health-disabled {
    background: #8d98a8;
}

.source-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.source-card {
    min-width: 0;
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: var(--surface-soft);
}

.source-disabled {
    opacity: 0.72;
}

.source-card-heading {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: start;
    gap: 0.75rem;
    margin-bottom: 0.9rem;
}

.source-card-heading h2 {
    margin: 0;
    overflow-wrap: anywhere;
}

.source-card-heading p {
    margin: 0.15rem 0 0;
    color: var(--muted);
    font-size: 0.85rem;
    overflow-wrap: anywhere;
}

.detail-list {
    display: grid;
    margin: 0 0 1rem;
    gap: 0;
}

.detail-list > div {
    display: grid;
    grid-template-columns: minmax(110px, 0.42fr) minmax(0, 1fr);
    gap: 0.75rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--line);
}

.detail-list dt {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 750;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.detail-list dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.form-layout {
    display: grid;
    gap: 0;
}

.form-section {
    margin-bottom: 1rem;
}

.form-grid {
    display: grid;
    gap: 1rem;
}

.form-grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-span-2 {
    grid-column: span 2;
}

label:not(.checkbox) {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 0.35rem;
    color: #354259;
    font-size: 0.88rem;
    font-weight: 720;
}

label > small,
fieldset > small {
    font-weight: 450;
}

input,
select,
textarea {
    width: 100%;
    min-height: 43px;
    padding: 0.62rem 0.7rem;
    border: 1px solid var(--line-strong);
    border-radius: 9px;
    background: #fff;
    color: var(--text);
}

textarea {
    min-height: 110px;
    resize: vertical;
}

input::placeholder,
textarea::placeholder {
    color: #98a4b5;
}

fieldset {
    min-width: 0;
    margin: 0;
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: 11px;
}

legend {
    padding: 0 0.35rem;
    color: #354259;
    font-size: 0.88rem;
    font-weight: 760;
}

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.6rem;
}

.checkbox-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.checkbox {
    display: flex;
    min-height: 48px;
    padding: 0.65rem;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface-soft);
    align-items: flex-start;
    gap: 0.6rem;
    cursor: pointer;
}

.checkbox:hover {
    border-color: #b5c2d3;
}

.checkbox input {
    width: 18px;
    min-width: 18px;
    height: 18px;
    min-height: 18px;
    margin-top: 0.15rem;
}

.checkbox span {
    display: flex;
    min-width: 0;
    flex-direction: column;
    font-size: 0.88rem;
}

.checkbox small {
    margin-top: 0.12rem;
    font-weight: 450;
}

.checkbox-standalone {
    align-self: end;
}

.field-error,
.inline-error {
    color: var(--danger);
    font-weight: 650;
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    margin-bottom: 1rem;
}

.action-spacer {
    flex: 1;
}

.danger-zone {
    display: flex;
    border-color: #e7b9b9;
    background: linear-gradient(145deg, #fff, var(--danger-soft));
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.danger-zone p {
    margin-bottom: 0;
    color: #784040;
}

.confirm-form {
    display: flex;
    min-width: min(100%, 360px);
    align-items: flex-end;
    gap: 0.6rem;
}

.confirm-form label {
    flex: 1;
}

.filter-form {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
}

.filter-form label {
    min-width: 145px;
}

.filter-grow {
    flex: 1;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 11px;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    font-size: 0.88rem;
}

th,
td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

th {
    background: var(--surface-soft);
    color: #44536b;
    font-size: 0.72rem;
    letter-spacing: 0.045em;
    text-transform: uppercase;
}

tbody tr:last-child td {
    border-bottom: 0;
}

tbody tr:hover td {
    background: #fbfcfe;
}

.nowrap {
    white-space: nowrap;
}

.tab-nav {
    display: flex;
    margin-bottom: 1rem;
    gap: 0.45rem;
    overflow-x: auto;
}

.tab-nav a {
    padding: 0.55rem 0.8rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: #45536a;
    font-size: 0.86rem;
    font-weight: 700;
    white-space: nowrap;
}

.tab-nav a.active {
    border-color: var(--primary);
    background: var(--primary);
    color: #fff;
}

.conflict-list {
    display: grid;
    gap: 0.85rem;
}

.conflict-card {
    display: grid;
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: var(--surface-soft);
    gap: 0.8rem;
    color: var(--text);
}

.conflict-card:hover {
    border-color: #b7c4d5;
    background: #fff;
    color: var(--text);
}

.conflict-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
}

.conflict-events {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: 0.75rem;
}

.conflict-events > div {
    display: flex;
    min-width: 0;
    flex-direction: column;
}

.conflict-events strong,
.conflict-events span {
    overflow-wrap: anywhere;
}

.conflict-events span {
    color: var(--muted);
    font-size: 0.85rem;
}

.conflict-versus,
.comparison-symbol {
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary-dark);
    font-size: 0.74rem;
    font-weight: 800;
}

.conflict-note {
    margin: 0;
    color: var(--muted);
    font-size: 0.88rem;
}

.event-comparison {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: stretch;
    gap: 1rem;
}

.event-detail {
    min-width: 0;
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface-soft);
}

.event-detail h2,
.event-detail p {
    overflow-wrap: anywhere;
}

.event-detail p:last-child {
    margin-bottom: 0;
}

.token-panel {
    border-color: #b9ccec;
    background: linear-gradient(145deg, #fff, var(--primary-soft));
}

.secret-box {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.secret-box code {
    display: block;
    min-width: 0;
    padding: 0.8rem;
    border: 1px solid var(--line-strong);
    border-radius: 9px;
    background: #fff;
    flex: 1;
    overflow-wrap: anywhere;
}

.setup-steps {
    padding-left: 1.25rem;
}

.setup-steps li {
    margin-bottom: 0.6rem;
}

.test-result pre,
.log-list pre {
    padding: 0.9rem;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #152033;
    color: #ecf3ff;
    font-size: 0.8rem;
}

.log-list {
    display: grid;
    gap: 0.55rem;
}

.log-list details {
    padding: 0.7rem;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface-soft);
}

.log-list summary {
    cursor: pointer;
    font-weight: 700;
}

.log-list details p {
    margin: 0.75rem 0;
}

.login-card {
    width: 100%;
    padding: 2rem;
    border: 1px solid var(--line);
    border-radius: 22px;
    background: var(--surface);
    box-shadow: 0 24px 65px rgba(31, 49, 78, 0.14);
}

.login-brand {
    display: flex;
    margin-bottom: 1.5rem;
    align-items: center;
    gap: 1rem;
}

.login-brand h1 {
    margin-bottom: 0.25rem;
    font-size: 1.65rem;
}

.login-brand p {
    margin: 0;
    color: var(--muted);
}

.stack-form {
    display: grid;
    gap: 1rem;
}

@media (max-width: 1120px) {
    .site-header {
        grid-template-columns: auto auto 1fr auto;
    }

    .nav-toggle {
        display: inline-flex;
    }

    .primary-nav {
        position: absolute;
        top: calc(100% + 1px);
        right: 1rem;
        left: 1rem;
        display: none;
        padding: 0.75rem;
        border: 1px solid var(--line);
        border-radius: 12px;
        background: #fff;
        box-shadow: var(--shadow);
        flex-direction: column;
        align-items: stretch;
    }

    .primary-nav.is-open {
        display: flex;
    }

    .primary-nav a {
        padding: 0.7rem;
    }

    .metric-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 820px) {
    .site-header {
        grid-template-columns: minmax(0, 1fr) auto auto;
        gap: 0.7rem;
    }

    .brand > span:last-child {
        display: none;
    }

    .page-shell {
        width: min(calc(100% - 1.2rem), var(--content));
        padding-top: 1.25rem;
    }

    .page-heading,
    .danger-zone {
        flex-direction: column;
    }

    .dashboard-grid,
    .source-grid,
    .form-grid-2,
    .form-grid-3,
    .checkbox-grid {
        grid-template-columns: 1fr;
    }

    .panel-span-2,
    .form-span-2 {
        grid-column: auto;
    }

    .filter-form {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .filter-grow,
    .filter-form .button {
        grid-column: span 2;
    }

    .event-comparison {
        grid-template-columns: 1fr;
    }

    .comparison-symbol {
        margin: -0.35rem auto;
    }

    .confirm-form {
        width: 100%;
        min-width: 0;
    }
}

@media (max-width: 560px) {
    .site-header {
        min-height: 64px;
        padding: 0.55rem 0.7rem;
    }

    .brand-mark {
        width: 38px;
        height: 38px;
    }

    .logout-form .button {
        min-height: 38px;
        padding: 0.5rem 0.65rem;
        font-size: 0.82rem;
    }

    .metric-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.65rem;
    }

    .metric-card {
        min-height: 105px;
        padding: 0.85rem;
    }

    .metric-value {
        font-size: 1.7rem;
    }

    .panel,
    .login-card {
        padding: 1rem;
        border-radius: 13px;
    }

    .agenda-item {
        grid-template-columns: 72px minmax(0, 1fr);
        gap: 0.7rem;
    }

    .agenda-status {
        grid-column: 2;
    }

    .compact-item-row {
        grid-template-columns: auto minmax(0, 1fr);
    }

    .compact-item-row > small:last-child {
        grid-column: 2;
    }

    .source-card-heading {
        grid-template-columns: auto minmax(0, 1fr);
    }

    .source-card-heading > .badge {
        grid-column: 2;
        justify-self: start;
    }

    .detail-list > div {
        grid-template-columns: 1fr;
        gap: 0.1rem;
    }

    .filter-form {
        grid-template-columns: 1fr;
    }

    .filter-grow,
    .filter-form .button {
        grid-column: auto;
    }

    .conflict-events {
        grid-template-columns: 1fr;
    }

    .conflict-versus {
        margin: 0 auto;
    }

    .secret-box,
    .confirm-form,
    .form-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .action-spacer {
        display: none;
    }

    .site-footer {
        flex-direction: column;
        gap: 0.25rem;
    }
}

/* Mobile-first daily home screen */
.simulation-notice {
    display: flex;
    max-width: 980px;
    margin: 0 auto 1rem;
    padding: 0.65rem 0.8rem;
    border: 1px solid #c7d5eb;
    border-radius: 12px;
    background: #f1f6fd;
    align-items: center;
    gap: 0.65rem;
    color: #284b7d;
    font-size: 0.82rem;
}

.simulation-notice > span:nth-child(2) {
    display: flex;
    min-width: 0;
    flex: 1;
    flex-direction: column;
}

.simulation-notice small {
    color: #5b718f;
}

.simulation-notice a {
    font-weight: 750;
}

.simulation-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--primary);
    box-shadow: 0 0 0 4px rgba(36, 87, 167, 0.12);
}

.home-dashboard {
    width: 100%;
    max-width: 980px;
    margin: 0 auto;
}

.today-header {
    display: flex;
    margin-bottom: 1rem;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.today-header h1 {
    margin-bottom: 0.25rem;
    font-size: clamp(2rem, 6vw, 3rem);
}

.today-header p:last-child {
    margin: 0;
    color: var(--muted);
}

.today-date,
.section-kicker {
    margin: 0 0 0.2rem;
    color: var(--primary);
    font-size: 0.75rem;
    font-weight: 820;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.refresh-form {
    margin: 0;
}

.refresh-button {
    display: inline-flex;
    min-height: 42px;
    padding: 0.55rem 0.8rem;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: var(--surface);
    box-shadow: 0 3px 12px rgba(31, 49, 78, 0.05);
    align-items: center;
    gap: 0.38rem;
    color: #354259;
    font-weight: 750;
    cursor: pointer;
}

.refresh-button:hover {
    border-color: #aebcd0;
    color: var(--primary-dark);
}

.refresh-button > span:first-child {
    font-size: 1.2rem;
    line-height: 1;
}

.attention-banner {
    display: grid;
    margin-bottom: 1rem;
    padding: 0.85rem 0.95rem;
    border: 1px solid #efb4b4;
    border-radius: 14px;
    background: var(--danger-soft);
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.8rem;
    color: #7e2424;
}

.attention-banner:hover {
    border-color: #db8e8e;
    color: #671b1b;
}

.attention-banner > span:nth-child(2) {
    display: flex;
    min-width: 0;
    flex-direction: column;
}

.attention-banner small {
    color: #915151;
}

.attention-count {
    display: grid;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--danger);
    place-items: center;
    color: #fff;
    font-size: 1.05rem;
    font-weight: 850;
}

.attention-arrow {
    font-size: 1.8rem;
    line-height: 1;
}

.next-card,
.home-section {
    margin-bottom: 1rem;
    border: 1px solid var(--line);
    border-radius: 17px;
    background: var(--surface);
    box-shadow: 0 8px 24px rgba(31, 49, 78, 0.06);
}

.next-card {
    padding: 1rem;
    border-color: #b8cae7;
    background: linear-gradient(145deg, #fff, #f3f7fd);
}

.next-event {
    display: grid;
    grid-template-columns: minmax(120px, 0.28fr) minmax(0, 1fr) auto;
    align-items: center;
    gap: 1rem;
}

.next-when,
.next-details,
.next-empty {
    display: flex;
    min-width: 0;
    flex-direction: column;
}

.next-when strong {
    color: var(--primary-dark);
    font-size: 0.92rem;
}

.next-when span,
.next-details p,
.next-empty span {
    margin: 0;
    color: var(--muted);
    font-size: 0.88rem;
}

.next-details h2 {
    margin: 0 0 0.2rem;
    font-size: clamp(1.15rem, 3vw, 1.45rem);
    overflow-wrap: anywhere;
}

.next-location {
    margin-top: 0.18rem !important;
    overflow-wrap: anywhere;
}

.next-empty {
    padding: 0.35rem 0;
    gap: 0.2rem;
}

.home-section {
    padding: 1rem;
}

.home-section-heading {
    display: flex;
    margin-bottom: 0.8rem;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
}

.home-section-heading h2 {
    margin: 0;
    font-size: 1.25rem;
}

.home-section-heading a {
    flex: 0 0 auto;
    font-size: 0.86rem;
    font-weight: 760;
}

.simple-empty {
    display: flex;
    min-height: 90px;
    padding: 1rem;
    border: 1px dashed var(--line-strong);
    border-radius: 12px;
    background: var(--surface-soft);
    flex-direction: column;
    justify-content: center;
    gap: 0.2rem;
    color: var(--muted);
}

.simple-empty strong {
    color: var(--text);
}

.simple-empty-good {
    border-color: #b8dbc7;
    background: var(--success-soft);
}

.simple-empty-good strong,
.simple-empty-good span {
    color: #175c3a;
}

.today-timeline {
    display: grid;
}

.timeline-event {
    display: grid;
    min-height: 78px;
    grid-template-columns: 58px 18px minmax(0, 1fr);
    gap: 0.55rem;
}

.timeline-time {
    display: flex;
    padding-top: 0.72rem;
    flex-direction: column;
    align-items: flex-end;
    color: #41506a;
    line-height: 1.05;
}

.timeline-time strong {
    font-size: 0.9rem;
}

.timeline-time span {
    margin-top: 0.14rem;
    color: var(--muted);
    font-size: 0.65rem;
    font-weight: 720;
}

.timeline-marker {
    position: relative;
}

.timeline-marker::before {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 8px;
    width: 2px;
    background: #dce4ef;
    content: "";
}

.timeline-marker::after {
    position: absolute;
    top: 0.98rem;
    left: 3px;
    width: 10px;
    height: 10px;
    border: 2px solid #8fa5c4;
    border-radius: 50%;
    background: #fff;
    content: "";
}

.timeline-event:first-child .timeline-marker::before {
    top: 1rem;
}

.timeline-event:last-child .timeline-marker::before {
    bottom: calc(100% - 1.08rem);
}

.timeline-event.is-current .timeline-marker::after {
    border-color: var(--primary);
    background: var(--primary);
    box-shadow: 0 0 0 4px rgba(36, 87, 167, 0.14);
}

.timeline-content {
    display: flex;
    min-width: 0;
    margin-bottom: 0.55rem;
    padding: 0.68rem 0.75rem;
    border: 1px solid #e3e9f1;
    border-radius: 11px;
    background: #fbfcfe;
    flex-direction: column;
}

.timeline-event.is-current .timeline-content {
    border-color: #b7cae8;
    background: var(--primary-soft);
}

.timeline-content strong,
.timeline-content span {
    overflow-wrap: anywhere;
}

.timeline-content > span:not(.now-label) {
    color: var(--muted);
    font-size: 0.82rem;
}

.now-label {
    align-self: flex-start;
    margin-bottom: 0.25rem;
    color: var(--primary-dark);
    font-size: 0.68rem;
    font-weight: 850;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.timeline-badges {
    display: flex;
    margin-top: 0.35rem;
    gap: 0.35rem;
}

.upcoming-list {
    display: grid;
}

.upcoming-list h3 {
    margin: 0.85rem 0 0.25rem;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid var(--line);
    color: #44536a;
    font-size: 0.82rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.upcoming-list h3:first-child {
    margin-top: 0;
}

.upcoming-event {
    display: grid;
    min-height: 58px;
    padding: 0.58rem 0.25rem;
    border-bottom: 1px solid #edf1f6;
    grid-template-columns: 118px minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.75rem;
}

.upcoming-event:last-child {
    border-bottom: 0;
}

.upcoming-event time {
    color: #48576d;
    font-size: 0.8rem;
    font-weight: 740;
}

.upcoming-event > div {
    display: flex;
    min-width: 0;
    flex-direction: column;
}

.upcoming-event strong,
.upcoming-event span {
    overflow-wrap: anywhere;
}

.upcoming-event > div span {
    color: var(--muted);
    font-size: 0.8rem;
}

.home-conflict-list {
    display: grid;
    gap: 0.6rem;
}

.home-conflict {
    display: grid;
    padding: 0.8rem;
    border: 1px solid #edc0c0;
    border-radius: 12px;
    background: #fffafa;
    color: var(--text);
}

.home-conflict:hover {
    border-color: #d99a9a;
    color: var(--text);
}

.home-conflict-top {
    display: flex;
    margin-bottom: 0.45rem;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.home-conflict-top time {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 650;
}

.conflict-with {
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 700;
    text-transform: uppercase;
}

.historical-conflict-note {
    margin: 0.8rem 0 0;
    color: var(--muted);
    font-size: 0.8rem;
}

.mobile-nav {
    display: none;
}

@media (max-width: 820px) {
    .page-shell {
        padding-bottom: 6rem;
    }

    .site-footer {
        padding-bottom: 6rem;
    }

    .mobile-nav {
        position: fixed;
        z-index: 60;
        right: 0;
        bottom: 0;
        left: 0;
        display: grid;
        min-height: 62px;
        padding: 0.35rem max(0.4rem, env(safe-area-inset-right)) max(0.35rem, env(safe-area-inset-bottom)) max(0.4rem, env(safe-area-inset-left));
        border-top: 1px solid var(--line-strong);
        background: rgba(255, 255, 255, 0.97);
        box-shadow: 0 -5px 22px rgba(31, 49, 78, 0.09);
        grid-template-columns: repeat(4, minmax(0, 1fr));
        backdrop-filter: blur(14px);
    }

    .mobile-nav a {
        display: flex;
        min-width: 0;
        padding: 0.25rem;
        border-radius: 9px;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 0.1rem;
        color: #5e6c80;
        font-size: 0.68rem;
        font-weight: 750;
    }

    .mobile-nav a span {
        display: grid;
        width: 22px;
        height: 22px;
        place-items: center;
        color: #718096;
        font-size: 1rem;
        line-height: 1;
    }

    .mobile-nav a[aria-current="page"] {
        background: var(--primary-soft);
        color: var(--primary-dark);
    }

    .mobile-nav a[aria-current="page"] span {
        color: var(--primary);
    }

    .next-event {
        grid-template-columns: 1fr auto;
    }

    .next-when {
        grid-column: 1 / -1;
        padding-bottom: 0.55rem;
        border-bottom: 1px solid #dbe5f2;
    }
}

@media (max-width: 560px) {
    .home-dashboard {
        margin-top: -0.15rem;
    }

    .today-header {
        align-items: center;
    }

    .today-header h1 {
        font-size: 2.15rem;
    }

    .today-header p:last-child {
        font-size: 0.88rem;
    }

    .refresh-button {
        width: 42px;
        padding: 0;
        justify-content: center;
    }

    .refresh-button > span:last-child {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }

    .attention-banner {
        padding: 0.75rem;
    }

    .attention-banner small {
        font-size: 0.76rem;
    }

    .next-card,
    .home-section {
        padding: 0.85rem;
        border-radius: 14px;
    }

    .next-event {
        gap: 0.65rem;
    }

    .next-details h2 {
        font-size: 1.12rem;
    }

    .home-section-heading h2 {
        font-size: 1.1rem;
    }

    .home-section-heading a {
        font-size: 0.78rem;
    }

    .timeline-event {
        grid-template-columns: 48px 15px minmax(0, 1fr);
        gap: 0.42rem;
    }

    .timeline-time strong {
        font-size: 0.82rem;
    }

    .timeline-marker::before {
        left: 6px;
    }

    .timeline-marker::after {
        left: 1px;
    }

    .timeline-content {
        padding: 0.62rem;
    }

    .upcoming-event {
        grid-template-columns: 84px minmax(0, 1fr);
        gap: 0.55rem;
    }

    .upcoming-event > .badge {
        grid-column: 2;
        justify-self: start;
    }

    .upcoming-event time {
        font-size: 0.72rem;
    }

    .home-conflict-top {
        align-items: flex-start;
        flex-direction: column;
        gap: 0.35rem;
    }

    .simulation-notice {
        align-items: flex-start;
    }

    .simulation-notice small {
        display: none;
    }

    .site-footer {
        display: none;
    }
}

/* Application shell, PWA controls, and More hub */
.connection-notice {
    display: flex;
    max-width: 980px;
    min-height: 44px;
    margin: 0 auto 1rem;
    padding: 0.65rem 0.8rem;
    border: 1px solid #e4c26d;
    border-radius: 12px;
    background: var(--warning-soft);
    align-items: center;
    gap: 0.65rem;
    color: var(--warning);
    font-size: 0.88rem;
    font-weight: 680;
}

.connection-notice svg {
    width: 21px;
    height: 21px;
    flex: 0 0 auto;
}

.more-layout {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.more-summary {
    display: flex;
    margin: -0.35rem 0 1rem;
    flex-wrap: wrap;
    gap: 0.55rem;
}

.more-summary a {
    display: inline-flex;
    min-height: 44px;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    align-items: center;
    gap: 0.42rem;
    color: var(--text);
}

.more-summary a:hover {
    border-color: var(--line-strong);
    color: var(--text);
}

.more-summary a strong {
    color: var(--danger);
    font-size: 1.05rem;
}

.more-summary a span {
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 700;
}

.more-layout .panel {
    margin: 0;
}

.more-panel-span,
.account-panel {
    grid-column: 1 / -1;
}

.theme-switcher {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.6rem;
}

.theme-switcher button {
    display: flex;
    min-height: 66px;
    padding: 0.65rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface-soft);
    align-items: center;
    gap: 0.55rem;
    color: var(--text);
    text-align: left;
    cursor: pointer;
}

.theme-switcher button:hover {
    border-color: var(--line-strong);
    background: var(--surface);
}

.theme-switcher button[aria-pressed="true"] {
    border-color: var(--primary);
    background: var(--primary-soft);
    box-shadow: inset 0 0 0 1px var(--primary);
    color: var(--primary-dark);
}

.theme-switcher button svg {
    width: 24px;
    height: 24px;
    flex: 0 0 auto;
}

.theme-switcher button span,
.install-copy,
.more-link-list a > span:nth-child(2),
.more-link-list-compact a > span:first-child,
.mode-status > span:last-child {
    display: flex;
    min-width: 0;
    flex-direction: column;
}

.theme-switcher small {
    margin-top: 0.08rem;
    font-size: 0.74rem;
}

.install-panel {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}

.install-icon {
    flex: 0 0 auto;
}

.install-icon img {
    display: block;
    border-radius: 17px;
    box-shadow: 0 9px 22px rgba(36, 87, 167, 0.2);
}

.install-copy h2 {
    margin-bottom: 0.25rem;
}

.install-copy > p {
    margin-bottom: 0.55rem;
    color: var(--muted);
}

.install-state {
    font-size: 0.84rem;
    font-weight: 650;
}

.install-panel.is-installed {
    border-color: #b9ddc9;
    background: var(--success-soft);
}

.ios-install-help {
    margin: 0.15rem 0 0.75rem;
    padding: 0.75rem 0.85rem;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: var(--surface-soft);
}

.ios-install-help ol {
    margin: 0;
    padding-left: 1.25rem;
}

.ios-install-help li {
    margin: 0.2rem 0;
}

.more-link-list {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.7rem;
}

.more-link-list a {
    display: grid;
    min-height: 78px;
    padding: 0.75rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface-soft);
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.7rem;
    color: var(--text);
}

.more-link-list a:hover {
    border-color: var(--line-strong);
    background: var(--surface);
    color: var(--text);
    transform: translateY(-1px);
}

.more-link-list a small {
    margin-top: 0.1rem;
    line-height: 1.35;
}

.more-link-icon {
    display: grid;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--primary-soft);
    place-items: center;
    color: var(--primary);
}

.more-link-icon svg {
    width: 22px;
    height: 22px;
}

.more-link-icon-green {
    background: var(--success-soft);
    color: var(--success);
}

.more-link-icon-purple {
    background: #f0eafd;
    color: #7145ad;
}

.more-link-arrow {
    width: 20px;
    height: 20px;
    color: var(--muted);
}

.more-link-list-compact {
    grid-template-columns: 1fr;
    gap: 0.45rem;
}

.more-link-list-compact a {
    min-height: 60px;
    grid-template-columns: minmax(0, 1fr) auto;
}

.mode-status {
    display: flex;
    margin-bottom: 0.75rem;
    padding: 0.7rem;
    border: 1px solid #c7d5eb;
    border-radius: 11px;
    background: var(--primary-soft);
    align-items: center;
    gap: 0.65rem;
    color: var(--primary-dark);
}

.mode-status small {
    color: inherit;
    opacity: 0.78;
}

.mode-status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary);
    box-shadow: 0 0 0 4px rgba(36, 87, 167, 0.14);
}

.account-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.account-panel h2 {
    margin-bottom: 0.15rem;
}

.account-panel p {
    margin: 0;
    color: var(--muted);
}

.account-panel form {
    margin: 0;
}

.app-toast {
    position: fixed;
    z-index: 120;
    right: max(1rem, env(safe-area-inset-right));
    bottom: max(1rem, env(safe-area-inset-bottom));
    display: grid;
    width: min(calc(100% - 2rem), 440px);
    padding: 0.85rem;
    border: 1px solid var(--line-strong);
    border-radius: 15px;
    background: var(--surface-raised);
    box-shadow: var(--shadow-strong);
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 0.75rem;
}

/* Reusable calendar-view foundation (Agenda / Day / Week / Month). */
.calendar-workspace {
    --calendar-hour-height: 64px;
    --calendar-time-column: 64px;
    --calendar-day-min: 112px;
    min-width: 0;
}

.calendar-toolbar {
    display: flex;
    margin-bottom: 0.8rem;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.7rem;
}

.view-switcher {
    display: inline-flex;
    max-width: 100%;
    padding: 0.22rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface-soft);
    gap: 0.15rem;
    overflow-x: auto;
    scrollbar-width: none;
}

.view-switcher::-webkit-scrollbar {
    display: none;
}

.view-switcher a,
.view-switcher button {
    display: inline-flex;
    min-width: 64px;
    min-height: 40px;
    padding: 0.45rem 0.7rem;
    border: 0;
    border-radius: 9px;
    background: transparent;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    font: inherit;
    font-size: 0.84rem;
    font-weight: 760;
    white-space: nowrap;
    cursor: pointer;
}

.view-switcher :is(a, button):hover {
    background: var(--surface);
    color: var(--text);
}

.view-switcher :is(a, button).active,
.view-switcher :is(a, button)[aria-current="page"],
.view-switcher :is(button)[aria-pressed="true"] {
    background: var(--surface);
    box-shadow: 0 2px 8px rgba(31, 49, 78, 0.1);
    color: var(--primary-dark);
}

.calendar-period-nav {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.calendar-period-nav :is(a, button) {
    display: inline-grid;
    min-width: 44px;
    min-height: 44px;
    padding: 0.45rem;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    place-items: center;
    color: var(--text);
    cursor: pointer;
}

.calendar-period-title {
    min-width: 0;
    margin: 0;
    font-size: clamp(1rem, 2.5vw, 1.25rem);
    overflow-wrap: anywhere;
}

.calendar-viewport {
    max-width: 100%;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
    overflow: auto;
    overscroll-behavior-inline: contain;
    -webkit-overflow-scrolling: touch;
}

.calendar-grid {
    position: relative;
    display: grid;
    min-width: 0;
    background: var(--surface);
}

.day-grid {
    grid-template-columns: var(--calendar-time-column) minmax(0, 1fr);
}

.week-grid {
    min-width: calc(var(--calendar-time-column) + (7 * var(--calendar-day-min)));
    grid-template-columns: var(--calendar-time-column) repeat(7, minmax(var(--calendar-day-min), 1fr));
}

.month-grid {
    min-width: calc(7 * var(--calendar-day-min));
    grid-template-columns: repeat(7, minmax(var(--calendar-day-min), 1fr));
}

.calendar-grid-head {
    position: sticky;
    z-index: 4;
    top: 0;
    min-height: 48px;
    padding: 0.55rem;
    border-bottom: 1px solid var(--line);
    background: var(--surface-raised);
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 780;
    text-align: center;
}

.calendar-time-label {
    min-height: var(--calendar-hour-height);
    padding: 0.3rem 0.45rem;
    border-right: 1px solid var(--line);
    color: var(--muted);
    font-size: 0.72rem;
    text-align: right;
}

.calendar-day-column,
.calendar-day-cell {
    position: relative;
    min-width: 0;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

.calendar-day-cell {
    min-height: 116px;
    padding: 0.42rem;
}

.calendar-event-block {
    min-width: 0;
    padding: 0.35rem 0.45rem;
    border-left: 3px solid var(--primary);
    border-radius: 7px;
    background: var(--primary-soft);
    color: var(--text);
    font-size: 0.76rem;
    line-height: 1.3;
    overflow: hidden;
}

.calendar-event-block strong {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.week-start-note {
    color: var(--muted);
    font-size: 0.78rem;
}

.app-toast > div {
    display: flex;
    min-width: 0;
    flex-direction: column;
}

.app-toast > div span {
    color: var(--muted);
    font-size: 0.82rem;
}

.toast-dismiss {
    display: grid;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: transparent;
    place-items: center;
    color: var(--muted);
    font-size: 1.4rem;
    cursor: pointer;
}

.toast-dismiss:hover {
    background: var(--surface-soft);
    color: var(--text);
}

@media (max-width: 1120px) {
    .site-header {
        grid-template-columns: auto auto minmax(0, 1fr) auto;
    }

    .primary-nav a svg {
        display: none;
    }
}

@media (max-width: 820px) {
    body.is-authenticated {
        padding-bottom: calc(70px + env(safe-area-inset-bottom));
    }

    .site-header {
        grid-template-columns: minmax(0, 1fr);
        min-height: calc(58px + env(safe-area-inset-top));
        padding: calc(0.45rem + env(safe-area-inset-top)) max(0.75rem, env(safe-area-inset-right)) 0.45rem max(0.75rem, env(safe-area-inset-left));
    }

    .nav-toggle,
    .primary-nav,
    .header-logout {
        display: none !important;
    }

    .brand-copy {
        display: flex !important;
        flex-direction: column;
        font-size: 0.95rem;
    }

    .brand-copy small {
        display: none;
    }

    .brand {
        justify-self: start;
    }

    .brand-icon {
        width: 40px;
        height: 40px;
    }

    .page-shell {
        width: min(calc(100% - 1rem), var(--content));
        min-height: calc(100dvh - 128px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
        padding-top: 1rem;
        padding-bottom: 1rem;
    }

    .site-footer {
        padding-bottom: 1rem;
    }

    .mobile-nav {
        min-height: calc(64px + env(safe-area-inset-bottom));
        padding: 0.3rem max(0.35rem, env(safe-area-inset-right)) max(0.3rem, env(safe-area-inset-bottom)) max(0.35rem, env(safe-area-inset-left));
        background: var(--nav-bg);
    }

    .mobile-nav a {
        min-height: 52px;
        padding: 0.25rem;
        gap: 0.12rem;
        font-size: 0.72rem;
    }

    .mobile-nav a svg {
        width: 23px;
        height: 23px;
    }

    .mobile-nav a > span,
    .mobile-nav a[aria-current="page"] > span {
        display: block;
        width: auto;
        height: auto;
        color: inherit;
        font-size: inherit;
        line-height: 1.2;
    }

    .mobile-nav a[aria-current="page"] {
        position: relative;
    }

    .mobile-nav a[aria-current="page"]::before {
        position: absolute;
        top: -0.28rem;
        width: 28px;
        height: 3px;
        border-radius: 0 0 3px 3px;
        background: var(--primary);
        content: "";
    }

    .more-layout {
        grid-template-columns: 1fr;
    }

    .more-panel-span,
    .account-panel {
        grid-column: auto;
    }

    .more-link-list {
        grid-template-columns: 1fr;
        gap: 0.45rem;
    }

    .more-link-list a {
        min-height: 66px;
    }

    .app-toast {
        right: max(0.5rem, env(safe-area-inset-right));
        bottom: calc(72px + env(safe-area-inset-bottom));
        width: calc(100% - 1rem - env(safe-area-inset-left) - env(safe-area-inset-right));
    }
}

@media (max-width: 560px) {
    input,
    select,
    textarea {
        font-size: 16px;
    }

    .more-heading {
        margin-bottom: 1rem;
    }

    .more-heading p:not(.eyebrow) {
        font-size: 0.9rem;
    }

    .theme-switcher {
        grid-template-columns: 1fr;
    }

    .theme-switcher button {
        min-height: 56px;
    }

    .install-panel,
    .account-panel {
        flex-direction: column;
        align-items: stretch;
    }

    .account-panel .button {
        width: 100%;
    }

    .app-toast {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .app-toast .button {
        grid-column: 1 / -1;
        grid-row: 2;
    }

    .toast-dismiss {
        grid-column: 2;
        grid-row: 1;
    }

    .calendar-workspace {
        --calendar-time-column: 52px;
        --calendar-day-min: 96px;
    }

    .calendar-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .view-switcher {
        display: grid;
        width: 100%;
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .view-switcher a,
    .view-switcher button {
        min-width: 0;
        min-height: 44px;
        padding-inline: 0.35rem;
    }

    .calendar-period-nav {
        justify-content: space-between;
    }

    .calendar-period-title {
        text-align: center;
    }
}

/* Dark theme: explicit choice and operating-system choice share one palette. */
[data-theme="dark"] {
    --bg: #0b1220;
    --surface: #121c2d;
    --surface-soft: #172337;
    --surface-raised: #18243a;
    --text: #eef4ff;
    --muted: #9cabc1;
    --line: #29374d;
    --line-strong: #3b4c64;
    --primary: #76a9ff;
    --primary-dark: #a9c9ff;
    --primary-soft: #182f52;
    --success: #69d39b;
    --success-soft: #153428;
    --warning: #f0bd61;
    --warning-soft: #3b2c13;
    --danger: #ff8d8d;
    --danger-soft: #3b1e24;
    --shadow: 0 12px 34px rgba(0, 0, 0, 0.28);
    --shadow-strong: 0 18px 55px rgba(0, 0, 0, 0.45);
    --header-bg: rgba(11, 18, 32, 0.94);
    --nav-bg: rgba(11, 18, 32, 0.97);
    --focus: rgba(118, 169, 255, 0.42);
}

[data-theme="dark"] body {
    background: radial-gradient(circle at top right, rgba(70, 125, 210, 0.14), transparent 30rem), var(--bg);
}

[data-theme="dark"] :is(.site-header, .primary-nav, .panel, .metric-card, .source-card, .conflict-card, .event-detail, .login-card, .next-card, .home-section, .refresh-button, .simple-empty, .timeline-content, .tab-nav a, .compact-item, .secret-box code, input, select, textarea, table) {
    border-color: var(--line);
    background-color: var(--surface);
    color: var(--text);
}

[data-theme="dark"] :is(th, tbody tr:hover td) {
    background: var(--surface-soft);
    color: var(--text);
}

[data-theme="dark"] :is(label:not(.checkbox), legend, .primary-nav a, .refresh-button, .agenda-time, .upcoming-event time, .upcoming-list h3) {
    color: var(--text);
}

[data-theme="dark"] :is(.timeline-content, .source-card, .event-detail, .compact-item, .checkbox, .empty-state, .more-link-list a, .theme-switcher button, .ios-install-help) {
    background: var(--surface-soft);
}

[data-theme="dark"] :is(.next-card, .metric-alert, .metric-warning, .danger-zone) {
    background-image: none;
}

[data-theme="dark"] .more-link-icon-purple {
    background: #2b2042;
    color: #c2a5f3;
}

@media (prefers-color-scheme: dark) {
    [data-theme="system"] {
        --bg: #0b1220;
        --surface: #121c2d;
        --surface-soft: #172337;
        --surface-raised: #18243a;
        --text: #eef4ff;
        --muted: #9cabc1;
        --line: #29374d;
        --line-strong: #3b4c64;
        --primary: #76a9ff;
        --primary-dark: #a9c9ff;
        --primary-soft: #182f52;
        --success: #69d39b;
        --success-soft: #153428;
        --warning: #f0bd61;
        --warning-soft: #3b2c13;
        --danger: #ff8d8d;
        --danger-soft: #3b1e24;
        --shadow: 0 12px 34px rgba(0, 0, 0, 0.28);
        --shadow-strong: 0 18px 55px rgba(0, 0, 0, 0.45);
        --header-bg: rgba(11, 18, 32, 0.94);
        --nav-bg: rgba(11, 18, 32, 0.97);
        --focus: rgba(118, 169, 255, 0.42);
    }

    [data-theme="system"] body {
        background: radial-gradient(circle at top right, rgba(70, 125, 210, 0.14), transparent 30rem), var(--bg);
    }

    [data-theme="system"] :is(.site-header, .primary-nav, .panel, .metric-card, .source-card, .conflict-card, .event-detail, .login-card, .next-card, .home-section, .refresh-button, .simple-empty, .timeline-content, .tab-nav a, .compact-item, .secret-box code, input, select, textarea, table) {
        border-color: var(--line);
        background-color: var(--surface);
        color: var(--text);
    }

    [data-theme="system"] :is(th, tbody tr:hover td) {
        background: var(--surface-soft);
        color: var(--text);
    }

    [data-theme="system"] :is(label:not(.checkbox), legend, .primary-nav a, .refresh-button, .agenda-time, .upcoming-event time, .upcoming-list h3) {
        color: var(--text);
    }

    [data-theme="system"] :is(.timeline-content, .source-card, .event-detail, .compact-item, .checkbox, .empty-state, .more-link-list a, .theme-switcher button, .ios-install-help) {
        background: var(--surface-soft);
    }

    [data-theme="system"] :is(.next-card, .metric-alert, .metric-warning, .danger-zone) {
        background-image: none;
    }

    [data-theme="system"] .more-link-icon-purple {
        background: #2b2042;
        color: #c2a5f3;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}

@media (prefers-contrast: more) {
    :root {
        --line: #7b8798;
        --line-strong: #566274;
    }

    .button:focus-visible,
    input:focus-visible,
    select:focus-visible,
    textarea:focus-visible,
    a:focus-visible,
    summary:focus-visible {
        outline-width: 4px;
    }
}

/* Calendar Control Center 2.0 product surfaces. */
.today-heading,
.schedule-options,
.attention-strip,
.next-card,
.all-day-strip,
.next-card-actions,
.event-action-row,
.conflict-card-actions,
.snooze-form,
.route-card,
.suggestion-list > div {
    display: flex;
    align-items: center;
}

.today-heading {
    margin-bottom: 1rem;
    justify-content: space-between;
    gap: 1rem;
}

.today-heading h1 {
    margin-bottom: 0.22rem;
}

.today-heading p:last-child {
    margin: 0;
    color: var(--muted);
}

.attention-strip {
    margin-bottom: 1rem;
    padding: 0.55rem;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
    gap: 0.55rem;
}

.attention-strip > :is(a, div) {
    display: flex;
    min-width: 0;
    min-height: 52px;
    padding: 0.55rem 0.7rem;
    border-radius: 10px;
    background: var(--warning-soft);
    flex: 1 1 260px;
    flex-direction: column;
    justify-content: center;
    color: var(--text);
}

.attention-strip > :is(a, div):first-child strong {
    color: var(--danger);
}

.attention-strip span {
    color: var(--muted);
    font-size: 0.78rem;
}

.next-card {
    position: relative;
    margin-bottom: 1rem;
    padding: clamp(1rem, 3vw, 1.45rem);
    border: 1px solid #bfd1eb;
    border-radius: 20px;
    background: linear-gradient(135deg, var(--surface), var(--primary-soft));
    box-shadow: var(--shadow);
    align-items: stretch;
    gap: 1.1rem;
}

.next-card.is-current {
    border-color: #a9d7bc;
    background: linear-gradient(135deg, var(--surface), var(--success-soft));
}

.next-card-label {
    display: flex;
    min-width: 126px;
    padding-right: 1rem;
    border-right: 1px solid var(--line);
    flex-direction: column;
    justify-content: center;
}

.next-card-label span {
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.next-card-label strong {
    margin-top: 0.2rem;
    color: var(--primary-dark);
    font-size: 1.05rem;
}

.next-card-main {
    min-width: 0;
    flex: 1;
}

.next-card-main h2 {
    margin: 0.35rem 0 0.2rem;
    font-size: clamp(1.25rem, 3vw, 1.7rem);
}

.next-card-main p,
.leave-alert span {
    margin: 0;
    color: var(--muted);
}

.category-pill {
    display: inline-flex;
    min-height: 26px;
    padding: 0.25rem 0.55rem;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary-dark);
    font-size: 0.72rem;
    font-weight: 800;
}

.leave-alert {
    display: flex;
    min-width: 190px;
    padding: 0.65rem 0.75rem;
    border-radius: 11px;
    background: var(--warning-soft);
    flex-direction: column;
    justify-content: center;
}

.leave-alert span {
    font-size: 0.76rem;
}

.next-card-actions,
.event-action-row,
.conflict-card-actions {
    flex-wrap: wrap;
    gap: 0.45rem;
}

.next-card-actions {
    align-content: center;
}

.next-card-clear {
    min-height: 126px;
}

.all-day-strip {
    margin-bottom: 1rem;
    padding: 0.65rem 0.8rem;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: var(--surface);
    gap: 0.8rem;
}

.all-day-strip > strong {
    color: var(--muted);
    font-size: 0.75rem;
    text-transform: uppercase;
}

.all-day-strip > div {
    display: flex;
    min-width: 0;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.all-day-strip a {
    padding: 0.28rem 0.55rem;
    border-radius: 8px;
    background: var(--surface-soft);
    color: var(--text);
    font-size: 0.82rem;
    font-weight: 700;
}

.today-layout {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(280px, 0.9fr);
    align-items: start;
    gap: 1rem;
}

.today-primary,
.today-sidebar {
    display: grid;
    min-width: 0;
    gap: 1rem;
}

.today-sidebar {
    position: sticky;
    top: 90px;
}

.agenda-event-list {
    display: grid;
    gap: 0.48rem;
}

.schedule-event-card {
    display: grid;
    min-height: 60px;
    padding: 0.65rem 0.7rem;
    border: 1px solid var(--line);
    border-left: 4px solid var(--primary);
    border-radius: 11px;
    background: var(--surface-soft);
    grid-template-columns: minmax(82px, auto) minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.7rem;
    color: var(--text);
}

.schedule-event-card:hover {
    border-color: var(--line-strong);
    color: var(--text);
}

.schedule-event-card > time {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 750;
}

.schedule-event-copy {
    display: flex;
    min-width: 0;
    flex-direction: column;
}

.schedule-event-copy strong {
    overflow-wrap: anywhere;
}

.schedule-event-copy small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.priority-critical { border-left-color: var(--danger) !important; }
.priority-high { border-left-color: #d36a1f !important; }
.priority-flexible { border-left-color: #6d58ad !important; }
.priority-informational { border-left-color: var(--muted) !important; }

.priority-badge {
    text-transform: capitalize;
}

.is-completed {
    opacity: 0.65;
}

.completed-events {
    margin-top: 0.75rem;
}

.completed-events summary {
    min-height: 44px;
    padding: 0.65rem 0;
    color: var(--muted);
    font-weight: 700;
    cursor: pointer;
}

.coming-days {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

.coming-days section {
    padding: 0.65rem;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: var(--surface-soft);
}

.coming-days h3 {
    display: flex;
    margin-bottom: 0.4rem;
    justify-content: space-between;
}

.coming-days h3 span {
    color: var(--muted);
    font-size: 0.78rem;
}

.coming-days section > a {
    display: grid;
    min-height: 40px;
    padding: 0.3rem 0;
    border-top: 1px solid var(--line);
    grid-template-columns: 72px minmax(0, 1fr);
    align-items: center;
    gap: 0.45rem;
    color: var(--text);
    font-size: 0.82rem;
}

.coming-days time {
    color: var(--muted);
    font-size: 0.72rem;
}

.compact-conflicts > a,
.compact-changes > a {
    display: flex;
    min-height: 58px;
    padding: 0.55rem 0;
    border-top: 1px solid var(--line);
    flex-direction: column;
    color: var(--text);
}

.compact-conflicts > a:first-of-type,
.compact-changes > a:first-of-type {
    border-top: 0;
}

.compact-conflicts small,
.compact-changes small {
    font-size: 0.74rem;
}

.compact-changes > a > span {
    color: var(--primary-dark);
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
}

.free-window-panel > div:not(.panel-heading) {
    display: flex;
    min-height: 44px;
    padding: 0.45rem 0;
    border-top: 1px solid var(--line);
    flex-direction: column;
}

.free-window-panel span {
    color: var(--muted);
    font-size: 0.75rem;
}

.calendar-view-shortcuts .view-switcher {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
}

.schedule-options {
    margin-bottom: 0.8rem;
    justify-content: space-between;
    gap: 0.65rem;
}

.filter-sheet {
    position: relative;
}

.filter-sheet > summary {
    list-style: none;
    cursor: pointer;
}

.filter-sheet > summary::-webkit-details-marker { display: none; }

.filter-sheet[open] > form {
    position: absolute;
    z-index: 12;
    top: calc(100% + 0.45rem);
    left: 0;
    width: min(780px, calc(100vw - 2rem));
    padding: 0.85rem;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface-raised);
    box-shadow: var(--shadow-strong);
}

.week-start-form {
    display: flex;
    align-items: end;
    gap: 0.4rem;
}

.week-start-form label {
    margin: 0;
}

.week-start-form select {
    min-height: 44px;
}

.agenda-calendar {
    display: grid;
    gap: 0.75rem;
}

.agenda-day-card {
    display: grid;
    padding: 0.75rem;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 0.8rem;
}

.agenda-day-card > header {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

.agenda-day-card > header time {
    display: flex;
    flex-direction: column;
}

.agenda-day-card > header time strong {
    color: var(--primary-dark);
    font-size: 0.78rem;
    text-transform: uppercase;
}

.agenda-day-card > header time span {
    font-size: 1.12rem;
    font-weight: 800;
}

.agenda-day-card > header > span {
    color: var(--muted);
    font-size: 0.72rem;
}

.agenda-day-card.is-today {
    border-color: var(--primary);
    box-shadow: inset 4px 0 0 var(--primary);
}

.calendar-day-column {
    min-height: 310px;
    padding: 0.35rem;
}

.calendar-day-column .calendar-event-block,
.calendar-day-cell .calendar-event-block {
    display: flex;
    margin-bottom: 0.28rem;
    flex-direction: column;
}

.calendar-event-block span {
    color: var(--muted);
    font-size: 0.66rem;
}

.calendar-empty {
    display: block;
    padding: 0.65rem;
    color: var(--muted);
    font-size: 0.74rem;
    text-align: center;
}

.calendar-grid-head.is-today,
.calendar-day-cell.is-today {
    background: var(--primary-soft);
}

.calendar-day-cell.is-outside-month {
    opacity: 0.58;
}

.calendar-day-number {
    display: grid;
    width: 30px;
    height: 30px;
    margin-bottom: 0.35rem;
    border-radius: 50%;
    place-items: center;
    color: var(--text);
    font-size: 0.78rem;
    font-weight: 800;
}

.calendar-day-cell.is-today .calendar-day-number {
    background: var(--primary);
    color: #fff;
}

.calendar-more {
    display: block;
    padding: 0.2rem;
    font-size: 0.7rem;
    font-weight: 700;
}

.event-view-links {
    margin-bottom: 1rem;
}

.event-detail-layout,
.insight-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
    align-items: start;
    gap: 1rem;
}

.event-description {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--line);
}

.event-description p {
    margin: 0;
    white-space: normal;
    overflow-wrap: anywhere;
}

.event-preference-card {
    position: sticky;
    top: 90px;
}

.event-action-row {
    margin-bottom: 1rem;
}

.change-groups,
.change-list,
.location-list,
.route-list,
.suggestion-list,
.history-list,
.category-load-list {
    display: grid;
    gap: 0.7rem;
}

.change-group > h2 {
    margin: 1rem 0 0.5rem;
    color: var(--muted);
    font-size: 0.82rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.change-card {
    display: grid;
    padding: 0.55rem;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: var(--surface);
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.55rem;
}

.change-card.is-new {
    border-left: 4px solid var(--primary);
}

.change-card-main {
    display: grid;
    min-height: 56px;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.7rem;
    color: var(--text);
}

.change-type {
    display: inline-flex;
    max-width: 104px;
    min-height: 30px;
    padding: 0.32rem 0.5rem;
    border-radius: 8px;
    background: var(--primary-soft);
    align-items: center;
    color: var(--primary-dark);
    font-size: 0.7rem;
    font-weight: 800;
}

.change-type-cancelled,
.change-type-removed {
    background: var(--danger-soft);
    color: var(--danger);
}

.change-copy {
    display: flex;
    min-width: 0;
    flex-direction: column;
}

.change-copy small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.diff-list {
    display: grid;
    gap: 0.65rem;
}

.diff-row {
    display: grid;
    padding: 0.75rem;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: var(--surface-soft);
    grid-template-columns: 130px repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

.diff-row h3,
.diff-row p {
    margin: 0;
}

.diff-row span {
    color: var(--muted);
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
}

.conflict-action-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.conflict-action-card {
    margin: 0;
    border-left: 5px solid var(--warning);
}

.conflict-action-card.severity-critical { border-left-color: var(--danger); }

.conflict-action-card > header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.conflict-action-card > header > div {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.conflict-action-card > header time {
    color: var(--muted);
    font-size: 0.78rem;
}

.conflict-action-card h2 {
    margin: 0.8rem 0;
    font-size: 1.08rem;
}

.conflict-mini-timeline {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
}

.conflict-mini-timeline > span {
    display: flex;
    padding: 0.55rem;
    border-radius: 9px;
    background: var(--surface-soft);
    flex-direction: column;
}

.conflict-mini-timeline small {
    margin-top: 0.15rem;
}

.conflict-recommendation {
    margin: 0.65rem 0;
    color: var(--muted);
    font-size: 0.82rem;
}

.conflict-card-actions form,
.decision-grid form {
    margin: 0;
}

.conflict-chronology {
    position: relative;
    display: grid;
    gap: 0.65rem;
}

.conflict-chronology article {
    display: grid;
    padding: 0.75rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface-soft);
    grid-template-columns: 100px minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.8rem;
}

.conflict-chronology time,
.conflict-chronology time span {
    display: flex;
    flex-direction: column;
}

.conflict-chronology time span {
    color: var(--muted);
    font-size: 0.72rem;
}

.conflict-chronology h3,
.conflict-chronology p {
    margin: 0.2rem 0 0;
}

.conflict-chronology p {
    color: var(--muted);
    font-size: 0.8rem;
}

.conflict-calculation {
    margin-top: 1rem;
}

.recommendation-card {
    margin-top: 0.8rem;
    padding: 0.75rem;
    border: 1px solid #e7c46b;
    border-radius: 11px;
    background: var(--warning-soft);
}

.recommendation-card p {
    margin: 0.2rem 0 0;
}

.action-link-grid,
.decision-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.6rem;
}

.action-link-grid a,
.decision-grid button {
    display: flex;
    width: 100%;
    min-height: 74px;
    padding: 0.7rem;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: var(--surface-soft);
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    color: var(--text);
    text-align: left;
    cursor: pointer;
}

.action-link-grid span,
.decision-grid span {
    color: var(--muted);
    font-size: 0.76rem;
}

.decision-note {
    margin-bottom: 0.7rem;
}

.snooze-form {
    margin-top: 0.8rem;
    padding-top: 0.8rem;
    border-top: 1px solid var(--line);
    align-items: end;
    gap: 0.55rem;
}

.snooze-form label {
    min-width: 190px;
    flex: 1;
}

.history-list > div {
    display: grid;
    padding: 0.55rem 0;
    border-top: 1px solid var(--line);
    grid-template-columns: 170px minmax(0, 1fr);
    gap: 0.7rem;
}

.history-list time {
    color: var(--muted);
    font-size: 0.76rem;
}

.suggestion-list > div,
.route-card {
    min-height: 58px;
    padding: 0.6rem;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface-soft);
    justify-content: space-between;
    gap: 0.7rem;
}

.draft-card textarea {
    width: 100%;
}

.location-card {
    padding: 0.65rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface-soft);
}

.location-card summary {
    display: flex;
    min-height: 48px;
    align-items: center;
    justify-content: space-between;
    gap: 0.7rem;
    cursor: pointer;
}

.location-card summary > span:first-child,
.route-card > span {
    display: flex;
    min-width: 0;
    flex-direction: column;
}

.location-card[open] summary {
    margin-bottom: 0.8rem;
    padding-bottom: 0.6rem;
    border-bottom: 1px solid var(--line);
}

.route-list {
    margin-top: 1rem;
}

.insight-metrics {
    margin-bottom: 1rem;
}

.daily-load-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(70px, 1fr));
    gap: 0.45rem;
    overflow-x: auto;
}

.daily-load-grid a {
    display: flex;
    min-height: 116px;
    padding: 0.55rem;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface-soft);
    flex-direction: column;
    color: var(--text);
}

.daily-load-grid span,
.daily-load-grid small {
    color: var(--muted);
    font-size: 0.72rem;
}

.daily-load-grid strong {
    margin: 0.2rem 0 0.45rem;
}

.daily-load-grid i,
.category-load-list i {
    display: block;
    height: 7px;
    border-radius: 999px;
    background: var(--line);
    overflow: hidden;
}

.daily-load-grid i b,
.category-load-list i b {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--primary);
}

.load-pct-0 { width: 0; }
.load-pct-5 { width: 5%; }
.load-pct-10 { width: 10%; }
.load-pct-15 { width: 15%; }
.load-pct-20 { width: 20%; }
.load-pct-25 { width: 25%; }
.load-pct-30 { width: 30%; }
.load-pct-35 { width: 35%; }
.load-pct-40 { width: 40%; }
.load-pct-45 { width: 45%; }
.load-pct-50 { width: 50%; }
.load-pct-55 { width: 55%; }
.load-pct-60 { width: 60%; }
.load-pct-65 { width: 65%; }
.load-pct-70 { width: 70%; }
.load-pct-75 { width: 75%; }
.load-pct-80 { width: 80%; }
.load-pct-85 { width: 85%; }
.load-pct-90 { width: 90%; }
.load-pct-95 { width: 95%; }
.load-pct-100 { width: 100%; }

.daily-load-grid small {
    margin-top: auto;
}

.category-load-list > div {
    display: grid;
    grid-template-columns: 145px minmax(0, 1fr);
    align-items: center;
    gap: 0.65rem;
}

.category-load-list span {
    display: flex;
    flex-direction: column;
}

.insight-summary ul {
    margin: 0;
    padding-left: 1.25rem;
}

.insight-summary li + li {
    margin-top: 0.45rem;
}

@media (max-width: 1040px) {
    .next-card {
        flex-wrap: wrap;
    }

    .next-card-main {
        flex-basis: calc(100% - 170px);
    }

    .next-card-actions {
        width: 100%;
    }

    .today-layout,
    .event-detail-layout,
    .insight-layout {
        grid-template-columns: 1fr;
    }

    .today-sidebar,
    .event-preference-card {
        position: static;
    }
}

@media (max-width: 760px) {
    .today-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .today-heading .refresh-form,
    .today-heading .refresh-button {
        width: 100%;
    }

    .attention-strip,
    .next-card,
    .schedule-options,
    .snooze-form {
        align-items: stretch;
        flex-direction: column;
    }

    .next-card-label {
        min-width: 0;
        padding: 0 0 0.6rem;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .next-card-main {
        flex-basis: auto;
    }

    .leave-alert {
        min-width: 0;
    }

    .next-card-actions .button {
        flex: 1;
    }

    .coming-days,
    .conflict-action-list,
    .action-link-grid,
    .decision-grid,
    .more-link-list {
        grid-template-columns: 1fr;
    }

    .schedule-event-card {
        grid-template-columns: 82px minmax(0, 1fr);
    }

    .schedule-event-card > .badge {
        display: none;
    }

    .week-start-form {
        width: 100%;
    }

    .week-start-form label {
        flex: 1;
    }

    .agenda-day-card {
        grid-template-columns: 1fr;
    }

    .agenda-day-card > header {
        flex-direction: row;
        align-items: end;
        justify-content: space-between;
    }

    .agenda-day-card > header time {
        flex-direction: row;
        align-items: baseline;
        gap: 0.35rem;
    }

    .conflict-mini-timeline {
        grid-template-columns: 1fr;
    }

    .conflict-chronology article {
        grid-template-columns: 76px minmax(0, 1fr);
    }

    .conflict-chronology article .button-row {
        grid-column: 1 / -1;
    }

    .diff-row {
        grid-template-columns: 1fr;
    }

    .history-list > div {
        grid-template-columns: 1fr;
        gap: 0.15rem;
    }

    .filter-sheet {
        width: 100%;
    }

    .filter-sheet > summary {
        width: 100%;
    }

    .filter-sheet[open] > form {
        position: fixed;
        z-index: 95;
        right: max(0.65rem, env(safe-area-inset-right));
        bottom: calc(74px + env(safe-area-inset-bottom));
        left: max(0.65rem, env(safe-area-inset-left));
        width: auto;
        max-height: 70dvh;
        overflow: auto;
    }

    .change-card {
        grid-template-columns: 1fr;
    }

    .change-card form .button {
        width: 100%;
    }

    .change-card-main {
        grid-template-columns: 88px minmax(0, 1fr) auto;
    }

    .category-load-list > div {
        grid-template-columns: 105px minmax(0, 1fr);
    }
}
