/* Nxtly – grafisk profil v1.0 (Inter + Jade Teal) */

:root {
    /* Nøytrale */
    --color-ink:    #1A2035;
    --color-slate:  #4A5568;
    --color-mist:   #8A94A6;
    --color-frost:  #E2E8F0;
    --color-cloud:  #F7F8FA;
    --color-white:  #FFFFFF;

    /* Accent */
    --color-jade-50:  #E6FAF6;
    --color-jade-300: #00E5C8;
    --color-jade-500: #00C9A7;
    --color-jade-700: #009B80;

    /* Støttefarger */
    --color-royal:  #3D52C4;
    --color-ember:  #F97316;
    --color-leaf:   #22C55E;
    --color-coral:  #EF4444;
    --color-amber:  #F59E0B;

    /* Gradienter */
    --gradient-bg:     linear-gradient(135deg, #F7F8FA 0%, #EEF2FF 100%);
    --gradient-dark:   linear-gradient(135deg, #1A2035 0%, #2D3A5C 100%);
    --gradient-accent: linear-gradient(135deg, #00C9A7 0%, #00E5C8 60%, #3D52C4 140%);

    /* Radiuser */
    --radius-sm:   6px;
    --radius-md:   10px;
    --radius-lg:   14px;
    --radius-xl:   20px;
    --radius-pill: 999px;

    /* Skygger */
    --shadow-sm: 0 1px 3px rgba(26,32,53,0.07);
    --shadow-md: 0 4px 16px rgba(26,32,53,0.10);
    --shadow-lg: 0 8px 32px rgba(26,32,53,0.14);

    /* Typografi-fallbacks */
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    min-height: 100vh;
    background: var(--color-cloud);
    color: var(--color-ink);
    font-family: var(--font-body);
    font-size: 0.875rem;  /* 14px */
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1 { font-size: 1.625rem; font-weight: 600; line-height: 1.2; margin: 0; color: var(--color-ink); }
h2 { font-size: 1.25rem;  font-weight: 500; line-height: 1.3; margin: 0; color: var(--color-ink); }
h3 { font-size: 1rem;     font-weight: 500; line-height: 1.4; margin: 0; color: var(--color-ink); }

/* Sørg for at [hidden] slår gjennom element-spesifikke display-regler */
[hidden] { display: none !important; }

/* ───────── Login ───────── */

#view-login {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: var(--gradient-bg);
}
#login-form {
    background: var(--color-white);
    padding: 32px;
    border-radius: var(--radius-lg);
    border: 1.5px solid var(--color-frost);
    width: 100%;
    max-width: 380px;
    box-shadow: var(--shadow-lg);
    text-align: center;
}
.login-logo {
    display: block;
    margin: 0 auto 12px;
    border-radius: var(--radius-lg);
}
#login-form h1 { margin: 0 0 4px; font-size: 2.25rem; line-height: 1.15; }
#login-form .subtitle { margin: 0 0 24px; color: var(--color-slate); }
#login-form label {
    display: block;
    margin-bottom: 16px;
    font-size: 0.6875rem;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-mist);
    text-align: left;
}
#login-form input {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 10px 12px;
    font-size: 0.875rem;
    border: 1.5px solid var(--color-frost);
    border-radius: var(--radius-sm);
    background: var(--color-white);
    color: var(--color-ink);
    font-family: inherit;
    text-transform: none;
    letter-spacing: normal;
}
#login-form input:focus {
    outline: none;
    border-color: var(--color-jade-500);
    box-shadow: 0 0 0 3px rgba(0,201,167,0.15);
}
#login-form button {
    width: 100%;
    padding: 0.55rem 1.25rem;
    border: none;
    border-radius: var(--radius-md);
    background: var(--color-jade-500);
    color: var(--color-white);
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s;
}
#login-form button:hover { background: var(--color-jade-300); }
#login-form .error {
    margin: 16px 0 0;
    padding: 10px 12px;
    background: rgba(239,68,68,0.10);
    color: var(--color-coral);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    text-align: left;
}

/* ───────── App chrome ───────── */

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 24px;
    background: var(--color-white);
    border-bottom: 1.5px solid var(--color-frost);
    gap: 24px;
}
.topbar-left { display: flex; align-items: center; gap: 24px; min-width: 0; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    background: transparent;
    border: none;
    padding: 0;
    cursor: pointer;
    font-family: inherit;
}
.brand-logo { border-radius: var(--radius-sm); flex-shrink: 0; }
.brand-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-ink);
    transition: color 0.15s;
}
.brand:hover .brand-name { color: var(--color-jade-700); }

.ws-switcher { position: relative; }
.ws-switcher-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--color-white);
    border: 1.5px solid var(--color-frost);
    border-radius: var(--radius-md);
    color: var(--color-ink);
    cursor: pointer;
    font-size: 0.8125rem;
    font-weight: 500;
    font-family: inherit;
    transition: background 0.15s, border-color 0.15s;
    max-width: 200px;
}
.ws-switcher-btn:hover { background: var(--color-cloud); }
.ws-switcher-btn > span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ws-switcher-btn .chevron {
    width: 12px;
    height: 12px;
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
    flex-shrink: 0;
    color: var(--color-mist);
    transition: transform 0.15s;
}
.ws-switcher-btn[aria-expanded=true] .chevron { transform: rotate(180deg); }

