/* Planner – Task Manager
   Light theme (default), .dark for dark mode
*/
:root {
    --bg: #f4f2ef;
    --surface: #fff;
    --text: #1a1a1a;
    --text-muted: #5c5c5c;
    --border: #e0ddd8;
    --primary: #2d5a4a;
    --primary-hover: #234a3d;
    --secondary: #6b7280;
    --danger: #b91c1c;
    --danger-hover: #991b1b;
    --asap: #7c3aed;
    --high: #b91c1c;
    --medium: #b45309;
    --low: #0e7490;
    --shadow: rgba(0,0,0,0.06);
    --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* Private (default): green/earthy */
/* Work: blue/professional – overridden below via [data-context="work"] */

[data-context="work"] {
    --primary: #1e5a8c;
    --primary-hover: #164a73;
}

.dark {
    --bg: #1a1b1e;
    --surface: #25262b;
    --text: #e8e6e3;
    --text-muted: #9ca3af;
    --border: #3f3f46;
    --primary: #4ade80;
    --primary-hover: #22c55e;
    --secondary: #9ca3af;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --asap: #a78bfa;
    --high: #f87171;
    --medium: #fbbf24;
    --low: #22d3ee;
    --shadow: rgba(0,0,0,0.3);
}

.dark[data-context="work"] {
    --primary: #38bdf8;
    --primary-hover: #0ea5e9;
}

* {
    box-sizing: border-box;
}

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

/* ----- Login ----- */
.login-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--text);
}

.login-header {
    flex-shrink: 0;
}

.login-page__content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 1rem;
}

.login-card {
    width: 100%;
    max-width: 360px;
    padding: 1.5rem 1.25rem;
    background: var(--surface);
    border-radius: 12px;
    box-shadow: 0 20px 50px var(--shadow);
    border: 1px solid var(--border);
}

.login-subtitle {
    margin: 0 0 1.25rem;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.login-form label {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text);
}

.login-form input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    margin-bottom: 1rem;
    font-size: 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
}

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

.login-form input:focus {
    outline: none;
    border-color: var(--primary);
}

.login-form .btn {
    width: 100%;
    margin-top: 0.25rem;
}

.error-message {
    margin-top: 1rem;
    color: var(--danger);
    font-size: 0.9rem;
}

/* ----- App header ----- */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 1.5rem;
    background: var(--surface);
    border-bottom: 3px solid var(--primary);
    flex-wrap: wrap;
}

