/* Summer — mobile-first stylesheet */

:root {
    --bg: #fbf7f0;
    --surface: #ffffff;
    --ink: #1f2630;
    --muted: #6b7280;
    --line: #e7e2d8;
    --primary: #f6b352;
    --primary-ink: #2b1d05;
    --primary-hover: #ecaa49;
    --danger: #c0392b;
    --good: #2e7d32;
    --warn: #b15500;
    --bad: #b3261e;
    --band: rgba(246, 179, 82, 0.18);
    --radius: 12px;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 12px rgba(0, 0, 0, 0.05);
    --tap: 44px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.4;
    -webkit-text-size-adjust: 100%;
}

body { min-height: 100vh; }

a { color: var(--ink); text-decoration: none; }
a:hover { text-decoration: underline; }

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

/* Topbar */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 10;
    padding-top: max(12px, env(safe-area-inset-top));
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 18px;
}
.brand:hover { text-decoration: none; }
.brand-mark { color: var(--primary); }

/* Container */
.container {
    max-width: 720px;
    margin: 0 auto;
    padding: 16px;
    padding-bottom: max(24px, env(safe-area-inset-bottom));
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: var(--tap);
    padding: 10px 16px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    background: var(--surface);
    color: var(--ink);
    font-weight: 600;
    font-size: 16px;
    cursor: pointer;
    line-height: 1;
    text-align: center;
}
.btn:hover { text-decoration: none; }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.btn-primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-ghost:hover { background: var(--surface); }
.btn-danger { background: var(--danger); color: white; border-color: var(--danger); }
.btn-danger:hover { filter: brightness(1.05); }
.btn-block { display: flex; width: 100%; }

/* Flash */
.flashes {
    list-style: none;
    margin: 0 0 16px;
    padding: 12px 14px;
    background: #fff5d6;
    border: 1px solid #f1d56a;
    border-radius: var(--radius);
}
.flashes li + li { margin-top: 4px; }

/* Card grid */
.card-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: 1fr;
    margin-top: 12px;
}
@media (min-width: 540px) { .card-grid { grid-template-columns: 1fr 1fr; } }

.dog-card {
    display: flex;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}
.dog-card:hover { text-decoration: none; }
.dog-card-media {
    width: 96px;
    flex: 0 0 96px;
    background: #f1ece0;
    position: relative;
    aspect-ratio: 1;
}
.dog-card-media img {
    width: 100%; height: 100%; object-fit: cover; display: block;
}
.dog-card-initial {
    width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    font-size: 36px; font-weight: 700;
    color: var(--primary-ink);
    background: var(--primary);
}
.dog-card-initial-lg { font-size: 64px; }

.dog-card-body { padding: 10px 12px; flex: 1; min-width: 0; }
.dog-card-name { font-weight: 700; font-size: 17px; }
.dog-card-weight { font-size: 15px; margin-top: 2px; }

.delta { font-size: 13px; font-weight: 600; margin-left: 4px; }
.delta-up { color: var(--warn); }
.delta-down { color: var(--good); }
.delta-good { color: var(--good); }