.ws-switcher-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 240px;
    background: var(--color-white);
    border: 1.5px solid var(--color-frost);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    padding: 4px;
    z-index: 500;
}
.ws-switcher-list { display: flex; flex-direction: column; }
.ws-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--color-ink);
    font-family: inherit;
    font-size: 0.8125rem;
    text-align: left;
    width: 100%;
}
.ws-option:hover { background: var(--color-cloud); }
.ws-option.current { background: var(--color-jade-50); color: var(--color-jade-700); font-weight: 500; }
.ws-option .ws-type-badge {
    font-size: 0.625rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-mist);
    padding: 1px 6px;
    border: 1px solid var(--color-frost);
    border-radius: var(--radius-pill);
    margin-left: auto;
    flex-shrink: 0;
    font-weight: 500;
}
.ws-option.combined { border-top: 1px solid var(--color-frost); margin-top: 2px; padding-top: 10px; }
.ws-option.combined .ws-type-badge { color: var(--color-jade-700); border-color: var(--color-jade-500); background: var(--color-jade-50); }

/* Combined-mode visibility toggles */
.combined-only { display: none !important; }
body.combined-mode .combined-only { display: revert !important; }
body.combined-mode .combined-hidden { display: none !important; }

.quick-add select[name=workspace_id] {
    padding: 0.55rem 10px;
    border: 1.5px solid var(--color-frost);
    border-radius: var(--radius-sm);
    background: var(--color-white);
    color: var(--color-ink);
    font-size: 0.8125rem;
    font-family: inherit;
    max-width: 160px;
}
#note-create select[name=workspace_id] {
    padding: 0.55rem 10px;
    border: 1.5px solid var(--color-frost);
    border-radius: var(--radius-sm);
    background: var(--color-white);
    color: var(--color-ink);
    font-size: 0.8125rem;
    font-family: inherit;
    max-width: 200px;
    margin-right: auto;
}
.ws-section {
    margin-bottom: 20px;
}
.ws-section-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 4px 8px;
    font-size: 0.6875rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-mist);
}
.ws-section-head .ws-type-badge {
    font-size: 0.625rem;
    padding: 1px 6px;
    border: 1px solid var(--color-frost);
    border-radius: var(--radius-pill);
    color: var(--color-mist);
    font-weight: 500;
    letter-spacing: 0.04em;
}
.ws-badge {
    font-size: 0.625rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-slate);
    padding: 1px 8px;
    border-radius: var(--radius-pill);
    background: var(--color-cloud);
    border: 1px solid var(--color-frost);
    white-space: nowrap;
}
.list-badge {
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--color-slate);
    padding: 1px 8px;
    border-radius: var(--radius-pill);
    background: var(--color-cloud);
    white-space: nowrap;
}
.ws-switcher-dropdown > button[data-ws-action=create] {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 12px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.8125rem;
    color: var(--color-jade-700);
    font-family: inherit;
    font-weight: 500;
}
.ws-switcher-dropdown > button[data-ws-action=create]:hover { background: var(--color-jade-50); }

.user-menu { position: relative; }
.user-menu-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0.4rem 0.85rem;
    background: var(--color-white);
    border: 1.5px solid var(--color-frost);
    border-radius: var(--radius-md);
    color: var(--color-ink);
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 500;
    font-family: inherit;
    transition: background 0.15s;
    max-width: 220px;
}
.user-menu-btn:hover { background: var(--color-cloud); }
.user-menu-btn > span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.user-menu-btn .chevron {
    width: 12px;
    height: 12px;
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
    flex-shrink: 0;
    transition: transform 0.15s;
}
.user-menu-btn[aria-expanded=true] .chevron { transform: rotate(180deg); }

.user-menu-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 180px;
    background: var(--color-white);
    border: 1.5px solid var(--color-frost);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    padding: 4px;
    z-index: 500;
}
.user-menu-dropdown button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 12px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--color-ink);
    cursor: pointer;
    font-size: 0.8125rem;
    font-family: inherit;
}
.user-menu-dropdown button:hover { background: var(--color-cloud); }
.user-menu-divider { height: 1px; background: var(--color-frost); margin: 4px 0; }

.tabs {
    display: flex;
    align-items: center;
    gap: 2px;
}
.tab {
    padding: 6px 12px;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--color-mist);
    cursor: pointer;
    font-size: 0.8125rem;
    font-weight: 500;
    font-family: inherit;
    transition: color 0.15s, background 0.15s;
}
.tab:hover { color: var(--color-ink); background: var(--color-cloud); }
.tab.active { color: var(--color-jade-700); background: var(--color-jade-50); }

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: transparent;
    border: 1.5px solid var(--color-frost);
    border-radius: var(--radius-md);
    color: var(--color-slate);
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--color-cloud); color: var(--color-ink); }
.icon-btn .icon {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}

main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px;
}

/* ───────── Dashboard ───────── */

.greeting { margin-bottom: 24px; padding: 8px 4px; }
.greeting h1 {
    font-size: 2.25rem;
    font-weight: 600;
    line-height: 1.15;
    margin: 0 0 4px;
}
.greeting-date {
    margin: 0;
    font-size: 0.8125rem;
    color: var(--color-slate);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 16px;
    align-items: start;
}

.dash-card {
    background: var(--color-white);
    border: 1.5px solid var(--color-frost);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.dash-overdue { border-color: rgba(239,68,68,0.28); }
.dash-overdue .dash-head h2 { color: var(--color-coral); }

.dash-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    border: none;
    padding: 0;
}
.dash-head h2 { margin: 0; font-size: 0.75rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.08em; color: var(--color-mist); }
.dash-link {
    background: transparent;
    border: none;
    color: var(--color-jade-500);
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 500;
    font-family: inherit;
    padding: 0;
}
.dash-link:hover { color: var(--color-jade-700); text-decoration: underline; }

