:root {
    --bg: #f6f6f7;
    --fg: #1a1a1a;
    --panel-bg: #ffffff;
    --sidebar-bg: #ffffff;
    --border: #e2e2e2;
    --border-strong: #c8c8c8;
    --muted: #888888;
    --accent: #1a1a1a;
    --input-bg: #ffffff;
    --danger: #c44;
    --checked: #1a1a1a;
    --unchecked-bg: #ffffff;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --radius: 6px;
    --border-width: 1px;
}

[data-theme="dark"] {
    --bg: #050505;
    --fg: #eeeeee;
    --panel-bg: #0a0a0a;
    --sidebar-bg: #0a0a0a;
    --border: #1f1f1f;
    --border-strong: #333333;
    --muted: #666666;
    --accent: #eeeeee;
    --input-bg: #0a0a0a;
    --danger: #e55;
    --checked: #eeeeee;
    --unchecked-bg: #0a0a0a;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--fg);
    font-size: 14px;
    line-height: 1.5;
    font-weight: 400;
    letter-spacing: -0.01em;
}

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

.app { display: flex; height: 100vh; overflow: hidden; }

/* Sidebar */
.sidebar {
    width: 180px;
    background: var(--sidebar-bg);
    border-right: var(--border-width) solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}
.sidebar-nav {
    flex: 1;
    padding: 16px 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: none;
    border: none;
    border-radius: var(--radius);
    color: var(--muted);
    font-family: inherit;
    font-size: 13px;
    font-weight: 450;
    cursor: pointer;
    text-align: left;
    transition: all 0.15s;
}
.nav-item:hover { color: var(--fg); background: var(--bg); }
.nav-item.active { color: var(--fg); background: var(--bg); font-weight: 500; }
.nav-icon { font-size: 14px; line-height: 1; width: 18px; text-align: center; opacity: 0.7; }

/* Toggle */
.toggle {
    width: 40px; height: 22px;
    background: var(--bg);
    border: var(--border-width) solid var(--border-strong);
    border-radius: 11px;
    position: relative;
    cursor: pointer;
    padding: 2px;
    transition: background 0.2s;
    flex-shrink: 0;
}
.toggle[aria-pressed="true"] { background: var(--fg); border-color: var(--fg); }
.toggle-knob {
    display: block;
    width: 16px; height: 16px;
    background: var(--fg);
    border-radius: 50%;
    transition: transform 0.2s, background 0.2s;
}
.toggle[aria-pressed="true"] .toggle-knob { transform: translateX(18px); background: var(--bg); }

/* Main */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: var(--panel-bg);
    border-bottom: var(--border-width) solid var(--border);
    flex-shrink: 0;
}
.topbar h1 { font-size: 18px; font-weight: 500; letter-spacing: -0.02em; color: var(--fg); }
.date-display { font-size: 13px; font-weight: 400; color: var(--muted); }

.content {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    min-width: 0;
}

