.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    min-height: 44px;
    padding: 10px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-semibold);
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
}

.btn-sm {
    min-height: 36px;
    padding: 6px 12px;
    font-size: var(--font-size-sm);
}

.btn-lg {
    min-height: 52px;
    padding: 14px 24px;
    font-size: var(--font-size-md);
}

.btn-block {
    width: 100%;
}

.btn-icon {
    width: 44px;
    padding: 0;
}

.btn-primary { background: var(--color-primary); color: #ffffff; }
.btn-primary:hover { background: var(--color-primary-hover); }
.btn-secondary { background: var(--color-bg-alt); color: var(--color-text); border-color: var(--color-border); }
.btn-secondary:hover { background: var(--color-border); }
.btn-danger { background: var(--color-danger); color: #ffffff; }
.btn-danger:hover { background: var(--color-danger-hover); }
.btn-success { background: var(--color-success); color: #052e16; }
.btn-ghost { background: transparent; color: var(--color-text); }
.btn-ghost:hover { background: var(--color-primary-soft); }

.btn:active { transform: scale(0.97); }
.btn-primary:hover, .btn-danger:hover { box-shadow: var(--shadow-md); }

.btn:disabled,
.btn.is-disabled {
    opacity: 0.55;
    cursor: not-allowed;
    pointer-events: none;
}

.btn.is-loading::after {
    content: "";
    width: 1em;
    height: 1em;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: var(--radius-full);
    animation: spin 700ms linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    margin-bottom: var(--space-md);
}

.form-label {
    font-weight: var(--font-weight-semibold);
    color: var(--color-text);
}

.form-hint {
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
}

.form-control {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    background: var(--color-card);
    color: var(--color-text);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: var(--font-size-base);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-control:focus {
    border-color: var(--color-primary-light);
    box-shadow: 0 0 0 3px rgba(0, 156, 219, 0.35);
}

select.form-control {
    padding-right: 40px;
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, var(--color-text-muted) 50%), linear-gradient(135deg, var(--color-text-muted) 50%, transparent 50%);
    background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%;
    background-size: 6px 6px;
    background-repeat: no-repeat;
}

.form-control.is-invalid {
    border-color: var(--color-danger);
}

.form-error {
    color: var(--error-text);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
}

.form-check {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    min-height: 44px;
    cursor: pointer;
}

.form-check input {
    width: 1.35rem;
    height: 1.35rem;
    min-width: 20px;
    min-height: 20px;
    margin: 0;
    accent-color: var(--color-primary);
}

.form-checks {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
    gap: 0 var(--space-md);
}

.card {
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: var(--space-lg);
    transition: box-shadow var(--transition-base), border-color var(--transition-base);
}

a.card:hover,
.card:has(> a:only-child):hover {
    border-color: var(--color-primary-light);
    box-shadow: var(--shadow-md);
}

.card-title {
    margin-bottom: var(--space-md);
    font-size: var(--font-size-lg);
}

.card-form {
    max-width: 720px;
}

.form-split {
    display: grid;
    gap: var(--space-lg);
    align-items: start;
}

.form-split .card-form {
    max-width: none;
}

.form-split-actions {
    margin-top: 0;
}

@media (min-width: 900px) {
    .form-split {
        grid-template-columns: 1fr 1fr;
    }

    .form-split-actions {
        grid-column: 1 / -1;
    }
}

.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
    padding-bottom: var(--space-lg);
    border-bottom: 1px solid var(--color-border);
}

.page-header-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
}

.page-header h1 {
    font-size: clamp(1.35rem, 1.2rem + 0.5vw, 1.75rem);
    font-weight: var(--font-weight-extrabold);
    letter-spacing: -0.03em;
}

.page-header p {
    color: var(--color-text-muted);
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    margin-top: var(--space-lg);
}

.table-wrap {
    overflow-x: auto;
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-size-sm);
}

.table th {
    position: sticky;
    top: 0;
    padding: 12px 16px;
    background: var(--color-bg-alt);
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-bold);
    text-align: left;
    white-space: nowrap;
}