.dash-items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.dash-empty { margin: 0; color: var(--color-mist); font-size: 0.8125rem; padding: 4px 0; }

.home-todo {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 10px;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid var(--color-cloud);
}
.home-todo:last-child { border-bottom: none; }
.home-todo.done .home-todo-title { color: var(--color-mist); text-decoration: line-through; }
.home-todo-title {
    font-size: 0.875rem;
    color: var(--color-ink);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.home-todo-due {
    font-size: 0.75rem;
    color: var(--color-slate);
    white-space: nowrap;
}
.home-todo-due.overdue { color: var(--color-coral); font-weight: 500; }

.dash-notes { gap: 10px; }

/* ───────── Notes master-detail ───────── */

.notes-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 16px;
    align-items: start;
}
.notes-list-col {
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: sticky;
    top: 24px;
    max-height: calc(100vh - 160px);
}
.notes-new {
    padding: 8px 14px;
    background: var(--color-jade-500);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.8125rem;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s;
}
.notes-new:hover { background: var(--color-jade-300); }

.notes-list-items {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
    flex: 1;
}
.note-item {
    padding: 10px 14px;
    background: var(--color-white);
    border: 1.5px solid var(--color-frost);
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: border-color 0.12s, background 0.12s;
}
.note-item:hover { border-color: var(--color-mist); }
.note-item.selected {
    border-color: var(--color-jade-500);
    background: var(--color-jade-50);
}
.note-item-head {
    display: flex;
    align-items: center;
    gap: 6px;
}
.note-item-pin {
    color: var(--color-jade-500);
    width: 12px;
    height: 12px;
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
    flex-shrink: 0;
}
.note-item-title {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-ink);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.note-item-snippet {
    font-size: 0.75rem;
    color: var(--color-slate);
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.4;
}
.note-item-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.6875rem;
    color: var(--color-mist);
    gap: 8px;
}
.note-item-folder {
    padding: 1px 8px;
    background: var(--color-cloud);
    border-radius: var(--radius-pill);
    color: var(--color-slate);
    font-weight: 500;
}
.note-item.selected .note-item-folder { background: var(--color-white); }

.notes-editor-col {
    min-height: 520px;
    background: var(--color-white);
    border: 1.5px solid var(--color-frost);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
}
.notes-editor-empty {
    flex: 1;
    display: grid;
    place-items: center;
    color: var(--color-mist);
    font-size: 0.875rem;
    text-align: center;
}
.notes-editor-form {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.editor-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--color-ink);
    border: none;
    outline: none;
    background: transparent;
    padding: 0 0 6px;
    font-family: inherit;
    width: 100%;
    line-height: 1.3;
}
.editor-title::placeholder { color: var(--color-mist); }
.editor-toolbar {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--color-frost);
    flex-wrap: wrap;
}
.editor-toolbar > label {
    font-size: 0.75rem;
    color: var(--color-slate);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-transform: none;
    letter-spacing: normal;
    flex-direction: row;
}
.editor-toolbar select {
    padding: 4px 10px;
    border: 1.5px solid var(--color-frost);
    border-radius: var(--radius-sm);
    background: var(--color-white);
    color: var(--color-ink);
    font-size: 0.75rem;
    font-family: inherit;
}
.editor-spacer { flex: 1; }
.editor-toolbar .btn-ghost {
    padding: 0.4rem 0.9rem;
    font-size: 0.75rem;
}
.editor-toolbar .btn-save {
    padding: 0.4rem 1.1rem;
    background: var(--color-jade-500);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}
.editor-toolbar .btn-save:hover { background: var(--color-jade-300); }
.editor-updated {
    font-size: 0.6875rem;
    color: var(--color-mist);
    padding: 4px 0;
}
.editor-content {
    flex: 1;
    min-height: 340px;
    border: none;
    outline: none;
    background: transparent;
    font-size: 0.8125rem;
    line-height: 1.65;
    color: var(--color-ink);
    font-family: inherit;
    resize: none;
    padding: 4px 0;
}
.editor-content::placeholder { color: var(--color-mist); }
.editor-content[contenteditable=true]:empty::before {
    content: attr(data-placeholder);
    color: var(--color-mist);
    pointer-events: none;
}
.editor-content[contenteditable=true] {
    white-space: pre-wrap;
    word-break: break-word;
}
.editor-content[contenteditable=true] ul,
.editor-content[contenteditable=true] ol {
    padding-left: 24px;
    margin: 8px 0;
}
.editor-content[contenteditable=true] li { margin: 2px 0; }
.editor-content[contenteditable=true] a {
    color: var(--color-jade-700);
    text-decoration: underline;
    text-decoration-color: var(--color-jade-300);
}
.editor-content[contenteditable=true] input[type=checkbox] {
    margin-right: 6px;
    vertical-align: middle;
    cursor: pointer;
}
.editor-content[contenteditable=true] s,
.editor-content[contenteditable=true] strike,
.editor-content[contenteditable=true] del {
    color: var(--color-mist);
}

.rich-toolbar {
    display: flex;
    gap: 2px;
    padding: 6px 0;
    border-bottom: 1px solid var(--color-frost);
}
.rich-toolbar button {
    background: transparent;
    border: none;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    color: var(--color-slate);
    cursor: pointer;
    font-family: inherit;
    line-height: 0;
}
.rich-toolbar button:hover { background: var(--color-cloud); color: var(--color-ink); }
.rich-toolbar button .icon {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}
.rich-toolbar button[data-rt=bold] .icon { stroke-width: 2.2; }
.rich-toolbar .toolbar-separator {
    width: 1px;
    height: 20px;
    background: var(--color-frost);
    margin: 0 4px;
    align-self: center;
}

