/* Shaco Life Extended — components (owner: fe-core)
   Kullanım örnekleri için: #/dev/ui */

/* ───────── Buttons ───────── */
.btn {
    --btn-bg: var(--surface-3);
    --btn-fg: var(--text);
    --btn-border: transparent;
    --btn-hover: color-mix(in srgb, var(--btn-bg) 85%, var(--text) 15%);
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    height: var(--h-md);
    padding: 0 14px;
    border-radius: var(--r-sm);
    border: 1px solid var(--btn-border);
    background: var(--btn-bg);
    color: var(--btn-fg);
    font-size: var(--fs-sm);
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
    text-decoration: none;
    transition: background-color var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease), color var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease), transform var(--dur-1) var(--ease);
    -webkit-user-select: none;
    user-select: none;
}
.btn:hover { background: var(--btn-hover); }
.btn:active:not(:disabled) { transform: translateY(.5px) scale(.985); }
.btn:focus-visible { box-shadow: var(--focus-ring); border-radius: var(--r-sm); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; pointer-events: none; }
.btn .i { width: 16px; height: 16px; }

.btn-primary {
    --btn-bg: var(--accent);
    --btn-fg: var(--accent-fg);
    --btn-hover: var(--accent-hover);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22), 0 1px 2px rgba(0, 0, 0, .2);
    font-weight: 600;
}
.btn-secondary {
    --btn-bg: var(--surface-2);
    --btn-border: var(--border-strong);
    --btn-hover: var(--surface-3);
    box-shadow: var(--shadow-inset);
}
:root[data-theme="light"] .btn-secondary { --btn-bg: var(--surface); --btn-hover: var(--surface-2); box-shadow: var(--shadow-sm); }
.btn-ghost {
    --btn-bg: transparent;
    --btn-fg: var(--text-2);
    --btn-hover: var(--hover);
}
.btn-ghost:hover { color: var(--text); background: var(--active); }
.btn-danger {
    --btn-bg: color-mix(in srgb, var(--danger) 13%, transparent);
    --btn-fg: var(--danger);
    --btn-border: color-mix(in srgb, var(--danger) 24%, transparent);
    --btn-hover: color-mix(in srgb, var(--danger) 20%, transparent);
}
.btn-danger-solid {
    --btn-bg: var(--danger);
    --btn-fg: #fff;
    --btn-hover: color-mix(in srgb, var(--danger) 88%, #000);
}
:root[data-theme="dark"] .btn-danger-solid { --btn-fg: #1a0505; }
.btn-discord {
    --btn-bg: var(--discord);
    --btn-fg: #fff;
    --btn-hover: #4752c4;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18);
}

.btn-sm { height: var(--h-sm); padding: 0 10px; font-size: var(--fs-xs); gap: 6px; border-radius: 7px; }
.btn-sm .i { width: 14px; height: 14px; }
.btn-lg { height: var(--h-lg); padding: 0 18px; font-size: var(--fs-md); border-radius: 10px; }
.btn-lg .i { width: 18px; height: 18px; }
.btn-xs { height: var(--h-xs); padding: 0 8px; font-size: var(--fs-2xs); gap: 4px; border-radius: 6px; }
.btn-xs .i { width: 13px; height: 13px; }
.btn-block { display: flex; width: 100%; }

.btn-icon { width: var(--h-md); padding: 0; }
.btn-icon.btn-sm { width: var(--h-sm); }
.btn-icon.btn-lg { width: var(--h-lg); }
.btn-icon.btn-xs { width: var(--h-xs); }
.btn-icon .i { width: 18px; height: 18px; }
.btn-icon.btn-sm .i { width: 16px; height: 16px; }

.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading > * { visibility: hidden; }
.btn.is-loading::after {
    content: '';
    position: absolute;
    left: 50%; top: 50%;
    width: 16px; height: 16px;
    margin: -8px 0 0 -8px;
    border-radius: 50%;
    border: 2px solid var(--btn-fg);
    border-right-color: transparent;
    animation: spin .7s linear infinite;
    opacity: .9;
}
.btn-group { display: inline-flex; gap: var(--s-2); flex-wrap: wrap; align-items: center; }

/* ───────── Fields & inputs ───────── */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field + .field { margin-top: var(--s-4); }
.field-label {
    font-size: var(--fs-sm);
    font-weight: 500;
    color: var(--text-2);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-2);
}
.field-label .count { font-family: var(--font-mono); font-size: var(--fs-2xs); color: var(--text-3); font-weight: 400; }
.field-hint { font-size: var(--fs-xs); color: var(--text-3); }
.field-error { font-size: var(--fs-xs); color: var(--danger); display: flex; align-items: center; gap: 6px; }
.field-error:empty { display: none; }
.field-error .i { width: 14px; height: 14px; }

.input {
    width: 100%;
    height: var(--h-md);
    padding: 0 12px;
    border-radius: var(--r-sm);
    border: 1px solid var(--border-strong);
    background: var(--input-bg);
    color: var(--text);
    font-size: var(--fs-md);
    transition: border-color var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease), background-color var(--dur-1) var(--ease);
    -webkit-appearance: none;
    appearance: none;
}
.input::placeholder { color: var(--text-3); }
.input:hover { border-color: color-mix(in srgb, var(--text) 20%, transparent); }
.input:focus, .input:focus-visible {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
    border-radius: var(--r-sm);
}
.input:disabled { opacity: .55; cursor: not-allowed; }
.input.is-invalid, .field.is-invalid .input { border-color: var(--danger); }
.input.is-invalid:focus, .field.is-invalid .input:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 18%, transparent); }
.input-lg { height: var(--h-lg); font-size: var(--fs-md); padding: 0 14px; border-radius: 10px; }
.input-sm { height: var(--h-sm); font-size: var(--fs-sm); padding: 0 10px; }
textarea.input {
    height: auto;
    min-height: 92px;
    padding: 10px 12px;
    line-height: 1.5;
    resize: vertical;
}
select.input {
    padding-right: 34px;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238a8a94' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}
select.input option { background: var(--surface-overlay); color: var(--text); }

.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap > .input { flex: 1; }
.input-wrap > .input-icon {
    position: absolute;
    left: 11px;
    color: var(--text-3);
    pointer-events: none;
    width: 16px; height: 16px;
}
.input-wrap > .input-icon + .input { padding-left: 34px; }
.input-wrap > .input-suffix {
    position: absolute;
    right: 4px;
    display: flex;
    align-items: center;
    gap: 2px;
}
.input-wrap.has-suffix > .input { padding-right: 40px; }

/* Checkbox / radio / switch: <label class="check"><input type="checkbox"><span class="check-box">…</span> Metin</label> */
.check, .radio, .switch {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: var(--fs-sm);
    color: var(--text);
    -webkit-user-select: none;
    user-select: none;
    position: relative;
    min-height: 20px;
}
.check > input, .radio > input, .switch > input {
    position: absolute;
    opacity: 0;
    width: 1px; height: 1px;
    margin: 0;
    pointer-events: none;
}
.check-box, .radio-dot {
    width: 16px; height: 16px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    border: 1px solid var(--border-strong);
    background: var(--input-bg);
    border-radius: 5px;
    color: var(--accent-fg);
    transition: background-color var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease);
}
.check-box .i { width: 12px; height: 12px; stroke-width: 3; opacity: 0; transform: scale(.6); transition: opacity var(--dur-1) var(--ease), transform var(--dur-2) var(--ease); }
.check > input:checked + .check-box { background: var(--accent); border-color: var(--accent); }
.check > input:checked + .check-box .i { opacity: 1; transform: none; }
.check:hover .check-box, .radio:hover .radio-dot { border-color: color-mix(in srgb, var(--text) 30%, transparent); }
.check > input:focus-visible + .check-box,
.radio > input:focus-visible + .radio-dot,
.switch > input:focus-visible + .switch-track { box-shadow: var(--focus-ring); }
.check > input:disabled + .check-box, .switch > input:disabled + .switch-track { opacity: .45; }
.radio-dot { border-radius: 50%; }
.radio-dot::after { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--accent-fg); transform: scale(0); transition: transform var(--dur-2) var(--ease); }
.radio > input:checked + .radio-dot { background: var(--accent); border-color: var(--accent); }
.radio > input:checked + .radio-dot::after { transform: scale(1); }

