:root {
    --accent: #0084ff;
    --brand-blue: #0084ff;
    --page-bg: #f3f6f8;
    --panel: #ffffff;
    --text: #252933;
    --muted: #687385;
    --line: #e5eaf0;
    --soft-blue: #eef6ff;
    --danger: #f03e3e;
    --success: #00a870;
    color-scheme: light;
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
    background: var(--page-bg);
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--page-bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
    font-size: 15px;
    letter-spacing: 0;
}

button,
input,
textarea,
select {
    font: inherit;
    letter-spacing: 0;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

a {
    color: var(--brand-blue);
    text-decoration: none;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    height: 54px;
    border-bottom: 1px solid rgba(229, 234, 240, 0.9);
    background: rgba(255, 255, 255, 0.96);
}

.site-header-inner {
    width: min(1100px, 100%);
    height: 100%;
    margin: 0 auto;
    padding: 0 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand,
.brand-header {
    display: flex;
    align-items: center;
    min-width: 0;
}

.brand-mark {
    color: var(--brand-blue);
    font-size: 21px;
    font-weight: 800;
    white-space: nowrap;
}

.brand-divider {
    width: 1px;
    height: 18px;
    margin: 0 10px;
    background: var(--line);
}

.brand-subtitle {
    color: #39444f;
    font-weight: 700;
    white-space: nowrap;
}

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

.app-shell {
    width: min(1100px, 100%);
    margin: 0 auto;
    padding: 12px;
}

.project-tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 2px 0 12px;
    scrollbar-width: none;
}

.project-tabs::-webkit-scrollbar {
    display: none;
}

.project-tab {
    position: relative;
    min-width: max-content;
    height: 38px;
    padding: 0 15px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: #4c5968;
    cursor: pointer;
}

.project-tab.active {
    border-color: var(--tab-accent);
    background: color-mix(in srgb, var(--tab-accent) 9%, white);
    color: var(--tab-accent);
    font-weight: 700;
}

.tabs-loading {
    height: 38px;
    display: flex;
    align-items: center;
    color: var(--muted);
    font-size: 13px;
}

.workspace {
    display: grid;
    gap: 12px;
}

.project-panel,
.entries-panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.project-panel {
    padding: 18px 16px;
}

.project-heading {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--line);
}

.project-badge {
    width: 48px;
    height: 48px;
    flex: 0 0 48px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    color: #fff;
    font-size: 13px;
    font-weight: 800;
}

.project-heading h1 {
    margin: 0 0 4px;
    color: var(--text);
    font-size: 20px;
    line-height: 1.3;
}

.project-description {
    padding: 14px 0 8px;
    color: #4c5968;
    line-height: 1.7;
}

.project-description p,
.project-details p,
.form-alert p {
    margin: 0;
}

.project-notice {
    margin-top: 8px;
    padding: 10px 12px;
    border: 1px dashed color-mix(in srgb, var(--accent) 45%, white);
    border-radius: 6px;
    background: color-mix(in srgb, var(--accent) 6%, white);
    color: var(--accent);
    font-size: 13px;
    line-height: 1.6;
}

.project-details {
    margin-top: 12px;
    color: var(--muted);
    font-size: 13px;
}

.project-details summary {
    color: var(--accent);
    cursor: pointer;
    font-weight: 700;
}

.project-details > div {
    padding-top: 10px;
    line-height: 1.7;
}

.entries-panel {
    padding: 14px 12px;
}

.submit-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 76px;
    gap: 8px;
}

.submit-row input,
.setup-form input,
.admin-form input,
.admin-form textarea,
.admin-form select,
.report-dialog textarea {
    width: 100%;
    border: 1px solid #cfd7e2;
    border-radius: 6px;
    background: #fff;
    color: var(--text);
    outline: none;
}

.submit-row input {
    height: 44px;
    padding: 0 12px;
    min-width: 0;
}

.submit-row input:focus,
.setup-form input:focus,
.admin-form input:focus,
.admin-form textarea:focus,
.admin-form select:focus,
.report-dialog textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 12%, transparent);
}

.button {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 700;
    white-space: nowrap;
}

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

.button.secondary {
    border-color: var(--line);
    background: #fff;
    color: #4c5968;
}

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

.button.disabled,
.button:disabled {
    background: #d9dee5;
    color: #7e8997;
    cursor: not-allowed;
}

.button.compact {
    min-height: 32px;
    padding: 0 12px;
    font-size: 13px;
}

.submit-button {
    height: 44px;
}

.list-toolbar {
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 8px;
    border-bottom: 1px solid var(--line);
    color: #39444f;
    font-size: 13px;
    font-weight: 700;
}

.refresh-status {
    display: flex;
    align-items: center;
    color: var(--muted);
    font-size: 12px;
    font-weight: 400;
}

.refresh-status > span {
    margin-right: 3px;
    color: var(--accent);
    font-weight: 700;
}

.icon-button {
    width: 32px;
    height: 32px;
    display: inline-grid;
    place-items: center;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
}

.refresh-status .icon-button {
    margin-left: 3px;
    font-size: 18px;
}

.icon-button.spinning {
    animation: spin 0.8s linear infinite;
}

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