.editor-content[contenteditable=true] h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 12px 0 6px;
    line-height: 1.25;
}
.editor-content[contenteditable=true] h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 10px 0 6px;
    line-height: 1.3;
}
.editor-content[contenteditable=true] hr {
    border: none;
    border-top: 1.5px solid var(--color-frost);
    margin: 14px 0;
}

.btn-danger {
    padding: 0.55rem 1.1rem;
    background: var(--color-coral);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}
.btn-danger:hover { opacity: 0.9; }

.save-status {
    font-size: 0.6875rem;
    color: var(--color-mist);
    padding: 4px 0;
    transition: color 0.2s;
    min-height: 18px;
}
.save-status.saving { color: var(--color-jade-700); }

.editor-folder-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.6875rem;
    font-weight: 500;
    padding: 3px 10px;
    background: var(--color-cloud);
    color: var(--color-slate);
    border-radius: var(--radius-pill);
}
.editor-folder-chip .icon {
    width: 11px;
    height: 11px;
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}

/* Note-window (standalone) mode */
body.note-window .tabs,
body.note-window .ws-switcher,
body.note-window .notes-list-col,
body.note-window .sidebar { display: none !important; }
body.note-window .app-layout { grid-template-columns: 1fr !important; }
body.note-window .notes-layout { grid-template-columns: 1fr; }
body.note-window .notes-editor-col { max-width: 820px; margin: 0 auto; }
body.note-window main { padding-top: 16px; }
body.note-window .icon-btn[data-action=open-window] { display: none !important; }

@media (max-width: 820px) {
    .notes-layout { grid-template-columns: 1fr; }
    .notes-list-col { position: static; max-height: none; }
}
.home-note {
    padding: 8px 0;
    border-bottom: 1px solid var(--color-cloud);
}
.home-note:last-child { border-bottom: none; }
.home-note h3 { margin: 0; font-size: 0.875rem; font-weight: 500; color: var(--color-ink); }
.home-note p {
    margin: 4px 0 0;
    color: var(--color-slate);
    font-size: 0.75rem;
    line-height: 1.5;
    white-space: pre-wrap;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* ───────── Layout: sidebar + main-col ───────── */

.app-layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 24px;
    align-items: start;
}

.sidebar {
    position: sticky;
    top: 24px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-org {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px 12px;
    margin-bottom: 6px;
    background: var(--color-white);
    border: 1.5px solid var(--color-frost);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    cursor: default;
}
.sidebar-org .org-label {
    font-size: 0.6875rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-mist);
}
.sidebar-org .org-name {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--color-ink);
}

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

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: var(--radius-md);
    color: var(--color-slate);
    cursor: pointer;
    font-size: 0.8125rem;
    transition: background 0.12s, color 0.12s;
}
.sidebar-item:hover { background: var(--color-white); color: var(--color-ink); }
.sidebar-item.active {
    background: var(--color-jade-50);
    color: var(--color-jade-700);
    font-weight: 500;
}
.sidebar-item.drop-target {
    background: var(--color-jade-50) !important;
    outline: 1.5px solid var(--color-jade-500);
    outline-offset: -1.5px;
}

.todo[draggable=true], .note-item[draggable=true] { cursor: grab; }
.todo.dragging, .note-item.dragging { opacity: 0.4; }
.sidebar-item .label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-item .icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}
.sidebar-item .delete {
    display: none;
    background: transparent;
    border: none;
    color: var(--color-mist);
    cursor: pointer;
    padding: 2px;
    border-radius: 4px;
    font-family: inherit;
    line-height: 0;
}
.sidebar-item .delete .icon {
    width: 14px;
    height: 14px;
}
.sidebar-item:hover .delete { display: inline-flex; align-items: center; }
.sidebar-item .delete:hover { background: rgba(239,68,68,0.12); color: var(--color-coral); }

.sidebar-rename {
    flex: 1;
    min-width: 0;
    padding: 2px 6px;
    border: 1.5px solid var(--color-jade-500);
    border-radius: var(--radius-sm);
    background: var(--color-white);
    color: var(--color-ink);
    font-size: 0.8125rem;
    font-family: inherit;
    outline: none;
    box-shadow: 0 0 0 3px rgba(0,201,167,0.15);
}

.sidebar-add { margin-top: 8px; }

