:root {
    --bg-start: #fff1f7;
    --bg-end: #f8d7e6;
    --surface: rgba(255, 250, 251, 0.94);
    --surface-soft: #fff4f8;
    --border: rgba(148, 163, 184, 0.24);
    --text-main: #4f2f3e;
    --text-muted: #8f6678;
    --accent: #f48fb1;
    --button-bg: #d96c93;
    --button-text: #ffffff;
    --shadow: 0 18px 45px rgba(85, 98, 122, 0.14);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family:
        "Crimson Pro",
        Georgia,
        serif;
    background:
        radial-gradient(circle at top left, rgba(255, 255, 255, 0.55), transparent 36%),
        linear-gradient(180deg, var(--bg-start), var(--bg-end));
    color: var(--text-main);
}

.app-shell {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 32px 0 48px;
}

.app-header,
.toolbar-card,
.panel-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 26px;
    box-shadow: var(--shadow);
}

.app-header {
    padding: 24px;
    display: grid;
    gap: 20px;
    grid-template-columns: minmax(0, 1.4fr) minmax(260px, 0.9fr);
    align-items: center;
}

.eyebrow {
    margin: 0 0 8px;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    font-size: 0.72rem;
    color: var(--text-muted);
}

h1,
h2,
h3,
h4,
p {
    margin: 0;
}

h1 {
    font-size: clamp(2rem, 5vw, 3rem);
    line-height: 1;
}

.subhead {
    margin-top: 10px;
    color: var(--text-muted);
    max-width: 42rem;
}

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

.summary-card {
    border-radius: 18px;
    background: var(--surface-soft);
    border: 1px solid var(--border);
    padding: 14px 16px;
}

.summary-card span {
    display: block;
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.summary-card strong {
    font-size: 1.15rem;
}

.summary-day-card {
    display: grid;
    gap: 6px;
}

.active-day-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.active-day-row input[type="date"] {
    min-width: 0;
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    color: var(--text-main);
    font: inherit;
    font-weight: 800;
    padding: 8px 10px;
}

.routine-day-note {
    color: var(--text-muted);
    font-size: 0.86rem;
    font-weight: 700;
    margin-top: 4px;
}

.color-tile-field {
    gap: 8px;
}

.color-tile-grid {
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
}

.color-tile {
    appearance: none;
    border: 2px solid transparent;
    border-radius: 14px;
    background:
        linear-gradient(135deg, var(--tile-color), rgba(255, 255, 255, 0.86)),
        var(--tile-color);
    color: #1f2937;
    cursor: pointer;
    font: inherit;
    font-size: 0.82rem;
    font-weight: 900;
    min-height: 48px;
    padding: 10px;
    text-align: left;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.55);
}

.color-tile.is-selected {
    border-color: var(--text-main);
    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, 0.65),
        0 0 0 3px rgba(37, 99, 235, 0.16);
}

.confirmation-card {
    display: grid;
    gap: 12px;
}

.confirmation-card input {
    width: 100%;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text-main);
    font: inherit;
    font-size: 1.05rem;
    font-weight: 800;
    padding: 10px 12px;
}

.toolbar-card,
.panel-card {
    margin-top: 18px;
    padding: 20px;
}

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

.toolbar-actions,
.tab-row,
.stack-row,
.modal-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.data-toolbar-card {
    margin-top: 18px;
}

.data-actions {
    display: grid;
    flex: 0 0 auto;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    min-width: min(100%, 300px);
}

.data-actions .btn {
    padding-inline: 12px;
}

.btn {
    border: 0;
    border-radius: 14px;
    padding: 11px 15px;
    font: inherit;
    cursor: pointer;
    transition:
        transform 140ms ease,
        opacity 140ms ease;
}

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

.btn-primary {
    background: var(--button-bg);
    color: var(--button-text);
}

.btn-secondary {
    background: var(--surface-soft);
    color: var(--text-main);
    border: 1px solid var(--border);
}

.text-btn {
    border: 0;
    background: transparent;
    color: var(--button-bg);
    cursor: pointer;
    font: inherit;
    font-size: 0.82rem;
    font-weight: 800;
    padding: 2px 4px;
}

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

.tab-row {
    margin-top: 18px;
    position: sticky;
    top: 8px;
    z-index: 30;
    padding: 8px;
    background: rgba(244, 247, 251, 0.92);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: 0 12px 24px rgba(85, 98, 122, 0.12);
}

.tab-btn {
    background: rgba(255, 255, 255, 0.68);
    color: var(--text-main);
    border: 1px solid var(--border);
}

