:root {
    --ink: #18212b;
    --muted: #647184;
    --paper: #f6f9fc;
    --panel: rgba(255, 255, 255, 0.92);
    --panel-solid: #ffffff;
    --line: rgba(24, 33, 43, 0.11);
    --red: #c7302b;
    --red-dark: #a82423;
    --gold: #d6a23a;
    --jade: #087f6d;
    --blue: #2563eb;
    --danger: #c83f3f;
    --shadow: 0 24px 70px rgba(30, 48, 72, 0.14);
    --soft-shadow: 0 14px 38px rgba(30, 48, 72, 0.1);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
    line-height: 1.5;
    background: #f6f9fc url("/assets/surface.png") center / cover fixed;
}

body::before {
    position: fixed;
    inset: 0;
    z-index: -2;
    content: "";
    background:
        linear-gradient(118deg, rgba(247, 250, 252, 0.94) 0%, rgba(255, 255, 255, 0.76) 42%, rgba(235, 243, 251, 0.84) 100%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(238, 244, 251, 0.68));
}

body::after {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    content: "";
    background:
        linear-gradient(rgba(37, 99, 235, 0.045) 1px, transparent 1px),
        linear-gradient(90deg, rgba(199, 48, 43, 0.04) 1px, transparent 1px);
    background-size: 54px 54px;
    mask-image: linear-gradient(90deg, rgba(0, 0, 0, 0.62), rgba(0, 0, 0, 0.22), rgba(0, 0, 0, 0.55));
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

.site-shell,
.admin-shell {
    width: min(1180px, calc(100% - 48px));
    margin: 0 auto;
}

.site-shell {
    min-height: 100vh;
    padding: 28px 0 36px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 56px;
}

.topbar-actions {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
}

.brand-lockup {
    display: inline-flex;
    align-items: center;
    min-height: 52px;
    color: var(--ink);
    font-weight: 900;
}

.brand-lockup.centered {
    justify-content: center;
}

.brand-logo {
    display: block;
    width: 154px;
    height: auto;
}

.brand-lockup.centered .brand-logo {
    width: 178px;
}

.brand-mark {
    display: grid;
    width: 40px;
    height: 40px;
    place-items: center;
    color: #fff;
    background: linear-gradient(135deg, var(--red), #e65345);
    border: 1px solid rgba(255, 255, 255, 0.82);
    border-radius: 8px;
    box-shadow: 0 12px 28px rgba(199, 48, 43, 0.22);
}

.ghost-link,
.ghost-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 0 17px;
    color: var(--ink);
    background: rgba(255, 255, 255, 0.76);
    border: 1px solid rgba(24, 33, 43, 0.12);
    border-radius: 8px;
    box-shadow: 0 10px 24px rgba(30, 48, 72, 0.08);
    transition: transform 160ms ease, background 160ms ease, border-color 160ms ease, color 160ms ease;
}

.ghost-link:hover,
.ghost-button:hover {
    color: var(--red-dark);
    background: #fff;
    border-color: rgba(199, 48, 43, 0.28);
    transform: translateY(-1px);
}

.ghost-link.dark {
    background: #fff;
    box-shadow: none;
}

.hero-stage {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(380px, 500px);
    gap: 56px;
    align-items: center;
    min-height: calc(100vh - 120px);
    padding: 54px 0 42px;
}

.gateway-stage {
    grid-template-columns: minmax(0, 620px);
    justify-content: center;
    justify-items: center;
    align-content: center;
    gap: 24px;
    text-align: center;
}

.hero-copy {
    position: relative;
}

.gateway-stage .hero-copy {
    width: min(100%, 560px);
}

.hero-copy::before {
    display: block;
    width: 82px;
    height: 4px;
    margin-bottom: 26px;
    content: "";
    background: linear-gradient(90deg, var(--red), var(--gold), var(--jade));
    border-radius: 8px;
}

.gateway-stage .hero-copy::before {
    margin-right: auto;
    margin-left: auto;
}

.eyebrow {
    margin: 0 0 14px;
    color: var(--red-dark);
    font-size: 13px;
    font-weight: 900;
}

.hero-copy h1,
.admin-header h1,
.auth-panel h1 {
    margin: 0;
    line-height: 1.02;
    letter-spacing: 0;
}

.hero-copy h1 {
    max-width: 650px;
    color: var(--ink);
    font-size: 86px;
    font-weight: 900;
    text-shadow: 0 14px 40px rgba(30, 48, 72, 0.1);
}

.hero-wordmark {
    display: flex;
    justify-content: center;
    max-width: none;
}

.hero-wordmark img {
    display: block;
    width: min(100%, 560px);
    height: auto;
}

.hero-subtitle {
    max-width: 560px;
    margin: 20px 0 0;
    color: #4a5a6b;
    font-size: 21px;
    font-weight: 700;
}

.gateway-stage .hero-subtitle {
    margin-right: auto;
    margin-left: auto;
}

.signal-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    max-width: 650px;
    margin-top: 36px;
}

