.btn {
    --btn-bg: var(--surface-2);
    --btn-fg: var(--text);
    --btn-bd: var(--border-strong);
    --btn-shadow: 0 1px 2px rgba(0, 0, 0, .14);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: var(--control-h);
    padding: 0 18px;
    border-radius: var(--r-md);
    border: 1px solid var(--btn-bd);
    background: var(--btn-bg);
    color: var(--btn-fg);
    font-family: inherit;
    font-size: var(--text-md);
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    text-decoration: none;
    user-select: none;
    position: relative;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    box-shadow: inset 0 1px 0 var(--highlight), var(--btn-shadow);
    transition: background var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease), color var(--dur-1), filter var(--dur-1),
                transform var(--dur-1) var(--ease), box-shadow var(--dur-2) var(--ease), opacity var(--dur-1);
}
.btn svg { width: 18px; height: 18px; }
.btn:hover { --btn-bg: var(--surface-3); color: var(--btn-fg); text-decoration: none; }
.btn:not(.btn-ghost):not(.btn-icon):not(.btn-danger-ghost):hover { transform: translateY(-1px); --btn-shadow: 0 8px 18px -10px rgba(0, 0, 0, .45); }
.btn:active { transform: translateY(0) scale(.98); transition-duration: 60ms; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-ring); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; pointer-events: none; }

.btn-primary {
    --btn-fg: var(--text-on-accent); --btn-bd: transparent;
    --btn-shadow: 0 8px 20px -12px hsl(var(--hue-accent) 70% 45% / .9);
    background: var(--accent-gradient);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .24), inset 0 -1px 0 rgba(0, 0, 0, .12), var(--btn-shadow);
}
.btn-primary:hover { --btn-bd: transparent; filter: brightness(1.08) saturate(1.05); --btn-shadow: 0 14px 28px -12px hsl(var(--hue-accent) 80% 50% / .85); }
.btn-primary:active { filter: brightness(.97); }

.btn-ghost { --btn-bg: transparent; --btn-bd: transparent; --btn-fg: var(--text-2); --btn-shadow: none; box-shadow: none; }
.btn-ghost:hover { --btn-bg: var(--surface-2); --btn-bd: transparent; --btn-fg: var(--text); }

.btn-subtle { --btn-bg: var(--accent-soft); --btn-fg: var(--accent); --btn-bd: transparent; --btn-shadow: none; box-shadow: none; }
.btn-subtle:hover { --btn-bg: color-mix(in srgb, var(--accent) 22%, transparent); --btn-bd: transparent; }

.btn-danger { --btn-bg: var(--danger); --btn-fg: #fff; --btn-bd: transparent; --btn-shadow: 0 8px 20px -12px hsl(var(--hue-danger) 70% 45% / .9); }
.btn-danger:hover { --btn-bg: var(--danger); --btn-bd: transparent; filter: brightness(1.07); }
.btn-danger:active { --btn-bg: var(--danger); filter: brightness(.94); }
.btn-danger-ghost { --btn-bg: transparent; --btn-bd: transparent; --btn-fg: var(--danger); --btn-shadow: none; box-shadow: none; }
.btn-danger-ghost:hover { --btn-bg: var(--danger-soft); --btn-bd: transparent; }

.btn-sm { height: var(--control-h-sm); padding: 0 12px; gap: 6px; font-size: var(--text-sm); border-radius: 10px; }
.btn-sm svg { width: 16px; height: 16px; }
.btn-lg { height: var(--control-h-lg); padding: 0 var(--s-6); font-size: 15px; border-radius: 14px; }
.btn-block { width: 100%; }

.btn-icon { width: var(--control-h); padding: 0; }
.btn-icon.btn-sm { width: var(--control-h-sm); }

.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
    content: '';
    position: absolute;
    inset: 0;
    margin: auto;
    width: 18px; height: 18px;
    border: 2px solid currentColor;
    border-color: var(--btn-fg) transparent var(--btn-fg) var(--btn-fg);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}

.field { display: flex; flex-direction: column; gap: var(--s-2); min-width: 0; }
.field-label { font-size: var(--text-sm); font-weight: 600; color: var(--text-2); display: flex; align-items: center; gap: var(--s-1); }
.field-label .req { color: var(--danger); }
.field-hint  { font-size: var(--text-sm); color: var(--text-3); }
.field-error {
    font-size: var(--text-sm);
    color: var(--danger);
    display: none;
    align-items: flex-start;
    gap: var(--s-1);
    animation: rise-in var(--dur-2) var(--ease);
}
.field-error .icon { width: 14px; height: 14px; margin-top: 4px; }
.field.has-error .field-error { display: flex; }
.field.has-error .input,
.field.has-error .select,
.field.has-error .textarea { border-color: var(--danger); }
.field.has-error .input:focus,
.field.has-error .textarea:focus { box-shadow: 0 0 0 3px var(--danger-soft); }

.input, .select, .textarea {
    width: 100%;
    height: var(--control-h);
    padding: 0 var(--s-3);
    border-radius: var(--r-md);
    border: 1px solid var(--border-strong);
    background: var(--bg-elev);
    color: var(--text);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, .06);
    transition: border-color var(--dur-1), box-shadow var(--dur-1), background var(--dur-1);
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--text-3); }
.input:focus, .select:focus, .textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-ring), inset 0 1px 2px rgba(0, 0, 0, .04);
    outline: none;
}
.input:disabled, .select:disabled, .textarea:disabled { opacity: .5; background: var(--surface-2); cursor: not-allowed; }
.input[readonly] { background: var(--surface-2); }
.input-sm { height: var(--control-h-sm); padding: 0 var(--s-2); font-size: var(--text-sm); border-radius: var(--r-sm); }