.table td {
    padding: 12px 16px;
    border-top: 1px solid var(--color-border);
    vertical-align: middle;
    font-weight: var(--font-weight-medium);
    font-variant-numeric: tabular-nums;
}

.table tbody tr {
    transition: background-color var(--transition-fast);
}

.table tbody tr:hover {
    background: var(--color-primary-soft);
}

.table-actions {
    display: flex;
    gap: var(--space-xs);
    justify-content: flex-end;
}

.table-actions form {
    margin: 0;
}

.text-muted {
    color: var(--color-text-muted);
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    white-space: nowrap;
}

.badge::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: var(--radius-full);
    background: currentColor;
}

.badge-draft,
.badge-muted {
    background: var(--badge-draft-bg);
    color: var(--badge-draft-text);
}

.badge-submitted {
    background: var(--badge-submitted-bg);
    color: var(--badge-submitted-text);
}

.badge-final,
.badge-success {
    background: var(--badge-final-bg);
    color: var(--badge-final-text);
}

.badge-danger {
    background: var(--error-bg);
    color: var(--error-text);
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-2xl) var(--space-md);
    text-align: center;
    color: var(--color-text-muted);
    background: var(--color-bg-alt);
    border: 1px dashed var(--color-border-strong);
    border-radius: var(--radius-lg);
}

.card .empty-state,
td .empty-state {
    background: none;
    border: 0;
}

.empty-state i {
    font-size: 2.5rem;
}

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

.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    margin-top: var(--space-md);
    font-size: var(--font-size-sm);
}

.modal {
    width: calc(100% - 2 * var(--space-md));
    max-width: 320px;
    padding: var(--space-lg) var(--space-lg) var(--space-md);
    background: color-mix(in srgb, var(--color-card) 80%, transparent);
    color: var(--color-text);
    border: 1px solid color-mix(in srgb, var(--color-card) 60%, var(--color-border));
    border-radius: 26px;
    box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255, 255, 255, 0.35);
    backdrop-filter: blur(32px) saturate(1.8);
    text-align: center;
}

.modal[open] {
    animation: modal-in 320ms cubic-bezier(0.16, 1, 0.3, 1);
}

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

.modal-icon {
    display: grid;
    place-items: center;
    width: 3.5rem;
    height: 3.5rem;
    margin: 0 auto var(--space-md);
    background: var(--color-danger);
    border-radius: 14px;
    color: #ffffff;
    font-size: 1.75rem;
    box-shadow: var(--shadow-md);
}

.modal-title {
    margin-bottom: var(--space-xs);
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-bold);
}

.modal-text {
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
}

.modal-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-sm);
    margin-top: var(--space-lg);
}

.modal-actions .btn {
    border-radius: var(--radius-full);
}

@keyframes modal-in {
    from { opacity: 0; transform: scale(1.08); }
    to { opacity: 1; transform: scale(1); }
}

.toast-stack {
    position: fixed;
    right: var(--space-lg);
    bottom: var(--space-lg);
    z-index: 100;
    display: flex;
    flex-direction: column-reverse;
    gap: var(--space-sm);
    width: min(360px, calc(100vw - 2 * var(--space-md)));
    pointer-events: none;
}

.toast {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: 12px 14px 16px;
    background: color-mix(in srgb, var(--color-card) 72%, transparent);
    color: var(--color-text);
    border: 1px solid color-mix(in srgb, var(--color-card) 60%, var(--color-border));
    border-radius: 22px;
    box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255, 255, 255, 0.35);
    backdrop-filter: blur(28px) saturate(1.8);
    pointer-events: auto;
    animation: toast-in 380ms cubic-bezier(0.16, 1, 0.3, 1);
}

.toast.is-leaving {
    opacity: 0;
    transform: translateX(32px) scale(0.96);
    transition: opacity 220ms ease, transform 220ms ease;
}

.toast-icon {
    display: grid;
    place-items: center;
    flex: none;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 10px;
    background: var(--toast-color);
    color: var(--toast-ink);
    font-size: 1.4rem;
}

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

.toast-title {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-bold);
}

.toast-text {
    overflow-wrap: anywhere;
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
}

