/* ── Dark Mode Variables ── */
html[data-theme="dark"] {
    --primary: #818cf8;
    --primary-hover: #6366f1;
    --primary-light: #1e1b4b;
    --success: #34d399;
    --danger: #f87171;
    --text: #f1f5f9;
    --text-secondary: #94a3b8;
    --border: #334155;
    --surface: #1e293b;
    --bg: #0f172a;
    --shadow: 0 1px 3px rgba(0,0,0,.4), 0 1px 2px rgba(0,0,0,.3);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,.4), 0 2px 4px -2px rgba(0,0,0,.3);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.5), 0 4px 6px -4px rgba(0,0,0,.4);
}

/* ── Dark Mode Toggle Button ── */
.btn-dark-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: none;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    transition: background .15s, color .15s, border-color .15s;
    flex-shrink: 0;
    padding: 0;
}
.btn-dark-toggle:hover {
    background: var(--bg);
    color: var(--text);
}
.btn-dark-toggle svg {
    width: 16px;
    height: 16px;
    pointer-events: none;
}
.btn-dark-toggle .icon-sun { display: none; }
.btn-dark-toggle .icon-moon { display: block; }
html[data-theme="dark"] .btn-dark-toggle .icon-sun { display: block; }
html[data-theme="dark"] .btn-dark-toggle .icon-moon { display: none; }

/* login page floating toggle */
.btn-dark-toggle-float {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background .15s, color .15s;
    box-shadow: var(--shadow-md);
}
.btn-dark-toggle-float:hover { color: var(--text); }
.btn-dark-toggle-float svg { width: 18px; height: 18px; pointer-events: none; }
.btn-dark-toggle-float .icon-sun { display: none; }
.btn-dark-toggle-float .icon-moon { display: block; }
html[data-theme="dark"] .btn-dark-toggle-float .icon-sun { display: block; }
html[data-theme="dark"] .btn-dark-toggle-float .icon-moon { display: none; }

/* ── Navbar ── */
html[data-theme="dark"] .navbar {
    background: rgba(15,23,42,.96);
}
html[data-theme="dark"] .nav-overflow-panel {
    background: rgba(15,23,42,.97);
}
html[data-theme="dark"] .nav-link:hover {
    background: #1e293b;
    color: var(--text);
}
html[data-theme="dark"] .nav-link.active {
    background: #1e1b4b;
}
html[data-theme="dark"] .notif-bell:hover {
    background: #1e293b;
    color: var(--text);
}
html[data-theme="dark"] .notif-dot {
    border-color: #0f172a;
}

/* ── Notification Dropdown ── */
html[data-theme="dark"] .notif-dropdown {
    background: #1e293b;
    border-color: #334155;
}
html[data-theme="dark"] .notif-header {
    border-bottom-color: #334155;
}
html[data-theme="dark"] .notif-item {
    border-bottom-color: #334155;
    color: var(--text);
}
html[data-theme="dark"] .notif-item:hover {
    background: #273344;
}
html[data-theme="dark"] .notif-item.unread {
    background: #1e1b4b;
}
html[data-theme="dark"] .notif-item.unread:hover {
    background: #2d2a5e;
}
html[data-theme="dark"] .notif-delete-btn:hover {
    background: #3d1515;
    color: #f87171;
}

/* ── Buttons ── */
html[data-theme="dark"] .btn-nav-logout,
html[data-theme="dark"] .btn-logout {
    background: #2d1515;
    color: #f87171;
}
html[data-theme="dark"] .btn-nav-logout:hover,
html[data-theme="dark"] .btn-logout:hover {
    background: #3d1515;
}
html[data-theme="dark"] .btn-secondary {
    background: #1e293b;
    color: var(--text);
    border-color: #334155;
}
html[data-theme="dark"] .btn-secondary:hover {
    background: #334155;
}

/* ── Inputs / Forms ── */
html[data-theme="dark"] input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="submit"]):not([type="button"]),
html[data-theme="dark"] textarea,
html[data-theme="dark"] select {
    background: #1e293b;
    color: var(--text);
    border-color: #334155;
}
html[data-theme="dark"] input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="submit"]):not([type="button"]):focus,
html[data-theme="dark"] textarea:focus {
    background: #1e293b;
    border-color: #818cf8;
}
html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder {
    color: #475569;
}
html[data-theme="dark"] input:disabled,
html[data-theme="dark"] textarea:disabled,
html[data-theme="dark"] select:disabled {
    opacity: .5;
}