.textarea { height: auto; min-height: 96px; padding: var(--s-2) var(--s-3); resize: vertical; line-height: 1.6; }

.select-wrap { position: relative; display: block; width: 100%; }
.select-native { position: absolute; inset: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.select {
    display: flex; align-items: center; gap: var(--s-2); text-align: start; cursor: pointer;
    font: inherit; font-size: var(--text-md);
}
.select .select-label { flex: 1; min-width: 0; }
.select .select-label.is-placeholder { color: var(--text-3); }
.select-chevron { display: grid; place-items: center; color: var(--text-3); transition: transform var(--dur-2) var(--ease), color var(--dur-1); flex-shrink: 0; }
.select-chevron svg { width: 16px; height: 16px; }
.select[aria-expanded="true"] { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-ring); }
.select[aria-expanded="true"] .select-chevron { transform: rotate(180deg); color: var(--accent); }
.select:focus:not(:focus-visible):not([aria-expanded="true"]) { border-color: var(--border-strong); box-shadow: inset 0 1px 2px rgba(0, 0, 0, .06); }
.select.input-sm { font-size: var(--text-sm); gap: 6px; }
.select.input-sm .select-chevron svg { width: 14px; height: 14px; }
.select-menu {
    position: fixed; z-index: calc(var(--z-modal) + 6);
    max-height: min(320px, 60vh); overflow-y: auto; scrollbar-width: thin;
    padding: var(--s-1);
    background: var(--bg-elev); border: 1px solid var(--border-strong); border-radius: var(--r-md);
    box-shadow: var(--shadow-3);
    animation: pop-in var(--dur-1) var(--ease) both;
    transform-origin: top right;
}
.select-option {
    width: 100%; display: flex; align-items: center; gap: var(--s-2);
    padding: 8px var(--s-2) 8px var(--s-3); border-radius: var(--r-sm);
    font-size: var(--text-sm); font-weight: 500; color: var(--text); text-align: start;
    transition: background var(--dur-1);
}
.select-option:hover, .select-option:focus-visible { background: var(--surface-2); outline: none; }
.select-option.is-selected { color: var(--accent); font-weight: 700; background: var(--accent-soft); }
.select-option.is-muted { color: var(--text-3); }
.select-option small { display: block; font-size: 11px; color: var(--text-3); font-weight: 400; margin-top: 1px; }
.select-option-check { width: 16px; height: 16px; display: grid; place-items: center; opacity: 0; color: var(--accent); flex-shrink: 0; }
.select-option-check svg { width: 14px; height: 14px; }
.select-option.is-selected .select-option-check { opacity: 1; }
.select-option-icon { width: 24px; height: 24px; border-radius: 7px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); flex-shrink: 0; }
.select-option-icon svg { width: 14px; height: 14px; }

.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap:has(> svg) .input { padding-inline-start: 40px; }
.input-wrap > svg { position: absolute; inset-inline-start: 12px; width: 18px; height: 18px; color: var(--text-3); pointer-events: none; }
.input-wrap .input-suffix {
    position: absolute; inset-inline-end: 8px;
    padding: 3px 9px; border-radius: 7px;
    background: var(--surface-2); color: var(--text-3);
    font-size: 12px; font-weight: 500; line-height: 1.4; white-space: nowrap; pointer-events: none;
}
.input-wrap.has-suffix .input { padding-inline-end: 84px; }
.input-wrap .input-action {
    position: absolute; inset-inline-end: 6px;
    width: 28px; height: 28px; border-radius: var(--r-sm);
    display: grid; place-items: center; color: var(--text-3);
    transition: background var(--dur-1), color var(--dur-1);
}
.input-wrap .input-action:hover { background: var(--surface-2); color: var(--text); }
.input-wrap .input-action svg { width: 16px; height: 16px; }
.input-wrap.has-action .input { padding-inline-end: 40px; }

.input:is([type="number"], [type="password"], [type="tel"], [type="email"], [type="url"], [dir="ltr"], .ltr, [inputmode="numeric"], [inputmode="decimal"], [inputmode="tel"]) { direction: ltr; text-align: left; }
.input-wrap:has(> svg) .input:is([type="password"], [type="tel"], [type="email"], [type="url"], [dir="ltr"], .ltr, [inputmode="numeric"], [inputmode="decimal"], [inputmode="tel"]) { padding-right: 40px; padding-left: var(--s-3); }
.input-wrap.has-action .input:is([type="password"], [type="tel"], [type="email"], [type="url"], [dir="ltr"], .ltr, [inputmode="numeric"], [inputmode="decimal"], [inputmode="tel"]) { padding-left: 40px; }
.input-wrap.has-suffix .input:is([type="password"], [type="tel"], [type="email"], [type="url"], [dir="ltr"], .ltr, [inputmode="numeric"], [inputmode="decimal"], [inputmode="tel"]) { padding-left: 84px; padding-right: var(--s-3); }
.input[data-datepicker] { text-align: right; }
.input[type="number"]::-webkit-inner-spin-button { opacity: .4; }

