:root {
    /* Dark theme (default) */
    color-scheme: dark;
    --bg: #0b1020;
    --surface: #0f172a;
    --text: #e5e7eb;
    --muted: #9ca3af;
    --border: #22314a;

    --primary: #60a5fa;
    --primary-600: #3b82f6;
    --primary-700: #2563eb;
    --primary-border: rgba(96, 165, 250, 0.35);
    --focus-border: rgba(96, 165, 250, 0.65);
    --focus-shadow: rgba(96, 165, 250, 0.25);

    --radius: 12px;
    --shadow: 0 14px 40px rgba(0, 0, 0, 0.55);
    --shadow-sm: 0 6px 18px rgba(0, 0, 0, 0.35);

    --soft: rgba(255, 255, 255, 0.06);
    --tile-fade: rgba(15, 23, 42, 0);

    --glow-blue: rgba(96, 165, 250, 0.16);
    --glow-violet: rgba(139, 92, 246, 0.12);
    --hero-grad-1: rgba(96, 165, 250, 0.16);
    --hero-grad-2: rgba(139, 92, 246, 0.12);
    --spinner-track: rgba(96, 165, 250, 0.22);

    /* Accent palette (used for tiles/highlights) */
    --accent-blue: #60a5fa;
    --accent-emerald: #34d399;
    --accent-amber: #fbbf24;
    --accent-violet: #a78bfa;
    --accent-rose: #fb7185;
}

:root[data-theme="light"] {
    color-scheme: light;
    --bg: #f6f8fb;
    --surface: #ffffff;
    --text: #111827;
    --muted: #6b7280;
    --border: #e5e7eb;

    --primary: #2563eb;
    --primary-600: #1d4ed8;
    --primary-700: #1e40af;
    --primary-border: rgba(37, 99, 235, 0.35);
    --focus-border: rgba(37, 99, 235, 0.55);
    --focus-shadow: rgba(37, 99, 235, 0.15);

    --shadow: 0 10px 30px rgba(17, 24, 39, 0.10);
    --shadow-sm: 0 2px 10px rgba(17, 24, 39, 0.08);

    --soft: rgba(17, 24, 39, 0.04);
    --tile-fade: rgba(255, 255, 255, 0);

    --glow-blue: rgba(37, 99, 235, 0.10);
    --glow-violet: rgba(139, 92, 246, 0.08);
    --hero-grad-1: rgba(37, 99, 235, 0.10);
    --hero-grad-2: rgba(139, 92, 246, 0.08);
    --spinner-track: rgba(37, 99, 235, 0.18);

    --accent-blue: #2563eb;
    --accent-emerald: #10b981;
    --accent-amber: #f59e0b;
    --accent-violet: #8b5cf6;
    --accent-rose: #f43f5e;
}

html,
body {
    height: 100%;
}

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji",
        "Segoe UI Emoji";
    color: var(--text);
    background:
        radial-gradient(900px 420px at 15% 0%, var(--glow-blue), transparent 60%),
        radial-gradient(800px 360px at 85% 10%, var(--glow-violet), transparent 55%),
        var(--bg);
}

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

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

header .navbar {
    background-color: var(--surface) !important;
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1rem;
}

/* Bootstrap uses .navbar-light (black-ish links). Force theme colors instead. */
header .navbar.navbar-light .navbar-nav .nav-link,
header .navbar.navbar-light .navbar-nav .nav-link:focus {
    color: var(--text) !important;
}

header .navbar.navbar-light .navbar-nav .nav-link:hover {
    color: var(--primary) !important;
}

header .navbar.navbar-light .navbar-nav .active>.nav-link,
header .navbar.navbar-light .navbar-nav .nav-link.active {
    color: var(--text) !important;
}

header .navbar .navbar-brand {
    font-weight: 700;
    letter-spacing: 0.2px;
    background: linear-gradient(90deg, var(--accent-blue), var(--accent-violet));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

header .navbar .navbar-brand:hover {
    background: none;
    -webkit-text-fill-color: var(--primary);
}

.navbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.navbar-action {
    display: inline-flex;
    align-items: center;
    height: 34px;
    padding: 0 12px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    text-decoration: none;
    font-size: 0.95rem;
}

button.navbar-action {
    appearance: none;
    cursor: pointer;
    font: inherit;
}

.navbar-action:hover {
    border-color: var(--primary-border);
    color: var(--primary);
    text-decoration: none;
}

.navbar-user {
    display: inline-flex;
    align-items: center;
    height: 34px;
    padding: 0 12px;
    border-radius: 999px;
    background: var(--soft);
    border: 1px solid var(--border);
    color: var(--muted);
}

.header-extras {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
    color: var(--muted);
    font-size: 0.95rem;
    white-space: nowrap;
}

/* Shared page spacing */
.container,
.container-fluid {
    padding-top: 24px;
    padding-bottom: 24px;
}

/* Centered panels (index/login/settings/about) */
.center {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 140px);
    padding: 24px 16px;
}

/* Cards: keep Bootstrap card markup, improve visuals */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card .card-body {
    padding: 2rem;
}

/* Forms */
.form-row>[class^="col"] {
    margin-bottom: 12px;
}