/* ── Progress Track ── */
html[data-theme="dark"] .progress-track {
    background: #334155;
}

/* ── Common Card Patterns ── */
html[data-theme="dark"] .mini-idx-row {
    background: #1e293b;
}
html[data-theme="dark"] .mini-rank-item {
    background: #1e293b;
}
html[data-theme="dark"] .party-card.full {
    background: #0f172a;
}
html[data-theme="dark"] .member-chip {
    background: #1e293b;
}
html[data-theme="dark"] .member-chip.is-host {
    background: #1e1b4b;
    border-color: #4338ca;
}

/* ── Party / LFG Badges ── */
html[data-theme="dark"] .pbadge-fun {
    background: #052e16;
    color: #34d399;
}
html[data-theme="dark"] .pbadge-hard {
    background: #2d1515;
    color: #f87171;
}
html[data-theme="dark"] .pbadge-rank {
    background: #2e1065;
    color: #c4b5fd;
}
html[data-theme="dark"] .pbadge-normal {
    background: #1e293b;
    color: #94a3b8;
}
html[data-theme="dark"] .pbadge-voice {
    background: #2d1b00;
    color: #fbbf24;
}
html[data-theme="dark"] .pbadge-host {
    background: #1e1b4b;
    color: #818cf8;
}

/* ── Party Status Badges ── */
html[data-theme="dark"] .party-status.open {
    background: #052e16;
    color: #34d399;
}
html[data-theme="dark"] .party-status.full {
    background: #1e293b;
    color: #94a3b8;
}

/* ── Join Buttons ── */
html[data-theme="dark"] .btn-join:disabled {
    background: #334155;
    color: #64748b;
}
html[data-theme="dark"] .btn-join.is-mine {
    background: #052e16;
    color: #34d399;
    border-color: #166534;
}
html[data-theme="dark"] .btn-join.is-host {
    background: #1e1b4b;
    color: #818cf8;
    border-color: #4338ca;
}
html[data-theme="dark"] .btn-dissolve {
    border-color: #334155;
}

/* ── Write Page Topbar ── */
html[data-theme="dark"] .write-topbar {
    background: rgba(15,23,42,.97);
}
html[data-theme="dark"] .btn-back {
    background: #1e293b;
    color: var(--text-secondary);
    border-color: #334155;
}
html[data-theme="dark"] .btn-back:hover {
    background: #334155;
    color: var(--text);
}
html[data-theme="dark"] .draft-status {
    color: var(--text-secondary);
}

/* ── Login Page ── */
html[data-theme="dark"] .card {
    background: var(--surface);
    border-color: rgba(255,255,255,.06);
}
html[data-theme="dark"] body {
    background-image: radial-gradient(ellipse 80% 60% at 50% -20%, rgba(99,102,241,.18), transparent);
}

/* ── Tables ── */
html[data-theme="dark"] table {
    border-color: #334155;
}
html[data-theme="dark"] th {
    background: #1e293b;
    color: var(--text);
    border-color: #334155;
}
html[data-theme="dark"] td {
    border-color: #334155;
}
html[data-theme="dark"] tr:nth-child(even) td {
    background: #1a2535;
}
html[data-theme="dark"] tr:hover td {
    background: #273344;
}

/* ── Misc Hardcoded bg overrides ── */
html[data-theme="dark"] .feature-card:hover {
    border-color: #4338ca;
}
html[data-theme="dark"] .party-empty {
    border-color: #334155;
}
html[data-theme="dark"] .ws-dot {
    background: #475569;
}
html[data-theme="dark"] .ws-dot.live {
    background: #34d399;
}