.check {
    display: inline-flex; align-items: center; gap: var(--s-2);
    cursor: pointer; user-select: none; font-size: var(--text-md);
}
.check input { position: absolute; opacity: 0; width: 0; height: 0; }
.check .box {
    width: 18px; height: 18px; border-radius: 5px;
    border: 1.5px solid var(--border-strong); background: var(--surface);
    display: grid; place-items: center; flex-shrink: 0;
    transition: background var(--dur-1), border-color var(--dur-1), transform var(--dur-1);
}
.check .box svg { width: 12px; height: 12px; color: #fff; opacity: 0; transform: scale(.6); transition: opacity var(--dur-1), transform var(--dur-1) var(--ease-spring); }
.check:hover .box { border-color: var(--text-3); }
.check input:checked + .box { background: var(--accent); border-color: var(--accent); }
.check input:checked + .box svg { opacity: 1; transform: scale(1); }
.check input:focus-visible + .box { box-shadow: 0 0 0 3px var(--accent-ring); }
.check input:disabled ~ * { opacity: .5; cursor: not-allowed; }

.switch { display: inline-flex; align-items: center; gap: var(--s-2); cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
    width: 38px; height: 22px; border-radius: var(--r-full);
    background: var(--surface-3); border: 1px solid var(--border-strong);
    position: relative; transition: background var(--dur-2), border-color var(--dur-2);
}
.switch .track::after {
    content: ''; position: absolute; top: 2px; inset-inline-start: 2px;
    width: 16px; height: 16px; border-radius: 50%; background: var(--text-2);
    transition: transform var(--dur-2) var(--ease-spring), background var(--dur-2);
}
.switch input:checked + .track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .track::after { transform: translateX(-16px); background: #fff; }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px var(--accent-ring); }

.radio-cards { display: grid; gap: var(--s-2); }
.radio-card {
    display: flex; align-items: flex-start; gap: var(--s-3);
    padding: var(--s-3) var(--s-4); border-radius: var(--r-md);
    border: 1px solid var(--border); background: var(--surface);
    cursor: pointer; transition: border-color var(--dur-1), background var(--dur-1), box-shadow var(--dur-1);
}
.radio-card input { position: absolute; opacity: 0; width: 0; height: 0; }
.radio-card:hover { border-color: var(--border-strong); background: var(--surface-2); }
.radio-card .dot {
    width: 18px; height: 18px; border-radius: 50%; flex-shrink: 0; margin-top: 3px;
    border: 1.5px solid var(--border-strong); display: grid; place-items: center;
    transition: border-color var(--dur-1);
}
.radio-card .dot::after { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); transform: scale(0); transition: transform var(--dur-1) var(--ease-spring); }
.radio-card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.radio-card:has(input:checked) .dot { border-color: var(--accent); }
.radio-card:has(input:checked) .dot::after { transform: scale(1); }
.radio-card:has(input:focus-visible) { box-shadow: 0 0 0 3px var(--accent-ring); }
.radio-card .title { font-weight: 600; }
.radio-card .desc { font-size: var(--text-sm); color: var(--text-2); }

.segmented {
    display: inline-flex; padding: 3px; gap: 2px;
    background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md);
}
.segmented > button, .segmented > label {
    position: relative; height: 32px; padding: 0 var(--s-4);
    display: inline-flex; align-items: center; gap: var(--s-2);
    border-radius: calc(var(--r-md) - 3px); font-size: var(--text-sm); font-weight: 500;
    color: var(--text-2); cursor: pointer; white-space: nowrap;
    transition: background var(--dur-2) var(--ease), color var(--dur-2), box-shadow var(--dur-2);
}
.segmented > label input { position: absolute; opacity: 0; width: 0; height: 0; }
.segmented > button:hover, .segmented > label:hover { color: var(--text); }
.segmented > button.is-active, .segmented > label:has(input:checked) { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); font-weight: 600; }
.segmented > button:focus-visible, .segmented > label:has(input:focus-visible) { box-shadow: 0 0 0 3px var(--accent-ring); outline: none; }
.segmented.is-block { display: flex; } .segmented.is-block > * { flex: 1; justify-content: center; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: inset 0 1px 0 var(--highlight), var(--shadow-1);
}
.card-header {
    display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
    padding: var(--s-4) var(--s-5);
    border-bottom: 1px solid var(--border);
}
.card-header h2 { display: flex; align-items: center; gap: var(--s-2); }
.card-body { padding: var(--s-5); }
.card-footer { padding: var(--s-4) var(--s-5); border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: var(--s-2); }
.card.is-interactive { cursor: pointer; transition: border-color var(--dur-1), transform var(--dur-2) var(--ease), box-shadow var(--dur-2); }
.card.is-interactive:hover { border-color: var(--border-strong); box-shadow: var(--shadow-2); transform: translateY(-1px); }

