/* ============================================================
   NekoApi shared design system
   Light / Dark / Auto themes via [data-theme] on <html>.
   ============================================================ */

:root {
    --primary: #ff4757;
    --primary-2: #ff6b81;
    --primary-soft: rgba(255, 71, 87, 0.12);
    --success: #2ed573;
    --warning: #ffa502;
    --danger: #ff4757;

    --radius: 16px;
    --radius-sm: 10px;
    --maxw: 1180px;
    --font: 'SF Pro Text', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    --mono: 'Fira Code', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---- Light (default) ---- */
:root,
:root[data-theme="light"] {
    color-scheme: light;
    --bg: #eef1f6;
    --bg-grad: linear-gradient(135deg, #f6d365 0%, #fda085 100%);
    --surface: rgba(255, 255, 255, 0.72);
    --surface-2: rgba(255, 255, 255, 0.9);
    --surface-solid: #ffffff;
    --hover: rgba(47, 53, 66, 0.05);
    --text: #2f3542;
    --text-muted: #6b7280;
    --border: rgba(15, 23, 42, 0.08);
    --code-bg: rgba(47, 53, 66, 0.06);
    --code-text: #e0335a;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    --shadow-sm: 0 4px 14px rgba(0, 0, 0, 0.07);
    --sidebar-bg: #2f3542;
    --sidebar-text: rgba(255, 255, 255, 0.72);
}

/* ---- Dark ---- */
:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0d1117;
    --bg-grad: radial-gradient(1200px 600px at 15% -10%, rgba(255, 71, 87, 0.16), transparent 60%),
        radial-gradient(900px 500px at 100% 0%, rgba(102, 166, 255, 0.14), transparent 55%),
        linear-gradient(160deg, #0d1117 0%, #11161f 100%);
    --surface: rgba(28, 33, 43, 0.72);
    --surface-2: rgba(34, 40, 52, 0.92);
    --surface-solid: #1b212c;
    --hover: rgba(255, 255, 255, 0.06);
    --text: #e6e8ec;
    --text-muted: #97a0ad;
    --border: rgba(255, 255, 255, 0.1);
    --code-bg: rgba(255, 255, 255, 0.07);
    --code-text: #ff8095;
    --shadow: 0 10px 38px rgba(0, 0, 0, 0.45);
    --shadow-sm: 0 4px 16px rgba(0, 0, 0, 0.4);
    --sidebar-bg: #11161f;
    --sidebar-text: rgba(255, 255, 255, 0.7);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font);
    color: var(--text);
    line-height: 1.6;
    background: var(--bg);
    background-image: var(--bg-grad);
    background-attachment: fixed;
    transition: background-color var(--transition), color var(--transition);
}

html[lang^="zh"] body {
    font-size: 15px;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color var(--transition);
}

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

::selection {
    background: var(--primary-soft);
}

::-webkit-scrollbar {
    width: 9px;
    height: 9px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 5px;
}

/* ---- Layout container ---- */
.container {
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 0 20px 60px;
}

/* ---- Top bar ---- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 24px;
    background: var(--surface);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border);
}

.topbar .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    font-size: 1.15em;
    color: var(--text);
    letter-spacing: 0.3px;
}

.topbar .brand .logo {
    width: 30px;
    height: 30px;
    border-radius: 9px;
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    display: grid;
    place-items: center;
    color: #fff;
    font-size: 1em;
    box-shadow: 0 4px 12px rgba(255, 71, 87, 0.4);
}

.topbar .nav {
    display: flex;
    gap: 4px;
    margin-left: 8px;
    flex-wrap: wrap;
}

.topbar .nav a {
    padding: 7px 13px;
    border-radius: 10px;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.92em;
}

.topbar .nav a:hover {
    background: var(--hover);
    color: var(--text);
}

.topbar .nav a.active {
    background: var(--primary-soft);
    color: var(--primary);
}

.topbar .spacer {
    flex: 1;
}

.topbar .controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Theme toggle (segmented) */
.theme-toggle {
    display: inline-flex;
    background: var(--hover);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 3px;
    gap: 2px;
}

.theme-toggle button {
    border: none;
    background: transparent;
    color: var(--text-muted);
    width: 32px;
    height: 28px;
    border-radius: 7px;
    cursor: pointer;
    font-size: 0.95em;
    display: grid;
    place-items: center;
    transition: background var(--transition), color var(--transition);
}

.theme-toggle button:hover {
    color: var(--text);
}

.theme-toggle button.active {
    background: var(--surface-solid);
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

select.lang {
    border: 1px solid var(--border);
    background: var(--surface-solid);
    color: var(--text);
    border-radius: 10px;
    padding: 6px 10px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
}

/* ---- Cards / sections ---- */
.card {
    background: var(--surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 26px;
    margin-bottom: 26px;
    box-shadow: var(--shadow);
    scroll-margin-top: 80px;
    animation: fadeIn 0.5s ease-out backwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(16px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

h1,
h2,
h3 {
    color: var(--text);
    margin-top: 0;
    line-height: 1.3;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.4em;
    margin: 0 0 6px;
    padding-bottom: 10px;
    position: relative;
}

.section-title::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    width: 46px;
    height: 3px;
    border-radius: 2px;
    background: linear-gradient(90deg, var(--primary), var(--primary-2));
}

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

.lead {
    color: var(--text-muted);
    font-size: 1.02em;
    margin: 6px 0 20px;
}

/* ---- Hero ---- */
.hero {
    text-align: center;
    padding: 54px 20px 30px;
}

.hero h1 {
    font-size: clamp(2em, 5vw, 3em);
    margin: 0 0 12px;
    background: linear-gradient(120deg, var(--primary), var(--primary-2));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero p {
    color: var(--text-muted);
    max-width: 620px;
    margin: 0 auto;
    font-size: 1.08em;
}

/* ---- Stat cards ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
}

.stat {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 20px;
    text-align: center;
    box-shadow: var(--shadow-sm);
}

.stat .value {
    font-size: 2em;
    font-weight: 800;
    color: var(--primary);
    line-height: 1.1;
}

.stat .label {
    font-size: 0.85em;
    color: var(--text-muted);
    margin-top: 6px;
}

/* ---- API list cards ---- */
.api-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 18px;
}

.api-card {
    display: flex;
    flex-direction: column;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition), box-shadow var(--transition);
    color: inherit;
}

.api-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow);
    color: inherit;
}

.api-card .head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.api-card .icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    font-size: 1.3em;
    background: var(--primary-soft);
    color: var(--primary);
    flex-shrink: 0;
}

