:root {
    color-scheme: light dark;
    --bg: #f5f7fb;
    --surface: #ffffff;
    --border: #dde3ee;
    --text: #1c2536;
    --text-muted: #667085;

    --accent: #2563eb;
    --accent-dark: #1d4ed8;
    --accent-light: #eaf0ff;
    --accent-contrast: #ffffff;

    --error: #dc2626;
    --error-bg: #fdecec;
    --success-bg: #eaf6ee;
    --success-border: #34a065;

    --radius: 10px;
    --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #10141f;
        --surface: #171d2b;
        --border: #2a3244;
        --text: #e6e9f2;
        --text-muted: #94a0b8;

        --accent: #5b8def;
        --accent-dark: #7ea4f2;
        --accent-light: #1c2740;
        --accent-contrast: #0b0f18;

        --error: #f87171;
        --error-bg: #3a1c1c;
        --success-bg: #113224;
        --success-border: #2f9e64;

        --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 2px 6px rgba(0, 0, 0, 0.35);
    }
}

* {
    box-sizing: border-box;
}

body {
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
    margin: 0;
    line-height: 1.55;
    background: var(--bg);
    color: var(--text);
}

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 1.75rem 1.5rem 3rem;
}

h1, h2, h3 {
    line-height: 1.25;
    letter-spacing: -0.01em;
}

h1 {
    font-size: 1.75rem;
    margin-bottom: 1rem;
}

h2 {
    font-size: 1.2rem;
    margin: 2rem 0 0.75rem;
    color: var(--text);
}

h3 {
    font-size: 1.05rem;
    margin: 1.5rem 0 0.5rem;
}

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

a:hover {
    text-decoration: underline;
}

.details-list {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 0.9rem 1.25rem;
    list-style: none;
}

.alert {
    border-radius: var(--radius);
    padding: 0.8rem 1.1rem;
    margin: 1rem 0;
    border: 1px solid transparent;
}

.alert-success {
    background: var(--success-bg);
    border-color: var(--success-border);
}

.alert-error {
    background: var(--error-bg);
    border-color: var(--error);
    color: var(--error);
}

button,
input[type="submit"] {
    background: var(--accent);
    color: var(--accent-contrast);
    border: none;
    border-radius: 8px;
    padding: 0.55rem 1.1rem;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    transition: background 0.15s ease, transform 0.05s ease;
}

button:hover,
input[type="submit"]:hover {
    background: var(--accent-dark);
}

button:active {
    transform: translateY(1px);
}

form.stacked {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem 1.5rem 1.5rem;
    max-width: 640px;
}

form.stacked label {
    display: block;
    margin-top: 0.9rem;
    font-weight: 600;
    font-size: 0.92rem;
    color: var(--text);
}

form.stacked input,
form.stacked select,
form.stacked textarea {
    width: 100%;
    padding: 0.5rem 0.65rem;
    margin-top: 0.3rem;
    border: 1px solid var(--border);
    border-radius: 7px;
    font: inherit;
    background: var(--bg);
    color: var(--text);
}

form.stacked input:focus,
form.stacked select:focus,
form.stacked textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.app-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.nav {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 0.85rem 1.5rem;
    flex-wrap: wrap;
    max-width: 960px;
    margin: 0 auto;
}

.nav a {
    color: var(--text-muted);
    font-weight: 500;
}

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

.nav .brand {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--accent);
}

.nav .spacer {
    flex: 1;
}

.link-button {
    background: none;
    border: none;
    color: var(--accent);
    text-decoration: underline;
    cursor: pointer;
    padding: 0;
    font-size: inherit;
    font-weight: 500;
}

.inline-form {
    display: inline-block;
    margin: 0;
}

.muted {
    color: var(--text-muted);
    font-size: 0.88em;
}

.tag {
    display: inline-block;
    background: var(--accent-light);
    color: var(--accent-dark);
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 0.15rem 0.65rem;
    font-size: 0.78em;
    font-weight: 600;
    margin-right: 0.25rem;
}

.tag-priority-high { background: var(--error-bg); color: var(--error); }
.tag-priority-normal { background: var(--accent-light); color: var(--accent-dark); }
.tag-priority-low { background: var(--border); color: var(--text-muted); }

.tag-status-completed { background: var(--success-bg); color: var(--success-border); }
.tag-status-cancelled { background: var(--border); color: var(--text-muted); }
.tag-status-in_progress { background: #fff3cd; color: #92720d; }
.tag-status-paused { background: var(--border); color: var(--text-muted); }
.tag-status-not_started { background: var(--accent-light); color: var(--accent-dark); }

.goal-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.goal-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.7rem 0.9rem;
    margin-bottom: 0.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    flex-wrap: wrap;
}

.goal-row a {
    font-weight: 600;
    color: var(--text);
}

.goal-row a:hover {
    color: var(--accent);
}

.goal-node {
    margin: 0.6rem 0;
    padding: 0.5rem 0 0.5rem 0.9rem;
    border-left: 2px solid var(--border);
}

.goal-node summary {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    padding: 0.35rem 0.6rem;
    border-radius: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
}

.goal-node summary:hover {
    border-color: var(--accent);
}

.goal-node summary a {
    font-weight: 600;
    color: var(--text);
}

.goal-children {
    margin-left: 1.25rem;
}

.actions-bar {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    margin: 1.25rem 0;
    flex-wrap: wrap;
}

button.danger {
    background: var(--error);
}

button.danger:hover {
    background: #b91c1c;
}