.switch-track {
    width: 34px; height: 20px;
    flex-shrink: 0;
    border-radius: 999px;
    background: var(--surface-3);
    border: 1px solid var(--border-strong);
    position: relative;
    transition: background-color var(--dur-2) var(--ease), border-color var(--dur-2) var(--ease);
}
.switch-track::after {
    content: '';
    position: absolute;
    top: 2px; left: 2px;
    width: 14px; height: 14px;
    border-radius: 50%;
    background: var(--text-2);
    box-shadow: 0 1px 2px rgba(0, 0, 0, .3);
    transition: transform var(--dur-2) var(--ease), background-color var(--dur-2) var(--ease);
}
:root[data-theme="light"] .switch-track::after { background: #fff; }
.switch > input:checked + .switch-track { background: var(--accent); border-color: var(--accent); }
.switch > input:checked + .switch-track::after { transform: translateX(14px); background: var(--accent-fg); }
:root[data-theme="light"] .switch > input:checked + .switch-track::after { background: #fff; }

/* Segmented control */
.segmented {
    display: inline-flex;
    padding: 3px;
    gap: 2px;
    border-radius: 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
}
.segmented > button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: calc(var(--h-md) - 8px);
    padding: 0 12px;
    border-radius: 7px;
    font-size: var(--fs-sm);
    font-weight: 500;
    color: var(--text-2);
    transition: background-color var(--dur-1) var(--ease), color var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease);
}
.segmented > button .i { width: 15px; height: 15px; }
.segmented > button:hover { color: var(--text); }
.segmented > button[aria-pressed="true"], .segmented > button.is-active {
    background: var(--surface-3);
    color: var(--text);
    box-shadow: var(--shadow-sm), var(--shadow-inset);
}
:root[data-theme="light"] .segmented > button[aria-pressed="true"],
:root[data-theme="light"] .segmented > button.is-active { background: var(--surface); }
.segmented-block { display: flex; }
.segmented-block > button { flex: 1; }