.stat {
    display: flex; flex-direction: column; gap: var(--s-1);
    padding: var(--s-5); border-radius: var(--r-lg);
    background: var(--surface); border: 1px solid var(--border);
    box-shadow: inset 0 1px 0 var(--highlight), var(--shadow-1);
    position: relative; overflow: hidden;
    transition: transform var(--dur-2) var(--ease), box-shadow var(--dur-2), border-color var(--dur-2);
}
.stat:hover { transform: translateY(-2px); box-shadow: inset 0 1px 0 var(--highlight), var(--shadow-2); border-color: var(--border-strong); }
.stat-label { font-size: var(--text-sm); color: var(--text-2); font-weight: 500; display: flex; align-items: center; gap: var(--s-2); padding-inline-end: 44px; min-height: 36px; }
.stat-label svg {
    position: absolute; top: var(--s-4); inset-inline-end: var(--s-4);
    width: 36px; height: 36px; padding: 9px; border-radius: 11px;
    color: var(--accent); background: var(--accent-soft);
}
.stat-value { font-size: 30px; font-weight: 800; line-height: 1.2; font-variant-numeric: tabular-nums; letter-spacing: -.02em; margin-top: var(--s-1); }
.stat-meta  { font-size: var(--text-sm); color: var(--text-3); }
.stat-meta.is-warning { color: var(--warning); }

.badge {
    display: inline-flex; align-items: center; gap: 5px;
    height: 24px; padding: 0 9px; border-radius: var(--r-full);
    font-size: 12px; font-weight: 600; line-height: 1; white-space: nowrap;
    background: var(--surface-3); color: var(--text-2);
}
.badge svg { width: 12px; height: 12px; }
.badge-success  { background: var(--success-soft); color: var(--success); }
.badge-warning  { background: var(--warning-soft); color: var(--warning); }
.badge-danger   { background: var(--danger-soft);  color: var(--danger); }
.badge-accent   { background: var(--accent-soft);  color: var(--accent); }
.badge-superset { background: var(--superset-soft); color: var(--superset); }
.badge-dot::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.avatar {
    --size: 40px;
    --avatar-hue: 234;
    width: var(--size); height: var(--size); border-radius: 50%;
    display: grid; place-items: center; flex-shrink: 0; overflow: hidden;
    background: linear-gradient(145deg, hsl(var(--avatar-hue) 55% 36%), hsl(calc(var(--avatar-hue) + 30) 55% 24%));
    color: hsl(var(--avatar-hue) 90% 93%);
    font-size: calc(var(--size) * .36); font-weight: 700;
    border: 1px solid rgba(255, 255, 255, .08);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12);
    user-select: none;
}
:root[data-theme="light"] .avatar {
    background: linear-gradient(145deg, hsl(var(--avatar-hue) 70% 88%), hsl(calc(var(--avatar-hue) + 30) 70% 80%));
    color: hsl(var(--avatar-hue) 55% 32%);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { --size: 32px; } .avatar-lg { --size: 56px; } .avatar-xl { --size: 88px; }
.avatar.is-accent { background: var(--accent-soft); color: var(--accent); }

.table-wrap { overflow-x: auto; border-radius: var(--r-lg); border: 1px solid var(--border); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.table th, .table td { padding: var(--s-3) var(--s-4); text-align: right; vertical-align: middle; }
.table th { font-weight: 600; color: var(--text-2); background: var(--surface-2); white-space: nowrap; border-bottom: 1px solid var(--border); }
.table td { border-bottom: 1px solid var(--border); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background var(--dur-1); }
.table tbody tr:hover td { background: var(--surface-2); }
.table .actions { display: flex; gap: var(--s-1); justify-content: flex-end; }
.table .cell-main { display: flex; align-items: center; gap: var(--s-3); }
.table .cell-sub { color: var(--text-3); font-size: 12px; }

.tabs { display: flex; gap: var(--s-1); border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; margin-bottom: var(--s-6); }
.tabs::-webkit-scrollbar { display: none; }
.tab {
    position: relative; height: 44px; padding: 0 var(--s-4);
    display: inline-flex; align-items: center; gap: var(--s-2);
    color: var(--text-2); font-weight: 500; white-space: nowrap; font-size: var(--text-md);
    border-radius: var(--r-sm) var(--r-sm) 0 0;
    transition: color var(--dur-1), background var(--dur-1);
}
.tab svg { width: 16px; height: 16px; }
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab::after { content: ''; position: absolute; inset-inline: var(--s-3); bottom: -1px; height: 2px; border-radius: 2px; background: var(--accent); transform: scaleX(0); transition: transform var(--dur-2) var(--ease); }
.tab.is-active { color: var(--text); font-weight: 600; }
.tab.is-active::after { transform: scaleX(1); }
.tab .count { font-size: 11px; background: var(--surface-3); color: var(--text-2); padding: 1px 7px; border-radius: var(--r-full); }

.menu {
    position: fixed; z-index: calc(var(--z-modal) + 5);
    min-width: 180px; padding: var(--s-1);
    background: var(--bg-elev); border: 1px solid var(--border-strong); border-radius: var(--r-md);
    box-shadow: var(--shadow-3);
    animation: pop-in var(--dur-1) var(--ease) both;
    transform-origin: top right;
}
.menu-item {
    width: 100%; display: flex; align-items: center; gap: var(--s-3);
    padding: 8px var(--s-3); border-radius: var(--r-sm);
    font-size: var(--text-sm); font-weight: 500; color: var(--text); text-align: right;
    transition: background var(--dur-1);
}
.menu-item svg { width: 16px; height: 16px; color: var(--text-2); }
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-2); outline: none; }
.menu-item.is-danger { color: var(--danger); } .menu-item.is-danger svg { color: var(--danger); }
.menu-item:disabled { opacity: .4; }
.menu-item .kbd { margin-inline-start: auto; }
.menu-sep { height: 1px; background: var(--border); margin: var(--s-1) 0; }
.menu-title { padding: 6px var(--s-3) 2px; font-size: 11px; color: var(--text-3); font-weight: 600; }

