:root {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: #263449;
    background: #f5f6f8;
    font-synthesis: none;
    --blue: #4669a3;
    --muted: #687588;
    --line: #e5e9ee
}

* {
    box-sizing: border-box
}

body {
    margin: 0
}

button,
input,
select {
    font: inherit
}

button,
.button {
    cursor: pointer;
    transition: background .18s, color .18s;
    min-height: 46px;
    border-radius: 10px;
    padding: 11px 18px;
    border: 1px solid transparent;
    font-weight: 600;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px
}

button:disabled {
    opacity: .55;
    cursor: wait
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 3px solid #a3bce6;
    outline-offset: 3px
}

button:hover,
.button:hover {
    filter: brightness(.96)
}

a {
    color: inherit
}

.primary {
    background: var(--blue);
    color: white
}

.quiet {
    background: #eef1f6;
    color: #445774
}

.danger {
    background: #fff1ef;
    color: #aa3b32;
    border-color: #f1cdc8
}

.full {
    width: 100%
}

[hidden] {
    display: none !important
}

.header {
    max-width: 1240px;
    margin: auto;
    padding: 25px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--line)
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -.4px
}

.brand small {
    display: block;
    font-size: 12px;
    font-weight: 400;
    color: var(--muted);
    letter-spacing: .1px;
    margin-top: 3px
}

main {
    max-width: 1240px;
    margin: auto;
    padding: 38px 32px 0
}

.intro {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    margin-bottom: 32px
}

h1 {
    font-size: 30px;
    line-height: 1.2;
    font-weight: 650;
    letter-spacing: -1px;
    margin: 8px 0 12px
}

h2 {
    font-size: 21px;
    letter-spacing: -.5px;
    margin: 5px 0 0;
    font-weight: 650
}

h3 {
    font-size: 17px;
    margin: 0
}

.eyebrow {
    font-size: 11px;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--muted);
    margin: 0
}

.muted {
    color: var(--muted);
    font-size: 14px;
    line-height: 1.6;
    margin: 8px 0 18px
}

.intro .muted {
    margin-bottom: 0
}

.timezone {
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap
}

.workspace {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    gap: 24px;
    align-items: stretch
}

.panel {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 26px
}

.type-tabs {
    display: flex;
    background: #f2f4f7;
    padding: 4px;
    border-radius: 12px;
    margin: 23px 0
}

.type-tabs button {
    width: 50%;
    color: var(--muted);
    background: transparent;
    min-height: 44px;
    padding: 10px
}

.type-tabs .active {
    background: white;
    color: var(--blue);
    box-shadow: 0 1px 4px #26344912
}

label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 9px
}

input:not([type=checkbox]):not([type=file]),
select {
    border: 1px solid #d9e0e9;
    border-radius: 10px;
    background: #fff;
    color: #263449;
    width: 100%;
    padding: 12px;
    font-size: 16px
}

input.value-input {
    font-weight: 600;
    letter-spacing: -1px;
}

input::placeholder {
    color: #b2bac7
}

.field-hint {
    font-size: 12px;
    color: var(--muted);
    min-height: 18px;
    margin: 9px 0 23px
}

small {
    display: block;
    font-size: 12px;
    line-height: 1.5;
    color: var(--muted);
    margin-top: 8px
}

#save-entry {
    margin-top: 26px
}

#cancel-edit {
    margin-top: 8px
}

.status-dot {
    width: 6px;
    height: 6px;
    display: inline-block;
    background: #729487;
    border-radius: 50%
}

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    margin-bottom: 24px
}

.switch {
    font-weight: 400;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    margin: 0 0 0 auto;
    cursor: pointer
}

.switch input {
    width: 19px;
    height: 19px;
    accent-color: var(--blue)
}

.periods {
    display: flex;
    gap: 5px;
    border-bottom: 1px solid var(--line);
    padding-bottom: 18px;
    flex-wrap: wrap
}

.periods button:not(.quiet) {
    font-size: 12px;
    padding: 9px 14px;
    min-height: 38px;
    background: transparent;
    color: var(--muted);
    border-radius: 8px
}

.periods button.active {
    background: #eaf0fa;
    color: #3f6199
}

.chart-meta {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    font-size: 11px;
    color: var(--muted);
    margin: 20px 0
}

.legend-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    margin: 0 4px 0 8px
}

.glucose {
    background: #4669a3
}

.insulin {
    background: #b47a50
}

.chart {
    height: 290px;
    position: relative
}

.chart svg {
    width: 100%;
    height: 100%;
    overflow: visible
}