/* Tabs */
.tab-panel { display: none; animation: fadeIn 0.2s ease; }
.tab-panel.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* Overview Layout */
#tab-overview { height: 100%; }
.overview-layout {
    display: grid;
    grid-template-columns: 1fr 300px;
    grid-template-rows: auto 1fr;
    gap: 16px;
    height: 100%;
    padding: 20px 24px 24px;
    min-height: 0;
    transition: grid-template-columns 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.overview-layout.day-open {
    grid-template-columns: 0.85fr 1.15fr;
}
.ov-top {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.greeting {
    font-size: 26px;
    font-weight: 300;
    letter-spacing: -0.03em;
    color: var(--fg);
}
.prompt-card {
    background: var(--panel-bg);
    border: var(--border-width) solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    font-size: 14px;
    color: var(--muted);
}
.prompt-card strong { color: var(--fg); font-weight: 500; }

/* Calendar Area */
.ov-calendar {
    background: var(--panel-bg);
    border: var(--border-width) solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}
.cal-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: var(--border-width) solid var(--border);
    flex-shrink: 0;
}
.cal-header-row span {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.cal-nav { display: flex; gap: 6px; }
.cal-nav button {
    background: none;
    border: var(--border-width) solid var(--border);
    border-radius: var(--radius);
    color: var(--muted);
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    padding: 4px 10px;
    cursor: pointer;
    transition: all 0.15s;
}
.cal-nav button:hover { background: var(--bg); color: var(--fg); }

/* Month View */
.calendar-month {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-template-rows: 24px repeat(6, 1fr);
    gap: 1px;
    background: var(--border);
    overflow: auto;
    min-height: 0;
}
.cal-header {
    background: var(--panel-bg);
    text-align: center;
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.cal-day {
    background: var(--panel-bg);
    padding: 4px 5px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    cursor: pointer;
    min-height: 44px;
    transition: background 0.15s ease;
    position: relative;
}
.cal-day:hover { background: var(--bg); }
.cal-day.empty { background: var(--bg); cursor: default; }
.cal-day.empty:hover { background: var(--bg); }
.cal-day.today {
    background: #ebebeb;
    color: var(--fg);
}
[data-theme="dark"] .cal-day.today {
    background: #1c1c1c;
    color: var(--fg);
}
.cal-day.today .cal-day-num { font-weight: 700; }
.cal-day-num {
    font-size: 11px;
    font-weight: 500;
    color: var(--fg);
}
.cal-day-events {
    display: flex;
    flex-direction: column;
    gap: 1px;
    flex: 1;
    overflow: hidden;
}
.cal-event-bar {
    font-size: 11px;
    font-weight: 500;
    padding: 2px 5px;
    border-radius: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #fff;
    line-height: 1.5;
}
.cal-event-bar.done { opacity: 0.35; text-decoration: line-through; }
.cal-more {
    font-size: 8px;
    color: var(--muted);
    margin-top: auto;
}

/* Right Panel */
.ov-right {
    position: relative;
    overflow: hidden;
    border-radius: var(--radius);
}
.ov-side {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
}
.ov-day-panel {
    position: absolute;
    inset: 0;
    background: var(--panel-bg);
    border: var(--border-width) solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateX(105%);
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
}
.day-open .ov-side {
    transform: translateX(-8%);
    opacity: 0;
    pointer-events: none;
}
.day-open .ov-day-panel {
    transform: translateX(0);
    opacity: 1;
}

.day-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: var(--border-width) solid var(--border);
    flex-shrink: 0;
}
.day-panel-header span {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.day-panel-header button {
    background: none;
    border: var(--border-width) solid var(--border);
    border-radius: var(--radius);
    color: var(--muted);
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    padding: 4px 10px;
    cursor: pointer;
    transition: all 0.15s;
}
.day-panel-header button:hover { background: var(--bg); color: var(--fg); }

/* Day Schedule */
.day-schedule {
    flex: 1;
    overflow-y: auto;
    display: grid;
    grid-template-columns: 48px 1fr;
    grid-auto-rows: 44px;
    position: relative;
    padding-bottom: 8px;
}
.hour-row {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 48px 1fr;
    border-bottom: var(--border-width) solid var(--border);
}
.hour-label {
    font-size: 9px;
    font-weight: 500;
    color: var(--muted);
    text-align: right;
    padding-right: 8px;
    align-self: center;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.hour-line {
    border-bottom: var(--border-width) solid var(--border);
    align-self: end;
}
.hour-half {
    border-bottom: var(--border-width) dashed var(--border);
    align-self: end;
}
.event-block {
    grid-column: 2;
    border-radius: var(--radius);
    padding: 5px 10px;
    font-size: 13px;
    font-weight: 500;
    overflow: hidden;
    cursor: pointer;
    margin: 0 10px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    color: #fff;
    border: 1px solid rgba(0,0,0,0.08);
    transition: opacity 0.15s, transform 0.1s;
    animation: eventPop 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    animation-fill-mode: both;
}
@keyframes eventPop {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
}
.event-block:hover { transform: scale(1.01); }
.event-block.done { opacity: 0.35; text-decoration: line-through; }
.event-block time {
    font-size: 10px;
    font-weight: 400;
    opacity: 0.85;
}

/* Side cards */
.ov-side-card {
    background: var(--panel-bg);
    border: var(--border-width) solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
}
.ov-side-title {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
}

/* Death mini */
.death-mini-inner {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}
.death-mini-unit {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
}
.death-mini-unit b {
    font-size: 18px;
    font-weight: 300;
    line-height: 1;
    letter-spacing: -0.03em;
}
.death-mini-unit label {
    font-size: 9px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--muted);
}
.death-mini-note {
    font-size: 11px;
    color: var(--muted);
    text-align: center;
    font-weight: 400;
    margin-top: 6px;
}

/* Today lists */
.today-list { display: flex; flex-direction: column; gap: 5px; }
.today-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    background: var(--bg);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s;
    border: var(--border-width) solid transparent;
}
.today-item:hover { border-color: var(--border); }
.today-item.done { opacity: 0.4; }
.today-item.done .today-text { text-decoration: line-through; }
.today-check {
    width: 16px; height: 16px;
    border: var(--border-width) solid var(--border-strong);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.15s;
}
.today-item.done .today-check { background: var(--checked); border-color: var(--checked); }
.today-item.done .today-check::after {
    content: '';
    width: 4px; height: 7px;
    border: solid var(--bg);
    border-width: 0 1.5px 1.5px 0;
    transform: rotate(45deg) translate(-1px, -1px);
}
.today-text { font-size: 13px; font-weight: 400; }
.today-streak { margin-left: auto; font-size: 10px; font-weight: 500; color: var(--muted); }

/* Goals overview */
.goals-overview { display: flex; flex-direction: column; gap: 5px; }
.goal-overview-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    background: var(--bg);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s;
    border: var(--border-width) solid transparent;
}
.goal-overview-card:hover { border-color: var(--border); }
.goal-overview-card.done { opacity: 0.4; }
.goal-overview-card.done .goal-overview-text { text-decoration: line-through; }
.goal-overview-check {
    width: 14px; height: 14px;
    border: var(--border-width) solid var(--border-strong);
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.goal-overview-card.done .goal-overview-check { background: var(--checked); border-color: var(--checked); }
.goal-overview-card.done .goal-overview-check::after {
    content: '';
    width: 3px; height: 6px;
    border: solid var(--bg);
    border-width: 0 1.5px 1.5px 0;
    transform: rotate(45deg) translate(-1px, -1px);
}
.goal-overview-text { flex: 1; font-size: 13px; font-weight: 400; }
.goal-overview-date { font-size: 10px; font-weight: 500; color: var(--muted); }
.goal-overview-empty {
    text-align: center;
    padding: 14px;
    color: var(--muted);
    font-size: 12px;
    border: var(--border-width) dashed var(--border);
    border-radius: var(--radius);
}

/* Weight */
.weight-chart-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100px;
}
#weight-chart { width: 100%; height: 100%; display: block; }
.weight-current { text-align: center; font-size: 11px; color: var(--muted); margin-top: 4px; }

/* Stats row */
.stats-row {
    display: flex;
    gap: 16px;
    padding-top: 4px;
    flex-wrap: wrap;
}
.stat-mini { display: flex; flex-direction: column; gap: 1px; }
.stat-mini-val { font-size: 18px; font-weight: 500; letter-spacing: -0.02em; color: var(--fg); }
.stat-mini-label { font-size: 10px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }

/* Panels */
.panel {
    background: var(--panel-bg);
    border: var(--border-width) solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 16px;
    overflow: hidden;
}
.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: var(--border-width) solid var(--border);
}
.panel-header h2 { font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }
.panel-sub { font-size: 12px; font-weight: 400; color: var(--muted); }