input.form-control,
select.custom-select {
    background: var(--surface);
    color: var(--text);
    border-radius: 10px;
    border-color: var(--border);
}

input.form-control {
    height: 44px;
    line-height: 42px;
    padding: 0 0.85rem;
}

/* Fix select text sitting low in Chrome by using a deterministic height/line-height. */
select.custom-select {
    height: 44px;
    line-height: 42px;
    padding: 0 2.25rem 0 0.85rem;
}

input.form-control::placeholder {
    color: var(--muted);
}

input.form-control:focus,
select.custom-select:focus {
    border-color: var(--focus-border);
    box-shadow: 0 0 0 0.2rem var(--focus-shadow);
}

.btn {
    border-radius: 10px;
    padding: 0.55rem 0.95rem;
}

.btn.btn-primary {
    background-color: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 8px 18px rgba(37, 99, 235, 0.18);
}

.btn.btn-primary:hover {
    background-color: var(--primary-600);
    border-color: var(--primary-600);
    box-shadow: 0 10px 22px rgba(37, 99, 235, 0.22);
}

/* App panels for Characters/Tasks */
.task-form,
.character-form {
    margin: 16px 0 24px;
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

/* Lists (tasks/characters) */
.list-group-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: var(--surface);
    border-color: var(--border);
    color: var(--text);
}

.list-group-item span {
    margin: 0;
}

/* Tasks list: keep status/date vertically aligned and avoid wrapping (wrap makes center-aligned text look "low"). */
.checked-list-box .list-group-item {
    justify-content: flex-start;
}

.checked-list-box .list-group-item span {
    display: inline-flex;
    align-items: center;
    line-height: 1.15;
}

/* Task name takes remaining space */
.checked-list-box .list-group-item span:nth-of-type(1) {
    flex: 1;
    min-width: 0;
}

/* Status + date stay on one line and align to the right */
.checked-list-box .list-group-item span:nth-of-type(2),
.checked-list-box .list-group-item span:nth-of-type(3) {
    white-space: nowrap;
}

.checked-list-box .list-group-item span:nth-of-type(2) {
    margin-left: auto;
}

.checked-list-box .list-group-item span:nth-of-type(3) {
    color: var(--muted);
    font-size: 0.92rem;
}

footer {
    margin-top: auto;
    padding: 14px 0;
    border-top: 1px solid var(--border);
    background: var(--surface);
}

footer .author {
    margin-left: 0;
    color: var(--muted);
    font-size: 0.95rem;
}

/* Home dashboard */
.hero {
    background:
        linear-gradient(135deg, var(--hero-grad-1), var(--hero-grad-2)),
        var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 24px;
}

.hero h1 {
    font-size: 1.75rem;
    margin-bottom: 8px;
}

.hero p {
    color: var(--muted);
    margin-bottom: 0;
}

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

.panel h2 {
    font-size: 1.1rem;
    margin-bottom: 8px;
}

.panel p,
.panel li {
    color: var(--muted);
}

.empty-state {
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    padding: 18px;
    text-align: center;
    color: var(--muted);
}

.empty-state.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.empty-state.loading::before {
    content: "";
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid var(--spinner-track);
    border-top-color: var(--primary);
    animation: spin 0.8s linear infinite;
}

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

.tile-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-top: 16px;
}

@media (max-width: 992px) {
    .tile-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 576px) {
    .tile-grid {
        grid-template-columns: 1fr;
    }
}

.tile {
    display: block;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 18px;
    text-decoration: none;
    color: var(--text);
    transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
    position: relative;
    overflow: hidden;
    --tile-accent: var(--primary);
}

.tile::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 4px;
    background: linear-gradient(90deg, var(--tile-accent), var(--tile-fade));
    opacity: 0.9;
}

.tile:hover {
    transform: translateY(-2px);
    border-color: var(--primary-border);
    box-shadow: var(--shadow);
    text-decoration: none;
}

.tile--blue {
    --tile-accent: var(--accent-blue);
}

.tile--emerald {
    --tile-accent: var(--accent-emerald);
}

.tile--amber {
    --tile-accent: var(--accent-amber);
}

.tile--violet {
    --tile-accent: var(--accent-violet);
}

.tile--rose {
    --tile-accent: var(--accent-rose);
}

.tile-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
    font-weight: 700;
}

.tile-desc {
    color: var(--muted);
    margin: 0;
}

.kbd {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.85rem;
    color: var(--muted);
    background: var(--soft);
    border: 1px solid var(--border);
    padding: 2px 8px;
    border-radius: 999px;
    white-space: nowrap;
}

/* Bootstrap helpers: make sure "light" utilities don't stay white in dark mode */
:root:not([data-theme="light"]) .bg-light,
:root:not([data-theme="light"]) .bg-white {
    background-color: var(--surface) !important;
}

:root:not([data-theme="light"]) .text-dark {
    color: var(--text) !important;
}

:root:not([data-theme="light"]) .text-muted {
    color: var(--muted) !important;
}

:root:not([data-theme="light"]) .border,
:root:not([data-theme="light"]) .border-top,
:root:not([data-theme="light"]) .border-right,
:root:not([data-theme="light"]) .border-bottom,
:root:not([data-theme="light"]) .border-left {
    border-color: var(--border) !important;
}