.sidebar-section {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--color-frost);
}
.sidebar-section-label {
    font-size: 0.6875rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-mist);
    margin-bottom: 8px;
    padding: 0 2px;
}
.sidebar-tags {
    list-style: none;
    margin: 0 0 8px;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

/* Combined sidebar tree */
.sidebar-divider {
    height: 1px;
    background: var(--color-frost);
    margin: 8px 4px;
    list-style: none;
}
.ws-group { list-style: none; margin: 2px 0; }
.ws-group-head {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: var(--radius-md);
    cursor: pointer;
    color: var(--color-ink);
    font-size: 0.8125rem;
    font-weight: 500;
    transition: background 0.12s;
}
.ws-group-head:hover { background: var(--color-cloud); }
.ws-group-head .chevron {
    width: 12px;
    height: 12px;
    stroke: var(--color-mist);
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
    transform: rotate(-90deg);
    transition: transform 0.15s;
    flex-shrink: 0;
}
.ws-group.expanded .ws-group-head .chevron { transform: rotate(0); }
.ws-group-head .label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ws-group-head .ws-type-badge {
    font-size: 0.625rem;
    padding: 1px 6px;
    border: 1px solid var(--color-frost);
    border-radius: var(--radius-pill);
    color: var(--color-mist);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 500;
}
.ws-group-items {
    list-style: none;
    margin: 2px 0 6px 14px;
    padding: 0 0 0 10px;
    border-left: 1px solid var(--color-frost);
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.ws-group-items .sidebar-item { padding: 6px 10px; font-size: 0.8125rem; }
.ws-group-items .sidebar-item .icon { width: 14px; height: 14px; }
.sidebar-item.combined-root { font-weight: 500; }
.tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px 3px 10px;
    background: var(--color-cloud);
    color: var(--color-ink);
    border-radius: var(--radius-pill);
    font-size: 0.6875rem;
    font-weight: 500;
    cursor: pointer;
    border: 1.5px solid transparent;
    transition: background 0.12s, border-color 0.12s;
    position: relative;
}
.tag-chip::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--tag-color, var(--color-mist));
    flex-shrink: 0;
}
.tag-chip:hover { background: var(--color-white); border-color: var(--color-frost); }
.tag-chip.active {
    background: var(--color-jade-50);
    color: var(--color-jade-700);
    border-color: var(--color-jade-500);
}
.tag-chip .delete {
    display: none;
    background: transparent;
    border: none;
    color: var(--color-mist);
    cursor: pointer;
    padding: 0;
    margin-left: 2px;
    line-height: 0;
    font-family: inherit;
}
.tag-chip .delete .icon {
    width: 10px;
    height: 10px;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}
.tag-chip:hover .delete { display: inline-flex; align-items: center; }
.tag-chip .delete:hover { color: var(--color-coral); }
.sidebar-add input {
    width: 100%;
    padding: 8px 12px;
    border: 1.5px dashed var(--color-frost);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--color-slate);
    font-size: 0.8125rem;
    font-family: inherit;
}
.sidebar-add input:focus {
    outline: none;
    border-style: solid;
    border-color: var(--color-jade-500);
    box-shadow: 0 0 0 3px rgba(0,201,167,0.15);
    color: var(--color-ink);
    background: var(--color-white);
}

.main-col { min-width: 0; }

/* ───────── Quick-add (todos) ───────── */

.quick-add {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}
.quick-add form {
    flex: 1;
    display: flex;
    gap: 8px;
    background: var(--color-white);
    padding: 12px 14px;
    border: 1.5px solid var(--color-frost);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}
.quick-add input[type=text] {
    flex: 1;
    padding: 0.55rem 12px;
    border: 1.5px solid var(--color-frost);
    border-radius: var(--radius-sm);
    background: var(--color-white);
    color: var(--color-ink);
    font-size: 0.875rem;
    font-family: inherit;
}
.quick-add input[type=text]::placeholder { color: var(--color-mist); }
.quick-add input[type=text]:focus {
    outline: none;
    border-color: var(--color-jade-500);
    box-shadow: 0 0 0 3px rgba(0,201,167,0.15);
}
.quick-add button[type=submit] {
    padding: 0.55rem 1.25rem;
    background: var(--color-jade-500);
    color: var(--color-white);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.8125rem;
    font-family: inherit;
    transition: background 0.15s;
}
.quick-add button[type=submit]:hover { background: var(--color-jade-300); }
.btn-detail {
    background: var(--color-white);
    border: 1.5px solid var(--color-frost);
    border-radius: var(--radius-md);
    color: var(--color-slate);
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
    padding: 0 16px;
    font-family: inherit;
    box-shadow: var(--shadow-sm);
    transition: color 0.15s, border-color 0.15s;
}
.btn-detail:hover { color: var(--color-jade-500); border-color: var(--color-jade-500); }

/* ───────── Panel head (notat-create-form) ───────── */

.panel-head {
    background: var(--color-white);
    border: 1.5px solid var(--color-frost);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
}
.panel-head form { display: flex; flex-direction: column; gap: 8px; margin: 0; }
.panel-head form .row { display: flex; gap: 8px; }
.panel-head form .row.end { justify-content: flex-end; }
.panel-head input[type=text],
.panel-head textarea,
.panel-head select {
    padding: 0.55rem 12px;
    border: 1.5px solid var(--color-frost);
    border-radius: var(--radius-sm);
    background: var(--color-white);
    color: var(--color-ink);
    font-size: 0.875rem;
    font-family: inherit;
}
.panel-head input[type=text]::placeholder,
.panel-head textarea::placeholder { color: var(--color-mist); }
.panel-head input[type=text]:focus,
.panel-head textarea:focus,
.panel-head select:focus {
    outline: none;
    border-color: var(--color-jade-500);
    box-shadow: 0 0 0 3px rgba(0,201,167,0.15);
}
.panel-head textarea { min-height: 72px; resize: vertical; width: 100%; }
.panel-head button[type=submit] {
    padding: 0.55rem 1.25rem;
    background: var(--color-jade-500);
    color: var(--color-white);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.8125rem;
    font-family: inherit;
    transition: background 0.15s;
}
.panel-head button[type=submit]:hover { background: var(--color-jade-300); }

/* ───────── Filtre ───────── */