/* Controls */
.habit-controls, .goal-controls {
    display: flex;
    gap: 8px;
    padding: 10px 16px;
    border-bottom: var(--border-width) solid var(--border);
    flex-wrap: wrap;
    align-items: center;
}
.workout-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 10px 16px;
    border-bottom: var(--border-width) solid var(--border);
    align-items: stretch;
}

input[type="date"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator {
    filter: invert(0);
    cursor: pointer;
}
[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator,
[data-theme="dark"] input[type="time"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
}
input[type="text"], input[type="password"], input[type="email"], input[type="date"], input[type="number"], input[type="time"], select {
    background: var(--input-bg);
    color: var(--fg);
    border: var(--border-width) solid var(--border-strong);
    border-radius: var(--radius);
    padding: 7px 11px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 400;
    outline: none;
    transition: border-color 0.15s;
}
input[type="text"]:focus, input[type="password"]:focus, input[type="email"]:focus, input[type="date"]:focus, input[type="number"]:focus, input[type="time"]:focus, select:focus { border-color: var(--fg); }
input[type="text"]::placeholder, input[type="password"]::placeholder, input[type="email"]::placeholder, input[type="number"]::placeholder { color: var(--muted); }

.btn {
    background: var(--fg);
    color: var(--bg);
    border: none;
    border-radius: var(--radius);
    padding: 7px 14px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.15s;
    white-space: nowrap;
}
.btn:hover { opacity: 0.8; }

/* Day picker */
.day-picker { display: flex; gap: 6px; align-items: center; }
.day-pill {
    width: 30px; height: 30px;
    border: var(--border-width) solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--panel-bg);
    color: var(--muted);
    font-family: inherit;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    padding: 0;
}
.day-pill:hover { border-color: var(--fg); }
.day-pill.active { background: var(--fg); color: var(--bg); border-color: var(--fg); }

/* Event Form */
.event-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: var(--border-width) solid var(--border);
}
.event-time-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.event-time-row span { font-size: 12px; color: var(--muted); font-weight: 500; }
.event-time-row input[type="time"] { flex: 1; }
.color-picker {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.color-swatch {
    width: 24px; height: 24px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.15s, border-color 0.15s;
    position: relative;
}
.color-swatch:hover { transform: scale(1.15); }
.color-swatch.active { border-color: var(--fg); transform: scale(1.15); }
.color-swatch.active::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 1px solid var(--fg);
}
.event-list {
    padding: 8px 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.event-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border: var(--border-width) solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s;
    background: var(--panel-bg);
}
.event-item:hover { border-color: var(--border-strong); }
.event-item.done { opacity: 0.4; }
.event-item.done .event-item-text { text-decoration: line-through; }
.event-item-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.event-item-text { flex: 1; font-size: 13px; font-weight: 400; }
.event-item-time { font-size: 11px; color: var(--muted); font-weight: 500; white-space: nowrap; }