.api-card h3 {
    margin: 0;
    font-size: 1.15em;
}

.api-card .endpoint {
    font-family: var(--mono);
    font-size: 0.82em;
    color: var(--text-muted);
}

.api-card .desc {
    color: var(--text-muted);
    font-size: 0.93em;
    margin: 4px 0 16px;
    flex: 1;
}

.api-card .foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.api-card .cta {
    color: var(--primary);
    font-weight: 700;
    font-size: 0.92em;
}

/* ---- Status pill ---- */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 11px;
    border-radius: 20px;
    font-size: 0.8em;
    font-weight: 700;
}

.status-pill::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}

.status-ok {
    color: var(--success);
    background: rgba(46, 213, 115, 0.14);
}

.status-fail {
    color: var(--danger);
    background: rgba(255, 71, 87, 0.14);
}

.status-pending {
    color: var(--warning);
    background: rgba(255, 165, 2, 0.16);
}

/* ---- Badges ---- */
.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 0.72em;
    font-weight: 700;
    background: var(--primary);
    color: #fff;
    vertical-align: middle;
}

.badge.beta {
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
}

.badge.new {
    background: linear-gradient(135deg, #2ed573, #1dd1a1);
}

/* ---- Tables ---- */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    border-radius: var(--radius-sm);
    overflow: hidden;
}