.tab-btn.is-active {
    background: var(--button-bg);
    color: var(--button-text);
}

.panel-stack {
    display: grid;
    gap: 18px;
}

.is-hidden {
    display: none;
}

.section-title {
    margin-bottom: 14px;
}

.section-title-with-action {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
}

.kv-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.two-by-two-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.kv-card,
.list-card {
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 14px 16px;
}

.kv-card span,
.list-card span {
    display: block;
    color: var(--text-muted);
    font-size: 0.78rem;
    margin-bottom: 4px;
}

.mono {
    font-family:
        "SF Mono",
        "Space Mono",
        monospace;
}

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

.note-list {
    display: grid;
    gap: 10px;
    margin-top: 14px;
}

.note-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 12px 14px;
}

.dashboard-grid {
    display: grid;
    gap: 18px;
}

.dashboard-card {
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 18px;
    overflow-x: auto;
}

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

.stacked-card-header {
    display: grid;
    justify-content: stretch;
}

.compact-action-row {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    width: 100%;
}

.compact-action-row .btn {
    padding: 9px 8px;
    white-space: nowrap;
}

.status-pill-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 14px;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 7px 11px;
    background: #fff;
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.84rem;
}

.status-pill.is-good {
    background: #dcfce7;
    color: #166534;
    border-color: #bbf7d0;
}

.status-pill.is-warning {
    background: #fef9c3;
    color: #854d0e;
    border-color: #fde68a;
}

.flow-textarea,
.goal-input,
.checklist-add-input {
    width: 100%;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text-main);
    padding: 13px 14px;
    font: inherit;
}

.flow-textarea {
    min-height: 180px;
    resize: vertical;
    line-height: 1.45;
}

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

.goal-card {
    display: grid;
    gap: 8px;
}

.goal-card label,
.checklist-row label {
    font-size: 0.84rem;
    color: var(--text-muted);
}

.checklist-list {
    display: grid;
    gap: 10px;
    margin-top: 14px;
}

.checklist-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    padding: 12px;
    border-radius: 16px;
    background: #fff;
    border: 1px solid var(--border);
}

.checklist-row.is-checked .checklist-text {
    color: var(--text-muted);
    text-decoration: line-through;
}

.checklist-text {
    min-width: 0;
}

.quota-summary-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.quota-category-stack {
    display: grid;
    gap: 16px;
}

.quota-category-section {
    display: grid;
    gap: 10px;
}

.quota-category-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    color: var(--text-muted);
}

.quota-category-header h4 {
    color: var(--text-main);
}

.quota-compact-grid {
    display: flex;
    gap: 14px;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 4px 4px 12px;
    scroll-snap-type: x proximity;
}

.quota-compact-category {
    flex: 0 0 auto;
    display: grid;
    gap: 8px;
    min-width: 74px;
    scroll-snap-align: start;
}

.quota-compact-title {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    align-items: center;
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.78rem;
    padding: 0 2px 6px;
    white-space: nowrap;
}

.quota-compact-title strong {
    color: var(--text-main);
}

.quota-compact-chip-grid {
    display: grid;
    grid-auto-columns: 46px;
    grid-auto-flow: column;
    grid-template-rows: repeat(4, 46px);
    gap: 8px;
}

.quota-compact-chip {
    width: 46px;
    height: 46px;
    border-radius: 16px;
    border: 1px solid var(--quota-color, var(--border));
    background: #fff;
    background: color-mix(in srgb, var(--quota-color, #94a3b8) 14%, white);
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
    cursor: grab;
    display: inline-grid;
    place-items: center;
    font: inherit;
    line-height: 1;
    position: relative;
    transition:
        transform 0.16s ease,
        box-shadow 0.16s ease;
}

.quota-compact-chip span {
    font-size: 1.35rem;
}

.quota-compact-chip small {
    position: absolute;
    right: 4px;
    bottom: 3px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.88);
    color: var(--text-main);
    font-size: 0.58rem;
    font-weight: 900;
    line-height: 1;
    padding: 2px 4px;
}

.quota-compact-chip:hover {
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.14);
    transform: translateY(-1px);
}

.quota-compact-chip:active {
    cursor: grabbing;
}

.quota-category-stack.is-compact {
    gap: 0;
}

.quota-summary-card {
    border-radius: 18px;
    border: 1px solid var(--border);
    background: #fff;
    padding: 14px;
}

.quota-summary-card.is-quota-problem,
.quota-compact-chip.is-quota-problem {
    box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.18);
}

.quota-summary-card[draggable="true"] {
    cursor: grab;
}

.quota-summary-card[draggable="true"]:active {
    cursor: grabbing;
}

