/* WEAC shared design tokens and product shell. */
:root {
    color-scheme: light;
    --color-bg: #f4f7f5;
    --color-surface: #ffffff;
    --color-surface-muted: #eef3f0;
    --color-text: #18211c;
    --color-text-muted: #526159;
    --color-text-subtle: #607067;
    --color-brand: #087f4b;
    --color-brand-hover: #066a3f;
    --color-brand-soft: #e8f4ed;
    --color-border: #d8e0dc;
    --color-border-strong: #bdcbc3;
    --color-danger: #b42318;
    --color-danger-soft: #fff0ee;
    --color-warning: #875c00;
    --color-warning-soft: #fff8e6;
    --color-info: #245c45;
    --radius-control: 10px;
    --radius-panel: 14px;
    --shadow-panel: 0 10px 28px rgba(24, 33, 28, 0.055);
    --focus-ring: 0 0 0 3px rgba(8, 127, 75, 0.2);
    --content-wide: 1320px;
    --content-narrow: 820px;
    --z-header: 20;
    --z-toast: 80;
    --z-dialog: 100;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    min-width: 320px;
    background: var(--color-bg);
    scroll-behavior: smooth;
}

body {
    min-height: 100dvh;
    margin: 0;
    background: var(--color-bg);
    color: var(--color-text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

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

button,
[role="button"] {
    touch-action: manipulation;
}

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

a:hover {
    color: var(--color-brand-hover);
}

:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
    outline: 2px solid var(--color-brand);
    outline-offset: 3px;
    box-shadow: var(--focus-ring);
}

::selection {
    background: rgba(8, 127, 75, 0.18);
}

.skip-link {
    position: fixed;
    z-index: calc(var(--z-dialog) + 1);
    top: 12px;
    left: 16px;
    padding: 10px 14px;
    transform: translateY(-160%);
    border-radius: var(--radius-control);
    background: var(--color-text);
    color: var(--color-surface);
    text-decoration: none;
}

.skip-link:focus {
    transform: translateY(0);
}

.container {
    width: min(100% - 32px, var(--content-narrow));
    margin: 0 auto;
    padding: 30px 0 56px;
}

.container.wide {
    width: min(100% - 40px, var(--content-wide));
    max-width: none;
}

/* Shared header */
.site-header {
    position: relative;
    z-index: var(--z-header);
    border-bottom: 1px solid var(--color-border);
    background: rgba(255, 255, 255, 0.96);
}

.site-header-inner {
    display: grid;
    grid-template-columns: minmax(210px, 1fr) auto minmax(210px, 1fr);
    align-items: center;
    width: min(100% - 40px, var(--content-wide));
    min-height: 76px;
    margin: 0 auto;
    gap: 24px;
}

.site-brand {
    display: inline-grid;
    width: fit-content;
    color: var(--color-text);
    line-height: 1.15;
    text-decoration: none;
}

.site-brand:hover {
    color: var(--color-text);
}

.site-brand-name {
    font-size: 18px;
    font-weight: 720;
    letter-spacing: -0.02em;
}

.site-brand-meta {
    margin-top: 5px;
    color: var(--color-text-muted);
    font-size: 11px;
    font-weight: 650;
    letter-spacing: 0.1em;
}

.site-nav {
    display: flex;
    align-self: stretch;
    align-items: center;
    justify-content: center;
    gap: 34px;
    white-space: nowrap;
}

.site-nav a {
    position: relative;
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    color: var(--color-text);
    font-size: 14px;
    font-weight: 560;
    text-decoration: none;
}

.site-nav a::after {
    position: absolute;
    right: 0;
    bottom: -1px;
    left: 0;
    height: 2px;
    transform: scaleX(0.55);
    background: var(--color-brand);
    content: "";
    opacity: 0;
    transition: opacity 160ms ease, transform 160ms ease;
}

.site-nav a:hover,
.site-nav a.is-active {
    color: var(--color-brand);
}

.site-nav a:hover::after,
.site-nav a.is-active::after {
    transform: scaleX(1);
    opacity: 1;
}

.site-account {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    min-width: 0;
    gap: 9px;
    white-space: nowrap;
}

.site-account-avatar {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    object-fit: cover;
}

.site-account-name {
    max-width: 132px;
    overflow: hidden;
    color: var(--color-text);
    font-size: 13px;
    text-overflow: ellipsis;
}

.site-account-action {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    color: var(--color-text-muted);
    font-size: 13px;
    text-decoration: none;
}

/* Legacy navigation remains available on non-sample pages. */
.nav {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
    padding: 12px 0;
}

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

.nav a:hover {
    text-decoration: underline;
}

.header {
    margin-bottom: 24px;
}

.header h1 {
    margin: 0 0 8px;
    color: var(--color-text);
    font-size: clamp(24px, 3vw, 30px);
    line-height: 1.2;
    letter-spacing: -0.025em;
}

.header p,
.stats {
    margin: 0;
    color: var(--color-text-muted);
    font-size: 14px;
}

.card {
    margin-bottom: 20px;
    padding: 28px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-panel);
    background: var(--color-surface);
    box-shadow: var(--shadow-panel);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 10px 20px;
    border: 1px solid var(--color-brand);
    border-radius: var(--radius-control);
    background: var(--color-brand);
    color: #ffffff;
    font-size: 14px;
    font-weight: 650;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, transform 120ms ease;
}

.btn:hover {
    border-color: var(--color-brand-hover);
    background: var(--color-brand-hover);
    color: #ffffff;
}

.btn:active {
    transform: translateY(1px);
}