/* Lists */
.habit-list, .bad-habit-list, .workout-list, .goal-list {
    padding: 8px 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 20px;
}
.habit-card, .bad-habit-card, .workout-card {
    border: var(--border-width) solid var(--border);
    border-radius: var(--radius);
    padding: 10px;
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    gap: 6px 10px;
    align-items: center;
    background: var(--panel-bg);
    cursor: grab;
    transition: box-shadow 0.15s, opacity 0.15s;
}
.habit-card.dragging, .bad-habit-card.dragging, .workout-card.dragging { opacity: 0.4; box-shadow: 0 8px 24px rgba(0,0,0,0.12); }
.habit-card .habit-name, .bad-habit-card .bad-habit-name, .workout-card .workout-name {
    font-weight: 500;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: text;
    padding: 2px 4px;
    margin: -2px -4px;
    border-radius: 3px;
    transition: background 0.1s;
}
.habit-card .habit-name:hover, .bad-habit-card .bad-habit-name:hover, .workout-card .workout-name:hover { background: var(--bg); }
.habit-card .habit-name input, .bad-habit-card .bad-habit-name input, .workout-card .workout-name input {
    background: var(--input-bg); border: var(--border-width) solid var(--fg); border-radius: 3px;
    padding: 2px 6px; font-family: inherit; font-size: 14px; font-weight: 500; color: var(--fg);
    outline: none; width: 100%;
}
.habit-streak { font-size: 11px; font-weight: 500; color: var(--muted); white-space: nowrap; }
.habit-days, .bad-habit-days, .workout-days {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(7, 26px);
    gap: 5px;
    justify-content: center;
}
.day-box {
    width: 26px;
    height: 26px;
    border: var(--border-width) solid var(--border);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 9px;
    font-weight: 500;
    user-select: none;
    background: var(--unchecked-bg);
    color: var(--fg);
    transition: all 0.1s;
}
.day-box:hover { border-color: var(--border-strong); }
.day-box.done { background: var(--checked); color: var(--bg); border-color: var(--checked); }
.day-box.today { outline: 1.5px solid var(--fg); outline-offset: -2px; }
.delete-btn {
    background: none; border: none; color: var(--muted);
    width: 22px; height: 22px; font-size: 15px;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    padding: 0; line-height: 1; transition: color 0.15s; border-radius: 3px;
}
.delete-btn:hover { color: var(--danger); background: var(--bg); }
.workout-schedule { font-size: 11px; font-weight: 500; color: var(--muted); white-space: nowrap; }