.quota-summary-title {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: flex-start;
    font-weight: 700;
}

.quota-summary-meta {
    margin-top: 8px;
    color: var(--text-muted);
    font-size: 0.84rem;
}

.quota-progress-track {
    height: 9px;
    border-radius: 999px;
    background: #e2e8f0;
    overflow: hidden;
    margin-top: 10px;
}

.quota-progress-fill {
    height: 100%;
    border-radius: inherit;
    background: #22c55e;
}

.is-quota-problem .quota-progress-fill {
    background: #dc2626;
}

.quota-assignment-note {
    margin-top: 6px;
    color: #166534;
    font-size: 0.8rem;
    font-weight: 800;
}

.is-quota-problem .quota-assignment-note {
    color: #b91c1c;
}

.quota-card-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.activity-chip-summary {
    display: grid;
    gap: 10px;
    grid-template-columns: minmax(140px, 0.8fr) minmax(180px, 1fr) auto;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #fff;
    margin-bottom: 12px;
    padding: 12px;
}

.activity-chip-summary-main {
    display: grid;
    gap: 2px;
}

.activity-chip-summary-main span {
    color: var(--text-muted);
    font-size: 0.76rem;
    font-weight: 800;
    text-transform: uppercase;
}

.activity-chip-summary-main strong {
    color: var(--text-main);
    font-size: 1.35rem;
}

.activity-chip-summary-breakdown {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.activity-chip-summary-breakdown span {
    border: 1px solid var(--activity-type-color, var(--border));
    border-radius: 999px;
    background: color-mix(in srgb, var(--activity-type-color, #bfdbfe) 40%, white);
    color: #1f2937;
    font-size: 0.78rem;
    font-weight: 900;
    padding: 5px 9px;
}

.activity-summary-toggle .btn.is-active {
    background: var(--button-bg);
    color: var(--button-text);
    border-color: var(--button-bg);
}

.activity-table-wrap {
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow-x: auto;
    background: #fff;
}

.activity-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 760px;
}

.activity-table th,
.activity-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
}

.activity-table th {
    color: var(--text-muted);
    font-size: 0.76rem;
    text-transform: uppercase;
}

.activity-area-row td {
    background: var(--surface-soft);
    color: var(--text-main);
    font-weight: 900;
}

.activity-table-row {
    border-left: 5px solid var(--activity-type-color, var(--border));
}

.activity-table-row.is-underassigned {
    background: #fef2f2;
    box-shadow: inset 0 0 0 2px rgba(220, 38, 38, 0.18);
}

.activity-type-pill {
    display: inline-flex;
    border-radius: 999px;
    background: color-mix(in srgb, var(--activity-type-color, #fde68a) 48%, white);
    border: 1px solid var(--activity-type-color, #fde68a);
    color: #1f2937;
    font-size: 0.76rem;
    font-weight: 800;
    padding: 4px 8px;
}

.activity-repeatable-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 999px;
    background: var(--surface-soft);
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 900;
}

.activity-hidden-pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    background: #e5e7eb;
    color: #374151;
    font-size: 0.68rem;
    font-weight: 900;
    margin-left: 6px;
    padding: 2px 6px;
    text-transform: uppercase;
}

.activity-note-line {
    color: var(--text-muted);
    font-size: 0.76rem;
    font-weight: 700;
    margin-top: 4px;
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.field select[multiple] {
    min-height: 110px;
}

.activity-table-actions {
    white-space: nowrap;
}

.daily-agenda-card {
    border: 1px solid var(--border);
    border-radius: 18px;
    background: #fff;
    margin-top: 14px;
    padding: 12px;
}

.daily-agenda-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
}

.daily-agenda-header h4 {
    margin: 0;
}

.daily-agenda-header p {
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 700;
    margin: 3px 0 0;
}

.daily-agenda-body {
    display: grid;
    gap: 8px;
    margin-top: 10px;
}

.daily-agenda-type-title,
.calendar-type-title {
    border-left: 4px solid var(--activity-type-color, var(--border));
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 900;
    line-height: 1;
    margin-top: 4px;
    padding-left: 6px;
    text-transform: uppercase;
}

.daily-agenda-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 8px 10px;
}

.daily-agenda-row strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.daily-agenda-row small {
    color: var(--text-muted);
    font-size: 0.74rem;
    font-weight: 800;
}

.activity-area-settings-bar {
    display: flex;
    justify-content: flex-end;
    margin-top: 12px;
}

.activity-default-settings {
    display: grid;
    gap: 12px;
    margin-top: 12px;
}

.activity-checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-main);
    font-weight: 800;
}