.entry-list {
    display: grid;
    gap: 8px;
    padding-top: 10px;
}

.entry-row {
    min-height: 66px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 10px 10px 12px;
    border-left: 3px solid var(--accent);
    border-radius: 6px;
    background: #f7f9fb;
}

.entry-row.mine {
    border-left-color: var(--success);
    background: #f0fbf7;
}

.entry-row.used {
    border-left-color: #d8dee6;
    background: #fafafa;
}

.entry-main {
    min-width: 0;
    flex: 1;
}

.entry-code-line {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 7px;
}

.entry-code {
    min-width: 0;
    overflow: hidden;
    color: #344054;
    font-family: Consolas, "SFMono-Regular", monospace;
    font-size: 16px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.entry-row.used .entry-code {
    color: #9aa4b1;
}

.entry-meta {
    display: flex;
    gap: 10px;
    margin-top: 5px;
    color: #8a95a3;
    font-size: 11px;
}

.entry-actions {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 3px;
}

.text-button {
    padding: 2px 4px;
    border: 0;
    background: transparent;
    cursor: pointer;
    font-size: 11px;
}

.danger-text,
.error-text {
    color: var(--danger);
}

.used-label {
    padding: 0 7px;
    color: #a3acb8;
    font-size: 13px;
}

.list-empty {
    padding: 38px 12px;
    text-align: center;
    color: #8994a2;
    font-size: 13px;
}

.toast {
    position: fixed;
    left: 50%;
    bottom: calc(24px + env(safe-area-inset-bottom));
    z-index: 50;
    max-width: calc(100vw - 32px);
    padding: 10px 16px;
    transform: translateX(-50%);
    border-radius: 6px;
    background: rgba(30, 35, 43, 0.94);
    color: #fff;
    box-shadow: 0 8px 24px rgba(30, 35, 43, 0.18);
    font-size: 13px;
    text-align: center;
}

.report-dialog {
    width: min(420px, calc(100vw - 28px));
    padding: 0;
    border: 0;
    border-radius: 8px;
}

.report-dialog::backdrop {
    background: rgba(20, 27, 36, 0.46);
}

.dialog-card {
    padding: 18px;
}

.dialog-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.dialog-heading h2 {
    margin: 0;
    font-size: 18px;
}

.dialog-card p {
    margin: 8px 0 12px;
    color: var(--muted);
    font-size: 13px;
}

.report-dialog textarea {
    padding: 10px;
    resize: vertical;
}

.wechat-token {
    min-height: 54px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #f7f9fb;
}

.wechat-token span {
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 12px;
}

.wechat-token strong {
    min-width: 0;
    overflow-wrap: anywhere;
    color: var(--text);
    font-size: 15px;
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 14px;
}

.site-footer {
    width: min(1100px, 100%);
    margin: 0 auto;
    padding: 14px 16px 26px;
    display: flex;
    justify-content: center;
    gap: 12px;
    color: #8994a2;
    font-size: 11px;
    text-align: center;
}

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

.empty-state-page,
.setup-body {
    min-height: 100vh;
}

.empty-state-page,
.setup-shell {
    width: min(720px, 100%);
    margin: 0 auto;
    padding: 28px 14px;
}

.empty-state-panel,
.setup-panel {
    padding: 24px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.empty-state-panel h1,
.setup-panel h1 {
    margin: 0 0 10px;
    font-size: 22px;
}

.empty-state-panel p,
.setup-lead {
    margin: 0 0 18px;
    color: var(--muted);
}

.setup-brand {
    padding: 0 4px 18px;
}

.setup-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.setup-form {
    margin-top: 18px;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.form-grid label span {
    display: block;
    margin-bottom: 6px;
    color: #4c5968;
    font-size: 13px;
    font-weight: 700;
}

.setup-form input {
    height: 42px;
    padding: 0 10px;
}

.form-alert {
    margin: 14px 0;
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 13px;
    line-height: 1.6;
}

.form-alert.error {
    border: 1px solid #ffc9c9;
    background: #fff5f5;
    color: #c92a2a;
}

.submit-wide {
    width: 100%;
    margin-top: 16px;
}

code {
    padding: 2px 5px;
    border-radius: 4px;
    background: #eef2f5;
    color: #39444f;
}

@media (min-width: 720px) {
    .app-shell {
        padding: 18px 20px;
    }

    .workspace {
        grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
        align-items: start;
    }

    .project-panel {
        position: sticky;
        top: 72px;
        padding: 20px;
    }

    .entries-panel {
        padding: 18px;
    }

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

    .form-grid .full {
        grid-column: 1 / -1;
    }
}

@media (max-width: 430px) {
    .site-header-inner {
        padding: 0 12px;
    }

    .brand-mark {
        font-size: 19px;
    }

    .app-shell {
        padding: 10px 8px;
    }

    .project-panel {
        padding: 15px 13px;
    }

    .project-heading h1 {
        font-size: 18px;
    }

    .entries-panel {
        padding: 12px 8px;
    }

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

    .entry-row {
        padding-left: 9px;
    }

    .entry-code {
        font-size: 15px;
    }

    .site-footer {
        flex-direction: column;
        gap: 4px;
    }

    .wechat-dialog .dialog-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }
}
