/* Apple iOS / iPadOS Human Interface Guidelines Design System */
:root {
    color-scheme: light;
    --bg: #f2f2f7;
    --bg-translucent: rgba(249, 249, 251, 0.78);
    --surface: #ffffff;
    --surface-translucent: rgba(255, 255, 255, 0.78);
    --surface-soft: #f2f2f7;
    --surface-strong: #e5e5ea;
    --paper: var(--bg);
    --panel: var(--surface);
    --panel-subtle: var(--surface-soft);

    --ink: #1c1c1e;
    --ink-secondary: #3a3a3c;
    --muted: #8e8e93;
    --faint: #aeaeb2;

    --line: rgba(60, 60, 67, 0.12);
    --line-strong: rgba(60, 60, 67, 0.2);

    /* iOS System Blue */
    --accent: #007aff;
    --accent-dark: #0062cc;
    --accent-text: #007aff;
    --accent-soft: rgba(0, 122, 255, 0.1);
    --accent-border: rgba(0, 122, 255, 0.25);

    /* iOS System Indigo (Opponent / Secondary Accent) */
    --indigo: #5856d6;
    --indigo-text: #5856d6;
    --indigo-soft: rgba(88, 86, 214, 0.1);
    --indigo-border: rgba(88, 86, 214, 0.25);

    /* iOS System Semantic Colors */
    --danger: #ff3b30;
    --danger-dark: #d70015;
    --danger-soft: rgba(255, 59, 48, 0.1);
    --danger-border: rgba(255, 59, 48, 0.25);

    --success: #34c759;
    --success-soft: rgba(52, 199, 89, 0.12);
    --success-border: rgba(52, 199, 89, 0.28);

    --warning: #ff9500;
    --warning-soft: rgba(255, 149, 0, 0.12);
    --warning-border: rgba(255, 149, 0, 0.28);

    /* iOS Segmented Control Tokens */
    --segmented-track: rgba(118, 118, 128, 0.12);
    --segmented-thumb: #ffffff;
    --segmented-shadow: 0 3px 8px rgba(0, 0, 0, 0.12), 0 3px 1px rgba(0, 0, 0, 0.04);

    --control-hover: rgba(118, 118, 128, 0.12);
    --control-active: rgba(118, 118, 128, 0.2);

    --radius-sm: 10px;
    --radius: 14px;
    --radius-lg: 18px;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.03);
    --shadow-lg: 0 16px 38px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.05);
    --focus-ring: 0 0 0 3px rgba(0, 122, 255, 0.25);

    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "PingFang SC", "Helvetica Neue", "Microsoft YaHei", system-ui, sans-serif;
    font-synthesis: none;
    text-rendering: optimizeLegibility;
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #000000;
    --bg-translucent: rgba(28, 28, 30, 0.76);
    --surface: #1c1c1e;
    --surface-translucent: rgba(28, 28, 30, 0.78);
    --surface-soft: #2c2c2e;
    --surface-strong: #3a3a3c;

    --ink: #ffffff;
    --ink-secondary: #ebebf5;
    --muted: #8e8e93;
    --faint: #636366;

    --line: rgba(84, 84, 88, 0.45);
    --line-strong: rgba(84, 84, 88, 0.68);

    --accent: #0a84ff;
    --accent-dark: #0070e0;
    --accent-text: #0a84ff;
    --accent-soft: rgba(10, 132, 255, 0.16);
    --accent-border: rgba(10, 132, 255, 0.36);

    --indigo: #5e5ce6;
    --indigo-text: #7d7aff;
    --indigo-soft: rgba(94, 92, 230, 0.18);
    --indigo-border: rgba(94, 92, 230, 0.38);

    --danger: #ff453a;
    --danger-dark: #ff6961;
    --danger-soft: rgba(255, 69, 58, 0.16);
    --danger-border: rgba(255, 69, 58, 0.36);

    --success: #30d158;
    --success-soft: rgba(48, 209, 88, 0.16);
    --success-border: rgba(48, 209, 88, 0.36);

    --warning: #ff9f0a;
    --warning-soft: rgba(255, 159, 10, 0.16);
    --warning-border: rgba(255, 159, 10, 0.36);

    --segmented-track: rgba(118, 118, 128, 0.24);
    --segmented-thumb: #636366;
    --segmented-shadow: 0 3px 8px rgba(0, 0, 0, 0.3), 0 3px 1px rgba(0, 0, 0, 0.12);

    --control-hover: rgba(118, 118, 128, 0.24);
    --control-active: rgba(118, 118, 128, 0.34);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 20px 48px rgba(0, 0, 0, 0.6);
    --focus-ring: 0 0 0 3px rgba(10, 132, 255, 0.32);
}