.app-header__brand {
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.app-header h1 {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 700;
}

.app-header__context {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.dark .app-header__context {
    color: var(--primary);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.mode-switch {
    display: flex;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.mode-btn {
    padding: 0.4rem 0.9rem;
    font-size: 0.9rem;
    font-weight: 500;
    background: transparent;
    color: var(--text-muted);
    border: none;
    cursor: pointer;
}

.mode-btn:hover {
    color: var(--text);
}

.mode-btn.active {
    background: var(--primary);
    color: #fff;
}

.dark .mode-btn.active {
    color: #1a1b1e;
}

.icon-btn {
    padding: 0.4rem 0.6rem;
    font-size: 1rem;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
}

.icon-btn:hover {
    color: var(--text);
    background: var(--bg);
}

.logout-btn {
    font-size: 0.85rem;
}

/* ----- Main ----- */
.app-main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem;
}

.toolbar {
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.tasks-density-switch {
    margin-left: auto;
}

/* Label filter bar */
.label-filter {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.label-filter__icon {
    font-size: 0.8rem;
    color: var(--text-muted);
    user-select: none;
}

.label-filter__chips {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    flex-wrap: wrap;
}

.label-filter__chip {
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    white-space: nowrap;
    transition: all 0.15s;
}

.label-filter__chip:hover {
    border-color: hsl(var(--tag-hue) 40% 70%);
    color: hsl(var(--tag-hue) 50% 38%);
}

.label-filter__chip--active {
    color: hsl(var(--tag-hue) 50% 38%);
    background: hsl(var(--tag-hue) 48% 94%);
    border-color: hsl(var(--tag-hue) 40% 82%);
    font-weight: 600;
}

.dark .label-filter__chip:hover {
    border-color: hsl(var(--tag-hue) 30% 45%);
    color: hsl(var(--tag-hue) 65% 75%);
}

.dark .label-filter__chip--active {
    color: hsl(var(--tag-hue) 65% 75%);
    background: hsl(var(--tag-hue) 25% 18%);
    border-color: hsl(var(--tag-hue) 25% 30%);
}

.label-filter__clear {
    padding: 0.15rem 0.35rem;
    font-size: 0.7rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
}

.label-filter__clear:hover {
    color: var(--danger);
    border-color: var(--danger);
}

.btn {
    padding: 0.5rem 1rem;
    font-size: 0.95rem;
    font-weight: 500;
    border-radius: 8px;
    border: none;
    cursor: pointer;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.dark .btn-primary {
    color: #1a1b1e;
}

.btn-secondary {
    background: var(--secondary);
    color: #fff;
}

.btn-secondary:hover {
    opacity: 0.9;
}

/* ----- List view (groups / categories) ----- */
.task-groups {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    padding-bottom: 2rem;
}

/* Compact list – dense rows similar in spirit to classic productivity lists (e.g. Toodledo) */
.task-groups.task-groups--compact {
    gap: 1rem;
    padding-bottom: 1rem;
}

.task-groups.task-groups--compact .task-list__section {
    padding: 0.55rem 0.65rem;
    border-radius: 8px;
}

.task-groups.task-groups--compact .task-list__section-head {
    gap: 0.5rem;
}

.task-groups.task-groups--compact .task-list__section-title {
    font-size: 0.95rem;
}

.task-groups.task-groups--compact .task-list__subtitle {
    margin: 0 0 0.45rem;
    font-size: 0.78rem;
}

.task-groups.task-groups--compact .task-list__quick-add {
    margin-bottom: 0.35rem;
    padding: 0.28rem 0.45rem;
    font-size: 0.82rem;
    border-radius: 6px;
}

.task-groups.task-groups--compact .task-list__row {
    padding: 0.28rem 0.45rem;
    gap: 0.45rem;
    border-radius: 4px;
    border-left-width: 2px;
}

.task-groups.task-groups--compact .task-list__name-wrap {
    gap: 0.28rem;
}

.task-groups.task-groups--compact .task-list__name {
    font-size: 0.875rem;
}

.task-groups.task-groups--compact .task-list__inline-input--name {
    font-size: 0.875rem;
}

.task-groups.task-groups--compact .task-list__meta {
    gap: 0.3rem;
    font-size: 0.72rem;
}

.task-groups.task-groups--compact .task-list__pill {
    padding: 0.06rem 0.28rem;
    font-size: 0.68rem;
    border-radius: 3px;
}

.task-groups.task-groups--compact .task-list__subtask-badge {
    font-size: 0.62rem;
    padding: 0.06rem 0.26rem;
}

.task-groups.task-groups--compact .task-list__priority-select {
    font-size: 0.62rem;
    min-width: 3.1rem;
    padding: 0.1rem 0.25rem;
}

.task-groups.task-groups--compact .task-list__group-select {
    font-size: 0.68rem;
    max-width: 5.5rem;
    padding: 0.12rem 0.35rem;
}

.task-groups.task-groups--compact .task-list__action {
    width: 24px;
    height: 24px;
    font-size: 0.8rem;
    border-radius: 4px;
}

.task-groups.task-groups--compact .task-list__sort-field {
    font-size: 0.68rem;
    padding: 0.12rem 0.3rem;
}

.task-groups.task-groups--compact .task-list__sort-dir {
    width: 24px;
    height: 24px;
    font-size: 0.75rem;
}

.task-groups.task-groups--compact .task-list__count {
    font-size: 0.72rem;
    padding: 0.12rem 0.4rem;
}

.task-groups.task-groups--compact .task-list__inprogress-toggle {
    padding: 0.06rem 0.36rem;
    font-size: 0.68rem;
}

.task-groups.task-groups--compact .task-list__due-btn {
    font-size: 0.72rem;
}

.task-groups.task-groups--compact .task-list__subtasks-inner {
    padding: 0.35rem 0.5rem 0.35rem 2rem;
}

.task-groups.task-groups--compact .task-list__subtask-line {
    padding: 0.12rem 0;
    font-size: 0.78rem;
}

.task-groups.task-groups--compact .task-list__subtask-checkbox {
    width: 0.9rem;
    height: 0.9rem;
}

.task-groups.task-groups--compact .task-list__empty {
    padding: 1rem 0.75rem;
    gap: 0.5rem;
}

.task-groups.task-groups--compact .task-list__empty-text {
    font-size: 0.85rem;
}

.task-groups.task-groups--compact .task-list__inline-input {
    font-size: 0.72rem;
    padding: 0.1rem 0.3rem;
}

.task-list__section {
    background: var(--surface);
    border-radius: 12px;
    border: 1px solid var(--border);
    padding: 1rem 1.25rem;
}

/* Today = focus section – highlight with context primary */
.task-list__section--focus {
    border-left: 4px solid var(--primary);
    box-shadow: 0 0 0 1px var(--primary);
}

.task-list__section--focus .task-list__section-title {
    color: var(--primary);
}

.task-list__section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.task-list__section-title {
    margin: 0 0 0.15rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.task-list__sort {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.task-list__sort-field {
    font-size: 0.75rem;
    padding: 0.2rem 0.4rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    cursor: pointer;
}

.task-list__sort-dir {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-size: 0.9rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
}

.task-list__sort-dir:hover {
    color: var(--text);
}

.task-list__quick-add {
    width: 100%;
    margin-bottom: 0.5rem;
    padding: 0.4rem 0.6rem;
    font-size: 0.9rem;
    border: 1px dashed var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
}

.task-list__quick-add::placeholder {
    color: var(--text-muted);
}

.task-list__quick-add:focus {
    outline: none;
    border-color: var(--primary);
}

.task-list__count {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    background: var(--bg);
    padding: 0.2rem 0.5rem;
    border-radius: 10px;
}

.task-list__subtitle {
    margin: 0 0 0.75rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.task-list__items {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.task-list__row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    border-radius: 8px;
    border-left: 3px solid var(--border);
    background: var(--bg);
    transition: background 0.15s;
}

.task-list__row:hover {
    background: var(--surface);
}

.task-list__row--asap { border-left-color: var(--asap); }
.task-list__row--high { border-left-color: var(--high); }
.task-list__row--medium { border-left-color: var(--medium); }
.task-list__row--low { border-left-color: var(--low); }

.task-list__name-wrap {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.task-list__name {
    flex: 0 1 auto;
    min-width: 0;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text);
    background: none;
    border: none;
    padding: 0;
    text-align: left;
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.task-list__name:hover {
    text-decoration: underline;
}

.task-list__subtask-badge {
    font-size: 0.7rem;
    color: var(--text-muted);
    background: var(--surface);
    padding: 0.15rem 0.35rem;
    border-radius: 6px;
    flex-shrink: 0;
}

.task-list__inline-input--name {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 0.95rem;
}

.task-list__meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.task-list__due {
    white-space: nowrap;
}

.task-list__pill {
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    flex-shrink: 0;
    white-space: nowrap;
}

.task-list__pill--label {
    color: hsl(var(--tag-hue) 50% 38%);
    background: hsl(var(--tag-hue) 48% 94%);
    border-color: hsl(var(--tag-hue) 40% 82%);
}

.dark .task-list__pill--label {
    color: hsl(var(--tag-hue) 65% 75%);
    background: hsl(var(--tag-hue) 25% 18%);
    border-color: hsl(var(--tag-hue) 25% 30%);
}

.task-list__priority {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    min-width: 3.5rem;
    text-align: right;
}

.task-list__priority--asap { color: var(--asap); }
.task-list__priority--high { color: var(--high); }
.task-list__priority--medium { color: var(--medium); }
.task-list__priority--low { color: var(--low); }

.task-list__actions {
    display: flex;
    gap: 0.2rem;
    flex-shrink: 0;
}

.task-list__action {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-size: 0.9rem;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
}

.task-list__action:hover {
    color: var(--text);
    background: var(--surface);
}

.task-list__empty {
    padding: 1.5rem 1rem;
    font-size: 0.9rem;
    color: var(--text-muted);
    text-align: center;
    list-style: none;
    background: var(--bg);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.task-list__empty-text {
    margin: 0;
    font-size: 0.95rem;
}

.task-list__empty-add {
    flex-shrink: 0;
}

.task-list__editable {
    cursor: pointer;
}

.task-list__due-btn {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    color: inherit;
    font-size: 0.8rem;
    white-space: nowrap;
    border-radius: 4px;
}

.task-list__due-btn:hover {
    text-decoration: underline;
}

.task-list__pill--add {
    color: var(--text-muted);
    font-style: italic;
    border-style: dashed;
}

.task-list__pill--inprogress {
    color: var(--primary);
    background: rgba(74, 222, 128, 0.15);
    border-color: var(--primary);
}

.dark .task-list__pill--inprogress {
    background: rgba(74, 222, 128, 0.12);
}

/* In progress toggle on list row – quick toggle without opening edit */
.task-list__inprogress-toggle {
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.task-list__inprogress-toggle:hover {
    color: var(--text);
    border-color: var(--text-muted);
}

.task-list__inprogress-toggle--on {
    color: var(--primary);
    border-color: var(--primary);
    background: rgba(74, 222, 128, 0.15);
}

.task-list__inprogress-toggle--on:hover {
    background: rgba(74, 222, 128, 0.25);
}

.dark .task-list__inprogress-toggle--on {
    background: rgba(74, 222, 128, 0.12);
}

.dark .task-list__inprogress-toggle--on:hover {
    background: rgba(74, 222, 128, 0.2);
}

.task-list__priority-select {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    min-width: 3.5rem;
    padding: 0.2rem 0.35rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: inherit;
    cursor: pointer;
}

.task-list__priority-select option { color: inherit; }

.task-list__group-select {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    max-width: 7rem;
}

.task-list__inline-input {
    font-size: 0.75rem;
    padding: 0.15rem 0.35rem;
    border: 1px solid var(--primary);
    border-radius: 4px;
    background: var(--surface);
    color: var(--text);
    min-width: 5rem;
}

.tag-autocomplete {
    position: relative;
    display: inline-flex;
    flex-shrink: 0;
}

.tag-autocomplete__list {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 100%;
    max-height: 10rem;
    overflow-y: auto;
    margin: 0.2rem 0 0;
    padding: 0.25rem 0;
    list-style: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 4px 12px var(--shadow);
    z-index: 300;
}

.tag-autocomplete__item {
    padding: 0.3rem 0.6rem;
    font-size: 0.75rem;
    cursor: pointer;
    color: hsl(var(--tag-hue) 50% 38%);
    white-space: nowrap;
}

.dark .tag-autocomplete__item {
    color: hsl(var(--tag-hue) 65% 75%);
}

.tag-autocomplete__item:hover,
.tag-autocomplete__item--active {
    background: var(--bg);
}

.tag-autocomplete__hash {
    opacity: 0.5;
    margin-right: 0.05rem;
}

/* Modal tag chips */
.modal-tags-wrap {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    min-height: 2.2rem;
    position: relative;
}

.modal-tags-wrap:focus-within {
    border-color: var(--primary);
}

.modal-tags-input,
.form-row .modal-tags-input {
    border: none !important;
    outline: none;
    background: transparent !important;
    font: inherit;
    font-size: 0.85rem;
    color: var(--text);
    padding: 0.1rem 0 !important;
    min-width: 5rem;
    flex: 1 1 4rem;
    width: auto !important;
    border-radius: 0 !important;
}

.modal-tags-input::placeholder {
    color: var(--text-muted);
}

.modal-tags-hint {
    font-weight: 400;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.modal-tag-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    padding: 0.15rem 0.2rem 0.15rem 0.45rem;
    border-radius: 4px;
    font-size: 0.8rem;
    white-space: nowrap;
    color: hsl(var(--tag-hue) 50% 38%);
    background: hsl(var(--tag-hue) 48% 94%);
    border: 1px solid hsl(var(--tag-hue) 40% 82%);
}

.dark .modal-tag-pill {
    color: hsl(var(--tag-hue) 65% 75%);
    background: hsl(var(--tag-hue) 25% 18%);
    border-color: hsl(var(--tag-hue) 25% 30%);
}

.modal-tag-pill__remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1rem;
    height: 1rem;
    padding: 0;
    border: none;
    background: transparent;
    color: inherit;
    font-size: 0.85rem;
    line-height: 1;
    cursor: pointer;
    border-radius: 3px;
    opacity: 0.6;
}

.modal-tag-pill__remove:hover {
    opacity: 1;
    background: hsl(var(--tag-hue) 40% 82%);
}

.dark .modal-tag-pill__remove:hover {
    background: hsl(var(--tag-hue) 25% 30%);
}

.modal-tags-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 0.2rem;
}

.inline-popover {
    z-index: 200;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 24px var(--shadow);
    padding: 0.25rem;
}

.inline-popover__input {
    width: 140px;
    padding: 0.4rem 0.5rem;
    font-size: 0.9rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    color: var(--text);
}

/* ----- Modal ----- */
.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal[hidden] {
    display: none !important;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
    cursor: pointer;
}

.modal-content {
    position: relative;
    width: 100%;
    max-width: 440px;
    max-height: 90vh;
    overflow-x: hidden;
    overflow-y: auto;
    /* Hide scrollbar visually but keep scrolling (mouse/touch) so text stays visible */
    scrollbar-width: none;
    -ms-overflow-style: none;
    background: var(--surface);
    color: var(--text);
    border-radius: 12px;
    box-shadow: 0 20px 50px var(--shadow);
    border: 1px solid var(--border);
}

.modal-content::-webkit-scrollbar {
    display: none;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
}

.modal-close {
    font-size: 1.5rem;
    line-height: 1;
    padding: 0.25rem;
}

.task-form {
    padding: 1.25rem;
}

.form-row {
    margin-bottom: 1rem;
}

.form-row label {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text);
}

.form-row input:not(.subtasks-list__text),
.form-row select,
.form-row textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
}

.form-row textarea {
    resize: vertical;
    min-height: 5rem;
}

.task-description-preview {
    margin-top: 0.5rem;
    padding: 0.75rem;
    font-size: 0.9rem;
    line-height: 1.5;
    background: var(--bg);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.task-description-preview .task-description-img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    margin: 0.25rem 0;
    display: block;
}

.form-row--checkbox {
    margin-bottom: 1rem;
}

.form-row--checkbox .form-row__checkbox-wrap {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
}

.form-row--checkbox .form-row__checkbox-wrap input[type="checkbox"] {
    width: auto;
    margin: 0;
    flex-shrink: 0;
}

.form-row--subtasks {
    min-width: 0;
    overflow: visible;
    width: 100%;
}

.form-row--subtasks label {
    display: block;
    margin-bottom: 0.35rem;
}

.subtasks-list {
    list-style: none;
    margin: 0 0 0.5rem;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-height: 2.5rem;
    min-width: 0;
    width: 100%;
    max-width: 100%;
}

.subtasks-list__item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    min-height: 1.75rem;
    min-width: 0;
    width: 100%;
    max-width: 100%;
}

.subtasks-list__item-content {
    display: flex;
    align-items: center;
    gap: 0.2rem;
    flex: 1 1 0%;
    min-width: 0;
    max-width: min(20rem, 100%);
}

.subtasks-list__checkbox-wrap {
    flex: 0 0 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 0.75rem;
    min-width: 0.75rem;
    height: 0.75rem;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    pointer-events: none;
}

.subtasks-list__checkbox-wrap .subtasks-list__checkbox {
    pointer-events: auto;
    cursor: pointer;
}

.subtasks-list__checkbox {
    flex: none;
    width: 0.75rem;
    height: 0.75rem;
    min-width: 0.75rem;
    min-height: 0.75rem;
    margin: 0;
    padding: 0;
    border: 0;
    accent-color: var(--primary);
    box-sizing: border-box;
}

.subtasks-list__text {
    flex: 1 1 0%;
    min-width: 4rem;
    width: 100%;
    max-width: 100%;
    padding: 0.25rem 0.375rem;
    font-size: 0.9rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    color: var(--text);
    text-align: left;
    direction: ltr;
    box-sizing: border-box;
}

.subtasks-list__delete {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    padding: 0;
    font-size: 1rem;
    line-height: 1;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
}

.subtasks-list__delete:hover {
    color: var(--danger);
    background: var(--bg);
}

.subtasks-add__input {
    width: 100%;
    padding: 0.4rem 0.5rem;
    font-size: 0.9rem;
    border: 1px dashed var(--border);
    border-radius: 6px;
    background: var(--bg);
    color: var(--text);
}

.subtasks-add__input::placeholder {
    color: var(--text-muted);
}

/* Expandable subtasks in list view */
.task-list__subtask-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0;
    margin: 0;
    background: none;
    border: none;
    cursor: pointer;
    font: inherit;
    color: inherit;
}

.task-list__subtask-chevron {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.task-list__subtask-toggle:hover .task-list__subtask-chevron {
    color: var(--primary);
}

.task-list__row-subtasks {
    list-style: none;
    margin: 0;
    padding: 0;
    border: none;
    background: var(--surface);
    border-radius: 0 0 8px 8px;
    border-left: 3px solid transparent;
    margin-left: 0;
}

.task-list__row-subtasks[data-task-id] {
    border-left-color: var(--border);
}

.task-list__subtasks-inner {
    padding: 0.5rem 0.75rem 0.5rem 2.5rem;
    border-top: 1px solid var(--border);
}

.task-list__subtask-line {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.task-list__subtask-check {
    flex-shrink: 0;
    width: 1rem;
    color: var(--primary);
}

.task-list__subtask-checkbox {
    flex-shrink: 0;
    width: 1rem;
    height: 1rem;
    margin: 0;
    cursor: pointer;
    accent-color: var(--primary);
}

.task-list__subtask-text {
    flex: 1 1 auto;
    min-width: 0;
    color: var(--text);
}

.task-list__subtask-text--done {
    text-decoration: line-through;
    color: var(--text-muted);
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

/* ----- Sidebar + Layout ----- */
.app-layout {
    display: flex;
    min-height: calc(100vh - 56px);
}

.sidebar {
    width: 200px;
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 0.75rem 0;
    position: sticky;
    top: 56px;
    height: calc(100vh - 56px);
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    transition: width 0.2s ease;
}

.sidebar::-webkit-scrollbar {
    display: none;
}

.sidebar__toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    text-align: left;
}

.sidebar__toggle:hover {
    color: var(--text);
}

.sidebar__nav {
    list-style: none;
    margin: 0;
    padding: 0 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar__item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    width: 100%;
    padding: 0.6rem 0.75rem;
    font-size: 0.95rem;
    font-weight: 500;
    font-family: var(--font);
    color: var(--text-muted);
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s, color 0.15s;
}

.sidebar__item:hover {
    background: var(--bg);
    color: var(--text);
}

.sidebar__item.active {
    background: var(--primary);
    color: #fff;
}

.dark .sidebar__item.active {
    color: #1a1b1e;
}

.sidebar__icon {
    font-size: 1.1rem;
    flex-shrink: 0;
    width: 1.4rem;
    text-align: center;
}

.sidebar__label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 85;
    background: rgba(0, 0, 0, 0.4);
    cursor: pointer;
}

.app-content {
    flex: 1;
    min-width: 0;
}

.view-panel[hidden] {
    display: none !important;
}

/* ----- Goals ----- */
.goals-toolbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.goals-filter-select {
    padding: 0.4rem 0.6rem;
    font-size: 0.9rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    cursor: pointer;
    font-family: var(--font);
}

.goals-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 1.25rem;
    padding-bottom: 2rem;
}

.goals-section-title {
    grid-column: 1 / -1;
    margin: 0.5rem 0 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.goals-section-title .task-list__count {
    font-size: 0.8rem;
}

.goal-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.15rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    transition: box-shadow 0.15s;
    cursor: default;
}

.goal-card:hover {
    box-shadow: 0 4px 16px var(--shadow);
}

.goal-card--completed {
    opacity: 0.7;
}

.goal-card--archived {
    opacity: 0.5;
}

.goal-card__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
}

.goal-card__name {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text);
    margin: 0;
    flex: 1;
    min-width: 0;
    word-break: break-word;
}

.goal-card__actions {
    display: flex;
    gap: 0.2rem;
    flex-shrink: 0;
}

.goal-card__action {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-size: 0.9rem;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
}

.goal-card__action:hover {
    color: var(--text);
    background: var(--bg);
}

.goal-card__description {
    font-size: 0.88rem;
    color: var(--text-muted);
    line-height: 1.45;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.goal-card__meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    font-size: 0.8rem;
}

.goal-card__pill {
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 500;
    border: 1px solid var(--border);
    background: var(--bg);
}

.goal-card__pill--category {
    color: var(--primary);
    border-color: var(--primary);
    background: transparent;
}

.goal-card__pill--priority-asap { color: var(--asap); border-color: var(--asap); }
.goal-card__pill--priority-high { color: var(--high); border-color: var(--high); }
.goal-card__pill--priority-medium { color: var(--medium); border-color: var(--medium); }
.goal-card__pill--priority-low { color: var(--low); border-color: var(--low); }

.goal-card__date {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-left: auto;
}

.goal-card__progress {
    width: 100%;
    height: 6px;
    background: var(--bg);
    border-radius: 3px;
    overflow: hidden;
}

.goal-card__progress-bar {
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
    transition: width 0.3s ease;
    min-width: 0;
}

.goal-card__milestones {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.goal-card__milestone {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    padding: 0.15rem 0;
}

.goal-card__milestone-checkbox {
    flex-shrink: 0;
    width: 0.9rem;
    height: 0.9rem;
    margin: 0;
    cursor: pointer;
    accent-color: var(--primary);
}

.goal-card__milestone-text {
    flex: 1;
    min-width: 0;
    color: var(--text);
}

.goal-card__milestone-text--done {
    text-decoration: line-through;
    color: var(--text-muted);
}

.goal-card__milestone-date {
    font-size: 0.75rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.goal-card__progress-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    text-align: right;
}

.goals-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* ----- Media cards (Books & Films) ----- */
.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
    padding-bottom: 2rem;
}

.media-section-title {
    grid-column: 1 / -1;
    margin: 0.5rem 0 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.media-section-title .task-list__count {
    font-size: 0.8rem;
}

.media-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem 1.15rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    transition: box-shadow 0.15s;
}

.media-card:hover {
    box-shadow: 0 4px 16px var(--shadow);
}

.media-card--faded {
    opacity: 0.6;
}

.media-card__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
}

.media-card__title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin: 0;
    flex: 1;
    min-width: 0;
    word-break: break-word;
}

.media-card__subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0;
}

.media-card__actions {
    display: flex;
    gap: 0.2rem;
    flex-shrink: 0;
}

.media-card__action {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-size: 0.9rem;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
}

.media-card__action:hover {
    color: var(--text);
    background: var(--bg);
}

.media-card__meta {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
    font-size: 0.8rem;
}

.media-card__pill {
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    font-size: 0.73rem;
    font-weight: 500;
    border: 1px solid var(--border);
    background: var(--bg);
    white-space: nowrap;
}

.media-card__pill--genre {
    color: var(--primary);
    border-color: var(--primary);
    background: transparent;
}

.media-card__pill--status {
    text-transform: capitalize;
}

.media-card__pill--type {
    color: var(--text-muted);
    font-style: italic;
}

.media-card__year {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-left: auto;
}

.media-card__notes {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.4;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.media-card__stars {
    display: flex;
    gap: 2px;
    font-size: 1rem;
    color: var(--border);
}

.media-card__stars .star--filled {
    color: #f59e0b;
}

.media-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* ----- Star rating input (modals) ----- */
.star-rating {
    display: flex;
    align-items: center;
    gap: 2px;
}

.star-rating__star {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--border);
    cursor: pointer;
    padding: 0.1rem;
    line-height: 1;
    transition: color 0.1s;
}

.star-rating__star:hover,
.star-rating__star.active {
    color: #f59e0b;
}

.star-rating__clear {
    background: none;
    border: none;
    font-size: 0.75rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem 0.4rem;
    margin-left: 0.35rem;
}

.star-rating__clear:hover {
    color: var(--danger);
}

/* ----- Shopping List ----- */
.shopping-card {
    position: relative;
}

.shopping-card__image-wrap {
    width: 100%;
    max-height: 160px;
    overflow: hidden;
    border-radius: 8px 8px 0 0;
    margin: -1rem -1.15rem 0.5rem -1.15rem;
    width: calc(100% + 2.3rem);
}

.shopping-card__image {
    width: 100%;
    height: 160px;
    object-fit: cover;
    display: block;
}

.shopping-card__labels {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
}

.shopping-card__label {
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.73rem;
    font-weight: 500;
    white-space: nowrap;
    color: hsl(var(--tag-hue) 50% 38%);
    background: hsl(var(--tag-hue) 48% 94%);
    border: 1px solid hsl(var(--tag-hue) 40% 82%);
}

.dark .shopping-card__label {
    color: hsl(var(--tag-hue) 65% 75%);
    background: hsl(var(--tag-hue) 25% 18%);
    border-color: hsl(var(--tag-hue) 25% 30%);
}

.shopping-card__price {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary);
    margin-left: auto;
}