.activity-default-days {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.activity-default-days label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-soft);
    padding: 7px 9px;
    font-size: 0.82rem;
    font-weight: 800;
}

.area-manager-list,
.quota-notice-list {
    display: grid;
    gap: 10px;
}

.area-manager-row {
    display: grid;
    grid-template-columns: minmax(90px, 0.8fr) 72px minmax(140px, 1fr) auto;
    gap: 8px;
    align-items: center;
}

.area-manager-row input {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 12px;
    font: inherit;
}

.quota-notice-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 12px;
    background: var(--surface-soft);
}

.quota-notice-row > div {
    display: grid;
    gap: 3px;
}

.quota-notice-row > div span {
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 700;
}

.quota-dismiss-check {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 14px;
    color: var(--text-muted);
    font-weight: 700;
}

.calendar-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.calendar-title {
    font-size: 1.2rem;
    font-weight: 800;
}

.calendar-grid {
    display: grid;
    gap: 10px;
    margin-top: 14px;
}

.calendar-grid.is-week {
    grid-template-columns: repeat(7, minmax(0, 1fr));
}

.calendar-grid.is-month {
    grid-template-columns: repeat(7, minmax(0, 1fr));
}

.calendar-day-name {
    font-size: 0.76rem;
    color: var(--text-muted);
    text-align: center;
    font-weight: 700;
}

.calendar-cell {
    min-height: 132px;
    border-radius: 18px;
    border: 1px solid var(--border);
    background: #fff;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    color: var(--text-main);
    cursor: pointer;
    font: inherit;
    text-align: left;
    transition:
        box-shadow 0.16s ease,
        transform 0.16s ease;
}

.calendar-cell:hover {
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.1);
    transform: translateY(-1px);
}

.calendar-cell.is-other {
    opacity: 0.48;
}

.calendar-cell.is-today {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(255, 143, 171, 0.18);
}

.calendar-cell.is-selected {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.16);
}

.calendar-cell.is-drag-over {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}

.calendar-cell-head {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    align-items: center;
}

.calendar-date {
    font-weight: 800;
}

.calendar-template {
    color: var(--text-muted);
    font-size: 0.72rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.calendar-chip-list {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.calendar-assign-row,
.calendar-assigned-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.calendar-assign-row select {
    flex: 1;
    min-width: 0;
}

.calendar-assign-row #calendarAssignArea {
    flex: 0 0 34%;
}

.calendar-assigned-list {
    display: grid;
    gap: 8px;
    margin-top: 10px;
}

.calendar-assigned-row {
    justify-content: space-between;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-soft);
    padding: 8px 10px;
}

.calendar-chip-divider {
    flex-basis: 100%;
    height: 1px;
    background: var(--border);
    margin: 2px 0;
}

.calendar-chip {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    border-radius: 999px;
    padding: 4px 8px;
    font-size: 0.72rem;
    font-weight: 700;
    color: #1f2937;
    background: #eef2ff;
    border: 1px solid rgba(148, 163, 184, 0.3);
}

.calendar-chip span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.calendar-quota-chip {
    cursor: pointer;
}

.calendar-quota-chip:hover {
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.16);
}

.calendar-event-chip {
    background: #dbeafe;
    color: #1e3a8a;
}

.calendar-empty {
    margin-top: auto;
    color: var(--text-muted);
    font-size: 0.78rem;
}

.calendar-more {
    color: var(--text-muted);
    font-size: 0.74rem;
    font-weight: 700;
}

.quota-checkbox-grid,
.calendar-event-editor-list {
    display: grid;
    gap: 8px;
}

.quota-checkbox-grid {
    max-height: 220px;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 10px;
    background: rgba(248, 250, 252, 0.72);
}

.quota-checkbox {
    display: flex;
    gap: 8px;
    align-items: center;
    color: var(--text-main);
    font-weight: 700;
}

.calendar-event-editor-row {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(90px, 0.6fr) minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
}

.calendar-event-editor-row input {
    width: 100%;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text-main);
    padding: 10px 12px;
    font: inherit;
}

.template-manager-list {
    display: grid;
    gap: 12px;
}

.template-manager-row {
    display: grid;
    grid-template-columns: minmax(110px, 0.7fr) minmax(140px, 1fr) minmax(0, 1.5fr) auto;
    gap: 8px;
    align-items: start;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: rgba(248, 250, 252, 0.72);
    padding: 10px;
}

.template-manager-row input,
.template-manager-row textarea {
    width: 100%;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text-main);
    padding: 10px 12px;
    font: inherit;
}