.toast-close {
    position: absolute;
    top: -8px;
    left: -8px;
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    padding: 0;
    background: var(--color-card);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-sm);
    font-size: 0.8rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.toast:hover .toast-close,
.toast-close:focus-visible {
    opacity: 1;
}

.toast-progress {
    position: absolute;
    right: 18px;
    bottom: 7px;
    left: 18px;
    height: 3px;
    border-radius: var(--radius-full);
    background: var(--toast-color);
    opacity: 0.85;
    transform-origin: left;
    animation: toast-timer 5s linear forwards;
}

.toast:hover .toast-progress {
    animation-play-state: paused;
}

@keyframes toast-timer {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}

.toast-success { --toast-color: var(--color-success); --toast-ink: #ffffff; }
.toast-error { --toast-color: var(--color-danger); --toast-ink: #ffffff; }
.toast-warning { --toast-color: var(--color-warning); --toast-ink: #ffffff; }
.toast-info { --toast-color: var(--color-info); --toast-ink: #ffffff; }

@keyframes toast-in {
    from { opacity: 0; transform: translateX(40px) scale(0.94); }
    to { opacity: 1; transform: translateX(0) scale(1); }
}

@media (max-width: 639px) {
    .toast-stack {
        right: 50%;
        bottom: var(--space-md);
        transform: translateX(50%);
    }

    .toast-close {
        opacity: 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    .toast { animation: none; }
    .toast-progress { animation-duration: 5s; }
}

.table-search {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
}

.table-search-field {
    position: relative;
    flex: 1 1 16rem;
    max-width: 24rem;
}

.table-search-field .form-control {
    padding-left: 40px;
}

.table-search-field i {
    position: absolute;
    top: 50%;
    left: 12px;
    transform: translateY(-50%);
    color: var(--color-text-muted);
    pointer-events: none;
}

.table-search .form-control:not(.table-search-field .form-control) {
    width: auto;
}

@media (max-width: 639px) {
    .table-search-field {
        max-width: none;
    }
}

.theme-switch {
    position: relative;
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: space-between;
    width: 3.5rem;
    height: 2rem;
    padding: 0 0.45rem;
    background: var(--color-bg-alt);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    color: var(--color-text-muted);
    font-size: 1rem;
    cursor: pointer;
}

.theme-switch::before {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: calc(2rem - 8px);
    height: calc(2rem - 8px);
    background: var(--color-primary-light);
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-sm);
    transition: transform 280ms cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="dark"] .theme-switch::before {
    transform: translateX(1.5rem);
}

.theme-switch i {
    position: relative;
    transition: color var(--transition-base);
}

.theme-switch i:first-child,
[data-theme="dark"] .theme-switch i:last-child {
    color: #ffffff;
}

[data-theme="dark"] .theme-switch i:first-child {
    color: var(--color-text-muted);
}

@media (prefers-reduced-motion: reduce) {
    .theme-switch::before {
        transition: none;
    }
}

.password-field {
    position: relative;
}

.password-field .form-control {
    padding-right: 3rem;
}

.password-toggle {
    position: absolute;
    top: 50%;
    right: var(--space-xs);
    display: grid;
    place-items: center;
    width: 2.25rem;
    height: 2.25rem;
    border: 0;
    border-radius: var(--radius-full);
    background: transparent;
    color: var(--color-text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    transform: translateY(-50%);
}

.password-toggle:hover {
    background: var(--color-primary-soft);
    color: var(--color-text);
}

.article-form {
    display: grid;
    gap: var(--space-lg);
    align-items: start;
}

@media (min-width: 1024px) {
    .article-form {
        grid-template-columns: minmax(0, 1fr) 22rem;
    }

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

.article-thumb-preview {
    display: block;
    width: 100%;
    max-width: 20rem;
    height: auto;
    aspect-ratio: 16 / 9;
    margin-bottom: var(--space-sm);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    object-fit: cover;
}

.slide-thumb {
    display: block;
    width: 8rem;
    height: auto;
    aspect-ratio: 16 / 10;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    object-fit: cover;
}