.shopping-card__url {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.8rem;
    color: var(--primary);
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
    padding: 0.2rem 0;
}

.shopping-card__url:hover {
    text-decoration: underline;
}

.shopping-card__priority--high {
    color: var(--high);
    border-color: var(--high);
}

.shopping-card__priority--medium {
    color: var(--medium);
    border-color: var(--medium);
}

.shopping-card__priority--low {
    color: var(--low);
    border-color: var(--low);
}

.shopping-card__status--wishlist {
    color: #8b5cf6;
    border-color: #8b5cf6;
}

.shopping-card__status--considering {
    color: #f59e0b;
    border-color: #f59e0b;
}

.shopping-card__status--planned {
    color: var(--primary);
    border-color: var(--primary);
}

.shopping-card__status--purchased {
    color: var(--text-muted);
    border-color: var(--border);
}

/* ----- Mindmap ----- */
.mindmap-root {
    width: 100%;
    height: calc(100vh - 56px);
    position: relative;
    overflow: hidden;
    background: var(--bg);
}

@media (max-width: 768px) {
    .mindmap-root {
        height: calc(100vh - 52px);
    }
}

#mindmap-view {
    padding: 0 !important;
}

#mindmap-view .app-main {
    padding: 0;
    max-width: none;
}

/* ----- Notes ----- */
.notes-main {
    padding: 0;
    max-width: none;
    height: calc(100vh - 56px);
    overflow: hidden;
}