.gateway-stage .signal-row {
    margin-right: auto;
    margin-left: auto;
    margin-top: 4px;
    width: min(100%, 680px);
}

.signal-row div {
    position: relative;
    min-width: 0;
    padding: 18px 16px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid rgba(255, 255, 255, 0.84);
    border-radius: 8px;
    box-shadow: var(--soft-shadow);
}

.signal-row div::before {
    position: absolute;
    inset: 0 0 auto;
    height: 3px;
    content: "";
    background: linear-gradient(90deg, var(--red), var(--gold), transparent);
}

.signal-row strong,
.signal-row span {
    display: block;
    overflow-wrap: anywhere;
}

.signal-row strong {
    color: var(--ink);
    font-size: 25px;
    font-weight: 900;
}

.signal-row span {
    margin-top: 4px;
    color: var(--muted);
    font-size: 13px;
}

.tool-panel,
.auth-panel,
.link-item,
.admin-card,
.admin-tools,
.empty-state {
    background: var(--panel);
    border: 1px solid rgba(255, 255, 255, 0.88);
    border-radius: 8px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px) saturate(1.08);
}

.tool-panel {
    position: relative;
    padding: 28px;
    overflow: hidden;
}

.tool-panel::before {
    position: absolute;
    inset: 0;
    pointer-events: none;
    content: "";
    background:
        linear-gradient(135deg, rgba(199, 48, 43, 0.09), transparent 36%),
        linear-gradient(315deg, rgba(8, 127, 109, 0.09), transparent 38%);
}

.tool-panel::after {
    position: absolute;
    inset: 10px;
    pointer-events: none;
    content: "";
    border: 1px solid rgba(214, 162, 58, 0.18);
    border-radius: 8px;
}

.shorten-form,
.lookup-form,
.stack-form,
.result-panel {
    position: relative;
    z-index: 1;
}

.shorten-form,
.lookup-form,
.stack-form {
    display: grid;
    gap: 17px;
}

.gateway-panel {
    width: min(100%, 560px);
    max-width: 560px;
    justify-self: center;
}

.code-field input {
    height: 78px;
    font-size: 34px;
    font-weight: 900;
    text-align: center;
    letter-spacing: 0;
}

.code-field input::placeholder {
    color: rgba(24, 33, 43, 0.28);
}

.split-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.field-block {
    display: grid;
    gap: 8px;
}

.field-block label {
    color: #344255;
    font-size: 12px;
    font-weight: 900;
}

.field-block input,
.field-block textarea,
.search-form input {
    width: 100%;
    min-width: 0;
    color: var(--ink);
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(24, 33, 43, 0.13);
    border-radius: 8px;
    outline: none;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.76), 0 8px 22px rgba(30, 48, 72, 0.05);
    transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease, transform 160ms ease;
}

.field-block input,
.search-form input {
    min-height: 52px;
    padding: 0 15px;
}

.field-block textarea {
    min-height: 82px;
    padding: 12px 14px;
    resize: vertical;
}

.field-block input:focus,
.field-block textarea:focus,
.search-form input:focus {
    background: #fff;
    border-color: rgba(199, 48, 43, 0.5);
    box-shadow: 0 0 0 4px rgba(199, 48, 43, 0.1), 0 14px 30px rgba(30, 48, 72, 0.08);
    transform: translateY(-1px);
}