/* Range */
.range {
    --val: 50%;
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 20px;
    background: transparent;
    cursor: pointer;
}
.range::-webkit-slider-runnable-track {
    height: 4px;
    border-radius: 999px;
    background: linear-gradient(to right, var(--accent) var(--val), var(--surface-3) var(--val));
}
.range::-moz-range-track { height: 4px; border-radius: 999px; background: var(--surface-3); }
.range::-moz-range-progress { height: 4px; border-radius: 999px; background: var(--accent); }
.range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px; height: 16px;
    margin-top: -6px;
    border-radius: 50%;
    background: #fff;
    border: 0;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, .1), 0 1px 3px rgba(0, 0, 0, .35);
    transition: transform var(--dur-1) var(--ease);
}
.range::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 0; box-shadow: 0 1px 3px rgba(0, 0, 0, .35); }
.range:hover::-webkit-slider-thumb { transform: scale(1.1); }
.range:focus-visible { box-shadow: none; }
.range:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px var(--accent-ring); }

/* ───────── Cards ───────── */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-inset);
    min-width: 0;
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-3);
    padding: 14px 16px 0;
    min-height: 48px;
}
.card-header.has-border { border-bottom: 1px solid var(--border); padding-bottom: 14px; }
.card-title {
    font-size: var(--fs-md);
    font-weight: 600;
    letter-spacing: var(--tracking-tight);
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}
.card-title .i { width: 16px; height: 16px; color: var(--text-3); }
.card-subtitle { font-size: var(--fs-xs); color: var(--text-3); margin-top: 2px; }
.card-body { padding: 14px 16px 16px; }
.card-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--s-2);
    padding: 12px 16px;
    border-top: 1px solid var(--border);
}
.card-link {
    font-size: var(--fs-xs);
    color: var(--text-3);
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-weight: 500;
    border-radius: 6px;
    padding: 2px 4px;
    margin-right: -4px;
    transition: color var(--dur-1) var(--ease);
}
.card-link:hover { color: var(--text); }
.card-link .i { width: 14px; height: 14px; }
.card-interactive { transition: border-color var(--dur-2) var(--ease), background-color var(--dur-2) var(--ease), transform var(--dur-2) var(--ease); cursor: pointer; }
.card-interactive:hover { border-color: var(--border-strong); background: color-mix(in srgb, var(--card-solid) 70%, var(--surface-2)); }

/* ───────── Rows ───────── */
.list { display: flex; flex-direction: column; }
.row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 10px;
    border-radius: 10px;
    min-width: 0;
    text-align: left;
    width: 100%;
    color: inherit;
    transition: background-color var(--dur-1) var(--ease);
}
a.row:hover, button.row:hover, .row.is-interactive:hover { background: var(--hover); }
a.row:active, button.row:active { background: var(--active); }
.row-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.row-title { font-size: var(--fs-md); font-weight: 500; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-meta { font-size: var(--fs-xs); color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.row-trail { font-size: var(--fs-xs); color: var(--text-3); flex-shrink: 0; font-variant-numeric: tabular-nums; }
.list-divided > .row + .row { border-top: 1px solid var(--border); border-radius: 0; }

/* ───────── Avatar ───────── */
.avatar {
    --size: 36px;
    --hue: 220;
    position: relative;
    display: inline-grid;
    place-items: center;
    width: var(--size);
    height: var(--size);
    flex-shrink: 0;
    border-radius: 50%;
    background: hsl(var(--hue) 28% 20%);
    color: hsl(var(--hue) 65% 80%);
    font-size: calc(var(--size) * .4);
    font-weight: 600;
    line-height: 1;
    letter-spacing: 0;
    -webkit-user-select: none;
    user-select: none;
    vertical-align: middle;
}
:root[data-theme="light"] .avatar { background: hsl(var(--hue) 55% 90%); color: hsl(var(--hue) 45% 34%); }
.avatar::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08);
    pointer-events: none;
    z-index: 1;
}
:root[data-theme="light"] .avatar::before { box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .06); }
.avatar > img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border-radius: inherit;
    object-fit: cover;
    background: var(--surface-2);
}
.avatar-dot {
    position: absolute;
    right: -1px;
    bottom: -1px;
    width: max(8px, calc(var(--size) * .28));
    height: max(8px, calc(var(--size) * .28));
    border-radius: 50%;
    background: var(--text-3);
    border: 2px solid var(--avatar-ring, var(--panel-solid));
    z-index: 2;
}
.avatar-dot.is-online { background: var(--success); }
.avatar-20 { --size: 20px; font-size: 9px; }
.avatar-28 { --size: 28px; font-size: 11px; }
.avatar-36 { --size: 36px; }
.avatar-48 { --size: 48px; }
.avatar-72 { --size: 72px; }
.avatar-112 { --size: 112px; }
.avatar-20 .avatar-dot, .avatar-28 .avatar-dot { border-width: 1.5px; }
.avatar-stack { display: inline-flex; }
.avatar-stack > .avatar { box-shadow: 0 0 0 2px var(--avatar-ring, var(--panel-solid)); }
.avatar-stack > .avatar + .avatar { margin-left: -6px; }