.notes-layout {
    display: flex;
    height: 100%;
    overflow: hidden;
}

.notes-sidebar {
    width: 280px;
    min-width: 200px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    background: var(--surface);
    overflow: hidden;
}

.notes-sidebar__toolbar {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.notes-label-filter {
    width: 100%;
}

.notes-editor__labels-row {
    margin: 0;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    flex-shrink: 0;
}

.notes-editor__labels-row label {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
}

.notes-format-toolbar {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-wrap: wrap;
    padding: 0.4rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    flex-shrink: 0;
}

.notes-format-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    min-height: 2rem;
    padding: 0.25rem 0.5rem;
    font-size: 0.85rem;
    font-family: var(--font);
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.notes-format-btn:hover {
    background: var(--border);
    border-color: var(--text-muted);
}

.notes-format-btn b,
.notes-format-btn i,
.notes-format-btn u,
.notes-format-btn s {
    font-size: 0.9rem;
    font-weight: 700;
}

.notes-format-sep {
    width: 1px;
    height: 1.25rem;
    background: var(--border);
    margin: 0 0.15rem;
}

.notes-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 0;
    -webkit-overflow-scrolling: touch;
}

.notes-list__empty {
    padding: 1.5rem 1rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    text-align: center;
}

.notes-list__item {
    display: block;
    width: 100%;
    padding: 0.75rem 1rem;
    text-align: left;
    border: none;
    background: transparent;
    color: var(--text);
    font-family: var(--font);
    font-size: 0.95rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
}