.filters {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 16px;
    padding: 0 4px;
}
.filters label {
    font-size: 0.75rem;
    color: var(--color-slate);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.filters select {
    padding: 0.4rem 12px;
    border: 1.5px solid var(--color-frost);
    border-radius: var(--radius-sm);
    background: var(--color-white);
    color: var(--color-ink);
    font-size: 0.75rem;
    font-family: inherit;
}
.filters select:focus {
    outline: none;
    border-color: var(--color-jade-500);
    box-shadow: 0 0 0 3px rgba(0,201,167,0.15);
}
.filter-toggle {
    margin-left: auto;
    cursor: pointer;
    user-select: none;
}
.filter-toggle input {
    accent-color: var(--color-jade-500);
    cursor: pointer;
}

/* ───────── Items ───────── */

.items { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.empty { text-align: center; color: var(--color-mist); padding: 32px 0; font-size: 0.8125rem; }

/* Notat-liste har luftigere oppsett enn todo-listen */
#note-list { gap: 8px; }

/* Todo */
.todo {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    gap: 10px;
    align-items: center;
    padding: 6px 12px;
    background: var(--color-white);
    border: 1.5px solid var(--color-frost);
    border-radius: var(--radius-md);
    transition: border-color 0.12s, background 0.12s;
}
.todo:hover { border-color: var(--color-mist); background: var(--color-cloud); }
.todo.subtask {
    margin-left: 28px;
    position: relative;
}
.todo.subtask::before {
    content: '';
    position: absolute;
    left: -18px;
    top: 50%;
    width: 12px;
    height: 1.5px;
    background: var(--color-frost);
}

.todo-tag-chips {
    display: inline-flex;
    gap: 4px;
    align-items: center;
}
.todo-tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px 2px 10px;
    background: var(--color-cloud);
    border-radius: var(--radius-pill);
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--color-slate);
    position: relative;
}
.todo-tag-chip::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--tag-color, var(--color-mist));
    flex-shrink: 0;
}
.todo-toggle {
    width: 18px;
    height: 18px;
    border: 1.5px solid var(--color-frost);
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-white);
    padding: 0;
    line-height: 1;
    flex-shrink: 0;
    transition: all 0.15s;
}
.todo-toggle:hover { border-color: var(--color-jade-500); }
.todo.done .todo-toggle { background: var(--color-jade-500); border-color: var(--color-jade-500); }
.todo.done .todo-title { color: var(--color-mist); text-decoration: line-through; }
.todo-title {
    font-size: 0.875rem;
    color: var(--color-ink);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: text;
}
.todo-title:hover { color: var(--color-jade-700); }
.todo-meta { display: flex; gap: 6px; font-size: 0.75rem; color: var(--color-slate); align-items: center; }
.prio {
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    font-weight: 500;
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.prio-low    { background: var(--color-cloud); color: var(--color-mist); }
.prio-high   { background: rgba(245,158,11,0.12); color: var(--color-amber); }
.prio-urgent { background: rgba(239,68,68,0.12); color: var(--color-coral); }
.due { color: var(--color-slate); font-size: 0.75rem; }
.due.overdue { color: var(--color-coral); font-weight: 500; }

.todo-delete, .note-delete {
    background: transparent;
    border: none;
    color: var(--color-mist);
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
    font-family: inherit;
    line-height: 0;
    transition: color 0.15s, background 0.15s;
}
.todo-delete .icon, .note-delete .icon {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}
.todo-delete:hover, .note-delete:hover {
    color: var(--color-coral);
    background: rgba(239,68,68,0.08);
}

.todo-toggle .icon {
    width: 10px;
    height: 10px;
    stroke: currentColor;
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}

/* Note */
.note {
    background: var(--color-white);
    border: 1.5px solid var(--color-frost);
    padding: 14px 16px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: border-color 0.12s;
}
.note:hover { border-color: var(--color-mist); }
.note-head { display: flex; align-items: center; gap: 8px; }
.note-title {
    margin: 0;
    flex: 1;
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--color-ink);
    cursor: text;
}
.note-title:hover { color: var(--color-jade-700); }
.note-pin {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    color: var(--color-mist);
    font-family: inherit;
    line-height: 0;
    transition: color 0.15s, background 0.15s;
}
.note-pin .icon {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}
.note-pin:hover { color: var(--color-slate); }
.note-pin.active { color: var(--color-jade-500); }
.note-pin.active:hover { color: var(--color-jade-700); background: var(--color-jade-50); }
.note-folder {
    font-size: 0.6875rem;
    color: var(--color-slate);
    padding: 2px 8px;
    background: var(--color-cloud);
    border-radius: var(--radius-pill);
    margin-right: 6px;
    font-weight: 500;
    letter-spacing: 0.02em;
}
.note-text {
    margin: 8px 0 0;
    color: var(--color-slate);
    font-size: 0.8125rem;
    line-height: 1.5;
    white-space: pre-wrap;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
}

/* ───────── Inline edit-former ───────── */

