:root {
    --bg: #f4efe7;
    --bg-accent: #efe4d5;
    --panel: rgba(255, 255, 255, 0.78);
    --panel-strong: #ffffff;
    --text: #1f2937;
    --muted: #667085;
    --border: rgba(31, 41, 55, 0.09);
    --shadow: 0 24px 60px rgba(121, 86, 47, 0.12);
    --primary: #cb6d43;
    --primary-deep: #9f4f2d;
    --secondary: #1f6f78;
    --success: #2f855a;
    --danger: #c05655;
    --warning: #d69e2e;
    --radius-xl: 28px;
    --radius-lg: 20px;
    --radius-md: 14px;
}

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

body {
    min-height: 100vh;
    font-family: "Manrope", "Segoe UI", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(203, 109, 67, 0.18), transparent 28%),
        radial-gradient(circle at right 15%, rgba(31, 111, 120, 0.16), transparent 24%),
        linear-gradient(160deg, var(--bg) 0%, #f8f6f1 48%, var(--bg-accent) 100%);
    transition: background-color 0.3s ease, color 0.3s ease;
}

body.modal-open {
    overflow: hidden;
}

body::before {
    content: "";
    position: fixed;
    inset: 24px;
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 36px;
    pointer-events: none;
}

body.dark-mode {
    --bg: #12171b;
    --bg-accent: #1a2228;
    --panel: rgba(17, 24, 39, 0.84);
    --panel-strong: #18212b;
    --text: #eef2f6;
    --muted: #a9b4c2;
    --border: rgba(255, 255, 255, 0.1);
    --shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
    --primary: #f28a5b;
    --primary-deep: #ffb387;
    --secondary: #72c2c9;
    --success: #57b882;
    --danger: #ff8c8c;
    --warning: #f5c86b;
}

.page-shell {
    padding: 40px 20px;
}

.container {
    width: min(1180px, 100%);
    margin: 0 auto;
    display: grid;
    grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
    gap: 28px;
    align-items: start;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    backdrop-filter: blur(20px);
    border-radius: var(--radius-xl);
    padding: 28px;
}

.form-container {
    display: flex;
    flex-direction: column;
}

.panel-intro,
.list-header,
.section-heading {
    margin-bottom: 22px;
}

.panel-topbar {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
}

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--secondary);
}

h1,
h2,
.goal-title {
    font-family: "Space Grotesk", "Manrope", sans-serif;
}

h1 {
    font-size: clamp(2rem, 4vw, 2.7rem);
    line-height: 1;
    margin-bottom: 12px;
}

h2 {
    font-size: 1.45rem;
    margin-bottom: 4px;
}

.panel-copy {
    color: var(--muted);
    line-height: 1.6;
    max-width: 56ch;
}

.form-card {
    background: var(--panel-strong);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 18px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.field-full {
    grid-column: 1 / -1;
}

.field span,
.stat-label,
.progress-copy,
.meta-label {
    color: var(--muted);
    font-size: 0.92rem;
    font-weight: 600;
}

.helper-text {
    color: var(--muted);
    font-size: 0.88rem;
    line-height: 1.5;
}

input,
select {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.75);
    color: var(--text);
    font: inherit;
    outline: none;
    transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

body.dark-mode input,
body.dark-mode select {
    background: rgba(15, 23, 42, 0.78);
}

input:focus,
select:focus {
    border-color: rgba(203, 109, 67, 0.7);
    box-shadow: 0 0 0 4px rgba(203, 109, 67, 0.14);
}

button {
    border: none;
    border-radius: 999px;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease, color 0.18s ease;
}

button:hover {
    transform: translateY(-1px);
}

.primary-btn,
.secondary-btn,
.theme-toggle {
    min-height: 48px;
    padding: 0 18px;
}

.primary-btn {
    width: 100%;
    background: linear-gradient(135deg, var(--primary) 0%, #e5915c 100%);
    color: #fffdf9;
    box-shadow: 0 16px 32px rgba(203, 109, 67, 0.24);
}

.secondary-btn {
    background: rgba(31, 111, 120, 0.1);
    color: var(--secondary);
}

.theme-toggle {
    background: rgba(255, 255, 255, 0.7);
    color: var(--text);
    border: 1px solid var(--border);
    white-space: nowrap;
}

body.dark-mode .theme-toggle {
    background: rgba(15, 23, 42, 0.72);
}

.stats-panel {
    margin-top: 22px;
    margin-left: auto;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.56), rgba(255, 255, 255, 0.82));
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    width: min(100%, 360px);
}

.stats-actions {
    margin-top: 18px;
}

body.dark-mode .stats-panel {
    background: linear-gradient(180deg, rgba(24, 33, 43, 0.82), rgba(18, 24, 32, 0.96));
}

.section-heading {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
}

.stats-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 76px;
    padding: 10px 14px;
    border-radius: 999px;
    font-weight: 800;
    color: var(--primary);
    background: rgba(203, 109, 67, 0.12);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.stat-card {
    background: var(--panel-strong);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 16px;
}

.stat-card strong {
    display: block;
    margin-top: 10px;
    font-size: 1.4rem;
}

.progress-block {
    margin-top: 18px;
}