/* Goals */
.goal-card {
    border: var(--border-width) solid var(--border);
    border-radius: var(--radius);
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: all 0.15s;
    background: var(--panel-bg);
}
.goal-card:hover { border-color: var(--border-strong); }
.goal-card.done .goal-text { text-decoration: line-through; color: var(--muted); }
.goal-check {
    width: 16px; height: 16px;
    border: var(--border-width) solid var(--border-strong);
    border-radius: 4px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; transition: all 0.15s;
}
.goal-card.done .goal-check { background: var(--checked); border-color: var(--checked); }
.goal-card.done .goal-check::after {
    content: '';
    width: 4px; height: 7px;
    border: solid var(--bg);
    border-width: 0 1.5px 1.5px 0;
    transform: rotate(45deg) translate(-1px, -1px);
}
.goal-text { flex: 1; font-size: 14px; font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: text; padding: 2px 4px; margin: -2px -4px; border-radius: 3px; transition: background 0.1s; }
.goal-text:hover { background: var(--bg); }
.goal-text input { background: var(--input-bg); border: var(--border-width) solid var(--fg); border-radius: 3px; padding: 2px 6px; font-family: inherit; font-size: 14px; font-weight: 400; color: var(--fg); outline: none; width: 100%; }
.goal-date { font-size: 11px; font-weight: 500; color: var(--muted); white-space: nowrap; }

/* Death */
.death-display { text-align: center; padding: 28px 16px 36px; }
.countdown {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    max-width: 460px;
    margin: 0 auto 20px;
}
.count-box { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.count-box b { font-size: 30px; font-weight: 300; line-height: 1; letter-spacing: -0.03em; }
.count-box label { font-size: 10px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.estimate { font-size: 13px; color: var(--muted); margin-bottom: 4px; font-weight: 400; }
.age { font-size: 12px; color: var(--muted); font-weight: 400; }

/* Settings */
.settings-grid { display: flex; flex-direction: column; gap: 16px; padding: 20px; max-width: 600px; margin: 0 auto; }
.field { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; border-bottom: var(--border-width) solid var(--border); gap: 12px; }
.field:last-child { border-bottom: none; }
.field span { font-weight: 500; font-size: 13px; }
.field input[type="text"], .field input[type="date"], .field select { min-width: 160px; }

.weight-input-row { display: flex; gap: 8px; padding: 10px 16px; border-bottom: var(--border-width) solid var(--border); align-items: center; flex-wrap: wrap; }
.weight-input-row input[type="number"] { width: 80px; }
.weight-list { padding: 8px 16px 14px; display: flex; flex-direction: column; gap: 6px; }
.weight-entry { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; border-bottom: var(--border-width) solid var(--border); font-size: 13px; }
.weight-entry:last-child { border-bottom: none; }
.weight-entry-date { color: var(--muted); }
.weight-entry-lbs { font-weight: 600; }
.weight-entry .delete-btn { opacity: 0; transition: opacity 0.15s; }
.weight-entry:hover .delete-btn { opacity: 1; }

.empty-state { text-align: center; padding: 24px; color: var(--muted); font-size: 13px; font-weight: 400; border: var(--border-width) dashed var(--border); border-radius: var(--radius); margin: 8px 0; }

#tab-habits, #tab-goals, #tab-death, #tab-settings { padding: 20px 24px; }
#tab-habits .panel, #tab-goals .panel { max-width: 640px; margin-left: auto; margin-right: auto; }

/* Responsive */
@media (max-width: 900px) {
    .overview-layout { grid-template-columns: 1fr; grid-template-rows: auto 1fr auto; }
    .overview-layout.day-open { grid-template-columns: 1fr; }
    .ov-right { min-height: 300px; }
}
@media (max-width: 640px) {
    .sidebar { width: 52px; }
    .nav-item span:not(.nav-icon) { display: none; }
    .nav-item { justify-content: center; padding: 10px; }
    .countdown { grid-template-columns: repeat(3, 1fr); }
    .greeting { font-size: 22px; }
}


/* Work Board */
.work-layout { display: flex; height: 100%; gap: 0; }
.board-area { flex: 1; display: flex; flex-direction: column; min-width: 0; padding: 20px 24px 24px; }
.board-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-shrink: 0; }
.board-name { font-size: 18px; font-weight: 500; letter-spacing: -0.02em; cursor: text; padding: 2px 6px; margin: -2px -6px; border-radius: 4px; transition: background 0.1s; }
.board-name:hover { background: var(--bg); }
.board-name input { background: var(--input-bg); border: var(--border-width) solid var(--fg); border-radius: 4px; padding: 2px 6px; font-family: inherit; font-size: 18px; font-weight: 500; color: var(--fg); outline: none; width: 100%; }
.board {
    flex: 1;
    display: flex;
    gap: 12px;
    overflow-x: auto;
    overflow-y: hidden;
    align-items: flex-start;
    padding-bottom: 8px;
}
.board::-webkit-scrollbar { height: 6px; }
.board::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }

