:root {
    --bg-color: #f6f7fb;
    --surface: #ffffff;
    --surface-muted: #f0f3f8;
    --text-color: #172033;
    --text-muted: #657085;
    --card-border: #dfe5ef;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --success: #0f9f6e;
    --danger: #dc2626;
    --warning: #b45309;
    --input-bg: #ffffff;
    --input-text: #172033;
    --input-border: #cbd5e1;
    --shadow: 0 14px 34px rgba(23, 32, 51, 0.08);
}

[data-theme="dark"] {
    --bg-color: #111318;
    --surface: #181c23;
    --surface-muted: #202631;
    --text-color: #f7f9fc;
    --text-muted: #a8b1c2;
    --card-border: #303846;
    --primary: #5b8cff;
    --primary-hover: #7aa2ff;
    --success: #35c48f;
    --danger: #fb7185;
    --warning: #fbbf24;
    --input-bg: #12161d;
    --input-text: #f7f9fc;
    --input-border: #3a4352;
    --shadow: 0 16px 38px rgba(0, 0, 0, 0.28);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    align-items: flex-start;
    background: var(--bg-color);
    color: var(--text-color);
    display: flex;
    font-family: 'Inter', Arial, sans-serif;
    justify-content: center;
    min-height: 100vh;
    padding: 48px 20px;
    transition: background-color 0.2s, color 0.2s;
}

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

.theme-toggle {
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    box-shadow: var(--shadow);
    color: var(--text-color);
    cursor: pointer;
    display: flex;
    height: 44px;
    justify-content: center;
    padding: 0;
    position: fixed;
    right: 20px;
    top: 20px;
    transition: background 0.2s, border-color 0.2s;
    width: 44px;
    z-index: 1000;
}

.theme-toggle:hover {
    background: var(--surface-muted);
}

.hidden {
    display: none !important;
}

.sr-only {
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    width: 1px;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}

.container {
    width: min(100%, 960px);
}

.page-login .container,
.page-register .container {
    width: min(100%, 440px);
}

.card,
.glass-card {
    background: var(--surface);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.glass-card {
    margin-bottom: 20px;
    padding: 24px;
}

.form-card {
    margin: 0 auto;
    max-width: 440px;
}

.auth-card {
    padding: 28px;
}

.card-header {
    margin-bottom: 22px;
}

.card-header h2,
.dashboard-header h2,
.section-heading h3 {
    color: var(--text-color);
    font-size: 1.35rem;
    line-height: 1.25;
}

.card-header p,
.dashboard-header p,
.section-heading span,
.link-meta,
.long-url,
.card-footer {
    color: var(--text-muted);
}

.card-header p {
    font-size: 0.95rem;
    margin-top: 6px;
}

.auth-form,
.shorten-form {
    display: grid;
    gap: 16px;
}

.form-group {
    display: grid;
    gap: 7px;
}

.form-group label {
    color: var(--text-color);
    font-size: 0.86rem;
    font-weight: 700;
}

.form-group input {
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 8px;
    color: var(--input-text);
    font-family: inherit;
    font-size: 0.96rem;
    min-height: 44px;
    padding: 10px 12px;
    transition: border-color 0.2s, box-shadow 0.2s;
    width: 100%;
}

.form-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
    outline: none;
}

.input-addon {
    align-items: stretch;
    display: flex;
    min-width: 0;
}