.template-manager-row textarea {
    min-height: 96px;
    resize: vertical;
}

.routines-page {
    display: grid;
    gap: 16px;
}

.routine-node {
    margin-left: calc(var(--depth, 0) * 18px);
    border-radius: 20px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.74);
    padding: 12px;
}

.routine-node + .routine-node {
    margin-top: 10px;
}

.routine-node.is-section {
    background: var(--surface-soft);
}

.routine-node.is-task.is-complete {
    opacity: 0.62;
}

.routine-node.is-task.is-complete .routine-title {
    text-decoration: line-through;
}

.routine-node.is-task.is-skipped .routine-meta::after {
    content: " · skipped";
    color: var(--text-muted);
    font-weight: 800;
}

.routine-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 12px;
    align-items: start;
}

.routine-chevron {
    width: 34px;
    height: 34px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    cursor: pointer;
}

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

.routine-title {
    font-weight: 800;
    line-height: 1.35;
}

.routine-meta {
    margin-top: 5px;
    color: var(--text-muted);
    font-size: 0.82rem;
}

.routine-notes {
    margin-top: 5px;
    color: var(--text-muted);
    white-space: pre-wrap;
    line-height: 1.35;
}

.routine-actions {
    display: flex;
    gap: 7px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.routine-actions .btn {
    padding: 8px 10px;
    font-size: 0.84rem;
}

.routine-child-wrap {
    margin-top: 12px;
}

.routine-child-wrap.is-hidden {
    display: none;
}

.routine-add-input {
    width: 100%;
    border-radius: 16px;
    border: 1px dashed var(--border);
    background: rgba(255, 255, 255, 0.82);
    color: var(--text-main);
    padding: 12px 14px;
    font: inherit;
    margin-bottom: 10px;
}

.todos-page,
.todo-section {
    display: grid;
    gap: 16px;
}

.todo-section {
    margin-top: 18px;
}

.todo-section-tile {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.72);
    color: var(--text-main);
    cursor: pointer;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px 12px;
    align-items: center;
    padding: 14px;
    text-align: left;
    font: inherit;
}

.todo-section-tile:hover {
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
}

.todo-section-tile h2 {
    margin: 0;
}

.todo-section-tile p {
    grid-column: 1 / -1;
    margin: 0;
}

.todo-section-tile span {
    border-radius: 999px;
    background: var(--surface-soft);
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 800;
    padding: 5px 9px;
}

.section-title-with-action .todo-section-tile {
    flex: 1;
}

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

.todo-column {
    border: 1px solid var(--border);
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.78);
    padding: 14px;
    box-shadow: 0 14px 30px rgba(15, 23, 42, 0.08);
}

.todo-priority-column {
    grid-column: 1 / -1;
}

.todo-priority-sections {
    display: grid;
    gap: 12px;
}