.btn:disabled,
.btn[aria-disabled="true"] {
    border-color: var(--color-border);
    background: var(--color-surface-muted);
    color: var(--color-text-subtle);
    cursor: not-allowed;
    transform: none;
}

.btn-secondary,
.btn-paste,
.btn-clear {
    border-color: var(--color-border-strong);
    background: var(--color-surface);
    color: var(--color-text);
}

.btn-secondary:hover,
.btn-paste:hover,
.btn-clear:hover {
    border-color: var(--color-brand);
    background: var(--color-brand-soft);
    color: var(--color-brand-hover);
}

.btn-warning {
    border-color: var(--color-brand);
    background: var(--color-surface);
    color: var(--color-brand);
}

.btn-warning:hover {
    border-color: var(--color-brand-hover);
    background: var(--color-brand-soft);
    color: var(--color-brand-hover);
}

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

.btn-danger:hover {
    border-color: #8f1b13;
    background: #8f1b13;
    color: #ffffff;
}

.btn-small,
.btn-sm {
    min-height: 36px;
    padding: 7px 12px;
    font-size: 12px;
}

.tag {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 3px 9px;
    border: 1px solid #c8dfd2;
    border-radius: 999px;
    background: var(--color-brand-soft);
    color: #05663d;
    font-size: 12px;
    line-height: 1.2;
}

.tag .remove {
    margin-left: 3px;
    color: inherit;
    cursor: pointer;
    opacity: 0.75;
}

.tag .remove:hover {
    opacity: 1;
}

.status-badge,
.reposted-badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

.status-badge.reposted,
.reposted-badge {
    background: var(--color-brand-soft);
    color: #05663d;
}

.status-badge.not-reposted {
    background: var(--color-warning-soft);
    color: var(--color-warning);
}

.toast-container {
    position: fixed;
    z-index: var(--z-toast);
    top: 18px;
    right: 18px;
    width: min(360px, calc(100% - 36px));
}

.toast {
    display: flex;
    align-items: flex-start;
    margin-bottom: 10px;
    padding: 13px 16px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: var(--radius-control);
    background: var(--color-text);
    box-shadow: 0 10px 30px rgba(24, 33, 28, 0.16);
    color: #ffffff;
    gap: 10px;
}

.toast.success {
    background: #075f3b;
}

.toast.error {
    background: #8f1b13;
}

.toast.info {
    background: #245c45;
}

@media (prefers-reduced-motion: no-preference) {
    .toast {
        animation: toast-in 180ms ease-out;
    }

    .toast.hiding {
        animation: toast-out 160ms ease-in forwards;
    }
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes toast-out {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(-6px); }
}

.modal-overlay {
    position: fixed;
    z-index: var(--z-dialog);
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(24, 33, 28, 0.48);
}

.modal-box {
    width: min(100%, 420px);
    padding: 24px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-panel);
    background: var(--color-surface);
    box-shadow: 0 22px 60px rgba(24, 33, 28, 0.2);
}

.modal-message {
    margin: 0 0 20px;
    color: var(--color-text);
    font-size: 15px;
    line-height: 1.6;
}

.modal-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.modal-btn {
    min-height: 42px;
    padding: 9px 18px;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-control);
    background: var(--color-surface);
    color: var(--color-text);
    font-weight: 650;
    cursor: pointer;
}

.modal-btn-confirm {
    border-color: var(--color-brand);
    background: var(--color-brand);
    color: #ffffff;
}

.modal-btn-cancel:hover {
    border-color: var(--color-brand);
    background: var(--color-brand-soft);
}

.modal-btn-confirm:hover {
    background: var(--color-brand-hover);
}

.loading {
    display: none;
    padding: 16px 0;
    color: var(--color-text-muted);
}

.login-prompt {
    max-width: 520px;
    margin: 0 auto;
    padding: 46px 20px;
    text-align: center;
}

.login-prompt h2 {
    margin: 0 0 10px;
    color: var(--color-text);
    font-size: 24px;
}

.login-prompt p {
    margin: 0 0 22px;
    color: var(--color-text-muted);
}

.empty-state,
.error-state {
    padding: 42px 24px;
    color: var(--color-text-muted);
    text-align: center;
}

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

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

@media (max-width: 768px) {
    .container,
    .container.wide {
        width: min(100% - 24px, var(--content-wide));
        padding: 20px 0 40px;
    }

    .site-header-inner {
        grid-template-areas:
            "brand account"
            "nav nav";
        grid-template-columns: minmax(0, 1fr) auto;
        width: 100%;
        min-height: 0;
        padding: 14px 12px 0;
        gap: 10px 12px;
    }

    .site-brand {
        grid-area: brand;
    }

    .site-brand-name {
        font-size: 17px;
    }

    .site-account {
        grid-area: account;
    }

    .site-account-name {
        max-width: 88px;
    }

    .site-nav {
        grid-area: nav;
        align-self: auto;
        justify-content: flex-start;
        width: calc(100% + 24px);
        margin-left: -12px;
        padding: 0 12px;
        overflow-x: auto;
        border-top: 1px solid var(--color-border);
        gap: 26px;
        scrollbar-width: none;
    }

    .site-nav::-webkit-scrollbar {
        display: none;
    }

    .site-nav a {
        min-height: 50px;
        font-size: 14px;
    }

    .card {
        padding: 20px;
    }

    .nav {
        flex-wrap: wrap;
    }

    .modal-buttons {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 420px) {
    .site-account-avatar {
        width: 30px;
        height: 30px;
    }

    .site-account-name {
        display: none;
    }

    .site-nav {
        justify-content: space-between;
        gap: 18px;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}