.col {
    width: 280px;
    flex-shrink: 0;
    background: var(--panel-bg);
    border: var(--border-width) solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    max-height: 100%;
}
.col-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    border-bottom: var(--border-width) solid var(--border);
    flex-shrink: 0;
}
.col-title {
    font-size: 13px;
    font-weight: 600;
    flex: 1;
    cursor: text;
    padding: 2px 4px;
    margin: -2px -4px;
    border-radius: 3px;
    transition: background 0.1s;
}
.col-title:hover { background: var(--bg); }
.col-title input { background: var(--input-bg); border: var(--border-width) solid var(--fg); border-radius: 3px; padding: 2px 6px; font-family: inherit; font-size: 13px; font-weight: 600; color: var(--fg); outline: none; width: 100%; }
.col-delete { background: none; border: none; color: var(--muted); font-size: 15px; cursor: pointer; padding: 0 2px; line-height: 1; transition: color 0.15s; opacity: 0; }
.col-header:hover .col-delete { opacity: 1; }
.col-delete:hover { color: var(--danger); }
.col-cards {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 20px;
}
.col-footer { padding: 8px; border-top: var(--border-width) solid var(--border); flex-shrink: 0; }
.add-card-btn {
    width: 100%;
    background: none;
    border: var(--border-width) dashed var(--border);
    border-radius: var(--radius);
    color: var(--muted);
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    padding: 8px;
    cursor: pointer;
    transition: all 0.15s;
}
.add-card-btn:hover { border-color: var(--border-strong); color: var(--fg); background: var(--bg); }

