:root {
    --bg: #0f1117;
    --surface: #1a1d27;
    --surface-hover: #222632;
    --border: #2a2e3a;
    --text: #e4e5e9;
    --text-muted: #8b8fa3;
    --primary: #6366f1;
    --primary-hover: #818cf8;
    --danger: #ef4444;
    --danger-hover: #f87171;
    --success: #22c55e;
    --success-bg: rgba(34, 197, 94, 0.12);
    --error-bg: rgba(239, 68, 68, 0.12);
    --radius: 8px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --mono: "SF Mono", "Fira Code", "Fira Mono", Menlo, monospace;
}

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

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* Header */
header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.header-inner {
    max-width: 960px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    gap: 16px;
}

header h1 {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

header nav { display: flex; gap: 8px; }

.back-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 14px;
    margin-right: 16px;
}
.back-link:hover { color: var(--text); }

/* Main */
main {
    max-width: 960px;
    margin: 0 auto;
    padding: 32px 24px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font-size: 14px;
    font-family: var(--font);
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
}
.btn:hover { background: var(--surface-hover); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--text); background: var(--surface-hover); }
.btn-sm { padding: 5px 12px; font-size: 13px; }

/* Flash */
.flash {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 24px;
    font-size: 14px;
}
.flash.success { background: var(--success-bg); color: var(--success); border: 1px solid rgba(34,197,94,0.2); }
.flash.error { background: var(--error-bg); color: var(--danger); border: 1px solid rgba(239,68,68,0.2); }

/* Site grid */
.site-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

.site-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    transition: border-color 0.15s;
}
.site-card:hover { border-color: var(--primary); }

.site-card-header {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 12px;
}
.site-card-header h2 { font-size: 16px; font-weight: 600; }
.site-slug {
    font-family: var(--mono);
    font-size: 12px;
    color: var(--text-muted);
    background: var(--bg);
    padding: 2px 6px;
    border-radius: 4px;
}

.site-card-platforms {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
}

.platform-badge {
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 4px;
    letter-spacing: 0.05em;
}
.platform-badge.on { background: var(--success-bg); color: var(--success); }
.platform-badge.off { background: var(--bg); color: var(--text-muted); }

.site-card-details {
    font-size: 13px;
    color: var(--text-muted);
    font-family: var(--mono);
    margin-bottom: 16px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.site-card-actions {
    display: flex;
    gap: 8px;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 64px 24px;
    color: var(--text-muted);
}
.empty-state p { margin-bottom: 16px; }

/* Forms */
.site-form { max-width: 680px; }

fieldset {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
}

legend {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    padding: 0 8px;
}

label {
    display: block;
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

label:last-child { margin-bottom: 0; }

input[type="text"],
input[type="email"],
input[type="number"],
textarea {
    display: block;
    width: 100%;
    margin-top: 4px;
    padding: 9px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 14px;
    font-family: var(--mono);
    transition: border-color 0.15s;
}
input:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
}
textarea { resize: vertical; font-size: 13px; }

small {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-muted);
    opacity: 0.7;
}

.field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.field-row-3 {
    grid-template-columns: 1fr 1fr 1fr;
}

/* Toggle switch */
.toggle-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
    color: var(--text);
}

.toggle-label input[type="checkbox"] {
    display: none;
}

.toggle-switch {
    position: relative;
    width: 40px;
    height: 22px;
    background: var(--border);
    border-radius: 11px;
    transition: background 0.2s;
    flex-shrink: 0;
}
.toggle-switch::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: all 0.2s;
}
.toggle-label input:checked + .toggle-switch {
    background: var(--primary);
}
.toggle-label input:checked + .toggle-switch::after {
    left: 21px;
    background: #fff;
}

.toggle-label small {
    margin-top: 0;
    margin-left: auto;
}

.form-actions {
    display: flex;
    gap: 12px;
    padding-top: 8px;
}

/* Confirm box */
.confirm-box {
    max-width: 480px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
}
.confirm-box p { margin-bottom: 12px; }
.confirm-warning {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 24px !important;
}

/* Login */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px;
    width: 100%;
    max-width: 360px;
    text-align: center;
}
.login-box h1 {
    font-size: 24px;
    margin-bottom: 24px;
    letter-spacing: -0.03em;
}
.login-box label {
    text-align: left;
}
.login-box button {
    width: 100%;
    margin-top: 8px;
}

/* Guide */
.guide { max-width: 720px; }

.guide-nav {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 32px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}
.guide-nav-item {
    padding: 6px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-muted);
    font-size: 13px;
    text-decoration: none;
    transition: all 0.15s;
}
.guide-nav-item:hover { color: var(--text); border-color: var(--primary); }

.guide-section {
    margin-bottom: 48px;
}
.guide-section h2 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 8px;
    letter-spacing: -0.02em;
}
.guide-section > p {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 24px;
}

.guide-step {
    display: flex;
    gap: 16px;
    margin-bottom: 28px;
}
.guide-step:last-child { margin-bottom: 0; }

.step-num {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    background: var(--primary);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    margin-top: 2px;
}

.guide-step h3 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 6px;
}
.guide-step p {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 8px;
}
.guide-step p:last-child { margin-bottom: 0; }

.guide-step ul, .guide-step ol {
    font-size: 14px;
    color: var(--text-muted);
    padding-left: 20px;
    margin-bottom: 8px;
}
.guide-step li { margin-bottom: 4px; }

.code-block {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px 16px;
    font-family: var(--mono);
    font-size: 12.5px;
    line-height: 1.7;
    color: var(--text);
    overflow-x: auto;
    margin-bottom: 10px;
    white-space: pre-wrap;
    word-break: break-all;
}
.code-block .ph {
    color: var(--primary-hover);
    font-style: italic;
}

.guide-callout {
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 6px;
    padding: 12px 16px;
    font-size: 13px;
    color: var(--text);
    margin-bottom: 10px;
    line-height: 1.7;
}

.guide-step code {
    font-family: var(--mono);
    font-size: 12.5px;
    background: var(--bg);
    padding: 2px 5px;
    border-radius: 3px;
    color: var(--primary-hover);
}

@media (max-width: 640px) {
    .field-row, .field-row-3 { grid-template-columns: 1fr; }
    .site-grid { grid-template-columns: 1fr; }
}