.toast-stack {
    position: fixed; z-index: var(--z-toast);
    bottom: var(--s-6); inset-inline-start: var(--s-6);
    display: flex; flex-direction: column; gap: var(--s-2);
    pointer-events: none; max-width: min(380px, calc(100vw - 32px));
}
.toast {
    pointer-events: auto;
    display: flex; align-items: flex-start; gap: var(--s-3);
    padding: var(--s-3) var(--s-4);
    background: var(--bg-elev); border: 1px solid var(--border-strong); border-radius: var(--r-md);
    box-shadow: var(--shadow-3); font-size: var(--text-sm);
    animation: rise-in var(--dur-3) var(--ease-spring) both;
}
.toast.is-leaving { animation: fade-in var(--dur-2) reverse both; }
.toast svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 2px; }
.toast-success svg { color: var(--success); }
.toast-error   svg { color: var(--danger); }
.toast-info    svg { color: var(--accent); }
.toast-warning svg { color: var(--warning); }
.toast .toast-close { margin-inline-start: auto; color: var(--text-3); width: 22px; height: 22px; border-radius: 4px; display: grid; place-items: center; }
.toast .toast-close:hover { background: var(--surface-2); color: var(--text); }
.toast .toast-close svg { width: 14px; height: 14px; margin: 0; }

.modal-backdrop {
    position: fixed; inset: 0; z-index: var(--z-modal);
    background: var(--overlay);
    display: grid; place-items: center; padding: var(--s-4);
    animation: fade-in var(--dur-2) both;
}
.modal-backdrop.is-leaving { animation: fade-in var(--dur-2) reverse both; }
.modal {
    width: 100%; max-width: 480px; max-height: calc(100dvh - 32px);
    display: flex; flex-direction: column;
    background: var(--bg-elev); border: 1px solid var(--border-strong); border-radius: var(--r-xl);
    box-shadow: var(--shadow-3);
    animation: pop-in var(--dur-3) var(--ease-spring) both;
}
.modal-lg { max-width: 720px; } .modal-xl { max-width: 960px; }

.upload-progress {
    position: absolute; inset: 0; z-index: 2; border-radius: inherit;
    display: grid; place-items: center;
    background: rgba(8, 11, 16, .68); color: #fff;
    font-size: 15px; font-weight: 800; font-variant-numeric: tabular-nums;
    text-shadow: 0 1px 2px rgba(0, 0, 0, .5);
}
.upload-progress::before {
    content: ''; position: absolute; inset: 4px; border-radius: inherit;
    background: conic-gradient(hsl(var(--hue-accent) 70% 55%) calc(var(--p, 0) * 1%), rgba(255, 255, 255, .3) 0);
    -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 5px), #000 calc(100% - 4px));
    mask: radial-gradient(farthest-side, transparent calc(100% - 5px), #000 calc(100% - 4px));
}
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-5) var(--s-6) var(--s-3); }
.modal-header h2 { font-size: var(--text-md); font-weight: 700; }
.modal-body { padding: var(--s-3) var(--s-6); overflow-y: auto; }
.modal-footer { display: flex; justify-content: flex-end; gap: var(--s-2); padding: var(--s-4) var(--s-6) var(--s-5); }
.modal-icon { width: 48px; height: 48px; border-radius: var(--r-lg); display: grid; place-items: center; margin-bottom: var(--s-3); }
.modal-icon svg { width: 22px; height: 22px; }
.modal-icon.is-danger { background: var(--danger-soft); color: var(--danger); }
.modal-icon.is-warning { background: var(--warning-soft); color: var(--warning); }
.modal-icon.is-accent { background: var(--accent-soft); color: var(--accent); }

@media (max-width: 560px) {
    .modal-backdrop { align-items: end; padding: 0; }
    .modal { max-width: none; border-radius: var(--r-xl) var(--r-xl) 0 0; max-height: 92dvh; animation: rise-in var(--dur-3) var(--ease) both; }
}

.empty {
    display: flex; flex-direction: column; align-items: center; text-align: center;
    padding: var(--s-12) var(--s-6); gap: var(--s-2);
    animation: rise-in var(--dur-3) var(--ease) both;
}
.empty-art { width: 156px; height: 120px; margin-bottom: var(--s-4); color: var(--text-3); filter: drop-shadow(0 12px 24px rgba(0,0,0,.18)); }
.empty-art .art-accent { color: var(--accent); }
.empty h2 { font-size: var(--text-md); font-weight: 700; }
.empty p { color: var(--text-2); font-size: var(--text-sm); max-width: 360px; }
.empty .btn { margin-top: var(--s-4); }
.empty.is-compact { padding: var(--s-8) var(--s-4); }
.empty.is-compact .empty-art { width: 96px; height: 76px; margin-bottom: var(--s-2); }