.card {
    background: var(--bg);
    border: var(--border-width) solid var(--border);
    border-radius: var(--radius);
    padding: 10px 12px;
    cursor: grab;
    position: relative;
    transition: box-shadow 0.15s, opacity 0.15s;
    overflow: hidden;
}
.card:hover { border-color: var(--border-strong); }
.card.dragging { opacity: 0.4; box-shadow: 0 8px 24px rgba(0,0,0,0.12); }
.card.done { opacity: 0.4; }
.card.done .card-name { text-decoration: line-through; color: var(--muted); }
.color-tag-bar { height: 4px; border-radius: 2px; margin: -10px -12px 8px; }
.card-name { font-size: 13px; font-weight: 500; line-height: 1.4; word-break: break-word; cursor: text; padding: 2px; margin: -2px; border-radius: 3px; transition: background 0.1s; }
.card-name:hover { background: var(--panel-bg); }
.card-name input { background: var(--input-bg); border: var(--border-width) solid var(--fg); border-radius: 3px; padding: 2px 6px; font-family: inherit; font-size: 13px; font-weight: 500; color: var(--fg); outline: none; width: 100%; }
.card-desc-preview { font-size: 11px; color: var(--muted); margin-top: 4px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-image-thumb { width: 100%; height: 80px; object-fit: cover; border-radius: 3px; margin-top: 6px; border: var(--border-width) solid var(--border); }
.card-check {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 18px;
    height: 18px;
    border: var(--border-width) solid var(--border-strong);
    border-radius: 4px;
    background: var(--panel-bg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s, border-color 0.15s;
}
.card:hover .card-check { opacity: 1; }
.card-check.checked { opacity: 1; background: var(--checked); border-color: var(--checked); }
.card-check.checked::after {
    content: '';
    width: 4px; height: 7px;
    border: solid var(--bg);
    border-width: 0 1.5px 1.5px 0;
    transform: rotate(45deg) translate(-1px, -1px);
}

.col.drag-over { border-color: var(--fg); }
.col.dragging { opacity: 0.5; }

.inline-input {
    width: 100%;
    background: var(--input-bg);
    border: var(--border-width) solid var(--border-strong);
    border-radius: var(--radius);
    padding: 7px 10px;
    font-family: inherit;
    font-size: 13px;
    color: var(--fg);
    outline: none;
    margin-bottom: 6px;
}
.inline-input:focus { border-color: var(--fg); }
.inline-actions { display: flex; gap: 6px; }
.inline-btn {
    background: var(--fg);
    color: var(--bg);
    border: none;
    border-radius: var(--radius);
    padding: 5px 12px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
}
.inline-cancel {
    background: none;
    color: var(--muted);
    border: none;
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
}
.inline-cancel:hover { color: var(--fg); }
.add-list-col {
    width: 280px;
    flex-shrink: 0;
    background: var(--panel-bg);
    border: var(--border-width) solid var(--border);
    border-radius: var(--radius);
    padding: 10px;
}

/* Board Sidebar */
.board-sidebar {
    width: 220px;
    background: var(--panel-bg);
    border-left: var(--border-width) solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 16px;
    gap: 10px;
    flex-shrink: 0;
    overflow-y: auto;
}
.sidebar-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
}
.board-list { display: flex; flex-direction: column; gap: 4px; }
.board-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 7px 10px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.1s;
}
.board-list-item:hover { background: var(--bg); }
.board-list-item.active { background: var(--bg); }
.board-list-item .board-del {
    opacity: 0;
    background: none;
    border: none;
    color: var(--muted);
    font-size: 13px;
    cursor: pointer;
    padding: 0 2px;
    line-height: 1;
}
.board-list-item:hover .board-del { opacity: 1; }
.board-list-item .board-del:hover { color: var(--danger); }
@media (hover: none) {
    .board-list-item .board-del { opacity: 1; }
}
.add-board-btn {
    width: 100%;
    background: none;
    border: var(--border-width) dashed var(--border);
    border-radius: var(--radius);
    color: var(--muted);
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    padding: 8px;
    cursor: pointer;
    transition: all 0.15s;
}
.add-board-btn:hover { border-color: var(--border-strong); color: var(--fg); background: var(--bg); }

/* Color Tags */
.color-tag-picker { display: flex; gap: 8px; flex-wrap: wrap; }
.color-tag-swatch {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.1s, border-color 0.1s;
}
.color-tag-swatch:hover { transform: scale(1.1); }
.color-tag-swatch.active { border-color: var(--fg); transform: scale(1.1); }

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}
.modal-overlay.active { display: flex; }
.modal {
    background: var(--panel-bg);
    border: var(--border-width) solid var(--border);
    border-radius: var(--radius);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.modal-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    border-bottom: var(--border-width) solid var(--border);
}
.modal-header input {
    flex: 1;
    background: none;
    border: none;
    font-family: inherit;
    font-size: 16px;
    font-weight: 600;
    color: var(--fg);
    outline: none;
    padding: 0;
}
.modal-header input::placeholder { color: var(--muted); }
.modal-close {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 22px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    transition: color 0.15s;
}
.modal-close:hover { color: var(--danger); }
.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.modal-section label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    margin-bottom: 8px;
}
.modal-section textarea {
    width: 100%;
    min-height: 100px;
    resize: vertical;
    background: var(--input-bg);
    color: var(--fg);
    border: var(--border-width) solid var(--border-strong);
    border-radius: var(--radius);
    padding: 10px 12px;
    font-family: inherit;
    font-size: 13px;
    line-height: 1.5;
    outline: none;
}
.modal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 18px;
    border-top: var(--border-width) solid var(--border);
}
.btn-secondary {
    background: var(--bg);
    color: var(--fg);
    border: var(--border-width) solid var(--border-strong);
}
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: 0.85; }
.card-image-preview-wrap { margin-bottom: 10px; }
.card-image-preview-wrap img { max-width: 100%; max-height: 240px; border-radius: var(--radius); border: var(--border-width) solid var(--border); display: block; }
.card-image-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.image-hint { font-size: 11px; color: var(--muted); }

