:root {
    --bg: #101826;
    --surface: #1a2436;
    --surface-2: #243149;
    --line: #2f3e5a;
    --text: #eef2f8;
    --muted: #9aa8bf;
    --accent: #5eead4;
    --accent-ink: #06231f;
    --warn: #fbbf24;
    --danger: #f87171;
    --ok: #86efac;
    --radius: 14px;
    --nav-height: 60px;
    color-scheme: dark;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    padding: env(safe-area-inset-top) 0 calc(var(--nav-height) + env(safe-area-inset-bottom));
}

[hidden] {
    display: none !important;
}

main {
    max-width: 640px;
    margin: 0 auto;
    padding: 0 16px 24px;
}

h1 {
    font-size: 1.5rem;
    margin: 20px 0 12px;
}

h2 {
    font-size: 1.1rem;
    margin: 20px 0 8px;
}

a {
    color: var(--accent);
}

button,
input,
select,
textarea {
    font: inherit;
    color: inherit;
}

button {
    cursor: pointer;
    border: 0;
    border-radius: 10px;
    padding: 10px 16px;
    background: var(--surface-2);
}

.button-primary {
    background: var(--accent);
    color: var(--accent-ink);
    font-weight: 600;
}

.button-quiet {
    background: transparent;
    color: var(--muted);
}

input,
select,
textarea {
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: var(--bg);
}

label {
    display: block;
    margin: 12px 0 4px;
    color: var(--muted);
    font-size: 0.9rem;
}

/* ---- Shell: banners -------------------------------------------------------------------------- */

#shell-status {
    max-width: 640px;
    margin: 0 auto;
    padding: 8px 16px 0;
    display: grid;
    gap: 8px;
}

.banner {
    display: block;
    width: 100%;
    text-align: left;
    padding: 10px 14px;
    border-radius: 10px;
    background: var(--surface);
    border: 1px solid var(--line);
    font-size: 0.95rem;
}

.banner-action {
    border-color: var(--warn);
    color: var(--warn);
}

.banner-warning {
    border-color: var(--danger);
    color: var(--danger);
}

.banner-warning button {
    display: block;
    margin-top: 8px;
}

/* ---- Shell: capture -------------------------------------------------------------------------- */

#capture-shell {
    display: grid;
    justify-items: center;
    gap: 12px;
    padding: 28px 0 8px;
}

.mic {
    width: 132px;
    height: 132px;
    border-radius: 50%;
    padding: 0;
    background: var(--accent);
    color: var(--accent-ink);
    display: grid;
    place-items: center;
    box-shadow: 0 10px 30px rgb(94 234 212 / 25%);
    transition: transform 0.12s ease, background 0.12s ease;
}

.mic:active {
    transform: scale(0.96);
}

.mic svg {
    width: 56px;
    height: 56px;
    fill: currentColor;
    stroke: currentColor;
    stroke-width: 1.8;
}

.mic.recording {
    background: var(--danger);
    color: #fff;
    box-shadow: 0 0 0 10px rgb(248 113 113 / 22%);
}

.capture-status {
    min-height: 1.5em;
    margin: 0;
    color: var(--muted);
    text-align: center;
}

.capture-latest {
    width: 100%;
    text-align: left;
}

.capture-latest p {
    margin: 0 0 6px;
}

.transcript {
    font-size: 1.05rem;
}

.transcript:empty {
    display: none;
}

/* ---- Shell: navigation ----------------------------------------------------------------------- */

#shell-nav {
    position: fixed;
    inset: auto 0 0;
    height: calc(var(--nav-height) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    background: var(--surface);
    border-top: 1px solid var(--line);
}

#shell-nav a {
    display: grid;
    place-items: center;
    color: var(--muted);
    text-decoration: none;
    font-weight: 600;
}

#shell-nav a.current {
    color: var(--accent);
}

/* ---- Shell: dialog --------------------------------------------------------------------------- */

dialog {
    width: min(92vw, 420px);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    padding: 20px;
}

dialog::backdrop {
    background: rgb(0 0 0 / 60%);
}

dialog h2 {
    margin-top: 0;
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 18px;
}

.form-error {
    color: var(--danger);
    margin: 10px 0 0;
}

/* ---- App ------------------------------------------------------------------------------------- */

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin: 10px 0;
}

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

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

.link-list a {
    display: block;
    padding: 14px 16px;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--line);
    color: var(--text);
    text-decoration: none;
    font-weight: 600;
}

.list-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

a.button-primary {
    display: inline-block;
    padding: 10px 16px;
    border-radius: 10px;
    text-decoration: none;
}

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

.item-list li {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 2px 10px;
    align-items: center;
    padding: 12px 14px;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--line);
}