*, *::before, *::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--line-strong);
    border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--muted);
}

body {
    margin: 0;
    min-width: 320px;
    min-height: 100dvh;
    background-color: var(--bg);
    color: var(--ink);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

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

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

a {
    color: var(--accent-text);
    text-decoration: none;
    transition: opacity 140ms ease-out;
}

a:hover {
    opacity: 0.78;
}

h1, h2, h3, p {
    overflow-wrap: anywhere;
}

h1 {
    margin: 0;
    font-size: clamp(1.5rem, 2.2vw, 2.1rem);
    line-height: 1.15;
    letter-spacing: -0.025em;
    font-weight: 700;
    color: var(--ink);
    text-wrap: balance;
}

h2 {
    margin: 0 0 12px;
    font-size: 1.05rem;
    line-height: 1.25;
    letter-spacing: -0.015em;
    font-weight: 600;
    color: var(--ink);
    text-wrap: balance;
}

h3 {
    margin: 0 0 8px;
    font-size: 0.86rem;
    line-height: 1.3;
    font-weight: 600;
    color: var(--ink-secondary);
}

code {
    font-family: "SFMono-Regular", "JetBrains Mono", Consolas, monospace;
    font-size: 12px;
    background: var(--surface-soft);
    color: var(--accent-text);
    border: 1px solid var(--line);
    padding: 2px 6px;
    border-radius: 6px;
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

[hidden] {
    display: none !important;
}

.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;
}

/* ---------- iOS Frosted Glass Navigation Bar ---------- */
.shell {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0 max(24px, calc((100vw - 1560px) / 2));
    border-bottom: 1px solid var(--line);
    background: var(--bg-translucent);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    color: var(--ink);
    text-decoration: none;
    flex-shrink: 0;
}

.brand:hover {
    color: var(--ink);
    opacity: 1;
}

.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: var(--accent);
    color: #ffffff;
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
}

.brand-mark svg {
    width: 18px;
    height: 18px;
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
    font-size: 0.92rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.brand-sub {
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    color: var(--muted);
    text-transform: uppercase;
    margin-top: 1px;
}

/* iOS Segmented Control Navigation */
.topnav {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 3px;
    border-radius: 11px;
    background: var(--segmented-track);
    overflow-x: auto;
    scrollbar-width: none;
}

.topnav::-webkit-scrollbar {
    display: none;
}

.nav-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    min-height: 32px;
    padding: 0 0.85rem;
    border-radius: 8px;
    color: var(--ink-secondary);
    font-size: 0.81rem;
    font-weight: 500;
    white-space: nowrap;
    text-decoration: none;
    transition: color 140ms ease-out, background-color 140ms ease-out, box-shadow 140ms ease-out;
}

.nav-link svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    opacity: 0.72;
}

.nav-link:hover {
    color: var(--ink);
    opacity: 1;
}

.nav-link.active {
    color: var(--ink);
    background: var(--segmented-thumb);
    font-weight: 600;
    box-shadow: var(--segmented-shadow);
}

:root[data-theme="dark"] .nav-link.active {
    color: #ffffff;
}

.nav-link.active svg {
    opacity: 1;
    color: var(--accent);
}

:root[data-theme="dark"] .nav-link.active svg {
    color: #ffffff;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-shrink: 0;
}

.topbar-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.38rem;
    min-height: 34px;
    padding: 0 0.78rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--ink);
    box-shadow: var(--shadow-sm);
    font-size: 0.78rem;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 140ms ease-out, transform 120ms ease-out;
}

.topbar-toggle:hover:not(:disabled) {
    background: var(--surface-soft);
}

.topbar-toggle:active:not(:disabled) {
    transform: scale(0.97);
}