.chart-empty {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 14px;
    color: var(--muted);
    padding: 35px;
    line-height: 1.7;
    background: repeating-linear-gradient(to top, transparent 0, transparent 57px, #edf0f4 58px, transparent 59px)
}


.history-panel {
    margin-top: 24px
}

.count {
    font-size: 12px;
    color: var(--muted);
    background: #f0f2f5;
    padding: 4px 9px;
    border-radius: 7px;
    vertical-align: middle;
    margin-left: 7px;
    font-weight: 500
}

.filter-label {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--muted);
    font-weight: 400;
    margin: 0
}

.filter-label select {
    font-size: 13px;
    min-height: 42px;
    width: 155px
}

.history-row {
    display: grid;
    grid-template-columns: 160px 1fr 130px auto;
    gap: 15px;
    align-items: center;
    padding: 6px 0;
    border-top: 1px solid var(--line);
    font-size: 14px
}

.record-date {
    font-size: 13px
}

.record-date small {
    font-size: 11px;
    margin-top: 4px
}

.record-type {
    display: flex;
    align-items: center;
    gap: 10px
}

.record-icon {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: #edf2fb;
    color: #4669a3;
    display: grid;
    place-items: center;
    font-size: 18px
}

.record-icon.insulin-icon {
    background: #f8efe7;
    color: #a76d42
}

.record-value {
    font-size: 18px;
    font-weight: 650;
    font-variant-numeric: tabular-nums
}

.record-value small {
    display: inline;
    font-size: 11px;
    font-weight: 400;
    margin-left: 4px
}

.record-actions {
    display: flex;
    gap: 5px
}

.record-actions button {
    font-size: 12px;
    min-height: 42px;
    padding: 8px 10px;
    background: transparent;
    color: var(--muted)
}

.record-actions button:last-child {
    color: #a4544c
}

.empty {
    padding: 30px 15px;
    text-align: center;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.7
}

.notice {
    border: 1px solid #cbdccc;
    background: #edf5ef;
    color: #325b3d;
    border-radius: 12px;
    padding: 15px 18px;
    font-size: 14px;
    line-height: 1.5
}

.notice.error {
    background: #fff2ef;
    color: #9e392c;
    border-color: #efd0c9
}

.settings {
    margin-bottom: 24px
}

.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 48px
}

.inline {
    display: flex;
    gap: 10px
}

.file-label {
    margin: 20px 0 10px
}

input[type=file] {
    max-width: 100%;
    font-size: 13px
}

footer {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 28px 0;
    color: #7d8797;
    font-size: 11px
}

.chart-point {
    cursor: help
}

.chart-point:hover {
    r: 6
}

#load-more {
    margin-top: 15px
}

@media(min-width:1100px) {
    .chart {
        height: 310px
    }
}

@media(max-width:960px) {
    .workspace {
        grid-template-columns: 280px minmax(0, 1fr);
        gap: 16px
    }

    .panel {
        padding: 22px
    }

    .section-heading {
        align-items: flex-start
    }

    .chart-panel .section-heading {
        flex-direction: column;
        gap: 16px
    }

    .history-row {
        grid-template-columns: 120px 1fr 110px auto
    }

    .timezone {
        display: none
    }

    .record-actions button {
        font-size: 11px;
        padding: 8px 5px
    }
}

@media(max-width:700px) {
    .header {
        padding: 18px 20px
    }

    main {
        padding: 28px 0 0
    }

    .header .quiet {
        font-size: 12px;
        padding: 10px 13px
    }

    .intro {
        margin-bottom: 24px
    }

    h1 {
        font-size: 26px;
        letter-spacing: -.8px
    }

    .intro .muted {
        font-size: 13px
    }

    .workspace {
        display: flex;
        flex-direction: column;
        gap: 18px
    }

    .panel {
        padding: 22px 20px;
        border-radius: 16px
    }

    .entry-panel {
        order: 0
    }

    .entry-panel h2 {
        font-size: 20px
    }

    .type-tabs {
        margin: 20px 0
    }

    .chart-panel .section-heading {
        flex-direction: row;
        align-items: center
    }

    .chart-panel .switch {
        max-width: 135px
    }

    .periods {
        gap: 2px;
        justify-content: space-between
    }

    .periods button {
        padding: 8px;
        min-height: 40px
    }

    .chart {
        height: 250px
    }

    .history-panel {
        margin-top: 18px
    }

    .history-panel .section-heading {
        align-items: center
    }

    .filter-label {
        font-size: 0
    }

    .filter-label select {
        font-size: 12px;
        width: 133px
    }

    .history-row {
        grid-template-columns: 1fr auto;
        gap: 10px;
        padding: 18px 0
    }

    .record-type {
        grid-column: 1;
        grid-row: 1
    }

    .record-value {
        grid-column: 2;
        grid-row: 1;
        text-align: right
    }

    .record-date {
        grid-column: 1;
        grid-row: 2;
        font-size: 12px
    }

    .record-date small {
        display: inline;
        margin-left: 7px
    }

    .record-actions {
        grid-column: 2;
        grid-row: 2
    }

    .record-actions button {
        font-size: 11px;
        min-height: 44px
    }

    .settings-grid {
        grid-template-columns: 1fr;
        gap: 30px
    }

    .chart-meta {
        font-size: 10px
    }

    .inline button {
        padding: 10px 14px
    }
}