.edit-form {
    background: var(--color-white);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    box-shadow: var(--shadow-sm);
    border: 1.5px solid var(--color-jade-500);
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.edit-form input[type=text],
.edit-form input[type=datetime-local],
.edit-form textarea,
.edit-form select {
    padding: 0.55rem 12px;
    border: 1.5px solid var(--color-frost);
    border-radius: var(--radius-sm);
    background: var(--color-white);
    color: var(--color-ink);
    font-size: 0.875rem;
    font-family: inherit;
    width: 100%;
}
.edit-form input:focus, .edit-form textarea:focus, .edit-form select:focus {
    outline: none;
    border-color: var(--color-jade-500);
    box-shadow: 0 0 0 3px rgba(0,201,167,0.15);
}
.edit-form textarea { min-height: 100px; resize: vertical; }
.edit-form .row { display: flex; gap: 8px; flex-wrap: wrap; }
.edit-form .row > * { flex: 1; min-width: 0; }
.edit-form .actions { display: flex; gap: 8px; justify-content: flex-end; }
.edit-form .actions button {
    padding: 0.55rem 1.25rem;
    border-radius: var(--radius-md);
    border: 1.5px solid transparent;
    cursor: pointer;
    font-size: 0.8125rem;
    font-weight: 600;
    font-family: inherit;
    transition: background 0.15s;
}
.edit-form .btn-save { background: var(--color-jade-500); color: var(--color-white); }
.edit-form .btn-save:hover { background: var(--color-jade-300); }
.edit-form .btn-cancel {
    background: var(--color-white);
    color: var(--color-ink);
    border-color: var(--color-frost);
}
.edit-form .btn-cancel:hover { background: var(--color-cloud); }

/* ───────── Modal ───────── */

.modal {
    position: fixed;
    inset: 0;
    z-index: 900;
    display: grid;
    place-items: center;
    padding: 24px;
}
.modal-backdrop {
    position: absolute;
    inset: 0;
    background: var(--gradient-dark);
    opacity: 0.72;
}
.modal-dialog {
    position: relative;
    background: var(--color-white);
    border: 1.5px solid var(--color-frost);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 520px;
    max-height: calc(100vh - 48px);
    overflow: auto;
    box-shadow: var(--shadow-lg);
}
.modal-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1.5px solid var(--color-frost);
}
.modal-head h2 { margin: 0; font-size: 1rem; font-weight: 600; }
.modal-close {
    background: transparent;
    border: none;
    color: var(--color-mist);
    cursor: pointer;
    font-size: 1.375rem;
    line-height: 1;
    padding: 4px 8px;
    border-radius: 4px;
    font-family: inherit;
}
.modal-close:hover { color: var(--color-coral); background: rgba(239,68,68,0.08); }

.modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.modal-body label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.6875rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-mist);
}
.modal-body label input,
.modal-body label textarea,
.modal-body label select {
    padding: 0.55rem 12px;
    border: 1.5px solid var(--color-frost);
    border-radius: var(--radius-sm);
    background: var(--color-white);
    color: var(--color-ink);
    font-size: 0.875rem;
    font-family: inherit;
    text-transform: none;
    letter-spacing: normal;
}
.modal-body label input:focus,
.modal-body label textarea:focus,
.modal-body label select:focus {
    outline: none;
    border-color: var(--color-jade-500);
    box-shadow: 0 0 0 3px rgba(0,201,167,0.15);
}
.modal-body label textarea { resize: vertical; min-height: 72px; }
.modal-body .row { display: flex; gap: 12px; }
.modal-body .row label { flex: 1; min-width: 0; }
.modal-body .actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 4px;
}
.modal-body .actions button {
    padding: 0.55rem 1.25rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.8125rem;
    font-family: inherit;
    font-weight: 600;
    border: 1.5px solid transparent;
    transition: background 0.15s;
}
.modal-body .btn-save { background: var(--color-jade-500); color: var(--color-white); }
.modal-body .btn-save:hover { background: var(--color-jade-300); }
.modal-body .btn-cancel {
    background: var(--color-white);
    color: var(--color-ink);
    border-color: var(--color-frost);
}
.modal-body .btn-cancel:hover { background: var(--color-cloud); }
.modal-body .error {
    margin: 0;
    padding: 8px 12px;
    background: rgba(239,68,68,0.10);
    color: var(--color-coral);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    text-transform: none;
    letter-spacing: normal;
}
.modal-divider {
    height: 1px;
    background: var(--color-frost);
    margin: 4px 0;
}
.modal-section {
    margin: 0;
    font-size: 0.6875rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-mist);
}
.toggle-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 4px 0;
    text-transform: none;
    letter-spacing: normal;
    color: var(--color-ink);
    cursor: pointer;
}
.toggle-row input[type=checkbox] {
    margin-top: 3px;
    flex-shrink: 0;
}
.toggle-row span {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.toggle-row strong {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--color-ink);
}
.toggle-row small {
    font-size: 0.75rem;
    color: var(--color-slate);
    line-height: 1.4;
}

.grocery-actions {
    margin-top: 16px;
    display: flex;
    justify-content: flex-end;
}

body.grocery-view #todo-filters,
body.grocery-view #todo-modal-open { display: none !important; }

/* Grocery-only and combined-only visibility */
.grocery-only { display: none !important; }
body.grocery-view .grocery-only { display: revert !important; }

#todo-quick-add select[name=repeat] {
    padding: 0.55rem 10px;
    border: 1.5px solid var(--color-frost);
    border-radius: var(--radius-sm);
    background: var(--color-white);
    color: var(--color-ink);
    font-size: 0.8125rem;
    font-family: inherit;
    max-width: 160px;
}

.todo-repeat {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.6875rem;
    color: var(--color-jade-700);
    padding: 2px 8px;
    background: var(--color-jade-50);
    border-radius: var(--radius-pill);
    font-weight: 500;
}
.todo-repeat .icon {
    width: 10px;
    height: 10px;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}
.btn-ghost {
    padding: 0.45rem 0.9rem;
    background: transparent;
    border: 1.5px solid var(--color-frost);
    border-radius: var(--radius-md);
    color: var(--color-slate);
    cursor: pointer;
    font-size: 0.75rem;
    font-family: inherit;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
}
.btn-ghost:hover { background: var(--color-cloud); color: var(--color-ink); }