#tab-work { padding: 0; height: 100%; }
.col.dragging { opacity: 0.4; box-shadow: 0 8px 24px rgba(0,0,0,0.12); }

.day-all-day {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px 10px;
    border-bottom: var(--border-width) solid var(--border);
    flex-shrink: 0;
}
.all-day-block {
    background: var(--bg);
    border: var(--border-width) solid var(--border);
    border-radius: var(--radius);
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: opacity 0.15s, border-color 0.15s;
}
.all-day-block.done { opacity: 0.35; text-decoration: line-through; }
.all-day-block:hover { border-color: var(--border-strong); }
.all-day-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Login */
.login-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}
.login-box {
    background: var(--panel-bg);
    border: var(--border-width) solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    width: 340px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.login-box h2 { font-size: 20px; font-weight: 500; text-align: center; letter-spacing: -0.02em; margin-bottom: 4px; }
.login-box input { width: 100%; }
.login-box button { width: 100%; margin-top: 4px; }
#login-error { color: var(--danger); font-size: 12px; text-align: center; margin: 0; min-height: 16px; }

/* Mobile improvements */
@media (max-width: 640px) {
    .sidebar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: auto;
        border-right: none;
        border-top: var(--border-width) solid var(--border);
        z-index: 100;
        flex-direction: row;
    }
    .sidebar-nav {
        flex-direction: row;
        justify-content: space-around;
        padding: 6px 0;
        gap: 0;
    }
    .nav-item {
        flex-direction: column;
        padding: 4px 8px;
        gap: 2px;
        font-size: 10px;
    }
    .nav-item span:not(.nav-icon) { display: inline; }
    .nav-icon { width: auto; font-size: 16px; }
    .main { padding-bottom: 56px; }
    .topbar { padding: 12px 16px; }
    .overview-layout { padding: 12px 16px 16px; }
    .greeting { font-size: 22px; }
    .board-sidebar { display: none; }
    .work-layout { flex-direction: column; }
    .board-area { padding: 12px 16px 16px; }
    .col { width: 260px; }
}

.login-toggle {
    text-align: center;
    font-size: 12px;
    color: var(--muted);
    margin: 0;
}
.login-toggle button {
    font-size: 12px;
    font-weight: 500;
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* Chat */
.chat-panel {
    border-top: var(--border-width) solid var(--border);
    margin-top: 10px;
    padding-top: 10px;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}
.chat-messages {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px 0;
    min-height: 120px;
}
.chat-message {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.chat-message-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
}
.chat-message-sender {
    font-size: 11px;
    font-weight: 600;
    color: var(--fg);
}
.chat-message-time {
    font-size: 9px;
    color: var(--muted);
}
.chat-message-text {
    font-size: 12px;
    color: var(--fg);
    line-height: 1.4;
    word-break: break-word;
}
.chat-message.own .chat-message-sender { color: var(--accent); }
.chat-input-row {
    display: flex;
    gap: 6px;
    padding-top: 8px;
    border-top: var(--border-width) solid var(--border);
}
.chat-input-row input { flex: 1; }
.chat-input-row button { padding: 7px 12px; }

/* Friend panel */
.friend-request {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: var(--border-width) solid var(--border);
    font-size: 13px;
}
.friend-request:last-child, .friend-item:last-child { border-bottom: none; }
.friend-request-actions { display: flex; gap: 6px; }
.friend-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: var(--border-width) solid var(--border);
    font-size: 13px;
}
.friend-item-name { font-weight: 500; }
.friend-item-code {
    font-size: 10px;
    color: var(--muted);
    font-family: monospace;
}

.board-members {
    display: flex;
    gap: 6px;
    align-items: center;
}
.member-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--fg);
    color: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 600;
    position: relative;
    flex-shrink: 0;
}
.member-avatar.online::after {
    content: '';
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
    border: 2px solid var(--panel-bg);
}
.share-dropdown-item:hover {
    background: var(--bg);
}
