:root {
    --bg: #f6f4ef;
    --surface: #ffffff;
    --surface-soft: #fbfaf6;
    --ink: #171c19;
    --text: #2a302c;
    --muted: #7d857f;
    --faint: #a8afa9;
    --line: #e8e1d7;
    --line-soft: #efebe4;
    --sage: #2f7656;
    --sage-soft: #e8f3ee;
    --mint: #dcefe7;
    --blue: #4f77b7;
    --amber: #a77a35;
    --plum: #8d6380;
    --danger: #b74d43;
    --shadow-card: 0 10px 28px rgba(31, 37, 33, 0.06);
    --shadow-nav: 0 18px 40px rgba(26, 31, 28, 0.16);
    --nav-height: 78px;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--bg);
}

body {
    min-height: 100%;
    margin: 0;
    color: var(--text);
    background:
        radial-gradient(circle at 50% -120px, #ffffff 0, rgba(255, 255, 255, 0.78) 240px, rgba(255, 255, 255, 0) 520px),
        var(--bg);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI", sans-serif;
    font-size: 16px;
    letter-spacing: 0;
}

body::after {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 9;
    height: 124px;
    background: linear-gradient(180deg, rgba(246, 244, 239, 0), rgba(246, 244, 239, 0.96) 34%, var(--bg) 100%);
    content: "";
    pointer-events: none;
}

button,
input {
    font: inherit;
}

button {
    -webkit-tap-highlight-color: transparent;
}

.app-shell {
    width: min(100%, 520px);
    min-height: 100vh;
    margin: 0 auto;
    padding: 15px 20px calc(var(--nav-height) + 76px + env(safe-area-inset-bottom));
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 18px;
}

.brand {
    display: inline-flex;
    align-items: center;
    min-width: 0;
    gap: 10px;
    color: var(--ink);
    text-decoration: none;
}

.brand-mark {
    display: grid;
    width: 38px;
    height: 38px;
    place-items: center;
    border: 1px solid #d8e7df;
    border-radius: 50%;
    background: linear-gradient(180deg, #ffffff, #eef7f2);
    color: var(--sage);
    box-shadow: 0 8px 18px rgba(47, 118, 86, 0.1);
}

.brand-mark svg {
    width: 23px;
    height: 23px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.7;
}

.brand-word {
    overflow: hidden;
    color: var(--ink);
    font-size: 20px;
    font-weight: 600;
    line-height: 1;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.person-chip {
    display: inline-flex;
    align-items: center;
    max-width: 46%;
    min-height: 36px;
    padding: 0 14px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.72);
    color: #69706b;
    font-size: 14px;
    font-weight: 400;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.view {
    display: none;
}

.view.is-active {
    display: block;
}

.daily-hero {
    margin-bottom: 16px;
}

.eyebrow {
    margin: 0 0 9px;
    color: var(--sage);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0;
}

.hero-title-row {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 14px;
}

h1 {
    margin: 0;
    color: var(--ink);
    font-size: 34px;
    font-weight: 600;
    line-height: 1.04;
    letter-spacing: 0;
}

.percent-label {
    color: var(--muted);
    font-size: 14px;
    font-weight: 400;
}

.progress-line {
    height: 4px;
    margin: 14px 0 8px;
    overflow: hidden;
    border-radius: 999px;
    background: #e2ddd5;
}

.progress-line i {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--sage), var(--blue));
    transition: width 180ms ease;
}

.hero-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    color: var(--muted);
    font-size: 13px;
}

.hero-meta strong {
    font-weight: 500;
}

.next-card {
    display: grid;
    grid-template-columns: auto auto minmax(0, 1fr);
    align-items: center;
    gap: 9px;
    margin: 0 0 22px;
    padding: 12px 14px;
    border: 1px solid #dbe9e1;
    border-radius: 8px;
    background: rgba(237, 247, 241, 0.82);
}

.next-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--sage);
    box-shadow: 0 0 0 4px rgba(47, 118, 86, 0.1);
}

.next-card span:not(.next-dot) {
    color: var(--sage);
    font-size: 13px;
    font-weight: 600;
}