.notes-list__item:hover {
    background: var(--bg);
}

.notes-list__item--active {
    background: var(--primary);
    color: #fff;
}

.dark .notes-list__item--active {
    color: #1a1b1e;
}

.notes-list__item--active:hover {
    background: var(--primary-hover);
}

.notes-list__title {
    display: block;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0.2rem;
}

.notes-list__snippet {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.notes-list__item--active .notes-list__snippet {
    color: rgba(255, 255, 255, 0.85);
}

.dark .notes-list__item--active .notes-list__snippet {
    color: rgba(0, 0, 0, 0.7);
}

.notes-list__date {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.notes-list__item--active .notes-list__date {
    color: rgba(255, 255, 255, 0.75);
}

.dark .notes-list__item--active .notes-list__date {
    color: rgba(0, 0, 0, 0.6);
}

.notes-editor-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

/* Ensure [hidden] wins over display: flex so only one panel shows */
.notes-editor-placeholder[hidden],
.notes-editor[hidden] {
    display: none !important;
}

.notes-editor-placeholder {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: var(--text-muted);
    font-size: 1rem;
}

.notes-editor {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.notes-editor__toolbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    flex-shrink: 0;
    flex-wrap: wrap;
}

.notes-editor__title {
    flex: 1;
    min-width: 120px;
    padding: 0.5rem 0.75rem;
    font-size: 1.1rem;
    font-weight: 600;
    font-family: var(--font);
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
}

.notes-editor__title:focus {
    outline: none;
    border-color: var(--primary);
}

.notes-editor__title::placeholder {
    color: var(--text-muted);
}

.notes-editor__actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.notes-editor__body {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 1rem;
    -webkit-overflow-scrolling: touch;
}

.notes-editor__content {
    min-height: 100%;
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text);
    outline: none;
    word-wrap: break-word;
}

.notes-editor__content:empty::before {
    content: attr(data-placeholder);
    color: var(--text-muted);
}

.notes-editor__content h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 1rem 0 0.5rem;
}
.notes-editor__content h2:first-child {
    margin-top: 0;
}
.notes-editor__content ul,
.notes-editor__content ol {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}
.notes-editor__content img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    vertical-align: middle;
}

