@font-face {
    font-family: "Open Sans";
    src: url("../fonts/OpenSans-Regular.ttf") format("truetype");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Open Sans";
    src: url("../fonts/OpenSans-Semibold.ttf") format("truetype");
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}

:root {
    --bg: #F6F7F9;
    --surface: #FFFFFF;
    --text: #17212B;
    --muted: #596573;
    --line: #DDE3E8;
    --accent: #126B64;
    --accent-soft: #E5F3EF;
    --on-accent: #FFFFFF;
    --danger: #B42318;
    --pad: 20px;
    --radius: 12px;
    color-scheme: light;
}

[data-theme="dark"] {
    --bg: #111A21;
    --surface: #1B2731;
    --text: #F2F5F7;
    --muted: #B5C0C9;
    --line: #33434F;
    --accent: #7CD5BD;
    --accent-soft: #17352E;
    --on-accent: #10241D;
    --danger: #FFB4A8;
    color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #111A21;
        --surface: #1B2731;
        --text: #F2F5F7;
        --muted: #B5C0C9;
        --line: #33434F;
        --accent: #7CD5BD;
        --accent-soft: #17352E;
        --on-accent: #10241D;
        --danger: #FFB4A8;
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Open Sans", sans-serif;
    font-size: 16px;
    line-height: 1.45;
}

a { color: var(--accent); text-decoration: none; }
button, input, select { font: inherit; color: inherit; }

.app {
    width: min(100%, 440px);
    min-height: 100dvh;
    margin: 0 auto;
    padding: 12px var(--pad) calc(120px + env(safe-area-inset-bottom));
}

.app.plain { padding-bottom: 32px; }

.date { color: var(--muted); font-size: 14px; margin: 8px 0 4px; }
.hello { font-size: 28px; font-weight: 600; letter-spacing: -0.03em; margin: 0; }
.section { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; margin: 0; }
.helper { color: var(--muted); font-size: 14px; margin: 0; }
.danger { color: var(--danger); font-size: 16px; margin: 0; }

.clock {
    font-size: 64px;
    font-weight: 600;
    letter-spacing: -0.04em;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    margin: 12px 0 0;
}

.headrow, .metric, .task, .goal, .choice {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    align-items: center;
}

.headrow { margin: 32px 0 16px; }

.metric { min-height: 32px; }
.metric b { font-weight: 600; font-variant-numeric: tabular-nums; }

.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-lg { display: flex; flex-direction: column; gap: 32px; }
.hairline { height: 1px; background: var(--line); border: 0; margin: 0; }

.task, .goal, .choice {
    grid-template-columns: auto 1fr auto;
    min-height: 48px;
    gap: 12px;
    padding: 8px 0;
    border-top: 1px solid var(--line);
}

.task:first-child, .goal:first-child, .choice:first-child { border-top: 0; }
.choice[hidden],
[data-group][hidden] { display: none; }

.task h3, .goal h3, .choice h3 { margin: 0; font-size: 16px; font-weight: 600; }
.done h3 { color: var(--muted); font-weight: 400; }

.ico {
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    color: var(--accent);
}

.ico svg, .scene svg, .check svg, .iconbtn svg { width: 24px; height: 24px; display: block; }
.ico svg *, .scene svg *, .check svg *, .iconbtn svg * {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.scene {
    width: 100%;
    height: 168px;
    border-radius: 20px;
    background: var(--accent-soft);
    color: var(--accent);
    display: grid;
    place-items: center;
    margin: 8px 0 16px;
}

.scene svg { width: 168px; height: 150px; }
.scene svg * { stroke-width: 2.4; }

.btn, .quiet, .iconbtn {
    border: 0;
    cursor: pointer;
    border-radius: var(--radius);
    min-height: 52px;
    padding: 12px 16px;
    text-align: center;
}

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    background: var(--accent);
    color: var(--on-accent);
    font-weight: 600;
    text-decoration: none;
}

.quiet {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: var(--accent);
    font-weight: 600;
    min-height: 48px;
}

.iconbtn {
    width: 48px;
    height: 48px;
    min-height: 48px;
    padding: 0;
    background: transparent;
    color: var(--text);
    display: grid;
    place-items: center;
}