.primary-button,
.secondary-button,
.danger-button,
.copy-button,
.secondary-link-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 0 20px;
    border-radius: 8px;
    font-weight: 900;
    transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease, border-color 160ms ease;
}

.primary-button {
    color: #fff;
    background: linear-gradient(135deg, var(--red), #e34d3e);
    border: 1px solid rgba(168, 36, 35, 0.34);
    box-shadow: 0 14px 32px rgba(199, 48, 43, 0.22);
}

.primary-button:hover,
.secondary-button:hover,
.danger-button:hover,
.copy-button:hover,
.secondary-link-button:hover {
    transform: translateY(-1px);
}

.primary-button:hover {
    box-shadow: 0 18px 42px rgba(199, 48, 43, 0.28);
}

.primary-button.as-link {
    width: 100%;
    margin-top: 14px;
}

.secondary-button {
    color: #fff;
    background: linear-gradient(135deg, var(--jade), #0aa38b);
    border: 1px solid rgba(8, 127, 109, 0.3);
    box-shadow: 0 12px 26px rgba(8, 127, 109, 0.18);
}

.danger-button {
    color: #fff;
    background: linear-gradient(135deg, #d94c4c, #a92935);
    border: 1px solid rgba(168, 41, 53, 0.38);
}

.copy-button {
    color: #4a3000;
    background: linear-gradient(135deg, #ffe7a8, var(--gold));
    border: 1px solid rgba(166, 120, 32, 0.18);
}

.secondary-link-button {
    color: var(--red-dark);
    background: #fff;
    border: 1px solid rgba(199, 48, 43, 0.18);
    box-shadow: 0 12px 28px rgba(30, 48, 72, 0.08);
}

.secondary-link-button:hover {
    background: #fff9f7;
    box-shadow: 0 16px 36px rgba(199, 48, 43, 0.12);
}

.primary-button:disabled {
    cursor: wait;
    opacity: 0.72;
    transform: none;
}

.form-message {
    min-height: 22px;
    margin: 0;
    color: var(--muted);
    font-size: 14px;
}

.form-message.error {
    color: var(--danger);
}

.result-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    margin-top: 18px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid rgba(8, 127, 109, 0.18);
    border-radius: 8px;
    box-shadow: 0 14px 34px rgba(30, 48, 72, 0.08);
}

.result-panel[hidden] {
    display: none;
}

.result-label {
    grid-column: 1 / -1;
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
}

.result-url {
    min-width: 0;
    overflow: hidden;
    color: var(--jade);
    font-weight: 900;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admin-page {
    color: var(--ink);
    background-color: var(--paper);
}

.admin-page::before {
    background:
        linear-gradient(130deg, rgba(247, 250, 252, 0.94), rgba(255, 255, 255, 0.78) 48%, rgba(232, 241, 251, 0.9) 100%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.66), rgba(245, 248, 252, 0.78));
}

.admin-shell {
    padding: 28px 0 56px;
}

.admin-header {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 22px;
    margin: 50px 0 22px;
    color: var(--ink);
}

.admin-header h1 {
    font-size: 46px;
    font-weight: 900;
}

.admin-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.admin-stats span {
    padding: 11px 13px;
    color: var(--ink);
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid rgba(255, 255, 255, 0.86);
    border-radius: 8px;
    box-shadow: var(--soft-shadow);
}

.notice {
    margin: 0 0 16px;
    padding: 13px 15px;
    border-radius: 8px;
    font-weight: 800;
}

.notice.success {
    color: #064f45;
    background: #ddfbf5;
    border: 1px solid rgba(8, 127, 109, 0.18);
}

.notice.error {
    color: #7e1515;
    background: #ffe6e1;
    border: 1px solid rgba(200, 63, 63, 0.16);
}

.admin-card,
.admin-tools {
    padding: 17px;
    margin-bottom: 16px;
    box-shadow: var(--soft-shadow);
}

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

.section-heading .eyebrow {
    margin-bottom: 6px;
    color: var(--red-dark);
}

.section-heading h2 {
    margin: 0;
    font-size: 22px;
    line-height: 1.2;
}

.password-form {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
    gap: 12px;
    align-items: end;
}

.search-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 10px;
    align-items: center;
}

.link-list {
    display: grid;
    gap: 14px;
}

.pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 18px;
}

.page-button,
.page-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 14px;
    border-radius: 8px;
    font-weight: 900;
}