@media(prefers-reduced-motion:reduce) {
    * {
        transition: none !important;
        scroll-behavior: auto !important
    }
}

.custom-period {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-left: auto;
}

.custom-period label {
    margin: 0;
    font-size: 12px;
    color: var(--muted);
    font-weight: 400
}

.custom-period input#custom-days {
    width: 92px;
    min-height: 44px;
    padding: 10px
}

.custom-period button {
    min-height: 44px;
    font-size: 12px;
    padding: 10px 14px
}

.zone-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 16px;
    margin-top: 18px;
    font-size: 11px;
    color: #526176
}

.zone-legend span {
    display: flex;
    align-items: center;
    gap: 6px
}

.zone-swatch {
    display: inline-block;
    width: 13px;
    height: 10px;
    border-radius: 3px;
    border: 1px solid #00000012
}

.zone-low {
    background: #f8deda
}

.zone-middle {
    background: #fcf0d5
}

.zone-target {
    background: #e6f2e9
}

.zone-high {
    background: #f8e7df
}

.memo {
    margin-top: 20px;
    padding-top: 22px;
    border-top: 1px solid var(--line);
    font-size: 14px;
    line-height: 1.75;
    overflow-wrap: anywhere
}

.memo h4 {
    font-size: 15px;
    margin: 24px 0 8px
}

.memo p {
    margin: 10px 0
}

.memo ul {
    padding-left: 21px;
    margin: 12px 0
}

.memo li {
    padding-left: 3px;
    margin: 12px 0
}

.memo h3 {
    line-height: 1.4
}

.zone-selected {
    background: #ccebd7;
    border-color: #92c7a5
}

.workspace {
    display: flex;
    flex-direction: column
}

.add-entry {
    position: fixed;
    right: 24px;
    bottom: max(24px, env(safe-area-inset-bottom));
    z-index: 20;
    width: 60px;
    height: 60px;
    padding: 0;
    border-radius: 50%;
    background: var(--blue);
    color: #fff;
    font-size: 36px;
    font-weight: 400;
    line-height: 1;
    box-shadow: 0 4px 18px #26344930
}

.entry-close {
    float: right;
    font-size: 12px;
    margin-left: 12px
}

footer {
    padding-bottom: 100px
}

#entry-panel {
    scroll-margin-top: 20px
}

@media(max-width:700px) {
    .add-entry {
        right: 18px;
        width: 56px;
        height: 56px
    }
}
.history-summary{display:flex;align-items:center;justify-content:space-between;gap:16px;cursor:pointer;list-style:none;min-height:48px}.history-summary::-webkit-details-marker{display:none}.history-summary:focus-visible{outline:3px solid #a3bce6;outline-offset:6px;border-radius:6px}.history-chevron{font-size:25px;color:var(--muted);transition:transform .18s}.history-panel[open] .history-chevron{transform:rotate(180deg)}.history-controls{justify-content:flex-end;margin-top:22px}

.dose-fieldset{border:0;margin:0;padding:0;min-width:0}.dose-fieldset legend{font-size:13px;font-weight:600;margin-bottom:12px;padding:0}.dose-options{display:flex;flex-wrap:wrap;gap:8px}.dose-option{position:relative;display:block;margin:0;cursor:pointer}.dose-option input[type=radio]{position:absolute;opacity:0;width:1px;height:1px}.dose-option span{display:flex;align-items:center;justify-content:center;min-width:56px;min-height:48px;padding:10px 14px;border:1px solid #d9e0e9;border-radius:10px;background:#fff;font-size:15px;color:#526176}.dose-option input:checked+span{background:#eaf0fa;border-color:var(--blue);color:var(--blue)}.dose-option input:focus-visible+span{outline:3px solid #a3bce6;outline-offset:3px}.dose-option:hover span{border-color:var(--blue)}.settings-grid{grid-template-columns:1fr}