.progress-copy {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.progress-container {
    width: 100%;
    height: 14px;
    overflow: hidden;
    background: rgba(31, 41, 55, 0.08);
    border-radius: 999px;
}

.progress-bar {
    height: 100%;
    width: 0;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--secondary), var(--primary));
    transition: width 0.35s ease;
}

.toolbar {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: end;
    margin-bottom: 24px;
}

.toolbar-field {
    flex: 1;
}

.category-create {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
}

.category-create .secondary-btn {
    min-width: 148px;
}

.category-pill-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.category-pill {
    display: inline-flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(31, 111, 120, 0.1);
    color: var(--secondary);
    font-size: 0.84rem;
    font-weight: 700;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: grid;
    place-items: center;
    padding: 24px;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.22s ease, visibility 0.22s ease;
}

.modal.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(7, 10, 15, 0.56);
    backdrop-filter: blur(10px);
}

.modal-card {
    position: relative;
    z-index: 1;
    width: min(100%, 760px);
    max-height: calc(100vh - 48px);
    overflow: auto;
    padding: 24px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 30px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(22px);
}

.modal-header {
    margin-bottom: 20px;
    padding-right: 64px;
}

.modal-form {
    margin: 0;
}

.modal-close {
    position: absolute;
    top: 18px;
    right: 18px;
    min-height: 40px;
    padding: 0 14px;
    background: rgba(31, 111, 120, 0.1);
    color: var(--secondary);
}

.goal-list {
    display: grid;
    gap: 16px;
}

.goal-card,
.empty-state {
    position: relative;
    overflow: hidden;
    background: var(--panel-strong);
    border: 1px solid var(--border);
    border-radius: 22px;
    padding: 20px;
}

.goal-card::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 7px;
    border-radius: 22px;
}

.goal-card.personal::before {
    background: #6aaed6;
}

.goal-card.work::before {
    background: #e27d60;
}

.goal-card.fitness::before {
    background: #5fb56f;
}

.goal-card.study::before {
    background: #e3b23c;
}

.goal-card.other::before {
    background: #8d99ae;
}

.goal-card.low-priority {
    box-shadow: inset 0 0 0 1px rgba(47, 133, 90, 0.1);
}

.goal-card.medium-priority {
    box-shadow: inset 0 0 0 1px rgba(214, 158, 46, 0.12);
}

.goal-card.high-priority {
    box-shadow: inset 0 0 0 1px rgba(192, 86, 85, 0.14);
}

.goal-card.completed {
    background: linear-gradient(135deg, rgba(47, 133, 90, 0.08), rgba(255, 255, 255, 0.9));
}

body.dark-mode .goal-card.completed {
    background: linear-gradient(135deg, rgba(47, 133, 90, 0.14), rgba(24, 33, 43, 0.95));
}

.goal-card:hover {
    transform: translateY(-2px);
    transition: transform 0.22s ease;
}

.goal-card-header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 14px;
}

.goal-title {
    font-size: 1.28rem;
    line-height: 1.15;
    margin-bottom: 8px;
}

.goal-card.completed .goal-title {
    text-decoration: line-through;
    opacity: 0.75;
}

.goal-desc,
.goal-deadline {
    color: var(--muted);
    line-height: 1.6;
}

.goal-deadline {
    margin-bottom: 10px;
}

.goal-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
}

.meta-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border-radius: 999px;
    padding: 8px 12px;
    font-size: 0.85rem;
    font-weight: 700;
}

.category-badge {
    background: rgba(31, 111, 120, 0.1);
    color: var(--secondary);
}

.priority-badge.low {
    background: rgba(47, 133, 90, 0.12);
    color: var(--success);
}

.priority-badge.medium {
    background: rgba(214, 158, 46, 0.16);
    color: #9a6b00;
}

.priority-badge.high {
    background: rgba(192, 86, 85, 0.14);
    color: var(--danger);
}

.status-pill {
    background: rgba(31, 41, 55, 0.08);
    color: var(--text);
}

.goal-actions {
    display: flex;
    gap: 12px;
    margin-top: 18px;
}

.goal-actions button {
    flex: 1;
    min-height: 44px;
}

.complete-btn {
    background: rgba(47, 133, 90, 0.12);
    color: var(--success);
}

.delete-btn {
    background: rgba(192, 86, 85, 0.1);
    color: var(--danger);
}

.empty-state {
    text-align: center;
    padding: 36px 24px;
}

.empty-state p {
    margin-top: 10px;
    color: var(--muted);
    line-height: 1.6;
}

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

@media (max-width: 640px) {
    body::before {
        inset: 12px;
        border-radius: 24px;
    }

    .page-shell {
        padding: 22px 14px;
    }

    .panel {
        padding: 20px;
        border-radius: 24px;
    }

    .panel-topbar,
    .toolbar,
    .section-heading,
    .progress-copy,
    .goal-card-header,
    .goal-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .theme-toggle,
    .secondary-btn {
        width: 100%;
    }

    .modal {
        padding: 12px;
    }

    .modal-card {
        width: 100%;
        max-height: calc(100vh - 24px);
        padding: 18px;
        border-radius: 24px;
    }

    .modal-header {
        padding-right: 0;
    }

    .modal-close {
        position: static;
        width: 100%;
        margin-bottom: 16px;
    }

    .category-create {
        grid-template-columns: 1fr;
    }

    .form-grid,
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .stats-panel {
        width: 100%;
        margin-left: 0;
    }
}