.page-button {
    color: #fff;
    background: linear-gradient(135deg, var(--red), #e34d3e);
    border: 1px solid rgba(168, 36, 35, 0.32);
    box-shadow: 0 12px 26px rgba(199, 48, 43, 0.16);
}

.page-button.disabled {
    color: #9ba6b5;
    background: rgba(255, 255, 255, 0.72);
    border-color: var(--line);
    box-shadow: none;
}

.page-status {
    color: var(--ink);
    background: rgba(255, 255, 255, 0.88);
    border: 1px solid rgba(255, 255, 255, 0.72);
    box-shadow: var(--soft-shadow);
}

.link-item {
    padding: 17px;
    box-shadow: var(--soft-shadow);
}

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

.link-main {
    display: grid;
    grid-template-columns: 164px 206px minmax(0, 1fr);
    gap: 12px;
    align-items: start;
}

.field-block.compact input {
    min-height: 42px;
}

.field-block.compact textarea {
    min-height: 64px;
}

.link-meta,
.link-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.link-meta {
    color: var(--muted);
    font-size: 13px;
}

.link-meta span,
.short-url {
    min-height: 30px;
    display: inline-flex;
    align-items: center;
    padding: 0 10px;
    background: rgba(24, 33, 43, 0.04);
    border: 1px solid rgba(24, 33, 43, 0.07);
    border-radius: 8px;
}

.short-url {
    max-width: 100%;
    overflow: hidden;
    color: var(--jade);
    font-weight: 900;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.link-actions {
    justify-content: flex-end;
}

.switch {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 42px;
    padding: 0 12px;
    color: #344255;
    background: rgba(24, 33, 43, 0.04);
    border: 1px solid var(--line);
    border-radius: 8px;
    font-weight: 900;
}

.switch input {
    width: 18px;
    height: 18px;
    accent-color: var(--red);
}

.empty-state {
    padding: 38px;
    color: var(--muted);
    text-align: center;
    box-shadow: var(--soft-shadow);
}

.auth-shell {
    display: grid;
    width: min(100% - 40px, 452px);
    min-height: 100vh;
    margin: 0 auto;
    place-items: center;
}

.auth-panel {
    width: 100%;
    padding: 28px;
}

.auth-panel h1 {
    margin-top: 22px;
    margin-bottom: 18px;
    font-size: 34px;
    text-align: center;
}

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

@media (max-width: 960px) {
    .hero-stage {
        grid-template-columns: 1fr;
        gap: 30px;
        min-height: auto;
        padding-top: 44px;
    }

    .gateway-stage {
        justify-content: stretch;
    }

    .hero-copy h1 {
        font-size: 60px;
    }

    .hero-wordmark img {
        width: min(100%, 540px);
    }

    .hero-subtitle {
        font-size: 19px;
    }

    .link-main,
    .password-form,
    .search-form {
        grid-template-columns: 1fr;
    }

    .admin-header {
        display: grid;
        align-items: start;
    }
}

@media (max-width: 640px) {
    .site-shell,
    .admin-shell,
    .auth-shell {
        width: min(100% - 24px, 1180px);
    }

    .site-shell,
    .admin-shell {
        padding-top: 18px;
    }

    .topbar {
        align-items: flex-start;
    }

    .topbar-actions {
        max-width: 150px;
    }

    .hero-stage {
        padding-top: 34px;
    }

    .hero-copy h1 {
        font-size: 44px;
    }

    .hero-wordmark img {
        width: min(100%, 360px);
    }

    .hero-subtitle {
        font-size: 17px;
    }

    .signal-row,
    .split-fields,
    .result-panel {
        grid-template-columns: 1fr;
    }

    .tool-panel,
    .auth-panel,
    .link-item,
    .admin-card,
    .admin-tools {
        padding: 16px;
    }

    .tool-panel::after {
        inset: 7px;
    }

    .code-field input {
        height: 68px;
        font-size: 28px;
    }

    .link-actions {
        justify-content: stretch;
    }

    .link-actions > *,
    .link-actions button,
    .password-form button,
    .lookup-form a,
    .search-form button,
    .search-form a {
        width: 100%;
    }
}