.skeleton {
    position: relative; overflow: hidden; border-radius: var(--r-sm);
    background: linear-gradient(90deg, var(--skeleton-a) 25%, var(--skeleton-b) 50%, var(--skeleton-a) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.6s linear infinite;
    color: transparent !important;
}
.skeleton-text   { height: 12px; width: 100%; }
.skeleton-text.w-60 { width: 60%; } .skeleton-text.w-40 { width: 40%; } .skeleton-text.w-25 { width: 25%; }
.skeleton-circle { border-radius: 50%; width: 40px; height: 40px; }
.skeleton-block  { height: 96px; border-radius: var(--r-lg); }
.skeleton-row    { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) 0; }

.progress { height: 6px; border-radius: var(--r-full); background: var(--surface-3); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width var(--dur-3) var(--ease); }
.progress.is-success > span { background: var(--success); }
.progress.is-warning > span { background: var(--warning); }
.progress.is-danger  > span { background: var(--danger); }

.tooltip {
    position: fixed; top: 0; left: 0; z-index: 9999; max-width: min(280px, calc(100vw - 16px));
    padding: 6px 10px; border-radius: 8px;
    background: #111827; color: #f9fafb; font-size: 12px; font-weight: 600; line-height: 1.6;
    box-shadow: 0 8px 24px -8px rgba(0, 0, 0, .45);
    opacity: 0; transform: translateY(3px); pointer-events: none;
    transition: opacity 120ms ease, transform 120ms ease;
}
.tooltip[data-side="bottom"] { transform: translateY(-3px); }
.tooltip.is-visible { opacity: 1; transform: none; }
:root[data-theme="dark"] .tooltip { background: #f3f4f6; color: #111827; }

.kbd {
    display: inline-block; padding: 1px 6px; border-radius: 4px;
    font-family: var(--font); font-size: 11px; font-weight: 600; direction: ltr;
    background: var(--surface-3); color: var(--text-2); border: 1px solid var(--border-strong); border-bottom-width: 2px;
}

.alert {
    display: flex; gap: var(--s-3); align-items: flex-start;
    padding: var(--s-3) var(--s-4); border-radius: var(--r-md);
    font-size: var(--text-sm); border: 1px solid transparent;
}
.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 2px; }
.alert-info    { background: var(--accent-soft);  color: var(--text); border-color: var(--accent-ring); } .alert-info svg { color: var(--accent); }
.alert-warning { background: var(--warning-soft); color: var(--text); } .alert-warning svg { color: var(--warning); }
.alert-danger  { background: var(--danger-soft);  color: var(--text); } .alert-danger svg { color: var(--danger); }
.alert-success { background: var(--success-soft); color: var(--text); } .alert-success svg { color: var(--success); }

.list-row {
    display: flex; align-items: center; gap: var(--s-3);
    padding: var(--s-3) var(--s-4);
    border-bottom: 1px solid var(--border);
    transition: background var(--dur-1);
}
.list-row:last-child { border-bottom: 0; }
.list-row.is-link { cursor: pointer; }
.list-row.is-link:hover { background: var(--surface-2); }
.list-row .list-main { flex: 1; min-width: 0; }
.list-row .list-title { font-weight: 600; font-size: var(--text-md); }
.list-row .list-sub { font-size: var(--text-sm); color: var(--text-2); }

.dp {
    position: fixed; z-index: calc(var(--z-modal) + 5);
    width: 296px; padding: var(--s-3);
    background: var(--bg-elev); border: 1px solid var(--border-strong); border-radius: var(--r-lg);
    box-shadow: var(--shadow-3);
    animation: pop-in var(--dur-1) var(--ease) both;
    user-select: none;
}
.dp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s-2); }
.dp-head .dp-title { font-weight: 700; font-size: var(--text-sm); display: flex; gap: 6px; }
.dp-head .dp-title button { padding: 2px 8px; border-radius: var(--r-sm); font-weight: 700; color: var(--text); }
.dp-head .dp-title button:hover { background: var(--surface-2); }
.dp-nav { width: 30px; height: 30px; border-radius: var(--r-sm); display: grid; place-items: center; color: var(--text-2); }
.dp-nav:hover { background: var(--surface-2); color: var(--text); }
.dp-nav svg { width: 16px; height: 16px; }
.dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.dp-grid .dp-wd { font-size: 11px; color: var(--text-3); text-align: center; padding: 4px 0; font-weight: 600; }
.dp-day {
    height: 34px; border-radius: var(--r-sm); font-size: var(--text-sm); font-variant-numeric: tabular-nums;
    display: grid; place-items: center; color: var(--text); transition: background var(--dur-1), color var(--dur-1);
}
.dp-day:hover { background: var(--surface-2); }
.dp-day.is-muted { color: var(--text-3); }
.dp-day.is-today { box-shadow: inset 0 0 0 1px var(--border-strong); font-weight: 700; }
.dp-day.is-selected { background: var(--accent); color: var(--text-on-accent); font-weight: 700; }
.dp-day.is-disabled { opacity: .3; pointer-events: none; }
.dp-day:focus-visible { box-shadow: 0 0 0 2px var(--accent-ring); outline: none; }
.dp-months, .dp-years { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.dp-months button, .dp-years button { height: 40px; border-radius: var(--r-sm); font-size: var(--text-sm); }
.dp-months button:hover, .dp-years button:hover { background: var(--surface-2); }
.dp-months button.is-selected, .dp-years button.is-selected { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.dp-foot { display: flex; justify-content: space-between; margin-top: var(--s-2); padding-top: var(--s-2); border-top: 1px solid var(--border); }
.dp-foot button { font-size: var(--text-sm); color: var(--accent); padding: 4px 8px; border-radius: var(--r-sm); }
.dp-foot button:hover { background: var(--accent-soft); }

.chips { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.chip {
    display: inline-flex; align-items: center; gap: 6px;
    height: 30px; padding: 0 6px 0 10px; border-radius: var(--r-full);
    background: var(--surface-2); border: 1px solid var(--border); font-size: var(--text-sm);
}
.chip button { width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; color: var(--text-3); }
.chip button:hover { background: var(--danger-soft); color: var(--danger); }
.chip button svg { width: 12px; height: 12px; }
.segmented { display: inline-flex; gap: 2px; padding: 3px; border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--border); }
.segmented-option {
    height: 32px; padding: 0 12px; border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    font-size: 12.5px; font-weight: 700; color: var(--text-3);
    transition: background var(--dur-1), color var(--dur-1), box-shadow var(--dur-1);
}
.segmented-option:hover:not(.is-on) { color: var(--text); }
.segmented-option.is-on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }
.segmented-count { min-width: 20px; height: 18px; padding: 0 6px; border-radius: 999px; display: grid; place-items: center; font-size: 11px; background: var(--surface-3); color: var(--text-2); font-variant-numeric: tabular-nums; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-4); margin-bottom: var(--s-6); flex-wrap: wrap; }
.page-head .page-sub { color: var(--text-2); font-size: var(--text-sm); margin-top: 4px; }
.page-head .page-actions { display: flex; gap: var(--s-2); align-items: center; }
@media (max-width: 640px) { .page-head { flex-direction: column; } .page-head .page-actions { width: 100%; } }
.breadcrumb { display: flex; align-items: center; gap: var(--s-1); font-size: var(--text-sm); color: var(--text-3); margin-bottom: var(--s-2); }
.breadcrumb a { color: var(--text-2); }
.breadcrumb svg { width: 14px; height: 14px; }

