:root {
    color-scheme: light;
    --ink: #17211f;
    --muted: #69756f;
    --line: #dfe7e2;
    --surface: #ffffff;
    --soft: #f4f7f5;
    --primary: #146c5f;
    --primary-strong: #0f5349;
    --accent: #d95f43;
    --danger: #b42318;
    --shadow: 0 18px 45px rgba(22, 33, 31, 0.08);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    background: #f7f3ee;
}

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

a {
    color: inherit;
}

.app-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    width: min(1120px, calc(100% - 32px));
    margin: 18px auto 0;
    padding: 14px 18px;
    border: 1px solid rgba(23, 33, 31, 0.08);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.86);
    box-shadow: var(--shadow);
}

.brand {
    font-weight: 800;
    text-decoration: none;
}

.app-topbar nav {
    display: flex;
    gap: 14px;
}

.app-topbar nav a {
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
}

.app-shell {
    width: min(1120px, calc(100% - 32px));
    margin: 26px auto 64px;
}

.auth-page {
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        linear-gradient(135deg, rgba(20, 108, 95, 0.12), transparent 36%),
        linear-gradient(315deg, rgba(217, 95, 67, 0.14), transparent 42%),
        #f7f3ee;
}

.auth-page .app-shell {
    width: min(430px, 100%);
    margin: 0;
}

.auth-panel,
.panel {
    border: 1px solid rgba(23, 33, 31, 0.08);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.auth-panel {
    padding: 28px;
}

.auth-brand span,
.eyebrow {
    color: var(--accent);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

h1,
h2 {
    margin: 0;
    line-height: 1.08;
}

h1 {
    font-size: clamp(32px, 6vw, 52px);
}

h2 {
    font-size: 22px;
}

.auth-brand h1 {
    margin-top: 6px;
    margin-bottom: 24px;
    font-size: 34px;
}

.dashboard-head {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 24px;
}

.stats-strip {
    display: grid;
    grid-template-columns: repeat(3, minmax(88px, 1fr));
    min-width: min(420px, 100%);
    overflow: hidden;
    border: 1px solid rgba(23, 33, 31, 0.08);
    border-radius: 8px;
    background: #ffffff;
}

.stats-strip div {
    padding: 14px 16px;
    border-left: 1px solid rgba(23, 33, 31, 0.08);
}

.stats-strip div:first-child {
    border-left: 0;
}

.stats-strip strong,
.stats-strip span {
    display: block;
}

.stats-strip strong {
    font-size: 24px;
}

.stats-strip span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr) minmax(260px, 0.75fr);
    gap: 18px;
    margin-bottom: 18px;
}

.panel {
    padding: 20px;
}

.panel h2 {
    margin-bottom: 16px;
}

.form-grid {
    display: grid;
    gap: 14px;
}

label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

input,
textarea,
select {
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--ink);
    background: #fff;
    outline: 0;
}

textarea {
    resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(20, 108, 95, 0.16);
}

.btn,
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    border: 0;
    border-radius: 8px;
    padding: 0 16px;
    cursor: pointer;
    font-weight: 800;
    text-decoration: none;
}

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

.btn.primary:hover {
    background: var(--primary-strong);
}

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

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

.icon-btn.danger {
    color: #fff;
    background: var(--danger);
}

.alert {
    margin-bottom: 16px;
    border-radius: 8px;
    padding: 12px 14px;
    font-weight: 700;
}

.alert-success {
    color: #125448;
    background: #dff4ef;
}

.alert-error {
    color: #851b13;
    background: #fde5e1;
}

.avatar-preview {
    width: 76px;
    height: 76px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid #fff;
    box-shadow: 0 0 0 1px var(--line);
}

.links-panel {
    padding-bottom: 12px;
}

.panel-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.save-state {
    min-height: 18px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

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

.link-row {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) 42px;
    gap: 12px;
    align-items: center;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfb;
}

.link-row.dragging {
    opacity: 0.58;
}

.drag-handle {
    width: 42px;
    height: 42px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--muted);
    background: #fff;
    cursor: grab;
    font-weight: 900;
}

.link-edit-form {
    display: grid;
    grid-template-columns: minmax(160px, 1fr) minmax(220px, 1.4fr) 82px 86px auto;
    gap: 10px;
    align-items: end;
}

.toggle-line {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
}

.toggle-line input {
    width: 18px;
    min-height: 18px;
}

.click-count {
    align-self: center;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
    white-space: nowrap;
}

.delete-form {
    align-self: end;
}

.empty-state,
.empty-public {
    margin: 0;
    color: var(--muted);
    text-align: center;
}

.public-page {
    display: grid;
    min-height: 100vh;
}

.public-wrap {
    width: min(480px, calc(100% - 32px));
    margin: auto;
    padding: 44px 0;
}

.profile-block {
    margin-bottom: 28px;
    text-align: center;
}

.avatar {
    width: 108px;
    height: 108px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 18px;
}

.avatar-fallback {
    display: inline-grid;
    place-items: center;
    font-size: 42px;
    font-weight: 900;
}

.profile-block h1 {
    margin-bottom: 10px;
    font-size: 34px;
}

.profile-block p {
    margin: 0;
    line-height: 1.6;
}

.link-stack {
    display: grid;
    gap: 13px;
}

.public-link {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 56px;
    padding: 12px 18px;
    text-align: center;
    text-decoration: none;
    font-weight: 850;
    line-height: 1.25;
}

@media (max-width: 980px) {
    .dashboard-head {
        align-items: stretch;
        flex-direction: column;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .link-edit-form {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 640px) {
    .app-topbar,
    .app-shell {
        width: min(100% - 20px, 1120px);
    }

    .app-topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .stats-strip {
        grid-template-columns: 1fr;
    }

    .stats-strip div {
        border-top: 1px solid rgba(23, 33, 31, 0.08);
        border-left: 0;
    }

    .stats-strip div:first-child {
        border-top: 0;
    }

    .link-row {
        grid-template-columns: 38px minmax(0, 1fr);
    }

    .delete-form {
        grid-column: 2;
        justify-self: start;
    }

    .link-edit-form {
        grid-template-columns: 1fr;
    }
}