/* ───────── Badges / chips / tags ───────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 20px;
    padding: 0 7px;
    border-radius: var(--r-full);
    background: var(--surface-3);
    color: var(--text-2);
    font-size: var(--fs-2xs);
    font-weight: 600;
    line-height: 1;
    letter-spacing: .01em;
    white-space: nowrap;
    vertical-align: middle;
}
.badge .i { width: 12px; height: 12px; }
.badge-accent { background: var(--accent-soft); color: var(--accent); }
.badge-solid { background: var(--accent); color: var(--accent-fg); }
.badge-success { background: color-mix(in srgb, var(--success) 14%, transparent); color: var(--success); }
.badge-warning { background: color-mix(in srgb, var(--warning) 14%, transparent); color: var(--warning); }
.badge-danger { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.badge-info { background: color-mix(in srgb, var(--info) 14%, transparent); color: var(--info); }
.badge-outline { background: transparent; box-shadow: inset 0 0 0 1px var(--border-strong); }
.badge-dot::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.count {
    display: inline-grid;
    place-items: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: var(--r-full);
    background: var(--accent);
    color: var(--accent-fg);
    font-family: var(--font-mono);
    font-size: 10.5px;
    font-weight: 600;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}
.count:empty, .count[data-n="0"] { display: none; }
.count-muted { background: var(--surface-3); color: var(--text-2); }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: var(--h-sm);
    padding: 0 11px;
    border-radius: var(--r-full);
    border: 1px solid var(--border-strong);
    background: transparent;
    color: var(--text-2);
    font-size: var(--fs-xs);
    font-weight: 500;
    white-space: nowrap;
    transition: background-color var(--dur-1) var(--ease), color var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease);
}
.chip .i { width: 14px; height: 14px; }
button.chip:hover, a.chip:hover { background: var(--hover); color: var(--text); }
.chip.is-active, .chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 22px;
    padding: 0 8px;
    border-radius: var(--r-xs);
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-2);
    font-size: var(--fs-xs);
    font-weight: 500;
    white-space: nowrap;
}

/* ───────── Tabs ───────── */
.tabs {
    display: flex;
    gap: 22px;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 40px;
    padding: 0 1px;
    color: var(--text-3);
    font-size: var(--fs-sm);
    font-weight: 500;
    white-space: nowrap;
    transition: color var(--dur-1) var(--ease);
}
.tab .i { width: 16px; height: 16px; }
.tab:hover { color: var(--text-2); }
.tab.is-active, .tab[aria-selected="true"] { color: var(--text); }
.tab.is-active::after, .tab[aria-selected="true"]::after {
    content: '';
    position: absolute;
    left: 0; right: 0; bottom: -1px;
    height: 2px;
    border-radius: 2px 2px 0 0;
    background: var(--accent);
}
.tab .count { margin-left: 2px; }

.pill-tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.pill-tabs::-webkit-scrollbar { display: none; }
.pill-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: var(--h-sm);
    padding: 0 12px;
    border-radius: var(--r-full);
    color: var(--text-2);
    font-size: var(--fs-sm);
    font-weight: 500;
    white-space: nowrap;
    transition: background-color var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
.pill-tab .i { width: 15px; height: 15px; }
.pill-tab:hover { color: var(--text); background: var(--hover); }
.pill-tab.is-active, .pill-tab[aria-selected="true"] { background: var(--active); color: var(--text); box-shadow: inset 0 0 0 1px var(--border); }

/* ───────── Tooltip (pure CSS) ───────── */
[data-tip] { position: relative; }
[data-tip]::after {
    content: attr(data-tip);
    position: absolute;
    left: 50%;
    bottom: calc(100% + 8px);
    transform: translate(-50%, 3px);
    padding: 5px 8px;
    border-radius: 6px;
    background: var(--tooltip-bg);
    color: var(--tooltip-fg);
    font-size: var(--fs-xs);
    font-weight: 500;
    line-height: 1.3;
    letter-spacing: 0;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    z-index: 50;
    box-shadow: var(--shadow-md);
    transition: opacity var(--dur-1) var(--ease), transform var(--dur-1) var(--ease);
}
[data-tip]:hover::after, [data-tip]:focus-visible::after {
    opacity: 1;
    transform: translate(-50%, 0);
    transition-delay: 350ms;
}
[data-tip-pos="bottom"]::after { bottom: auto; top: calc(100% + 8px); transform: translate(-50%, -3px); }
[data-tip-pos="right"]::after { left: calc(100% + 10px); bottom: auto; top: 50%; transform: translate(-3px, -50%); }
[data-tip-pos="right"]:hover::after, [data-tip-pos="right"]:focus-visible::after { transform: translate(0, -50%); }
[data-tip-pos="left"]::after { left: auto; right: calc(100% + 10px); bottom: auto; top: 50%; transform: translate(3px, -50%); }
[data-tip-pos="left"]:hover::after { transform: translate(0, -50%); }
[data-tip=""]::after { display: none; }
@media (hover: none) { [data-tip]::after { display: none; } }