.duration-chips { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.duration-chip {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 52px;
    border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2);
    transition: background var(--dur-1), border-color var(--dur-1), color var(--dur-1), box-shadow var(--dur-1);
}
.duration-chip strong { font-size: 18px; font-weight: 800; color: var(--text); line-height: 1; }
.duration-chip span { font-size: 11px; font-weight: 600; }
.duration-chip > span { display: inline-flex; align-items: center; gap: 4px; }
.duration-chip svg { width: 14px; height: 14px; }
.duration-chip:hover { border-color: var(--text-3); color: var(--text); }
.duration-chip:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-ring); }
.duration-chip.is-on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.duration-chip.is-on strong { color: var(--accent); }
.duration-custom {
    display: flex; align-items: center; gap: var(--s-3); width: 100%; margin-top: 6px;
    padding: 10px 12px; border-radius: var(--r-md); text-align: start;
    background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2);
    transition: background var(--dur-1), border-color var(--dur-1), color var(--dur-1), box-shadow var(--dur-1);
}
.duration-custom:hover { border-color: var(--text-3); color: var(--text); }
.duration-custom:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-ring); }
.duration-custom-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--border); color: var(--text-3); flex-shrink: 0; }
.duration-custom-icon svg { width: 16px; height: 16px; }
.duration-custom-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.duration-custom-text strong { font-size: var(--text-sm); font-weight: 700; color: var(--text); }
.duration-custom-text span { font-size: 11px; color: var(--text-3); }
.duration-custom-check { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; border: 1.5px solid var(--border-strong); color: transparent; flex-shrink: 0; transition: background var(--dur-1), border-color var(--dur-1), color var(--dur-1); }
.duration-custom-check svg { width: 13px; height: 13px; }
.duration-custom.is-on { background: var(--accent-soft); border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.duration-custom.is-on .duration-custom-icon { background: var(--accent); border-color: var(--accent); color: #fff; }
.duration-custom.is-on .duration-custom-text strong { color: var(--accent); }
.duration-custom.is-on .duration-custom-check { background: var(--accent); border-color: var(--accent); color: #fff; }
.field.is-computed .input { background: var(--surface-2); color: var(--text-2); cursor: default; }
.duration-summary { display: flex; align-items: center; gap: 6px; padding: 10px 12px; border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--border); font-size: var(--text-sm); color: var(--text-2); }
.duration-summary svg { width: 15px; height: 15px; color: var(--accent); flex-shrink: 0; }
.notify-option { display: flex; align-items: center; gap: var(--s-3); padding: 12px 14px; border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface); cursor: pointer; transition: border-color var(--dur-1), background var(--dur-1); }
.notify-option:hover { border-color: var(--border-strong); }
.notify-option:has(input:checked) { border-color: color-mix(in srgb, var(--accent) 45%, transparent); background: color-mix(in srgb, var(--accent) 5%, var(--surface)); }
.notify-option.is-disabled { cursor: not-allowed; opacity: .7; }
.notify-option-icon { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; flex-shrink: 0; background: var(--accent-soft); color: var(--accent); }
.notify-option-icon svg { width: 18px; height: 18px; }
.notify-option-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.notify-option-text strong { font-size: var(--text-sm); font-weight: 800; }
.notify-option-text > span { font-size: 12px; color: var(--text-3); }
.notify-option-text bdi { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--text-2); }
.notify-option .switch { flex-shrink: 0; }
.duration-summary strong { color: var(--text); }
@media (max-width: 640px) {
    .duration-chips { gap: 4px; }
    .duration-chip { min-height: 48px; }
    .duration-chip strong { font-size: 16px; }
}