.item-list li a {
    color: var(--text);
    text-decoration: none;
    font-weight: 600;
}

.item-list li .muted {
    grid-column: 1;
    font-size: 0.9rem;
}

.item-list li button {
    grid-column: 2;
    grid-row: 1 / span 2;
}

.capture-history h2 {
    margin-top: 28px;
}

.capture-row audio {
    grid-column: 1 / -1;
    width: 100%;
    height: 36px;
    margin-top: 6px;
}

.row-actions {
    grid-column: 1 / -1;
    display: flex;
    gap: 12px;
    align-items: center;
    margin-top: 6px;
}

.editor .check {
    display: flex;
    gap: 8px;
    align-items: center;
    color: var(--text);
}

.editor .check input {
    width: auto;
}

#blazor-error-ui {
    display: none;
    position: fixed;
    inset: auto 0 calc(var(--nav-height) + env(safe-area-inset-bottom));
    padding: 10px 16px;
    background: #7f1d1d;
    color: #fff;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    float: right;
}

/* ---- Habits ---- */

.habit-strip h2 {
    margin-top: 12px;
}

.habit-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
}

.habit-row-name {
    flex: 1 1 12ch;
}

.habit-choices {
    display: flex;
    gap: 6px;
}

.habit-choice {
    padding: 8px 12px;
    border: 1px solid var(--line);
}

.habit-choice[aria-pressed="true"] {
    color: var(--accent-ink);
    font-weight: 600;
}

.habit-choice-kept[aria-pressed="true"] {
    background: var(--ok);
    border-color: var(--ok);
}

.habit-choice-not-kept[aria-pressed="true"] {
    background: var(--danger);
    border-color: var(--danger);
}

.habit-row .form-error {
    flex-basis: 100%;
    margin: 0;
}

.habit h2,
.habit-form h2 {
    margin: 0 0 2px;
}

.habit-facts {
    margin: 0 0 8px;
    font-size: 0.9rem;
}

.habit-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 18px;
    margin: 0 0 10px;
}

.habit-grid {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 5px;
}

.habit-day {
    display: block;
    aspect-ratio: 1;
    min-width: 0;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: transparent;
}

.habit-day-kept {
    border-color: var(--ok);
    background: var(--ok);
}

/* Not kept carries a stroke as well, so it does not depend on telling red from green. */
.habit-day-not_kept {
    border-color: var(--danger);
    background: linear-gradient(135deg, var(--danger) 42%, var(--surface) 42%, var(--surface) 58%, var(--danger) 58%);
}

.habit-day-not_scheduled {
    border-style: dashed;
    opacity: 0.35;
}

button.habit-day[aria-pressed="true"] {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.habit-day-editor,
.habit-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
}

.habit-actions {
    gap: 2px;
}

.habit-actions button {
    padding: 6px 10px;
}

.habit-legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
}

.habit-legend .habit-day {
    width: 14px;
    margin-left: 8px;
}

.habit-weekdays {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 14px;
    margin: 12px 0 0;
    padding: 0;
    border: 0;
}

.habit-weekdays legend {
    margin-bottom: 4px;
    padding: 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.habit-weekdays label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin: 0;
    color: var(--text);
    font-size: 1rem;
}

.habit-weekdays input {
    width: auto;
}

/* ---- Settings ---- */

.settings-section h2 {
    margin-top: 0;
}

.settings-section p {
    margin: 6px 0;
}

.settings-section [role="status"]:empty {
    display: none;
}

.field-pair {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 12px;
    align-items: end;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    margin-top: 16px;
}

.inline-form {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.inline-form > div {
    flex: 1;
}

.form-ok {
    color: var(--ok);
}

.error-list {
    padding-left: 20px;
}

.plain-list {
    list-style: none;
    margin: 8px 0;
    padding: 0;
}

.plain-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    border-top: 1px solid var(--line);
}

.plain-list li:first-child {
    border-top: 0;
}

.checklist li {
    justify-content: flex-start;
}

.checklist input {
    width: 22px;
    height: 22px;
    flex: none;
    accent-color: var(--accent);
}

.checklist label {
    margin: 0;
    color: var(--text);
    font-size: 1rem;
}

.table-scroll {
    overflow-x: auto;
}

.measurements {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.measurements th,
.measurements td {
    padding: 8px 6px;
    border-top: 1px solid var(--line);
    text-align: right;
    white-space: nowrap;
}

.measurements th:first-child {
    text-align: left;
    white-space: normal;
    font-weight: 400;
}

.measurements thead th {
    border-top: 0;
    color: var(--muted);
    font-weight: 400;
}

.measurements th .muted {
    display: block;
    font-size: 0.8rem;
}