.topbar-toggle-icon {
    display: inline-flex;
    flex: none;
    color: var(--accent);
}

.topbar-toggle-icon svg {
    width: 15px;
    height: 15px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.85;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.topbar-toggle .icon-moon {
    display: inline-flex;
}

.topbar-toggle .icon-sun {
    display: none;
}

:root[data-theme="dark"] .topbar-toggle .icon-moon {
    display: none;
}

:root[data-theme="dark"] .topbar-toggle .icon-sun {
    display: inline-flex;
    color: var(--warning);
}

.menu-toggle {
    display: none;
}

.content {
    width: min(1560px, calc(100% - 48px));
    margin: 0 auto;
    padding: 24px 0 64px;
    flex: 1;
}

/* ---------- Page Header ---------- */
.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1.25rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
    padding-bottom: 0.9rem;
    border-bottom: 1px solid var(--line);
}

.page-head .meta {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 0.8rem;
}

/* ---------- iOS Grouped Cards & Panels ---------- */
.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.panel > h2:first-child,
.panel-head h2 {
    margin: 0;
}

.panel > h2:first-child {
    margin-bottom: 14px;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 14px;
    padding-bottom: 11px;
    border-bottom: 1px solid var(--line);
}

.row {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.row.center {
    align-items: center;
}

.grid {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.stack > * + * {
    margin-top: 14px;
}

.grow {
    flex: 1;
}

.muted,
.hint {
    color: var(--muted);
    font-size: 0.8rem;
}

.hint {
    margin: 6px 0;
    line-height: 1.55;
    text-wrap: pretty;
}

.right {
    margin-left: auto;
}

/* ---------- iOS Controls & Inputs ---------- */
label {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--ink-secondary);
    min-width: 0;
}

label.check {
    flex-direction: row;
    align-items: center;
    gap: 8px;
    font-size: 0.84rem;
    font-weight: 500;
    color: var(--ink);
    cursor: pointer;
    user-select: none;
}

input,
select,
textarea,
button,
.button {
    font: inherit;
    font-size: 0.84rem;
    color: var(--ink);
    background: var(--surface-soft);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    min-height: 36px;
    padding: 6px 12px;
    min-width: 0;
    transition: border-color 140ms ease-out, background-color 140ms ease-out, transform 120ms ease-out, box-shadow 140ms ease-out;
}

input:hover:not(:disabled):not(:focus),
select:hover:not(:disabled):not(:focus),
textarea:hover:not(:disabled):not(:focus) {
    border-color: var(--line-strong);
}

textarea {
    min-height: 90px;
    resize: vertical;
    line-height: 1.5;
}

select {
    cursor: pointer;
    text-overflow: ellipsis;
    padding-right: 30px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23007aff' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 15 5 5 5-5'/%3E%3Cpath d='m7 9 5-5 5 5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 9px center;
    appearance: none;
}

select.ios-select-open {
    border-color: var(--accent);
    background-color: var(--surface);
    box-shadow: var(--focus-ring);
}

select option {
    background: var(--surface);
    color: var(--ink);
    padding: 8px 12px;
}

select[size],
select[multiple] {
    background-image: none;
    padding-right: 12px;
}

/* iOS Frosted Glass Popover Menu for <select> */
@keyframes iosSelectPopoverIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-4px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.ios-select-popover {
    position: fixed;
    inset: auto;
    margin: 0;
    z-index: 1200;
    display: flex;
    flex-direction: column;
    padding: 4px;
    border-radius: 13px;
    border: 1px solid var(--line-strong);
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: saturate(180%) blur(24px);
    -webkit-backdrop-filter: saturate(180%) blur(24px);
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.16), 0 2px 8px rgba(0, 0, 0, 0.06);
    overflow-y: auto;
    overscroll-behavior: contain;
    transform-origin: top center;
    animation: iosSelectPopoverIn 150ms cubic-bezier(0.22, 1, 0.36, 1);
}

:root[data-theme="dark"] .ios-select-popover {
    background: rgba(44, 44, 46, 0.9);
    box-shadow: 0 18px 44px rgba(0, 0, 0, 0.58), 0 2px 8px rgba(0, 0, 0, 0.3);
}