/* ───────── Skeleton ───────── */
.skel {
    display: block;
    height: 12px;
    border-radius: 6px;
    background: linear-gradient(90deg, var(--skeleton-a) 0%, var(--skeleton-b) 45%, var(--skeleton-a) 90%);
    background-size: 220% 100%;
    animation: shimmer 1.6s var(--ease-in-out) infinite;
}
.skel-circle { border-radius: 50%; flex-shrink: 0; }
.skel-lines { display: flex; flex-direction: column; gap: 10px; padding: 4px 0; }
.skel-row { display: flex; align-items: center; gap: 12px; padding: 10px; }
.skel-row .skel-lines { flex: 1; gap: 8px; }
.skel-card { height: 132px; border-radius: var(--r-lg); }
.skel-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--s-4); }

/* ───────── Empty state ───────── */
.empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 48px 24px;
}
.empty-icon {
    width: 52px; height: 52px;
    border-radius: 15px;
    display: grid;
    place-items: center;
    color: var(--text-2);
    background: linear-gradient(180deg, var(--surface-3), var(--surface-2));
    border: 1px solid var(--border-strong);
    box-shadow: var(--shadow-md), var(--shadow-inset);
    margin-bottom: 18px;
}
.empty-icon .i { width: 22px; height: 22px; }
.empty-title { font-size: var(--fs-lg); font-weight: 600; letter-spacing: var(--tracking-tight); }
.empty-text { font-size: var(--fs-sm); color: var(--text-3); max-width: 380px; margin-top: 6px; line-height: 1.55; }
.empty-action { margin-top: 20px; display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.empty-sm { padding: 28px 16px; }
.empty-sm .empty-icon { width: 40px; height: 40px; border-radius: 12px; margin-bottom: 12px; }
.empty-sm .empty-icon .i { width: 18px; height: 18px; }
.empty-sm .empty-title { font-size: var(--fs-md); }

/* Error state */
.error-state .empty-icon { color: var(--danger); }

/* ───────── Spinner / progress ───────── */
.spinner {
    display: inline-block;
    width: 16px; height: 16px;
    border-radius: 50%;
    border: 2px solid currentColor;
    border-right-color: transparent;
    animation: spin .7s linear infinite;
    opacity: .7;
    vertical-align: middle;
    flex-shrink: 0;
}
.spinner-lg { width: 24px; height: 24px; }
.i-spin { animation: spin .8s linear infinite; }
:root[data-motion="reduce"] .spinner, :root[data-motion="reduce"] .i-spin, :root[data-motion="reduce"] .btn.is-loading::after {
    animation-duration: .8s !important;
    animation-iteration-count: infinite !important;
}
@media (prefers-reduced-motion: reduce) {
    .spinner, .i-spin, .btn.is-loading::after { animation-duration: .8s !important; animation-iteration-count: infinite !important; }
}
.loading-block { display: grid; place-items: center; padding: 48px; color: var(--text-3); }

.progress {
    --val: 0%;
    position: relative;
    height: 6px;
    border-radius: var(--r-full);
    background: var(--surface-3);
    overflow: hidden;
}
.progress-bar {
    height: 100%;
    width: var(--val);
    border-radius: inherit;
    background: var(--accent);
    transition: width var(--dur-3) var(--ease);
}
.progress.is-indeterminate .progress-bar { width: 35%; animation: progress-slide 1.2s var(--ease-in-out) infinite; }
@keyframes progress-slide { from { transform: translateX(-100%); } to { transform: translateX(300%); } }

/* ───────── Kbd / divider ───────── */
.kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 5px;
    border: 1px solid var(--border-strong);
    border-bottom-width: 2px;
    background: var(--surface-2);
    color: var(--text-2);
    font-family: var(--font-mono);
    font-size: 10.5px;
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
}
.kbd-group { display: inline-flex; gap: 3px; align-items: center; }
.divider { height: 1px; background: var(--border); margin: var(--s-4) 0; border: 0; }
.divider-v { width: 1px; align-self: stretch; background: var(--border); }
.divider-label {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-3);
    font-size: var(--fs-xs);
    margin: var(--s-4) 0;
}
.divider-label::before, .divider-label::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ───────── Toasts ───────── */
.toast-root {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    pointer-events: none;
    max-width: calc(100vw - 32px);
}
.toast {
    pointer-events: auto;
    width: 360px;
    max-width: 100%;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: start;
    gap: 10px;
    padding: 12px 10px 12px 14px;
    border-radius: 12px;
    background: var(--surface-overlay);
    border: 1px solid var(--border-strong);
    box-shadow: var(--shadow-lg);
    animation: toast-in var(--dur-3) var(--ease) both;
    transform-origin: bottom right;
}
.toast.is-leaving { animation: toast-out var(--dur-2) var(--ease) both; }
.toast-icon { width: 18px; height: 18px; margin-top: 1px; color: var(--info); }
.toast-success .toast-icon { color: var(--success); }
.toast-error .toast-icon { color: var(--danger); }
.toast-warning .toast-icon { color: var(--warning); }
.toast-body { min-width: 0; padding-top: 1px; }
.toast-title { font-size: var(--fs-sm); font-weight: 600; color: var(--text); line-height: 1.35; }
.toast-msg { font-size: var(--fs-sm); color: var(--text-2); line-height: 1.45; margin-top: 1px; overflow-wrap: anywhere; }
.toast-title + .toast-msg { margin-top: 2px; }
.toast-actions { display: flex; gap: 6px; margin-top: 10px; }
.toast-close { margin: -4px -2px 0 0; color: var(--text-3); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(16px); } }