th {
    background: var(--hover);
    padding: 13px 14px;
    text-align: left;
    font-weight: 700;
    font-size: 0.9em;
}

td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 0.92em;
    vertical-align: top;
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr:hover {
    background: var(--hover);
}

.table-wrap {
    overflow-x: auto;
}

/* ---- Code ---- */
code {
    font-family: var(--mono);
    background: var(--code-bg);
    color: var(--code-text);
    padding: 2px 6px;
    border-radius: 5px;
    font-size: 0.9em;
}

pre {
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 18px;
    overflow-x: auto;
    font-family: var(--mono);
    font-size: 0.86em;
}

pre code {
    background: none;
    padding: 0;
    color: var(--text);
}

.endpoint-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--code-bg);
    border-left: 4px solid var(--primary);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    padding: 12px 16px;
    font-family: var(--mono);
    margin: 16px 0;
    overflow-x: auto;
}

.endpoint-bar .method {
    font-weight: 800;
    color: var(--success);
}

/* ---- Note ---- */
.note {
    background: var(--primary-soft);
    border-left: 4px solid var(--primary);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    padding: 14px 18px;
    margin: 18px 0;
    font-size: 0.94em;
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 10px 18px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 0.95em;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
}

.btn:hover {
    transform: translateY(-2px);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    color: #fff;
    box-shadow: 0 6px 18px rgba(255, 71, 87, 0.32);
}

.btn-ghost {
    background: var(--surface-solid);
    color: var(--text);
    border-color: var(--border);
}

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

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85em;
}

/* ---- Online debugger ---- */
.debugger {
    display: grid;
    grid-template-columns: minmax(280px, 1fr) minmax(280px, 1.1fr);
    gap: 20px;
    align-items: start;
}

.dbg-panel {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 18px;
}

.dbg-panel h4 {
    margin: 0 0 14px;
    font-size: 1em;
}

.field {
    margin-bottom: 14px;
}

.field label {
    display: block;
    font-weight: 600;
    font-size: 0.85em;
    margin-bottom: 5px;
}

.field .hint {
    color: var(--text-muted);
    font-weight: 400;
    font-size: 0.92em;
}

.field input[type="text"],
.field input[type="number"],
.field select,
.modal input,
.modal textarea,
.modal select {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface-solid);
    color: var(--text);
    font-size: 0.92em;
    font-family: inherit;
}

.field input:focus,
.field select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.switch-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 18px;
}

.switch-row label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
    font-size: 0.9em;
    cursor: pointer;
}

.dbg-url {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--code-bg);
    border-radius: 9px;
    padding: 10px 12px;
    font-family: var(--mono);
    font-size: 0.82em;
    word-break: break-all;
    margin: 4px 0 14px;
}

.dbg-url .u {
    flex: 1;
    color: var(--code-text);
}

.dbg-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.dbg-note {
    margin: -4px 0 12px;
    font-size: 0.8em;
    color: var(--text-muted);
    line-height: 1.5;
}

.dbg-result {
    min-height: 220px;
}

.dbg-preview {
    width: 100%;
    border-radius: var(--radius-sm);
    border: 1px dashed var(--border);
    min-height: 200px;
    display: grid;
    place-items: center;
    overflow: hidden;
    background: var(--code-bg);
}

.dbg-preview img {
    max-width: 100%;
    max-height: 460px;
    display: block;
}

.dbg-preview .placeholder {
    color: var(--text-muted);
    padding: 30px;
    text-align: center;
}

.dbg-meta {
    margin-top: 12px;
    max-height: 320px;
    overflow: auto;
    font-size: 0.82em;
}

.tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
}

.tabs button {
    border: 1px solid var(--border);
    background: var(--surface-solid);
    color: var(--text-muted);
    padding: 6px 14px;
    border-radius: 9px;
    font-weight: 600;
    font-size: 0.85em;
    cursor: pointer;
}

.tabs button.active {
    background: var(--primary-soft);
    color: var(--primary);
    border-color: transparent;
}

/* ---- Preview grid (images / records) ---- */
.preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