.ios-select-popover.is-upward {
    transform-origin: bottom center;
}

.ios-select-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    min-height: 36px;
    padding: 7px 11px;
    border: 0;
    border-bottom: 1px solid var(--line);
    border-radius: 8px;
    background: transparent;
    color: var(--ink);
    box-shadow: none;
    font-size: 0.84rem;
    font-weight: 450;
    text-align: left;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 100ms ease-out, color 100ms ease-out;
}

.ios-select-option:last-child {
    border-bottom: 0;
}

.ios-select-option:hover:not(:disabled) {
    background: var(--accent-soft);
    color: var(--accent-text);
}

.ios-select-option:active:not(:disabled) {
    transform: none;
    background: var(--control-active);
}

.ios-select-option.is-selected {
    font-weight: 600;
    color: var(--accent-text);
    background: rgba(0, 122, 255, 0.06);
}

.ios-select-option-label {
    min-width: 0;
    white-space: normal;
    overflow-wrap: anywhere;
}

.ios-select-option-label small {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 400;
    line-height: 1.45;
}

.ios-select-option {
    flex-shrink: 0;
}

.ios-select-option-check {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    color: var(--accent);
    opacity: 0;
    flex-shrink: 0;
}

.ios-select-option.is-selected .ios-select-option-check {
    opacity: 1;
}

input[type=checkbox],
input[type=radio] {
    min-height: 0;
    width: 16px;
    height: 16px;
    padding: 0;
    accent-color: var(--accent);
    cursor: pointer;
    flex-shrink: 0;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
    background: var(--surface);
    outline: none;
    box-shadow: var(--focus-ring);
}

button,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    font-weight: 500;
    white-space: nowrap;
    background: var(--surface);
    border-color: var(--line-strong);
    box-shadow: var(--shadow-sm);
    user-select: none;
}

button svg,
.button svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}

button:hover:not(:disabled),
.button:hover {
    background: var(--surface-soft);
    border-color: var(--line-strong);
    color: var(--ink);
    opacity: 1;
    text-decoration: none;
}

button:active:not(:disabled),
.button:active {
    background: var(--control-active);
    transform: scale(0.97);
}

button:disabled {
    opacity: 0.42;
    cursor: not-allowed;
    box-shadow: none;
}

/* iOS System Blue Primary Button */
.primary {
    background: var(--accent);
    border-color: transparent;
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0, 122, 255, 0.25);
}

.primary:hover:not(:disabled) {
    background: var(--accent-dark);
    border-color: transparent;
    color: #ffffff;
}

.danger {
    color: var(--danger);
    border-color: var(--danger-border);
    background: var(--danger-soft);
}

.danger:hover:not(:disabled) {
    background: var(--danger);
    border-color: var(--danger);
    color: #ffffff;
}

.danger.solid {
    background: var(--danger);
    border-color: var(--danger);
    color: #ffffff;
    font-weight: 600;
}

.danger.solid:hover:not(:disabled) {
    background: var(--danger-dark);
    border-color: var(--danger-dark);
    color: #ffffff;
}

.small {
    min-height: 30px;
    padding: 4px 10px;
    font-size: 0.76rem;
    border-radius: 8px;
}

select.small {
    padding-right: 26px;
}

.file-button input {
    display: none;
}

input[type=file]::file-selector-button {
    font: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    color: #ffffff;
    background: var(--accent);
    border: 0;
    border-radius: 7px;
    padding: 5px 12px;
    margin-right: 10px;
    cursor: pointer;
}

input[type=file]::file-selector-button:hover {
    background: var(--accent-dark);
}

.actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

/* ---------- iOS Grouped Tables (tabular-nums) ---------- */
.table-scroll {
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: var(--surface);
}

.panel.table-scroll {
    padding: 0;
    border-radius: var(--radius);
    overflow: hidden;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
    text-align: left;
    font-variant-numeric: tabular-nums;
}

th,
td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

tbody tr:last-child td,
tbody tr:last-child th {
    border-bottom: none;
}

thead th {
    background: var(--surface-soft);
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--muted);
    letter-spacing: 0.02em;
    white-space: nowrap;
    border-bottom: 1px solid var(--line);
}