.todo-priority-section {
    border: 1px solid color-mix(in srgb, var(--tag-bg, #e2e8f0) 60%, var(--border));
    border-radius: 18px;
    background:
        linear-gradient(135deg, color-mix(in srgb, var(--tag-bg, #e2e8f0) 22%, #fff), rgba(255, 255, 255, 0.88));
    padding: 12px;
}

.todo-priority-section-header {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: center;
    margin-bottom: 10px;
}

.todo-priority-section-header h3 {
    margin: 0;
    font-size: 0.96rem;
}

.todo-priority-section-header span {
    border-radius: 999px;
    background: var(--tag-bg, #e2e8f0);
    color: var(--tag-text, var(--text-main));
    flex: 0 0 auto;
    font-size: 0.74rem;
    font-weight: 800;
    padding: 4px 8px;
}

.todo-show-more-btn {
    margin-top: 12px;
}

.todo-column.add-column {
    display: grid;
    place-items: center;
    min-height: 94px;
    border-style: dashed;
    background: rgba(255, 255, 255, 0.45);
}

.todo-column-header {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: center;
    border-radius: 16px;
    background: var(--column-color, #dbeafe);
    padding: 12px;
    margin-bottom: 12px;
}

.todo-category-tile {
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--text-main);
    cursor: pointer;
    display: flex;
    flex: 1;
    gap: 8px;
    align-items: center;
    justify-content: space-between;
    min-width: 0;
    padding: 0;
    text-align: left;
    font: inherit;
}

.todo-category-state {
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.72);
    color: var(--text-muted);
    flex: 0 0 auto;
    font-size: 0.74rem;
    font-weight: 800;
    padding: 4px 8px;
}

.todo-mini-actions,
.todo-card-actions {
    display: flex;
    gap: 7px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.todo-group {
    margin-top: 12px;
    border-radius: 18px;
    border: 1px solid rgba(148, 163, 184, 0.25);
    padding: 10px;
    background: rgba(248, 250, 252, 0.75);
}

.todo-group-header {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
    margin-bottom: 10px;
}

.todo-card-list {
    display: grid;
    gap: 10px;
}

.todo-card {
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface);
    padding: 12px;
}

.todo-card.is-pinned {
    border-color: color-mix(in srgb, var(--origin-color, #dbeafe) 70%, var(--border));
    background:
        linear-gradient(135deg, color-mix(in srgb, var(--origin-color, #dbeafe) 28%, #fff), rgba(255, 255, 255, 0.92));
}

.todo-card.is-complete {
    opacity: 0.66;
}

.todo-card.is-complete .todo-card-title,
.todo-mini-item.is-complete span {
    text-decoration: line-through;
}

.todo-card-title {
    font-weight: 800;
    line-height: 1.35;
}

.todo-card-notes,
.todo-card-meta {
    margin-top: 6px;
    color: var(--text-muted);
    font-size: 0.84rem;
    line-height: 1.4;
    white-space: pre-wrap;
}

.todo-card-actions {
    margin-top: 10px;
    justify-content: flex-start;
}

.todo-card-actions .btn {
    padding: 8px 10px;
    font-size: 0.84rem;
}

.todo-add-input {
    width: 100%;
    border-radius: 14px;
    border: 1px dashed var(--border);
    background: rgba(255, 255, 255, 0.84);
    color: var(--text-main);
    padding: 10px 12px;
    font: inherit;
}

.todo-add-input.compact {
    margin-top: 10px;
}

.todo-mini-list {
    display: grid;
    gap: 7px;
    margin-top: 10px;
}

.todo-mini-item {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 8px;
    align-items: center;
    color: var(--text-muted);
    font-size: 0.84rem;
}

.todo-mini-item .text-btn {
    justify-self: start;
}

.pinned-todo-grid {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.todo-origin-tag {
    display: inline-flex;
    border-radius: 999px;
    background: #dbeafe;
    color: #1e3a8a;
    font-weight: 800;
    margin-right: 6px;
    padding: 3px 8px;
}

.todo-type-tag {
    background: var(--tag-bg, #bbf7d0);
    color: var(--tag-text, #14532d);
}

.todo-priority-tag {
    background: #fecaca;
    color: #991b1b;
}

.todo-card.is-pinned .todo-origin-tag {
    background: var(--origin-color, #dbeafe);
    color: var(--text-main);
}

.mini-check {
    width: 26px;
    height: 26px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: #fff;
    cursor: pointer;
}

.todo-empty-line {
    margin: 8px 0 0;
}

.todo-archive-list {
    display: grid;
    gap: 8px;
}

.todo-archive-group {
    display: grid;
    gap: 8px;
}

.todo-archive-group h3 {
    color: var(--text-main);
    font-size: 0.95rem;
}

.todo-archive-row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.72);
    padding: 10px 12px;
}

.todo-archive-row span {
    display: block;
    color: var(--text-muted);
    font-size: 0.84rem;
}

.rewards-page,
.reward-section {
    display: grid;
    gap: 16px;
}

.reward-section {
    margin-top: 18px;
}

.reward-section-heading {
    border-radius: 16px;
    background: var(--column-color, #fecaca);
    padding: 10px 12px;
}

.reward-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 14px;
}

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

.reward-card,
.reward-column,
.reward-preset,
.reward-history-row {
    border: 1px solid var(--border);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.78);
    padding: 14px;
    box-shadow: 0 14px 30px rgba(15, 23, 42, 0.08);
}

.reward-card {
    display: grid;
    gap: 12px;
}

.reward-card h3 {
    margin: 0 0 6px;
    font-size: 1rem;
}

.reward-preset-list,
.reward-history-list {
    display: grid;
    gap: 10px;
}

.reward-preset {
    border-color: color-mix(in srgb, var(--preset-color, #dbeafe) 60%, var(--border));
    background:
        linear-gradient(135deg, color-mix(in srgb, var(--preset-color, #dbeafe) 34%, #fff), rgba(255, 255, 255, 0.92));
}

.reward-preset > div:first-child {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: baseline;
    margin-bottom: 10px;
}

.reward-preset span,
.reward-history-row span {
    color: var(--text-muted);
    font-size: 0.84rem;
}

.reward-actions {
    display: flex;
    gap: 7px;
    flex-wrap: wrap;
}

.reward-actions .btn {
    padding: 8px 10px;
    font-size: 0.84rem;
}

.reward-history-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
}

.reward-history-row > div {
    display: grid;
    gap: 4px;
}

.reward-history-row > div:last-child {
    text-align: right;
}

.insights-page {
    display: grid;
    gap: 18px;
}

.insights-calendar {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 8px;
}

.insights-day-name {
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 800;
    text-align: center;
    text-transform: uppercase;
}

.insights-day {
    min-height: 86px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.78);
    color: var(--text-main);
    cursor: pointer;
    display: grid;
    grid-template-rows: auto 1fr;
    padding: 10px;
    text-align: left;
    transition:
        transform 0.16s ease,
        box-shadow 0.16s ease;
}

.insights-day:hover {
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.1);
    transform: translateY(-1px);
}

.insights-day.is-other {
    opacity: 0.45;
}

.insights-day.is-today {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(255, 143, 171, 0.18);
}

.insights-day.is-ended {
    background: rgba(220, 252, 231, 0.72);
}

.insights-day.is-checked-in:not(.is-ended) {
    background: rgba(254, 249, 195, 0.72);
}

.insights-day span {
    font-weight: 900;
}

.insights-day-markers {
    align-self: end;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.insights-note-dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    display: inline-block;
}

.insights-note-dot {
    background: #2563eb;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.14);
}

.insights-mood-emoji {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.72);
    font-size: 1rem;
}

.insights-dream-emoji {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.72);
    font-size: 0.96rem;
}

.insight-note-list {
    display: grid;
    gap: 10px;
}

.insight-date-card {
    display: grid;
    gap: 8px;
}

.insight-date-tile {
    appearance: none;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface-soft);
    color: var(--text-main);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    padding: 12px 14px;
    text-align: left;
}

.insight-date-tile span,
.insight-date-tile strong {
    font-weight: 900;
}

.insight-date-body {
    display: grid;
    gap: 8px;
    padding-left: 8px;
}

.insight-note-card,
.day-note-row {
    border: 1px solid var(--border);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.78);
    padding: 12px;
}

.insight-mood-card {
    background: rgba(254, 249, 195, 0.58);
}

.mood-editor {
    display: grid;
    gap: 10px;
    margin: 14px 0;
}

.mood-editor label {
    color: var(--text-muted);
    font-weight: 800;
    font-size: 0.84rem;
}

.mood-picker {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.mood-button {
    width: 48px;
    height: 44px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: #fff;
    cursor: pointer;
    font-size: 1.35rem;
}

.mood-button.is-selected {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.mood-editor input,
.mood-editor textarea {
    width: 100%;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text-main);
    padding: 12px 14px;
    font: inherit;
}

.mood-editor textarea {
    min-height: 92px;
    resize: vertical;
}

.insight-note-card > div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.insight-note-card span,
.day-note-summary span {
    color: var(--text-muted);
    font-size: 0.84rem;
}

.insight-note-card p,
.day-note-row p {
    color: var(--text-muted);
    line-height: 1.45;
    margin: 8px 0 0;
    white-space: pre-wrap;
}

.dream-topic-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.dream-topic-row span {
    border-radius: 999px;
    background: #ede9fe;
    color: #4c1d95;
    font-size: 0.76rem;
    font-weight: 800;
    padding: 4px 8px;
}

.dream-topic-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.dream-topic-picker label {
    display: inline-flex;
    gap: 6px;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-soft);
    cursor: pointer;
    font-weight: 800;
    padding: 7px 10px;
}

.dream-topic-settings,
.dream-topic-settings-list {
    display: grid;
    gap: 10px;
}

.dream-topic-settings-row {
    display: grid;
    grid-template-columns: 70px minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
}

.dream-topic-settings-row.is-deleted {
    opacity: 0.45;
    text-decoration: line-through;
}

.dream-topic-settings-row input {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 12px;
    font: inherit;
}

.day-note-summary {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.day-note-summary span {
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-soft);
    padding: 6px 10px;
}

.day-note-list {
    display: grid;
    gap: 10px;
}

.day-note-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: start;
}

.is-hidden {
    display: none;
}

.json-preview {
    margin-top: 14px;
    max-height: 320px;
    overflow: auto;
    border-radius: 16px;
    padding: 14px;
    background: #1e293b;
    color: #e2e8f0;
    font-family:
        "SF Mono",
        "Space Mono",
        monospace;
    font-size: 0.82rem;
    line-height: 1.45;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    display: grid;
    place-items: center;
    padding: 20px;
    overflow: hidden;
}

.modal-card {
    width: min(620px, 100%);
    max-height: calc(100vh - 40px);
    background: var(--surface);
    border-radius: 24px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    padding: 20px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-body {
    min-height: 0;
    overflow-y: auto;
    padding-right: 4px;
}

.modal-actions {
    flex-shrink: 0;
    border-top: 1px solid var(--border);
    justify-content: flex-end;
    margin-top: 16px;
    padding-top: 14px;
}

.field {
    display: grid;
    gap: 8px;
    margin-top: 14px;
}

.field-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field label {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.field input,
.field textarea,
.field select {
    width: 100%;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text-main);
    padding: 12px 14px;
    font: inherit;
}

.field textarea {
    min-height: 220px;
    resize: vertical;
}

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

.checkbox-field input {
    width: auto;
}

.copy-status {
    margin: 8px 0 0;
    font-size: 0.84rem;
    line-height: 1.4;
}

.form-error {
    border: 1px solid #fecaca;
    border-radius: 14px;
    background: #fef2f2;
    color: #991b1b;
    font-weight: 700;
    line-height: 1.4;
    margin: 12px 0 0;
    padding: 10px 12px;
}

@media (max-width: 860px) {
    .tab-row {
        top: 0;
        margin-inline: -8px;
        overflow-x: auto;
        flex-wrap: nowrap;
    }

    .app-header {
        grid-template-columns: 1fr;
        gap: 14px;
        padding: 18px;
    }

    .summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .summary-card {
        padding: 10px 11px;
    }

    .summary-card strong {
        font-size: 1rem;
    }

    .toolbar-main {
        flex-direction: column;
        align-items: stretch;
    }

    .data-toolbar-card .toolbar-main {
        gap: 10px;
    }

    .data-actions {
        min-width: 0;
        width: 100%;
    }

    .data-actions .btn {
        padding: 9px 6px;
    }

    .compact-action-row {
        gap: 7px;
    }

    .compact-action-row .btn {
        font-size: 0.82rem;
        padding: 8px 5px;
    }

    .two-by-two-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .section-title-with-action {
        flex-direction: column;
        align-items: stretch;
    }

    .goal-grid {
        grid-template-columns: 1fr;
    }

    .calendar-grid.is-week {
        grid-template-columns: 1fr;
    }

    .calendar-grid.is-week .calendar-cell {
        min-height: auto;
    }

    .calendar-grid.is-week .calendar-chip-list {
        align-content: flex-start;
    }

    .calendar-grid.is-month {
        grid-template-columns: repeat(7, minmax(86px, 1fr));
        min-width: 700px;
    }

    .calendar-grid.is-month .calendar-cell {
        min-height: 116px;
        padding: 8px;
    }

    .calendar-grid.is-week .calendar-day-name {
        display: none;
    }

    .calendar-event-editor-row {
        grid-template-columns: 1fr;
    }

    .calendar-assign-row {
        align-items: stretch;
        flex-direction: column;
    }

    .calendar-assign-row #calendarAssignArea {
        flex-basis: auto;
    }

    .daily-agenda-header,
    .daily-agenda-row {
        grid-template-columns: 1fr;
    }

    .daily-agenda-header {
        display: grid;
    }

    .area-manager-row {
        grid-template-columns: 1fr;
    }

    .template-manager-row {
        grid-template-columns: 1fr;
    }

    .routine-node {
        margin-left: calc(var(--depth, 0) * 8px);
    }

    .routine-row {
        grid-template-columns: auto minmax(0, 1fr);
    }

    .routine-actions {
        grid-column: 1 / -1;
        justify-content: flex-start;
    }

    .field-grid {
        grid-template-columns: 1fr;
    }

    .todo-group-header,
    .todo-mini-item {
        grid-template-columns: auto minmax(0, 1fr);
    }

    .todo-mini-actions {
        grid-column: 1 / -1;
        justify-content: flex-start;
    }

    .todo-archive-row {
        align-items: flex-start;
        flex-direction: column;
    }

    .reward-history-row {
        align-items: flex-start;
        flex-direction: column;
    }

    .reward-history-row > div:last-child {
        text-align: left;
    }

    .insights-calendar {
        gap: 6px;
    }

    .insights-day-name {
        font-size: 0.68rem;
    }

    .insights-day {
        min-height: 58px;
        border-radius: 14px;
    }

    .modal-overlay {
        padding: 10px;
    }

    .modal-card {
        max-height: calc(100vh - 20px);
        padding: 14px;
    }

    .modal-actions {
        justify-content: stretch;
    }

    .modal-actions .btn {
        flex: 1 1 auto;
    }

    .day-note-row,
    .insight-note-card > div {
        grid-template-columns: 1fr;
        flex-direction: column;
    }
}