.list-chevron { display: grid; place-items: center; color: var(--text-3); flex-shrink: 0; }
.list-chevron svg { width: 16px; height: 16px; }

.body-icon { width: auto; height: 100%; max-width: 100%; display: block; overflow: hidden; }
.body-icon .b { fill: var(--body-fill); }
.body-icon .m { fill: var(--muscle); }
.body-icon .g { fill: none; stroke: var(--body-gap); stroke-width: .7; stroke-linecap: round; }

.ex-thumb { position: relative; display: grid; place-items: center; flex-shrink: 0; overflow: hidden; background: #fff; color: var(--text-3); isolation: isolate; }
.ex-thumb img { width: 100%; height: 100%; object-fit: contain; opacity: 0; transition: opacity 180ms ease; -webkit-user-drag: none; user-select: none; }
.ex-thumb.is-loaded img { opacity: 1; }
.ex-thumb.is-empty { background: var(--surface-3); }
.ex-thumb:not(.is-loaded):not(.is-empty)::before { content: ''; position: absolute; inset: 0; z-index: -1; background: linear-gradient(90deg, transparent 20%, var(--skeleton-b) 50%, transparent 80%) var(--skeleton-a); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
.ex-thumb-fallback { display: grid; place-items: center; width: 100%; height: 100%; }
.ex-thumb-fallback svg { width: 44%; height: 44%; max-width: 22px; max-height: 22px; }

.ex-viewer { max-width: 440px; position: relative; overflow: hidden; }
.ex-viewer .modal-header { position: absolute; top: 10px; inset-inline-end: 10px; z-index: 3; padding: 0; }
.ex-viewer .modal-header h2 { display: none; }
.ex-viewer .modal-header .btn { width: 34px; height: 34px; border-radius: 50%; background: rgba(10, 12, 17, .55); color: #fff; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.ex-viewer .modal-header .btn:hover { background: rgba(10, 12, 17, .75); }
.ex-viewer .modal-body { padding: 0; }
.ex-viewer .modal-footer { padding: 0 var(--s-5) var(--s-5); }
.ex-viewer-stage { position: relative; aspect-ratio: 1; background: #fff; display: grid; place-items: center; overflow: hidden; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.ex-viewer-stage > img, .ex-viewer-video { width: 100%; height: 100%; object-fit: contain; display: block; -webkit-user-drag: none; }
.ex-viewer-video::-webkit-media-controls, .ex-viewer-video::-webkit-media-controls-enclosure { display: none !important; }
.ex-viewer-stage.is-empty { background: var(--surface-2); }
.ex-viewer-empty { display: flex; flex-direction: column; align-items: center; gap: var(--s-3); color: var(--text-3); font-size: var(--text-sm); }
.ex-viewer-empty svg { width: 44px; height: 44px; }
.ex-viewer-state { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s-2); color: #55606e; font-size: var(--text-sm); pointer-events: none; }
.ex-viewer-state[hidden] { display: none; }
.ex-viewer-state.is-error { background: rgba(255, 255, 255, .86); color: #3b4250; font-weight: 600; }
.ex-viewer-state svg { width: 26px; height: 26px; }
.ex-viewer-state .spinner { width: 30px; height: 30px; border-radius: 50%; border: 3px solid rgba(20, 24, 32, .12); border-top-color: var(--accent); animation: spin .8s linear infinite; }
.ex-viewer-toggle { position: absolute; inset-inline-start: 10px; bottom: 10px; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: rgba(10, 12, 17, .55); color: #fff; opacity: 0; transition: opacity var(--dur-2); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.ex-viewer-toggle svg { width: 14px; height: 14px; }
.ex-viewer-stage:hover .ex-viewer-toggle, .ex-viewer-stage.is-paused .ex-viewer-toggle, .ex-viewer-toggle:focus-visible { opacity: 1; }
.ex-viewer-info { padding: var(--s-4) var(--s-5) var(--s-4); display: flex; flex-direction: column; gap: 6px; }
.ex-viewer-name { font-size: var(--text-md); font-weight: 800; line-height: 1.6; }
.ex-viewer-en { font-size: 12px; color: var(--text-3); text-align: right; }
.ex-viewer-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
@media (hover: none) { .ex-viewer-toggle { opacity: .9; } }
@media (max-width: 560px) { .ex-viewer { max-width: none; } .ex-viewer-stage { aspect-ratio: auto; height: min(100vw, 56dvh); } }
.lazy-sentinel { grid-column: 1 / -1; height: 1px; flex-shrink: 0; }

@media (max-width: 560px) {
    .modal-backdrop.ex-viewer-backdrop { align-items: center; padding: 16px; }
    .ex-viewer { border-radius: var(--r-xl); max-height: calc(100dvh - 32px); animation: pop-in var(--dur-3) var(--ease-spring) both; }
    .ex-viewer-stage { height: min(calc(100vw - 32px), 52dvh); }
    .ex-viewer .modal-footer { padding: 0 var(--s-4) var(--s-4); }
}