tbody th {
    font-weight: 600;
    color: var(--ink-secondary);
    background: var(--surface-soft);
    width: 140px;
}

tbody tr {
    transition: background-color 120ms ease-out;
}

tbody tr:hover {
    background: var(--surface-soft);
}

td.nowrap,
th.nowrap {
    white-space: nowrap;
}

td.muted[colspan] {
    text-align: center;
    padding: 28px 16px;
    color: var(--muted);
}

/* ---------- Notices, Badges & Toasts ---------- */
.notice {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border: 1px solid var(--accent-border);
    background: var(--accent-soft);
    color: var(--ink);
    border-radius: 11px;
    font-size: 0.82rem;
    font-weight: 500;
    margin-bottom: 14px;
}

.notice::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
    flex-shrink: 0;
}

.notice.error {
    border-color: var(--danger-border);
    background: var(--danger-soft);
    color: var(--danger-dark);
}

.notice.error::before {
    background: var(--danger);
}

.notice.success {
    border-color: var(--success-border);
    background: var(--success-soft);
    color: var(--success);
}

.notice.success::before {
    background: var(--success);
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 9px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent-text);
    font-size: 0.74rem;
    font-weight: 600;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.badge.accent {
    background: var(--indigo-soft);
    color: var(--indigo-text);
}

.badge.danger {
    background: var(--danger-soft);
    color: var(--danger);
}

.toast {
    position: fixed;
    right: max(20px, env(safe-area-inset-right));
    bottom: max(20px, env(safe-area-inset-bottom));
    z-index: 50;
    max-width: min(400px, calc(100vw - 40px));
    padding: 11px 18px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--surface-translucent);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    color: var(--ink);
    box-shadow: var(--shadow-lg);
    font-size: 0.82rem;
    font-weight: 600;
    opacity: 0;
    transform: translateY(8px) scale(0.97);
    transition: opacity 160ms ease-out, transform 160ms ease-out;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.toast.error {
    background: var(--danger);
    border-color: var(--danger);
    color: #ffffff;
}

.toast.success {
    background: var(--success);
    border-color: var(--success);
    color: #ffffff;
}

/* ---------- iOS Modal Sheets & Dialogs ---------- */
@keyframes dialogEnter {
    from {
        opacity: 0;
        transform: translateY(8px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

dialog {
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 22px 24px;
    color: var(--ink);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    max-width: calc(100vw - 24px);
    max-height: 90dvh;
}

dialog[open] {
    animation: dialogEnter 180ms cubic-bezier(0.22, 1, 0.36, 1);
}

dialog::backdrop {
    background: rgba(0, 0, 0, 0.32);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.dialog-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    padding-bottom: 11px;
    border-bottom: 1px solid var(--line);
}

.dialog-head h2 {
    margin: 0;
}

/* ---------- iOS Centered Clean Login ---------- */
body.login {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 24px;
}

.login form.panel {
    width: min(380px, 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 15px;
    padding: 32px 28px;
    border-radius: var(--radius-lg);
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-lg);
    margin: 0;
}

.login-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 5px;
    margin-bottom: 4px;
}

.login-badge {
    display: inline-grid;
    place-items: center;
    width: 46px;
    height: 46px;
    border-radius: 12px;
    background: var(--accent);
    color: #ffffff;
    box-shadow: var(--shadow-sm);
    margin-bottom: 6px;
}

.login-badge svg {
    width: 22px;
    height: 22px;
}

.login h1 {
    font-size: 1.35rem;
    margin: 0;
}

.login-subtitle {
    font-size: 0.8rem;
    color: var(--muted);
    margin: 0;
}

.login button.primary {
    min-height: 42px;
    font-size: 0.88rem;
    margin-top: 4px;
}

/* ---------- Reduced Motion & Responsive ---------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

@media (max-width: 1024px) {
    .topbar {
        flex-wrap: wrap;
        padding: 10px 16px;
        gap: 10px;
    }

    .topnav {
        order: 3;
        width: 100%;
        justify-content: flex-start;
    }

    .content {
        width: calc(100% - 32px);
        padding: 18px 0 48px;
    }

    .login-shell {
        grid-template-columns: 1fr;
    }
}