.input-addon .addon {
    align-items: center;
    background: var(--surface-muted);
    border: 1px solid var(--input-border);
    border-radius: 8px 0 0 8px;
    color: var(--text-muted);
    display: flex;
    flex: 0 1 auto;
    font-size: 0.86rem;
    min-width: 0;
    overflow: hidden;
    padding: 0 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.input-addon input {
    border-left: 0;
    border-radius: 0 8px 8px 0;
    min-width: 120px;
}

.btn,
.icon-button,
.advanced-toggle {
    align-items: center;
    border-radius: 8px;
    cursor: pointer;
    display: inline-flex;
    font-family: inherit;
    font-weight: 700;
    justify-content: center;
    line-height: 1;
    min-height: 42px;
    text-decoration: none;
    transition: background 0.2s, border-color 0.2s, color 0.2s, transform 0.1s;
}

.btn {
    border: 1px solid transparent;
    padding: 10px 18px;
}

.btn-primary {
    background: var(--primary);
    color: #ffffff;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-primary:disabled {
    cursor: wait;
    opacity: 0.7;
    transform: none;
}

.btn-block {
    width: 100%;
}

.btn-outline {
    background: transparent;
    border-color: var(--input-border);
    color: var(--text-color);
}

.btn-outline:hover {
    background: var(--surface-muted);
}

.card-footer {
    font-size: 0.88rem;
    margin-top: 20px;
    text-align: center;
}

.card-footer a {
    font-weight: 700;
    text-decoration: none;
}

.alert {
    border: 1px solid transparent;
    border-radius: 8px;
    font-size: 0.9rem;
    line-height: 1.4;
    margin-bottom: 16px;
    padding: 11px 13px;
}

.alert a {
    font-weight: 700;
}

.alert-error {
    background: rgba(220, 38, 38, 0.1);
    border-color: rgba(220, 38, 38, 0.22);
    color: var(--danger);
}

.alert-success {
    background: rgba(15, 159, 110, 0.1);
    border-color: rgba(15, 159, 110, 0.22);
    color: var(--success);
}

.alert-warning {
    background: rgba(180, 83, 9, 0.11);
    border-color: rgba(180, 83, 9, 0.22);
    color: var(--warning);
}

.compact-alert {
    font-size: 0.84rem;
    margin-bottom: 0;
}

.dashboard-shell {
    display: grid;
    gap: 22px;
}

.dashboard-header {
    align-items: center;
    display: flex;
    gap: 16px;
    justify-content: space-between;
}

.user-info {
    align-items: center;
    display: flex;
    gap: 14px;
    min-width: 0;
}

.user-info p {
    font-size: 0.92rem;
    margin-top: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.avatar {
    align-items: center;
    background: var(--primary);
    border-radius: 8px;
    color: #ffffff;
    display: flex;
    flex: 0 0 48px;
    font-size: 1.3rem;
    font-weight: 800;
    height: 48px;
    justify-content: center;
    width: 48px;
}

.section-heading {
    align-items: center;
    display: flex;
    gap: 12px;
    justify-content: space-between;
    margin-bottom: 18px;
}

.section-heading span {
    background: var(--surface-muted);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    font-size: 0.82rem;
    padding: 7px 10px;
    white-space: nowrap;
}

.dashboard-shortener {
    max-width: 100%;
}

.flex-group {
    align-items: stretch;
    display: grid;
    gap: 10px;
    grid-template-columns: minmax(0, 1fr) auto;
}

.advanced-toggle {
    background: transparent;
    border: 1px solid var(--input-border);
    color: var(--text-color);
    justify-self: start;
    min-height: 38px;
    padding: 9px 12px;
}

.advanced-toggle::after {
    content: "+";
    margin-left: 10px;
}

.advanced-toggle[aria-expanded="true"]::after {
    content: "-";
}

.advanced-toggle:hover {
    background: var(--surface-muted);
}

.advanced-options {
    border-top: 1px solid var(--card-border);
    padding-top: 16px;
}

.links-list {
    display: grid;
    gap: 12px;
}

.link-card {
    align-items: center;
    display: grid;
    gap: 18px;
    grid-template-columns: minmax(0, 1fr) auto;
    margin-bottom: 0;
    padding: 18px 20px;
}

.link-details {
    min-width: 0;
}

.short-url {
    display: inline-block;
    font-size: 1rem;
    font-weight: 800;
    margin-bottom: 7px;
    max-width: 100%;
    overflow-wrap: anywhere;
    text-decoration: none;
}

.long-url {
    font-size: 0.88rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.link-meta {
    font-size: 0.78rem;
    margin-top: 7px;
}

.link-actions {
    align-items: center;
    display: flex;
    gap: 16px;
}

.icon-button {
    background: var(--surface-muted);
    border: 1px solid var(--input-border);
    color: var(--text-color);
    min-width: 72px;
    padding: 9px 12px;
}

.icon-button:hover,
.icon-button.is-copied {
    background: var(--primary);
    border-color: var(--primary);
    color: #ffffff;
}

.link-clicks {
    min-width: 64px;
    text-align: right;
}

.clicks-number {
    color: var(--text-color);
    display: block;
    font-size: 1.35rem;
    font-weight: 800;
    line-height: 1;
}

.clicks-label {
    color: var(--text-muted);
    display: block;
    font-size: 0.72rem;
    margin-top: 5px;
}

.empty-state {
    padding: 28px;
    text-align: center;
}

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

.recaptcha-wrapper {
    display: flex;
    justify-content: center;
    overflow: hidden;
}

@media (max-width: 720px) {
    body {
        padding: 72px 14px 28px;
    }

    .theme-toggle {
        right: 14px;
        top: 14px;
    }

    .glass-card,
    .auth-card {
        padding: 20px;
    }

    .dashboard-header {
        align-items: stretch;
        flex-direction: column;
    }

    .dashboard-header .btn {
        width: 100%;
    }

    .section-heading {
        align-items: flex-start;
        flex-direction: column;
        gap: 8px;
    }

    .flex-group {
        grid-template-columns: 1fr;
    }

    .link-card {
        align-items: stretch;
        grid-template-columns: 1fr;
    }

    .link-actions {
        justify-content: space-between;
    }

    .long-url {
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .input-addon {
        display: grid;
        grid-template-columns: 1fr;
    }

    .input-addon .addon,
    .input-addon input {
        border: 1px solid var(--input-border);
        border-radius: 8px;
    }

    .input-addon input {
        border-top: 0;
        border-radius: 0 0 8px 8px;
    }

    .input-addon .addon {
        border-radius: 8px 8px 0 0;
        min-height: 40px;
    }
}