/* Tags tab */
.color-picker {
    display: flex;
    gap: 4px;
    align-items: center;
}
.color-swatch {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color 0.12s, transform 0.12s;
}
.color-swatch.active {
    border-color: var(--color-ink);
    transform: scale(1.15);
}
.tag-row {
    display: grid;
    grid-template-columns: auto 1fr auto auto auto;
    gap: 12px;
    align-items: center;
    padding: 10px 14px;
    background: var(--color-white);
    border: 1.5px solid var(--color-frost);
    border-radius: var(--radius-md);
    transition: border-color 0.12s, background 0.12s;
}
.tag-row:hover { border-color: var(--color-mist); }
.tag-row .tag-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--tag-color, var(--color-mist));
}
.tag-row .tag-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-ink);
    cursor: pointer;
}
.tag-row .tag-name:hover { color: var(--color-jade-700); }
.tag-row .tag-count {
    font-size: 0.75rem;
    color: var(--color-slate);
    padding: 2px 8px;
    background: var(--color-cloud);
    border-radius: var(--radius-pill);
    white-space: nowrap;
}
.tag-row .tag-action {
    background: transparent;
    border: none;
    color: var(--color-mist);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    line-height: 0;
    font-family: inherit;
}
.tag-row .tag-action .icon {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}
.tag-row .tag-action:hover { color: var(--color-ink); background: var(--color-cloud); }
.tag-row .tag-action.danger:hover { color: var(--color-coral); background: rgba(239,68,68,0.08); }
.tag-row.editing {
    grid-template-columns: 1fr auto auto;
    border-color: var(--color-jade-500);
}
.tag-row input[name=name] {
    padding: 6px 10px;
    border: 1.5px solid var(--color-frost);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-family: inherit;
}

.tag-picker {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.tag-picker-label {
    font-size: 0.6875rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-mist);
}
.tag-picker-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}
.tag-picker-empty {
    margin: 0;
    color: var(--color-mist);
    font-size: 0.75rem;
}
.tag-picker .tag-chip { cursor: pointer; }

.edit-form .tag-picker { margin-top: 4px; }

/* ───────── Search palette ───────── */

.modal-search { padding-top: 10vh; align-items: start; }
.modal-search .modal-dialog { max-width: 640px; padding: 0; }

.search-dialog { display: flex; flex-direction: column; max-height: 70vh; }

.search-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    border-bottom: 1.5px solid var(--color-frost);
}
.search-icon {
    width: 18px;
    height: 18px;
    stroke: var(--color-mist);
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
    flex-shrink: 0;
}
.search-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 1rem;
    font-family: inherit;
    color: var(--color-ink);
    outline: none;
    min-width: 0;
}
.search-input::placeholder { color: var(--color-mist); }
.search-hint {
    font-size: 0.6875rem;
    color: var(--color-mist);
    padding: 3px 8px;
    border: 1px solid var(--color-frost);
    border-radius: var(--radius-sm);
    flex-shrink: 0;
    font-weight: 500;
}

.search-results { flex: 1; overflow: auto; padding: 8px; }
.search-empty {
    margin: 0;
    padding: 24px 12px;
    text-align: center;
    color: var(--color-mist);
    font-size: 0.8125rem;
}

.search-group { margin-bottom: 8px; }
.search-group:last-child { margin-bottom: 0; }
.search-group-label {
    padding: 8px 12px 4px;
    font-size: 0.6875rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-mist);
}
.search-list { list-style: none; margin: 0; padding: 0; }
.search-item {
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 2px;
    transition: background 0.1s;
}
.search-item:hover,
.search-item.focused { background: var(--color-cloud); }
.search-item .search-title { font-size: 0.875rem; color: var(--color-ink); font-weight: 500; }
.search-item .search-snippet {
    font-size: 0.75rem;
    color: var(--color-slate);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ───────── Toast ───────── */

#toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 14px 10px 18px;
    background: var(--color-ink);
    color: var(--color-white);
    border-radius: var(--radius-md);
    font-size: 0.8125rem;
    z-index: 1000;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 14px;
    max-width: 480px;
}
#toast .toast-action {
    background: transparent;
    border: none;
    color: var(--color-jade-300);
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.8125rem;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
#toast .toast-action:hover { background: rgba(255,255,255,0.08); color: var(--color-white); }

/* ───────── Responsivt ───────── */

@media (max-width: 820px) {
    .app-layout { grid-template-columns: 1fr; }
    .sidebar { position: static; flex-direction: row; flex-wrap: wrap; gap: 6px; }
    .sidebar-org { flex: 1 1 100%; }
    .sidebar-menu { flex-direction: row; flex-wrap: wrap; gap: 4px; flex: 1 1 100%; }
    .sidebar-item { background: var(--color-white); border: 1.5px solid var(--color-frost); }
    .sidebar-add { margin-top: 4px; flex: 1 1 100%; }
}

@media (max-width: 640px) {
    main { padding: 16px; }
    .topbar { padding-left: 16px; padding-right: 16px; gap: 12px; }
    .topbar-left { gap: 12px; }
    .brand-name { display: none; }
    .tab { padding: 6px 10px; font-size: 0.75rem; }
    .panel-head form .row { flex-direction: column; }
    .panel-head form input[type=text] + select,
    .panel-head form select { width: 100%; }
    .todo { grid-template-columns: auto 1fr auto; }
    .todo-meta { grid-column: 1 / -1; padding-left: 34px; }
    .modal-body .row { flex-direction: column; }
    .quick-add { flex-direction: column; }
    .btn-detail { width: 100%; padding: 10px; }
}