.pill {
    display: inline-block;
    margin-top: 4px;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 999px;
}
.pill-in { background: #d8eed9; color: var(--good); }
.pill-above { background: #fdecd6; color: var(--warn); }
.pill-below { background: #fde0de; color: var(--bad); }

/* Empty state */
.empty-state {
    text-align: center;
    padding: 40px 16px;
}
.empty-state h2 { margin: 0 0 8px; }
.empty-state p { color: var(--muted); margin: 0 0 16px; }
.empty-state-sm { color: var(--muted); padding: 16px 0; text-align: center; }

/* Dog detail */
.dog-header {
    display: flex;
    gap: 16px;
    align-items: center;
    margin: 4px 0 16px;
}
.dog-header-photo {
    width: 88px; height: 88px; flex: 0 0 88px;
    border-radius: 50%; overflow: hidden; background: #f1ece0;
}
.dog-header-photo img {
    width: 100%; height: 100%; object-fit: cover; display: block;
}
.dog-header-photo .dog-card-initial {
    border-radius: 50%;
}
.dog-header-meta h1 { margin: 0 0 4px; font-size: 24px; }
.dog-header-meta p { margin: 2px 0; font-size: 14px; }

/* Chart */
.chart-section { margin: 16px 0; }
.range-tabs {
    display: flex;
    gap: 4px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 4px;
    margin-bottom: 8px;
}
.range-tab {
    flex: 1;
    background: transparent;
    border: none;
    border-radius: 8px;
    padding: 8px 4px;
    font-size: 14px;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
    min-height: 36px;
}
.range-tab.is-active {
    background: var(--primary);
    color: var(--primary-ink);
}
.chart-wrap {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 12px;
    box-shadow: var(--shadow);
    height: 280px;
    position: relative;
}
.chart-wrap canvas { width: 100% !important; height: 100% !important; }

/* Entry add */
.entry-add { margin: 16px 0; }
.entry-add details > summary {
    list-style: none;
    cursor: pointer;
}
.entry-add details > summary::-webkit-details-marker { display: none; }
.entry-add details[open] > summary { display: none; }
.entry-add .form { margin-top: 0; }

/* Forms */
.form {
    display: flex; flex-direction: column;
    gap: 14px;
    margin-top: 8px;
}
.form label {
    display: flex; flex-direction: column;
    gap: 6px;
    font-size: 14px;
    font-weight: 600;
    color: var(--ink);
}
.form input[type="text"],
.form input[type="date"],
.form input[type="number"],
.form input[type="file"],
.form textarea {
    width: 100%;
    min-height: var(--tap);
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    font: inherit;
    background: var(--surface);
    color: var(--ink);
}
.form input:focus, .form textarea:focus {
    outline: 2px solid var(--primary);
    outline-offset: 1px;
}
.form textarea { resize: vertical; min-height: 60px; }
.form fieldset {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 10px 12px 12px;
    margin: 0;
}
.form legend { font-size: 13px; font-weight: 600; padding: 0 6px; }
.row-2 { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
.photo-preview {
    margin: 4px 0 8px;
}
.photo-preview img {
    max-width: 120px; max-height: 120px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
}

/* Forms — sticky save on mobile */
.form-actions {
    display: flex; gap: 10px; justify-content: flex-end;
    position: sticky;
    bottom: 0;
    padding: 12px 0;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    background: linear-gradient(to top, var(--bg) 70%, transparent);
}
.form-actions .btn { flex: 1; }
@media (min-width: 540px) { .form-actions .btn { flex: 0 0 auto; } }

/* Section heading */
.section-head {
    display: flex; align-items: center; justify-content: space-between;
    margin: 24px 0 8px;
}
.section-head h2 { margin: 0; font-size: 18px; }

/* Entry list */
.entries {
    list-style: none;
    margin: 0;
    padding: 0;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
}
.entry + .entry { border-top: 1px solid var(--line); }
.entry > details > summary {
    list-style: none;
    cursor: pointer;
    padding: 10px 12px;
}
.entry > details > summary::-webkit-details-marker { display: none; }
.entry-summary {
    display: flex; align-items: center; gap: 12px;
}
.entry-thumb {
    width: 44px; height: 44px; flex: 0 0 44px;
    border-radius: 8px;
    background: #f1ece0;
    object-fit: cover;
    display: block;
}
.entry-thumb-empty { background: #f1ece0; }
.entry-main {
    flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0;
}
.entry-date { font-size: 13px; color: var(--muted); }
.entry-weight { font-size: 16px; font-weight: 700; }
.entry-chev { color: var(--muted); }
.entry > details[open] .entry-chev { transform: rotate(180deg); }
.entry-body {
    padding: 0 12px 12px 68px;
}
.entry-notes {
    margin: 0 0 8px;
    font-size: 14px;
    color: var(--ink);
    white-space: pre-wrap;
}
.entry-actions {
    display: flex; gap: 8px;
}

/* Danger zone */
.danger-zone { margin-top: 32px; }

/* Misc */
h1 { font-size: 22px; margin: 8px 0 12px; }
h2 { font-size: 18px; }