/* ───────── Overlay base (modal / drawer / sheet) ───────── */
.overlay {
    position: fixed;
    inset: 0;
    z-index: var(--z-overlay);
    display: flex;
}
.overlay-backdrop {
    position: absolute;
    inset: 0;
    background: var(--scrim);
    animation: fade-in var(--dur-2) var(--ease) both;
}
.overlay.is-leaving .overlay-backdrop { animation: fade-out var(--dur-2) var(--ease) both; }

/* Modal */
.overlay-modal { align-items: center; justify-content: center; padding: 24px; }
.modal {
    --modal-w: 460px;
    position: relative;
    width: min(100%, var(--modal-w));
    max-height: min(86vh, 900px);
    display: flex;
    flex-direction: column;
    background: var(--surface-overlay);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg);
    animation: modal-in var(--dur-3) var(--ease) both;
    overflow: hidden;
}
.modal-sm { --modal-w: 400px; }
.modal-md { --modal-w: 540px; }
.modal-lg { --modal-w: 760px; }
.overlay.is-leaving .modal { animation: modal-out var(--dur-2) var(--ease) both; }
.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 18px 0 20px;
}
.modal-title { font-size: var(--fs-lg); font-weight: 600; letter-spacing: var(--tracking-tight); line-height: 1.35; padding-top: 3px; }
.modal-close { margin: -2px -4px 0 0; color: var(--text-3); }
.modal-body { padding: 10px 20px 20px; overflow-y: auto; color: var(--text-2); font-size: var(--fs-md); line-height: 1.55; }
.modal-body:first-child { padding-top: 20px; }
.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface-2) 55%, transparent);
}
.modal-handle { display: none; }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.975); } to { opacity: 1; transform: none; } }
@keyframes modal-out { to { opacity: 0; transform: translateY(4px) scale(.985); } }

/* Drawer */
.overlay-drawer { justify-content: flex-end; }
.drawer {
    --drawer-w: 420px;
    position: relative;
    width: min(var(--drawer-w), calc(100vw - 16px));
    margin: 8px;
    display: flex;
    flex-direction: column;
    background: var(--surface-overlay);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg);
    animation: drawer-in var(--dur-3) var(--ease) both;
    overflow: hidden;
}
.overlay.is-leaving .drawer { animation: drawer-out var(--dur-2) var(--ease) both; }
.drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 0 10px 0 18px;
    height: 56px;
    flex-shrink: 0;
    border-bottom: 1px solid var(--border);
}
.drawer-title { font-size: var(--fs-lg); font-weight: 600; letter-spacing: var(--tracking-tight); }
.drawer-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.drawer-footer { padding: 12px 16px; border-top: 1px solid var(--border); flex-shrink: 0; }
@keyframes drawer-in { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
@keyframes drawer-out { to { opacity: 0; transform: translateX(24px); } }

/* Menu / popover */
.menu, .popover {
    position: fixed;
    z-index: calc(var(--z-overlay) + 10);
    min-width: 200px;
    max-width: min(320px, calc(100vw - 16px));
    max-height: calc(100vh - 16px);
    overflow-y: auto;
    padding: 5px;
    border-radius: 12px;
    background: var(--surface-overlay);
    border: 1px solid var(--border-strong);
    box-shadow: var(--shadow-lg);
    animation: menu-in var(--dur-2) var(--ease) both;
    transform-origin: var(--origin, top left);
}
.popover { padding: 12px; }
.menu.is-leaving, .popover.is-leaving { animation: menu-out var(--dur-1) var(--ease) both; }
.menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    height: 34px;
    padding: 0 10px;
    border-radius: 7px;
    color: var(--text);
    font-size: var(--fs-sm);
    text-align: left;
    white-space: nowrap;
    cursor: pointer;
}
.menu-item > .i { width: 16px; height: 16px; color: var(--text-2); }
.menu-item-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.menu-item-hint { color: var(--text-3); font-size: var(--fs-xs); margin-left: 12px; }
.menu-item:hover, .menu-item.is-focused, .menu-item:focus-visible { background: var(--active); box-shadow: none; }
.menu-item.is-danger { color: var(--danger); }
.menu-item.is-danger > .i { color: var(--danger); }
.menu-item:disabled, .menu-item[aria-disabled="true"] { opacity: .4; pointer-events: none; }
.menu-item .check-mark { margin-left: auto; color: var(--accent); width: 16px; height: 16px; }
.menu-sep { height: 1px; background: var(--border); margin: 5px -5px; }
.menu-label { padding: 7px 10px 4px; font-size: var(--fs-2xs); font-weight: 500; color: var(--text-3); letter-spacing: .02em; }
.menu-header { padding: 8px 10px 8px; display: flex; align-items: center; gap: 10px; }
@keyframes menu-in { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
@keyframes menu-out { to { opacity: 0; transform: scale(.98); } }

.menu-scrim { position: fixed; inset: 0; z-index: calc(var(--z-overlay) + 9); background: transparent; }

/* ───────── Dropzone ───────── */
.dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 28px 20px;
    border-radius: var(--r-md);
    border: 1.5px dashed var(--border-strong);
    background: var(--input-bg);
    color: var(--text-3);
    font-size: var(--fs-sm);
    text-align: center;
    cursor: pointer;
    transition: border-color var(--dur-2) var(--ease), background-color var(--dur-2) var(--ease), color var(--dur-2) var(--ease);
}
.dropzone .i { width: 22px; height: 22px; color: var(--text-2); }
.dropzone strong { color: var(--text); font-weight: 500; }
.dropzone:hover { border-color: color-mix(in srgb, var(--text) 25%, transparent); color: var(--text-2); }
.dropzone.is-over { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }

/* ───────── Lightbox ───────── */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: calc(var(--z-overlay) + 20);
    display: grid;
    grid-template-rows: auto 1fr auto;
    background: rgba(5, 5, 7, .94);
    color: #ededef;
    animation: fade-in var(--dur-2) var(--ease) both;
}
.lightbox.is-leaving { animation: fade-out var(--dur-2) var(--ease) both; }
.lightbox-bar { display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 20px; padding-top: max(10px, env(safe-area-inset-top)); }
.lightbox-title { flex: 1; min-width: 0; font-size: var(--fs-sm); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lightbox-counter { font-family: var(--font-mono); font-size: var(--fs-xs); color: #8a8a94; }
.lightbox .btn-ghost { --btn-fg: #d4d4d8; }
.lightbox .btn-ghost:hover { color: #fff; background: rgba(255, 255, 255, .1); }
.lightbox-stage { position: relative; display: grid; place-items: center; min-height: 0; padding: 8px 64px; }
.lightbox-stage img, .lightbox-stage video { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 8px; box-shadow: 0 20px 60px rgba(0, 0, 0, .5); animation: rise-in var(--dur-3) var(--ease) both; }
.lightbox-stage audio { width: min(480px, 90vw); }
.lightbox-nav { position: absolute; top: 50%; transform: translateY(-50%); }
.lightbox-nav.prev { left: 12px; }
.lightbox-nav.next { right: 12px; }
.lightbox-foot { height: 16px; }
@media (max-width: 640px) {
    .lightbox-stage { padding: 8px; }
    .lightbox-nav { top: auto; bottom: 16px; transform: none; }
    .lightbox-foot { height: 72px; }
}

/* ───────── Stat tile ───────── */
.stat {
    padding: 14px 16px;
    border-radius: var(--r-md);
    background: var(--card);
    border: 1px solid var(--border);
    min-width: 0;
}
.stat-label { font-size: var(--fs-xs); color: var(--text-3); font-weight: 500; display: flex; align-items: center; gap: 6px; }
.stat-label .i { width: 14px; height: 14px; }
.stat-value {
    font-size: 26px;
    font-weight: 600;
    letter-spacing: var(--tracking-tighter);
    font-variant-numeric: tabular-nums;
    line-height: 1.15;
    margin-top: 6px;
    color: var(--text);
}
.stat-delta { font-size: var(--fs-xs); font-weight: 500; margin-top: 4px; display: inline-flex; align-items: center; gap: 3px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.stat-delta.is-up { color: var(--success); }
.stat-delta.is-down { color: var(--danger); }
.stat-delta .i { width: 13px; height: 13px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }

/* ───────── App tile ───────── */
.app-tile {
    --app-color: var(--accent);
    --size: 36px;
    display: inline-grid;
    place-items: center;
    width: var(--size);
    height: var(--size);
    flex-shrink: 0;
    border-radius: calc(var(--size) * .3);
    color: var(--app-color);
    background:
        linear-gradient(180deg, color-mix(in srgb, var(--app-color) 20%, transparent), color-mix(in srgb, var(--app-color) 10%, transparent));
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--app-color) 24%, transparent), inset 0 1px 0 color-mix(in srgb, var(--app-color) 22%, transparent);
}
.app-tile .i { width: calc(var(--size) * .5); height: calc(var(--size) * .5); stroke-width: 1.85; }
:root[data-theme="light"] .app-tile { color: color-mix(in srgb, var(--app-color) 70%, #000); }
.app-tile-20 { --size: 20px; border-radius: 6px; }
.app-tile-20 .i { width: 12px; height: 12px; stroke-width: 2.2; }
.app-tile-24 { --size: 24px; border-radius: 7px; }
.app-tile-24 .i { width: 14px; height: 14px; stroke-width: 2; }
.app-tile-28 { --size: 28px; }
.app-tile-32 { --size: 32px; }
.app-tile-40 { --size: 40px; }
.app-tile-48 { --size: 48px; }
.app-tile-56 { --size: 56px; }
.app-tile-72 { --size: 72px; }

/* ───────── Misc ───────── */
.section-title {
    font-size: var(--fs-xs);
    font-weight: 500;
    color: var(--text-3);
    letter-spacing: .02em;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.inline-error {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: var(--fs-sm);
    color: var(--danger);
    background: color-mix(in srgb, var(--danger) 9%, transparent);
    border: 1px solid color-mix(in srgb, var(--danger) 22%, transparent);
    animation: rise-in var(--dur-2) var(--ease) both;
}
.inline-error .i { width: 16px; height: 16px; margin-top: 2px; flex-shrink: 0; }
.callout {
    display: flex;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--r-md);
    background: var(--surface-2);
    border: 1px solid var(--border);
    font-size: var(--fs-sm);
    color: var(--text-2);
}
.callout .i { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; color: var(--text-3); }
.callout-accent { background: var(--accent-soft); border-color: var(--accent-line); }
.callout-accent .i { color: var(--accent); }
.callout-warning { background: color-mix(in srgb, var(--warning) 9%, transparent); border-color: color-mix(in srgb, var(--warning) 22%, transparent); }
.callout-warning .i { color: var(--warning); }
.callout b { color: var(--text); }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; font-size: var(--fs-sm); }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; color: var(--text); min-width: 0; overflow-wrap: anywhere; }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); display: inline-block; flex-shrink: 0; }
.dot-success { background: var(--success); }
.dot-accent { background: var(--accent); }
.dot-danger { background: var(--danger); }
.dot-live { background: var(--success); box-shadow: 0 0 0 0 color-mix(in srgb, var(--success) 60%, transparent); animation: live-pulse 2s infinite; }
@keyframes live-pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--success) 55%, transparent); } 70% { box-shadow: 0 0 0 6px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

/* ───────── Mobile: sheets instead of modals ───────── */
@media (max-width: 640px) {
    .toast-root { left: 8px; right: 8px; top: max(8px, env(safe-area-inset-top)); bottom: auto; align-items: stretch; flex-direction: column; }
    .toast { width: 100%; transform-origin: top center; }
    @keyframes toast-in { from { opacity: 0; transform: translateY(-10px) scale(.98); } to { opacity: 1; transform: none; } }

    .overlay-modal { align-items: flex-end; padding: 0; }
    .modal {
        width: 100%;
        max-height: 92vh;
        max-height: 92dvh;
        border-radius: 20px 20px 0 0;
        border-bottom: 0;
        padding-bottom: env(safe-area-inset-bottom);
        animation: sheet-in var(--dur-3) var(--ease) both;
    }
    .overlay.is-leaving .modal { animation: sheet-out var(--dur-2) var(--ease) both; }
    .modal-handle { display: block; width: 36px; height: 4px; border-radius: 4px; background: var(--border-strong); margin: 8px auto 0; flex-shrink: 0; }
    .modal-header { padding-top: 12px; }
    .modal-footer { flex-direction: column-reverse; align-items: stretch; background: transparent; border-top: 0; padding: 4px 16px 16px; }
    .modal-footer .btn { height: var(--h-lg); font-size: var(--fs-md); }

    .drawer { margin: 0; width: 100vw; border-radius: 0; border: 0; padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); }

    .menu.is-sheet {
        left: 8px !important;
        right: 8px !important;
        top: auto !important;
        bottom: calc(8px + env(safe-area-inset-bottom)) !important;
        max-width: none;
        min-width: 0;
        padding: 6px;
        border-radius: 16px;
        animation: sheet-in var(--dur-3) var(--ease) both;
    }
    .menu.is-sheet .menu-item { height: 46px; font-size: var(--fs-md); padding: 0 12px; }
    .menu.is-sheet.is-leaving { animation: sheet-out var(--dur-2) var(--ease) both; }
    .menu-scrim.is-sheet { background: var(--scrim); animation: fade-in var(--dur-2) var(--ease) both; }
}
@keyframes sheet-in { from { transform: translateY(100%); } to { transform: none; } }
@keyframes sheet-out { to { transform: translateY(100%); } }