/* ── Quill Editor (write.html) ── */
/* specificity must beat: #editor-wrap .ql-toolbar.ql-snow (0,1,2,0) */
html[data-theme="dark"] #editor-wrap .ql-toolbar.ql-snow {
    background: #1e293b;
    border-color: #334155;
}
html[data-theme="dark"] #editor-wrap .ql-container.ql-snow {
    background: #1e293b;
    border-color: #334155;
}
html[data-theme="dark"] #editor-wrap .ql-editor {
    color: #f1f5f9;
    background: #1e293b;
}
html[data-theme="dark"] #editor-wrap .ql-editor.ql-blank::before {
    color: #475569;
}
html[data-theme="dark"] #editor-wrap .ql-snow .ql-stroke { stroke: #94a3b8; }
html[data-theme="dark"] #editor-wrap .ql-snow .ql-fill  { fill:   #94a3b8; }
html[data-theme="dark"] #editor-wrap .ql-snow.ql-toolbar button:hover .ql-stroke,
html[data-theme="dark"] #editor-wrap .ql-snow.ql-toolbar button.ql-active .ql-stroke { stroke: #818cf8; }
html[data-theme="dark"] #editor-wrap .ql-snow.ql-toolbar button:hover .ql-fill,
html[data-theme="dark"] #editor-wrap .ql-snow.ql-toolbar button.ql-active .ql-fill  { fill:   #818cf8; }
html[data-theme="dark"] #editor-wrap .ql-snow .ql-picker-label { color: #94a3b8; }
html[data-theme="dark"] #editor-wrap .ql-snow .ql-picker-label:hover,
html[data-theme="dark"] #editor-wrap .ql-snow .ql-picker.ql-expanded .ql-picker-label { color: #818cf8; }
html[data-theme="dark"] #editor-wrap .ql-snow .ql-picker-options {
    background: #1e293b;
    border-color: #334155;
}
html[data-theme="dark"] #editor-wrap .ql-snow .ql-picker-item { color: #f1f5f9; }
html[data-theme="dark"] #editor-wrap .ql-snow .ql-picker-item:hover { color: #818cf8; }
/* code block / blockquote in editor */
html[data-theme="dark"] #editor-wrap .ql-editor blockquote {
    border-left-color: #334155;
    color: #94a3b8;
}
html[data-theme="dark"] #editor-wrap .ql-editor pre.ql-syntax {
    background: #0f172a;
    color: #e2e8f0;
}

/* ── Write page: extras & title ── */
/* .extras-header specificity (0,0,1,0) — dark-mode attr+class (0,0,2,0) wins */
html[data-theme="dark"] .extras-header { background: #0f172a; }
html[data-theme="dark"] .extra-input   { background: #1e293b; }
html[data-theme="dark"] .title-input::placeholder { color: #475569; }
html[data-theme="dark"] .title-input   { border-bottom-color: #334155; }

/* ── Chat: Post rows / Notice / Series ── */
html[data-theme="dark"] .post-row:hover { background: #1e293b; }
html[data-theme="dark"] .post-row.notice-row {
    background: #1e1b4b;
    border-left-color: #818cf8;
}
html[data-theme="dark"] .post-row.notice-row:hover { background: #2d2a5e; }
html[data-theme="dark"] .post-row.notice-row .post-row-title { color: #a5b4fc; }
html[data-theme="dark"] .series-card.expanded { border-color: #0891b2; }
html[data-theme="dark"] .series-card-header:hover { background: #1e293b; }
html[data-theme="dark"] .series-card.expanded .series-card-header { background: #0c1929; }
html[data-theme="dark"] .series-episodes {
    background: #111827;
    border-top-color: #334155;
}
html[data-theme="dark"] .series-ep-item:hover { background: #1e3a4c; }
html[data-theme="dark"] .board-tab:hover { background: #1e293b; color: var(--text); }

/* ── Virtual: Asset Bar ── */
html[data-theme="dark"] .asset-bar { background: rgba(15,23,42,.97); }

/* ── Market: KR index / stock table hover ── */
html[data-theme="dark"] .kr-index-card { background: var(--surface); border-color: var(--border); }
html[data-theme="dark"] .kr-stock-row:hover td { background: #1e293b; }
html[data-theme="dark"] .tab-btn:hover { background: #1e293b; }
html[data-theme="dark"] .tab-btn.active { background: var(--primary); color: #fff; }

/* ── Scrollbar (Webkit) ── */
html[data-theme="dark"] ::-webkit-scrollbar-track {
    background: #0f172a;
}
html[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 4px;
}
html[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
    background: #475569;
}