.field { display: flex; flex-direction: column; gap: 8px; }
.field span { font-size: 14px; color: var(--muted); }

input[type="text"], input[type="email"], input[type="password"], input[type="number"], select {
    width: 100%;
    min-height: 52px;
    border: 1px solid var(--line);
    background: var(--surface);
    border-radius: var(--radius);
    padding: 12px 14px;
}

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
    min-height: 40px;
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: transparent;
    color: var(--text);
    cursor: pointer;
}
.chip.on { background: var(--accent-soft); border-color: transparent; color: var(--accent); font-weight: 600; }

.banner {
    background: var(--accent-soft);
    color: var(--text);
    border-radius: var(--radius);
    padding: 12px 14px;
    font-size: 14px;
}

.rhythm, .chart {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
    align-items: end;
    height: auto;
}

.rhythm i, .chart i {
    display: block;
    border-radius: 6px 6px 2px 2px;
    background: var(--line);
    min-height: 6px;
}

.rhythm i.on, .chart i.live { background: var(--accent); }

.chart b, .rhythm b {
    display: block;
    text-align: center;
    font-size: 12px;
    font-weight: 400;
    color: var(--muted);
    margin-top: 6px;
}

.chart { height: auto; }
.rhythm span, .chart span {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    min-height: 96px;
}

.ringwrap {
    width: min(100%, 280px);
    margin: 12px auto;
    position: relative;
    aspect-ratio: 1;
}

.ringwrap svg { width: 100%; height: 100%; }
.ring-track { fill: none; stroke: var(--line); stroke-width: 10; }
.ring-value {
    fill: none;
    stroke: var(--accent);
    stroke-width: 10;
    stroke-linecap: butt;
    transform: rotate(-90deg);
    transform-origin: 60px 60px;
}

.remain {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-size: 56px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.04em;
}

.state { text-align: center; font-size: 22px; font-weight: 600; margin: 8px 0 0; }

.tabbar {
    position: fixed;
    left: 50%;
    bottom: 0;
    transform: translateX(-50%);
    width: min(100%, 440px);
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    background: var(--surface);
    border-top: 1px solid var(--line);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    z-index: 5;
}

.tabbar a {
    min-height: 48px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--muted);
    font-size: 12px;
}

.tabbar a.on { color: var(--accent); font-weight: 600; }
.tabbar svg { width: 22px; height: 22px; }
.tabbar svg * {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.check {
    width: 48px;
    height: 48px;
    border: 0;
    background: transparent;
    color: var(--accent);
    cursor: pointer;
}

.rowactions { display: flex; align-items: center; flex-wrap: wrap; }
.mins { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 14px; }

.auth-card { display: flex; flex-direction: column; gap: 16px; margin-top: 24px; }

.own {
    margin-top: 20px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--surface);
}

.own summary {
    list-style: none;
    cursor: pointer;
    min-height: 56px;
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.own summary::-webkit-details-marker { display: none; }

.own summary::after {
    content: "";
    width: 8px;
    height: 8px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    flex: none;
}

.own[open] summary::after { transform: rotate(-135deg); margin-top: 4px; }

.own-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 0 16px 16px;
}