.notes-editor__pasted-img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0.5rem 0;
}

/* Notes: mobile – stack list / editor, touch-friendly */
@media (max-width: 768px) {
    .notes-layout {
        flex-direction: column;
    }

    .notes-sidebar {
        width: 100%;
        min-width: 0;
        max-height: 40vh;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .notes-list__item {
        padding: 1rem;
        min-height: 52px;
    }

    .notes-editor__toolbar {
        padding: 1rem;
    }

    .notes-editor__title {
        font-size: 1rem;
    }

    .notes-editor__actions .icon-btn,
    .notes-editor__actions .btn {
        min-width: 44px;
        min-height: 44px;
    }

    .notes-format-btn {
        min-width: 44px;
        min-height: 44px;
    }

    .notes-editor__body {
        padding: 1rem;
    }
}

/* ----- Habits ----- */
.habits-toolbar {
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
}

.habits-view-switcher .view-switcher__btn {
    width: auto;
    min-width: 4.25rem;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    white-space: nowrap;
}

.habits-date-nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.habits-date-label {
    font-weight: 600;
    min-width: 10rem;
    text-align: center;
}

.habits-range-view {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.habits-day-list {
    max-width: 480px;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.habit-day-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.habit-day-name-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.habit-day-name-btn,
.habit-grid-name-btn {
    text-align: left;
    padding: 0.35rem 0;
    font-size: 1rem;
    font-family: var(--font);
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;
    width: 100%;
}

.habit-day-name-wrap .habit-day-name-btn {
    flex: none;
}

.habit-frequency-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.habits-grid__habit-col .habit-frequency-label {
    display: block;
    margin-top: 0.1rem;
}

.habit-day-name-btn:hover,
.habit-grid-name-btn:hover {
    color: var(--primary);
    text-decoration: underline;
}

.habit-status-btns {
    display: flex;
    gap: 0.25rem;
}

.habit-status-btn {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: var(--bg);
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.habit-status-btn:hover {
    transform: scale(1.08);
}

.habit-status-btn--red { border-color: #dc2626; color: #dc2626; }
.habit-status-btn--red.habit-status-btn--active { background: #dc2626; color: #fff; }
.habit-status-btn--yellow { border-color: #ca8a04; color: #ca8a04; }
.habit-status-btn--yellow.habit-status-btn--active { background: #ca8a04; color: #fff; }
.habit-status-btn--green { border-color: #16a34a; color: #16a34a; }
.habit-status-btn--green.habit-status-btn--active { background: #16a34a; color: #fff; }

.dark .habit-status-btn--red { border-color: #f87171; color: #f87171; }
.dark .habit-status-btn--red.habit-status-btn--active { background: #f87171; color: #1a1b1e; }
.dark .habit-status-btn--yellow { border-color: #eab308; color: #eab308; }
.dark .habit-status-btn--yellow.habit-status-btn--active { background: #eab308; color: #1a1b1e; }
.dark .habit-status-btn--green { border-color: #22c55e; color: #22c55e; }
.dark .habit-status-btn--green.habit-status-btn--active { background: #22c55e; color: #1a1b1e; }

.habits-grid-wrap {
    overflow-x: auto;
    margin-top: 0.5rem;
}

.habits-grid {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.habits-grid th,
.habits-grid td {
    padding: 0.4rem 0.35rem;
    border: 1px solid var(--border);
    text-align: center;
}

.habits-grid__habit-col {
    text-align: left;
    min-width: 120px;
    max-width: 180px;
    position: sticky;
    left: 0;
    background: var(--surface);
    z-index: 1;
}

.habits-grid__date-col {
    min-width: 2.25rem;
}

.habits-grid__date-col--month {
    min-width: 1.75rem;
    font-size: 0.75rem;
}

.habits-grid__cell--week,
.habits-grid__cell--month {
    cursor: pointer;
    min-width: 2.25rem;
    transition: background 0.15s;
}

.habits-grid__cell--month {
    min-width: 1.75rem;
    font-size: 0.85rem;
}

.habits-grid__cell--week:hover,
.habits-grid__cell--month:hover {
    background: var(--bg);
}

.habit-cell--red { background: rgba(220, 38, 38, 0.25); color: #dc2626; }
.habit-cell--yellow { background: rgba(202, 138, 4, 0.25); color: #ca8a04; }
.habit-cell--green { background: rgba(22, 163, 74, 0.25); color: #16a34a; }

.dark .habit-cell--red { background: rgba(248, 113, 113, 0.2); color: #f87171; }
.dark .habit-cell--yellow { background: rgba(234, 179, 8, 0.2); color: #eab308; }
.dark .habit-cell--green { background: rgba(34, 197, 94, 0.2); color: #22c55e; }

.habits-empty {
    padding: 2rem;
    text-align: center;
    color: var(--text-muted);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
    border: none;
}

.btn-danger:hover {
    background: var(--danger-hover);
}

/* ----- Pomodoro Timer ----- */
.pomo-main {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 120px);
}

.pomo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    max-width: 400px;
    width: 100%;
    padding: 2rem 1rem;
}

.pomo__modes {
    display: flex;
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}

.pomo__mode-btn {
    padding: 0.5rem 1.1rem;
    font-size: 0.88rem;
    font-weight: 500;
    font-family: var(--font);
    background: transparent;
    color: var(--text-muted);
    border: none;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.pomo__mode-btn:hover {
    color: var(--text);
}

.pomo__mode-btn.active {
    background: var(--primary);
    color: #fff;
}

.dark .pomo__mode-btn.active {
    color: #1a1b1e;
}

.pomo__ring-wrap {
    position: relative;
    width: 240px;
    height: 240px;
}

.pomo__ring {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.pomo__ring-bg {
    fill: none;
    stroke: var(--border);
    stroke-width: 6;
}

.pomo__ring-progress {
    fill: none;
    stroke: var(--primary);
    stroke-width: 6;
    stroke-linecap: round;
    stroke-dasharray: 565.48;
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 0.4s ease;
}

.pomo__time {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3.5rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--text);
    letter-spacing: -0.02em;
}

.pomo__label {
    font-size: 1rem;
    color: var(--text-muted);
    text-align: center;
    min-height: 1.5em;
}

.pomo__controls {
    display: flex;
    gap: 0.75rem;
}

.pomo__btn {
    min-width: 6rem;
    padding: 0.65rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 10px;
    text-align: center;
}

.pomo__btn[hidden] {
    display: none;
}

.pomo__sessions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.88rem;
    color: var(--text-muted);
}

.pomo__dots {
    display: flex;
    gap: 4px;
    align-items: center;
}

.pomo__dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--border);
    transition: background 0.2s;
}

.pomo__dot--filled {
    background: var(--primary);
}

.pomo__dot--break {
    width: 14px;
    height: 14px;
    border: 2px solid var(--primary);
    background: transparent;
}

.pomo__dot--break.pomo__dot--filled {
    background: var(--primary);
}

.pomo__settings {
    width: 100%;
    max-width: 320px;
}

.pomo__settings-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
}

.pomo__settings-toggle {
    padding: 0.6rem 1rem;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    list-style: none;
    text-align: center;
}

.pomo__settings-toggle::-webkit-details-marker {
    display: none;
}

.pomo__settings-toggle::marker {
    content: '';
}

.pomo__settings-toggle:hover {
    color: var(--text);
}

.pomo__settings-body {
    padding: 0.75rem 1rem 1rem;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.pomo__setting {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.pomo__setting label {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-weight: 500;
}

.pomo__setting input[type="number"] {
    width: 100%;
    padding: 0.4rem 0.6rem;
    font-size: 0.9rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
}

.pomo__setting--row {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
}

.pomo__setting--row input[type="checkbox"] {
    width: 1.1rem;
    height: 1.1rem;
    accent-color: var(--primary);
    cursor: pointer;
}

/* ----- View Switcher ----- */
.view-switcher {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    margin-left: auto;
    flex-shrink: 0;
}

.view-switcher__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 30px;
    padding: 0;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.view-switcher__btn:not(:last-child) {
    border-right: 1px solid var(--border);
}

.view-switcher__btn:hover {
    background: var(--bg);
    color: var(--text);
}

.view-switcher__btn.active {
    background: var(--primary);
    color: #fff;
}

.dark .view-switcher__btn.active {
    color: #1a1b1e;
}

.view-switcher__btn svg {
    width: 15px;
    height: 15px;
    pointer-events: none;
}

/* ----- Feature List View (shared across goals/books/films/shopping) ----- */
.feature-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding-bottom: 2rem;
}

.feature-list__section {
    background: var(--surface);
    border-radius: 12px;
    border: 1px solid var(--border);
    padding: 0.75rem 1rem;
}

.feature-list__section-title {
    margin: 0 0 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.feature-list__items {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.feature-list__row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.65rem;
    border-radius: 6px;
    border-left: 3px solid var(--border);
    background: var(--bg);
    transition: background 0.15s;
}

.feature-list__row:hover {
    background: var(--surface);
}

.feature-list__row--faded {
    opacity: 0.6;
}

.feature-list__row--asap { border-left-color: var(--asap); }
.feature-list__row--high { border-left-color: var(--high); }
.feature-list__row--medium { border-left-color: var(--medium); }
.feature-list__row--low { border-left-color: var(--low); }
.feature-list__row--seed { border-left-color: #94a3b8; }
.feature-list__row--bud { border-left-color: #fbbf24; }
.feature-list__row--evergreen { border-left-color: #4ade80; }

.feature-list__name {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 0.92rem;
    font-weight: 500;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.feature-list__subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 10rem;
    flex-shrink: 0;
}

.feature-list__meta {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
    flex-wrap: nowrap;
}

.feature-list__pill {
    padding: 0.1rem 0.4rem;
    border-radius: 8px;
    font-size: 0.7rem;
    font-weight: 500;
    border: 1px solid var(--border);
    background: var(--bg);
    white-space: nowrap;
}

.feature-list__pill--genre,
.feature-list__pill--category {
    color: var(--primary);
    border-color: var(--primary);
    background: transparent;
}

.feature-list__pill--type {
    color: var(--text-muted);
    font-style: italic;
}

.feature-list__pill--status {
    text-transform: capitalize;
}

.feature-list__pill--priority-asap { color: var(--asap); border-color: var(--asap); }
.feature-list__pill--priority-high { color: var(--high); border-color: var(--high); }
.feature-list__pill--priority-medium { color: var(--medium); border-color: var(--medium); }
.feature-list__pill--priority-low { color: var(--low); border-color: var(--low); }

.feature-list__date {
    font-size: 0.78rem;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

.feature-list__stars {
    display: flex;
    gap: 1px;
    font-size: 0.8rem;
    color: var(--border);
    flex-shrink: 0;
}

.feature-list__stars .star--filled {
    color: #f59e0b;
}

.feature-list__progress {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

.feature-list__price {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--primary);
    white-space: nowrap;
    flex-shrink: 0;
}

.feature-list__labels {
    display: flex;
    gap: 0.25rem;
    flex-shrink: 0;
}

.feature-list__label {
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    font-size: 0.68rem;
    font-weight: 500;
    white-space: nowrap;
    color: hsl(var(--tag-hue) 50% 38%);
    background: hsl(var(--tag-hue) 48% 94%);
    border: 1px solid hsl(var(--tag-hue) 40% 82%);
}

.dark .feature-list__label {
    color: hsl(var(--tag-hue) 65% 75%);
    background: hsl(var(--tag-hue) 25% 18%);
    border-color: hsl(var(--tag-hue) 25% 30%);
}

.feature-list__url {
    font-size: 0.75rem;
    color: var(--primary);
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 8rem;
    flex-shrink: 1;
}

.feature-list__url:hover {
    text-decoration: underline;
}

.feature-list__actions {
    display: flex;
    gap: 0.2rem;
    flex-shrink: 0;
}

.feature-list__action {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-size: 0.85rem;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
}

.feature-list__action:hover {
    color: var(--text);
    background: var(--surface);
}

.feature-list__empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* ----- Board View (Kanban columns) ----- */
.board-layout {
    display: flex;
    gap: 1rem;
    padding-bottom: 2rem;
    overflow-x: auto;
    scrollbar-width: thin;
    align-items: flex-start;
}

.board-column {
    flex: 1 1 0;
    min-width: 260px;
    max-width: 380px;
    display: flex;
    flex-direction: column;
}

.board-column__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.55rem 0.75rem;
    margin-bottom: 0.5rem;
    border-radius: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
}

.board-column__title {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text);
    margin: 0;
}

.board-column__count {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--bg);
    padding: 0.15rem 0.45rem;
    border-radius: 8px;
}

.board-column__items {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
    min-height: 4rem;
    padding: 0.5rem;
    background: var(--bg);
    border-radius: 10px;
    border: 1px dashed var(--border);
}

.board-column__empty {
    text-align: center;
    padding: 1.5rem 0.5rem;
    color: var(--text-muted);
    font-size: 0.82rem;
}

/* ----- Mobile responsive ----- */
@media (max-width: 768px) {
    .app-header {
        padding: 0.5rem 0.75rem;
        gap: 0.5rem;
    }

    .app-header h1 {
        font-size: 1.15rem;
    }

    .mode-btn {
        padding: 0.35rem 0.65rem;
        font-size: 0.82rem;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        z-index: 90;
        width: 56px;
        height: 100vh;
        padding-top: 52px;
    }

    .sidebar.sidebar--expanded {
        width: 200px;
        box-shadow: 4px 0 16px var(--shadow);
    }

    .sidebar__toggle {
        display: block;
    }

    .sidebar:not(.sidebar--expanded) .sidebar__label {
        display: none;
    }

    .sidebar:not(.sidebar--expanded) .sidebar__item {
        justify-content: center;
        padding: 0.6rem;
    }

    .sidebar:not(.sidebar--expanded) .sidebar__icon {
        width: auto;
    }

    .app-content {
        margin-left: 56px;
    }

    .sidebar.sidebar--expanded ~ .sidebar-backdrop {
        display: block;
    }

    .sidebar.sidebar--expanded ~ .app-content {
        margin-left: 56px;
    }

    .app-main {
        padding: 1rem 0.75rem;
    }

    .goals-grid,
    .media-grid {
        grid-template-columns: 1fr;
    }

    .board-layout {
        flex-direction: column;
    }

    .board-column {
        min-width: 0;
        max-width: none;
    }

    .feature-list__row {
        flex-wrap: wrap;
        gap: 0.4rem;
    }

    .feature-list__meta {
        flex-wrap: wrap;
    }

    .feature-list__subtitle {
        max-width: 6rem;
    }

    .modal-content {
        max-width: 100%;
        max-height: 95vh;
        border-radius: 10px;
    }

    .modal {
        padding: 0.5rem;
    }

    .task-form {
        padding: 1rem;
    }

    .goal-card__action,
    .media-card__action {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }

    .task-list__action {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }

    .task-list__sort-dir {
        width: 36px;
        height: 36px;
    }

    .task-list__section {
        padding: 0.75rem 0.75rem;
    }
}

@media (max-width: 640px) {
    .task-list__row {
        flex-wrap: wrap;
        padding: 0.5rem 0.6rem;
        gap: 0.4rem;
    }

    .task-list__meta {
        order: 3;
        width: 100%;
        margin-left: 0;
        gap: 0.35rem;
    }

    .task-list__name {
        font-size: 0.9rem;
    }

    .task-list__priority-select,
    .task-list__group-select {
        font-size: 0.72rem;
        padding: 0.3rem 0.4rem;
    }

    .goals-toolbar,
    .toolbar {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .goals-filter-select {
        font-size: 0.82rem;
        padding: 0.35rem 0.5rem;
    }

    .goals-grid,
    .media-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .feature-list__subtitle {
        display: none;
    }

    .feature-list__url {
        display: none;
    }

    .header-actions {
        gap: 0.35rem;
    }

    .app-header__brand {
        gap: 0.4rem;
    }

    .form-actions {
        flex-direction: column;
        gap: 0.5rem;
    }

    .form-actions .btn {
        width: 100%;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .sidebar {
        width: 0;
        overflow: visible; /* keep so fixed-position toggle stays visible */
    }

    .sidebar:not(.sidebar--expanded) .sidebar__nav {
        display: none; /* hide nav when collapsed so only toggle shows */
    }

    .sidebar.sidebar--expanded {
        width: 200px;
        overflow: hidden;
    }

    .app-content {
        margin-left: 0;
    }

    .sidebar__toggle {
        display: block;
        position: fixed;
        top: max(0.5rem, env(safe-area-inset-top));
        left: max(0.5rem, env(safe-area-inset-left));
        z-index: 95;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: 6px;
        padding: 0.35rem 0.55rem;
        font-size: 1.1rem;
        min-width: 44px;
        min-height: 44px;
        box-sizing: border-box;
    }

    .app-header {
        padding-left: 2.75rem;
        padding-left: calc(2.75rem + env(safe-area-inset-left));
    }

    .app-main {
        padding: 0.75rem 0.5rem;
    }
}

/* Touch-friendly targets (44px minimum) on touch devices */
@media (pointer: coarse) {
    .mode-btn,
    .icon-btn {
        min-height: 44px;
        min-width: 44px;
        padding: 0.5rem 0.75rem;
        box-sizing: border-box;
    }

    .sidebar__item {
        min-height: 44px;
        padding: 0.65rem 0.75rem;
        box-sizing: border-box;
    }

    .modal-close {
        min-width: 44px;
        min-height: 44px;
        padding: 0.5rem;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .view-switcher__btn {
        min-width: 44px;
        min-height: 44px;
    }

    .task-list__action,
    .goal-card__action,
    .media-card__action {
        min-width: 44px;
        min-height: 44px;
    }

    .task-list__sort-dir {
        min-width: 44px;
        min-height: 44px;
    }
}