.media-card {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition);
}

.media-card:hover {
    transform: translateY(-4px);
}

.media-card img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    cursor: pointer;
    display: block;
    background: var(--code-bg);
}

.media-card .info {
    padding: 12px 14px;
}

.media-card .info h4 {
    margin: 0 0 4px;
    font-size: 0.95em;
}

.media-card .info p {
    margin: 0;
    font-size: 0.8em;
    color: var(--text-muted);
    word-break: break-all;
}

.media-card .info .dl {
    display: inline-block;
    margin-top: 8px;
    font-size: 0.82em;
    font-weight: 600;
    color: var(--primary);
    text-decoration: none;
}

.media-card .info .dl:hover {
    text-decoration: underline;
}

/* ---- Connectivity grid ---- */
.conn-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 12px;
    margin-top: 14px;
}

.conn-card {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    box-shadow: var(--shadow-sm);
}

.conn-card .t {
    font-weight: 700;
    margin-bottom: 8px;
}

.conn-card .d {
    color: var(--text-muted);
    font-size: 0.88em;
    margin-top: 8px;
    word-break: break-all;
}

/* ---- Recent list rows ---- */
.recent-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.recent-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9em;
}

.recent-row .tag {
    background: var(--primary-soft);
    color: var(--primary);
    padding: 2px 9px;
    border-radius: 20px;
    font-size: 0.8em;
    font-weight: 700;
    flex-shrink: 0;
}

.recent-row .name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.recent-row .time {
    color: var(--text-muted);
    font-size: 0.85em;
    flex-shrink: 0;
}

.recent-row .dl {
    flex-shrink: 0;
    font-size: 0.85em;
    font-weight: 600;
    color: var(--primary);
    text-decoration: none;
}

.recent-row .dl:hover {
    text-decoration: underline;
}

/* ---- Modal (full image) ---- */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(0, 0, 0, 0.88);
    backdrop-filter: blur(4px);
}

.modal.show {
    display: grid;
    place-items: center;
}

.modal img {
    max-width: 92%;
    max-height: 92vh;
    border-radius: 10px;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.4);
}

.modal .close {
    position: absolute;
    top: 18px;
    right: 26px;
    color: #fff;
    font-size: 36px;
    cursor: pointer;
    line-height: 1;
}

/* ---- Toast ---- */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translate(-50%, 120%);
    padding: 12px 22px;
    background: var(--text);
    color: var(--bg);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    z-index: 3000;
    opacity: 0;
    transition: transform var(--transition), opacity var(--transition);
    font-weight: 600;
}

.toast.show {
    transform: translate(-50%, 0);
    opacity: 1;
}

/* ---- Chips ---- */
.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chip {
    background: var(--hover);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 20px;
    padding: 5px 12px;
    font-size: 0.85em;
    font-weight: 600;
}

/* ---- Footer ---- */
.footer {
    text-align: center;
    padding: 30px 0;
    color: var(--text-muted);
    font-size: 0.88em;
}

.footer a {
    color: var(--text-muted);
}

.footer a:hover {
    color: var(--primary);
}

/* ---- Details / changelog ---- */
details {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin: 10px 0;
    overflow: hidden;
}

details summary {
    padding: 13px 16px;
    cursor: pointer;
    font-weight: 600;
    list-style: none;
}

details summary::-webkit-details-marker {
    display: none;
}

details summary::before {
    content: '▸';
    margin-right: 8px;
    color: var(--primary);
}

details[open] summary::before {
    content: '▾';
}

details .body {
    padding: 0 16px 14px;
}

/* ---- Responsive ---- */
@media (max-width: 860px) {
    .debugger {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 720px) {
    .topbar {
        flex-wrap: wrap;
        padding: 10px 16px;
    }

    .topbar .nav {
        order: 3;
        width: 100%;
        overflow-x: auto;
        margin-left: 0;
    }

    .container {
        padding: 0 14px 50px;
    }

    .card {
        padding: 20px;
    }
}