.own-times { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.own-check {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 48px;
}

.own-check input { width: 22px; height: 22px; margin: 0; }

@media (max-width: 360px) {
    .clock { font-size: 52px; }
    .remain { font-size: 44px; }
    .hello { font-size: 26px; }
}

.sider { display: none; }
.pocket-clock { width: 100%; height: 112px; display: block; margin: 0 0 8px; }
.visual-panel { display: none; }
.with-visual { display: block; }

.look-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 24px; }
.look-card { border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: var(--surface); }
.swatch {
    border: 1px solid;
    border-radius: 12px;
    min-height: 56px;
    padding: 12px;
    margin-top: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
input[type="color"] {
    width: 100%;
    height: 52px;
    border: 1px solid var(--line);
    background: var(--surface);
    border-radius: 12px;
    padding: 6px;
}

@media (min-width: 960px) {
    .shell:has(.sider) {
        display: grid;
        grid-template-columns: 232px minmax(0, 1fr);
        min-height: 100dvh;
    }

    .sider {
        display: flex;
        flex-direction: column;
        gap: 4px;
        position: sticky;
        top: 0;
        height: 100dvh;
        padding: 28px 16px;
        border-right: 1px solid var(--line);
        background: var(--surface);
    }

    .brand {
        display: block;
        margin: 0 12px 20px;
        color: var(--text);
        font-size: 22px;
        font-weight: 600;
        letter-spacing: -0.03em;
    }

    .navlink {
        display: flex;
        align-items: center;
        gap: 12px;
        min-height: 48px;
        padding: 0 12px;
        border-radius: 12px;
        color: var(--muted);
        font-weight: 600;
    }

    .navlink.on { background: var(--accent-soft); color: var(--accent); }
    .navlink svg { width: 22px; height: 22px; }
    .navlink svg * {
        fill: none;
        stroke: currentColor;
        stroke-width: 1.75;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

    .tabbar { display: none; }
    .pocket-clock { display: none; }

    .app { width: auto; max-width: none; padding: 28px 40px 48px; }
    .app.plain { max-width: 440px; margin: 0 auto; }

    .with-visual:has(.visual-panel) {
        display: grid;
        grid-template-columns: minmax(0, 1fr) 320px;
        gap: 36px;
        align-items: start;
    }

    .visual-panel { display: block; position: sticky; top: 28px; }
    .visual-panel canvas { width: 100%; aspect-ratio: 1; display: block; }

    [data-group] {
        display: grid;
        grid-template-columns: 1fr 1fr;
        column-gap: 28px;
    }

    [data-group] > .section { grid-column: 1 / -1; }
    .look-grid { grid-template-columns: repeat(3, 1fr); }
    .clock { font-size: 72px; }

    .app.plain:has(.gate) {
        max-width: 960px;
        width: 100%;
        min-height: 100dvh;
        display: flex;
        align-items: center;
        padding: 48px 40px;
    }

    .app.plain:has(.gate) .with-visual { width: 100%; }

    .gate {
        display: grid;
        grid-template-columns: minmax(0, 440px) minmax(240px, 320px);
        gap: 48px;
        align-items: center;
        width: 100%;
    }

    .gate-card {
        background: var(--surface);
        border: 1px solid var(--line);
        border-radius: 20px;
        padding: 32px;
    }

    .gate .sheet-handle { display: none; }
    .gate-visual canvas { width: 100%; aspect-ratio: 1; display: block; }
}

.gate-card {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.gate-back {
    align-self: flex-start;
    justify-content: flex-start;
    padding-left: 0;
    min-height: 40px;
}

.sheet-handle {
    width: 40px;
    height: 4px;
    border-radius: 999px;
    background: var(--line);
    margin: 4px auto 0;
}

.gate-visual { display: none; }

dialog.sheet {
    width: min(100%, 480px);
    max-height: min(92dvh, 760px);
    margin: auto auto 0;
    padding: 0;
    border: 0;
    border-radius: 20px 20px 0 0;
    background: var(--surface);
    color: var(--text);
    overflow: auto;
    box-shadow: 0 18px 48px rgba(17, 26, 33, 0.28);
}

dialog.sheet::backdrop {
    background: rgba(17, 26, 33, 0.48);
}

dialog.sheet .gate-card {
    padding: 8px 20px calc(20px + env(safe-area-inset-bottom));
}

@media (max-width: 959px) {
    .app.plain:has(.gate) {
        width: 100%;
        max-width: none;
        min-height: 100dvh;
        margin: 0;
        padding: 0;
        background: rgba(17, 26, 33, 0.48);
        display: flex;
        flex-direction: column;
        justify-content: flex-end;
    }

    .gate-card {
        width: 100%;
        max-height: 92dvh;
        overflow: auto;
        background: var(--surface);
        color: var(--text);
        border-radius: 20px 20px 0 0;
        padding: 8px 20px calc(20px + env(safe-area-inset-bottom));
    }
}

@media (min-width: 960px) {
    .gate-visual { display: block; }
}