.next-card strong {
    min-width: 0;
    overflow: hidden;
    color: var(--text);
    font-size: 15px;
    font-weight: 500;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.screen-note {
    margin: 0 0 14px;
    color: var(--muted);
    font-size: 15px;
}

.routine-groups {
    display: grid;
    gap: 22px;
}

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

.period-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 1px;
}

.period-mark {
    width: 9px;
    height: 28px;
    border-radius: 999px;
    background: var(--sage);
}

.routine-section-midday .period-mark {
    background: var(--amber);
}

.routine-section-afternoon .period-mark {
    background: var(--blue);
}

.routine-section-night .period-mark {
    background: var(--plum);
}

.period-head h2 {
    margin: 0;
    color: var(--ink);
    font-size: 18px;
    font-weight: 600;
    line-height: 1.1;
}

.period-head p {
    margin: 3px 0 0;
    color: var(--faint);
    font-size: 12px;
    line-height: 1.2;
}

.routine-list,
.simple-list {
    display: grid;
    gap: 10px;
}

.routine-item {
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: var(--shadow-card);
    transition: border-color 160ms ease, background 160ms ease, opacity 160ms ease;
}

.routine-item.is-next {
    border-color: rgba(47, 118, 86, 0.32);
    background: #fcfffd;
}

.routine-item.is-done {
    opacity: 0.64;
}

.routine-item label {
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    min-height: 86px;
    padding: 14px;
    cursor: pointer;
}

.routine-item input {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
}

.check-ui {
    display: grid;
    width: 30px;
    height: 30px;
    place-items: center;
    border: 1.6px solid #c8d3cc;
    border-radius: 50%;
    background: #fff;
    transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.check-ui::after {
    width: 7px;
    height: 13px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    content: "";
    opacity: 0;
    transform: rotate(45deg) translate(-1px, -1px);
}

.routine-item input:checked + .check-ui {
    border-color: var(--sage);
    background: var(--sage);
    box-shadow: 0 0 0 5px rgba(47, 118, 86, 0.08);
}

.routine-item input:checked + .check-ui::after {
    opacity: 1;
}

.item-copy {
    display: grid;
    min-width: 0;
    gap: 5px;
}

.item-topline {
    display: flex;
    align-items: center;
    gap: 8px;
}

.time,
.simple-row time {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: fit-content;
    min-height: 24px;
    padding: 0 9px;
    border-radius: 999px;
    background: var(--mint);
    color: #2e7153;
    font-size: 12px;
    font-weight: 600;
}

.item-title {
    min-width: 0;
    overflow-wrap: anywhere;
    color: var(--ink);
    font-size: 16px;
    font-weight: 500;
    line-height: 1.25;
}

.item-note {
    color: var(--faint);
    font-size: 14px;
    font-weight: 400;
    line-height: 1.35;
}

.next-pill {
    display: none;
    align-items: center;
    min-height: 22px;
    padding: 0 8px;
    border-radius: 999px;
    background: #eef7f2;
    color: var(--sage);
    font-size: 11px;
    font-weight: 600;
}

.routine-item.is-next .next-pill {
    display: inline-flex;
}

.routine-item.is-done .item-title,
.routine-item.is-done .item-note,
.routine-item.is-done .time {
    color: #909891;
}

.section-head {
    margin: 6px 0 18px;
}

.simple-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 12px;
    align-items: start;
    padding: 14px;
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: var(--shadow-card);
}

.simple-row strong {
    display: block;
    margin-bottom: 4px;
    color: var(--ink);
    font-size: 15px;
    font-weight: 500;
    line-height: 1.25;
}

.simple-row span {
    display: block;
    color: var(--faint);
    font-size: 14px;
    line-height: 1.35;
}

.order-list {
    display: grid;
    gap: 9px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.order-list li {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    padding: 13px 14px;
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.94);
}

.order-list time {
    color: var(--sage);
    font-size: 13px;
    font-weight: 600;
}

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

.stat-row {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) 48px;
    gap: 10px;
    align-items: center;
    padding: 14px;
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.94);
}

.stat-row span,
.stat-row small {
    color: var(--muted);
    font-size: 13px;
    font-weight: 400;
}

.stat-track {
    height: 7px;
    overflow: hidden;
    border-radius: 999px;
    background: #ece7df;
}

.stat-track i {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--sage), var(--blue));
}

.bottom-nav {
    position: fixed;
    right: 50%;
    bottom: calc(10px + env(safe-area-inset-bottom));
    z-index: 10;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    width: min(calc(100% - 24px), 480px);
    min-height: var(--nav-height);
    padding: 7px;
    border: 1px solid rgba(219, 214, 205, 0.95);
    border-radius: 28px;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: var(--shadow-nav);
    transform: translateX(50%);
}

.bottom-nav button {
    display: grid;
    min-width: 0;
    min-height: 62px;
    place-items: center;
    gap: 4px;
    border: 0;
    border-radius: 22px;
    background: transparent;
    color: #a0a79f;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
}

.bottom-nav svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
}

.bottom-nav button.is-active {
    background: #eef7f2;
    color: var(--sage);
}

.not-found {
    padding: 24px;
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    background: var(--surface);
}

.admin-shell {
    max-width: 760px;
}

.admin-head {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 16px;
}

.admin-link {
    color: var(--sage);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
}

.admin-card,
.admin-item {
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: var(--shadow-card);
}

.admin-card {
    display: block;
    padding: 18px;
}

.admin-form {
    display: grid;
    gap: 14px;
}

.admin-form label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
}

.admin-form input {
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    padding: 10px 12px;
    outline: none;
}

.admin-form input:focus {
    border-color: #9dc9ad;
    box-shadow: 0 0 0 4px rgba(47, 118, 86, 0.12);
}

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

.admin-item {
    position: relative;
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr);
    gap: 10px;
    padding: 12px;
    transition: opacity 140ms ease, transform 140ms ease, border-color 140ms ease;
}

.admin-item.is-dragging {
    border-color: rgba(47, 118, 86, 0.42);
    opacity: 0.72;
    transform: scale(0.995);
}

.drag-handle {
    display: grid;
    width: 36px;
    height: 44px;
    place-items: center;
    align-self: start;
    border: 1px solid var(--line-soft);
    border-radius: 999px;
    background: #fff;
    color: #929a94;
    cursor: grab;
    touch-action: none;
}

.drag-handle:active {
    cursor: grabbing;
}

.drag-handle svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 3;
}

.admin-item-grid {
    display: grid;
    grid-template-columns: 108px minmax(180px, 1fr);
    gap: 10px;
}

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

.row-actions {
    grid-column: 2;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 10px;
}

.row-actions button {
    display: grid;
    width: 38px;
    height: 38px;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: #fff;
    color: #707970;
    cursor: pointer;
}

.row-actions button[data-delete] {
    color: var(--danger);
}

.row-actions svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2;
}

.admin-actions {
    position: sticky;
    bottom: calc(12px + env(safe-area-inset-bottom));
    z-index: 10;
    display: grid;
    grid-template-columns: 1fr 1.35fr;
    gap: 10px;
    padding: 8px;
    border: 1px solid rgba(219, 214, 205, 0.95);
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: var(--shadow-nav);
}

.primary-button,
.ghost-button {
    min-height: 50px;
    border-radius: 18px;
    font-weight: 500;
    cursor: pointer;
}

.primary-button {
    border: 0;
    background: var(--ink);
    color: #fff;
}

.ghost-button {
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
}

.save-note,
.form-error {
    margin: 0 0 12px;
    padding: 11px 13px;
    border-radius: 8px;
    font-size: 14px;
}

.save-note {
    border: 1px solid #cee4d6;
    background: #eef8f2;
    color: var(--sage);
}

.form-error {
    border: 1px solid #efd0cf;
    background: #fff2f1;
    color: var(--danger);
}

.is-sorting {
    user-select: none;
}

@media (max-width: 430px) {
    .app-shell {
        padding-right: 20px;
        padding-left: 20px;
    }

    h1 {
        font-size: 31px;
    }

    .routine-item label {
        min-height: 84px;
        padding: 13px;
    }

    .item-title {
        font-size: 15.5px;
    }

    .bottom-nav {
        width: calc(100% - 20px);
    }
}

@media (max-width: 560px) {
    .admin-item {
        grid-template-columns: 34px minmax(0, 1fr);
        gap: 8px;
    }

    .admin-item-grid {
        grid-template-columns: 1fr;
    }

    .note-field {
        grid-column: auto;
    }

    .row-actions {
        grid-column: 1 / -1;
    }
}
