:root {
    --color-primary: #d4896c;
    --color-secondary: #9faf8e;
    --color-bg: #f7f5f1;
    --color-text: #2c2c2c;
    --color-muted: #666;
    --color-white: #fff;
    --color-border: rgba(212, 137, 108, 0.25);
    --font-display: 'Fraunces', serif;
    --font-body: 'Work Sans', sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font-body);
    background: radial-gradient(circle at 0% 0%, #fff7f2 0%, transparent 35%), var(--color-bg);
    color: var(--color-text);
}

.container {
    max-width: 860px;
    margin: 0 auto;
    padding: 0 1rem;
}

.tracker-hero {
    background: linear-gradient(135deg, var(--color-primary), #bf7a61);
    color: var(--color-white);
    padding: 1.2rem 0 1.6rem;
}

.back-link {
    color: rgba(255, 255, 255, 0.95);
    text-decoration: none;
    font-weight: 600;
    display: inline-block;
    margin-bottom: 0.8rem;
}

.tracker-hero h1 {
    margin: 0;
    font-family: var(--font-display);
    font-size: clamp(1.7rem, 5vw, 2.3rem);
}

.tracker-hero p {
    margin: 0.6rem 0 0;
    opacity: 0.95;
}

.tracker-main {
    padding: 1rem 0 1.6rem;
    display: grid;
    gap: 1rem;
}

.quick-panel,
.summary-panel,
.timeline-panel {
    background: var(--color-white);
    border-radius: 16px;
    border: 1px solid rgba(0, 0, 0, 0.04);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.05);
    padding: 1rem;
}

h2 {
    margin: 0 0 0.8rem;
    font-family: var(--font-display);
    font-size: 1.35rem;
}

h3 {
    margin: 0;
    font-size: 1rem;
}

.log-form {
    display: grid;
    gap: 0.7rem;
}

.type-segment {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.5rem;
}

.type-btn {
    border: 1px solid var(--color-border);
    border-radius: 12px;
    min-height: 48px;
    background: #fff;
    font-size: 0.95rem;
    font-weight: 600;
}

.type-btn.active {
    background: rgba(212, 137, 108, 0.14);
    border-color: var(--color-primary);
    color: #8e543f;
}

label {
    font-weight: 600;
}

input {
    width: 100%;
    min-height: 48px;
    border-radius: 12px;
    border: 1px solid var(--color-border);
    padding: 0.7rem 0.8rem;
    font-size: 1rem;
}

.datetime-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.5rem;
}

.preset-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.preset-btn,
.ghost-btn {
    border: 1px solid var(--color-border);
    border-radius: 999px;
    background: #fff;
    color: var(--color-text);
    min-height: 38px;
    padding: 0 0.85rem;
    font-weight: 600;
}

.cancel-edit-btn {
    justify-content: center;
}

.submit-btn {
    margin-top: 0.3rem;
    border: none;
    border-radius: 12px;
    min-height: 52px;
    background: var(--color-primary);
    color: #fff;
    font-size: 1rem;
    font-weight: 700;
}

.submit-btn:disabled {
    opacity: 0.72;
}

.tip {
    margin: 0;
    color: var(--color-muted);
    font-size: 0.9rem;
}

.status-message {
    min-height: 22px;
    margin-top: 0.6rem;
    font-size: 0.92rem;
    font-weight: 600;
}

.status-message.error {
    color: #b61f1f;
}

.status-message.success {
    color: #1e7d39;
}

.status-message.info {
    color: #7f5a12;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.6rem;
}

.summary-card {
    border-radius: 12px;
    padding: 0.8rem 0.7rem;
    background: #fffaf7;
    border: 1px solid var(--color-border);
    text-align: center;
}

.summary-jump {
    cursor: pointer;
}

button.summary-card {
    width: 100%;
    appearance: none;
    -webkit-appearance: none;
    font: inherit;
    color: inherit;
}

.summary-jump:hover {
    border-color: #d8c9bb;
    background: #fff5ed;
}

.summary-card span {
    font-size: 0.9rem;
    color: var(--color-muted);
    display: block;
}

.summary-card strong {
    font-size: 1.4rem;
}

.today-insight {
    margin-top: 0.8rem;
    border-radius: 12px;
    border: 1px solid var(--color-border);
    background: #ffffff;
    padding: 0.8rem;
}

.today-insight h3 {
    margin: 0 0 0.5rem;
    font-size: 1rem;
}

.today-summary-text {
    margin: 0 0 0.7rem;
    color: var(--color-muted);
    font-size: 0.9rem;
}

.today-bars {
    display: grid;
    gap: 0.5rem;
}

.bar-row {
    display: grid;
    grid-template-columns: 76px 1fr 34px;
    align-items: center;
    gap: 0.45rem;
}

.bar-label,
.bar-value {
    font-size: 0.82rem;
    color: #4b5563;
}

.bar-track {
    background: #eef2f7;
    border-radius: 999px;
    height: 10px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    width: 0%;
    border-radius: 999px;
    transition: width 0.35s ease;
}

.bar-fill.feeding { background: #f59e0b; }
.bar-fill.poop { background: #8b5cf6; }
.bar-fill.sleep { background: #0ea5e9; }
.bar-fill.exercise { background: #10b981; }
.bar-fill.study { background: #ef4444; }

.today-extra {
    margin: 0.7rem 0 0;
    font-size: 0.82rem;
    color: var(--color-muted);
}

.daily-timeline {
    margin-top: 0.8rem;
    border-radius: 12px;
    border: 1px solid var(--color-border);
    background: #fff;
    padding: 0.8rem;
}

.daily-timeline h3 {
    margin: 0 0 0.5rem;
    font-size: 1rem;
}

.timeline-axis {
    position: relative;
    height: 18px;
    margin: 0.2rem 0 0.5rem 76px;
    border-top: 1px dashed #d1d5db;
}

.timeline-axis span {
    position: absolute;
    top: -0.55rem;
    transform: translateX(-50%);
    font-size: 0.68rem;
    color: #6b7280;
}

.timeline-lane {
    display: grid;
    grid-template-columns: 76px 1fr;
    align-items: center;
    gap: 0.45rem;
    margin-bottom: 0.45rem;
}

.lane-label {
    font-size: 0.82rem;
    color: #4b5563;
}

.lane-track {
    position: relative;
    height: 24px;
    border-radius: 999px;
    background: #f3f4f6;
    overflow: hidden;
}

.event-dot {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 16px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    line-height: 1;
    color: #fff;
    box-shadow: 0 0 0 2px #fff;
}

.event-dot.feeding { background: #f59e0b; }
.event-dot.poop { background: #8b5cf6; }
.event-dot.sleep { background: #0ea5e9; }
.event-dot.exercise { background: #10b981; }
.event-dot.study { background: #ef4444; }

.timeline-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    margin-bottom: 0.7rem;
}

.list-filter-panel,
.export-panel {
    border: 1px dashed var(--color-border);
    border-radius: 12px;
    padding: 0.75rem;
    margin-bottom: 0.75rem;
}

.export-range {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.55rem;
    margin-top: 0.55rem;
}

.range-field label {
    display: block;
    margin-bottom: 0.3rem;
    font-size: 0.88rem;
    color: var(--color-muted);
}

.range-field input {
    min-height: 42px;
}

.export-actions {
    margin-top: 0.65rem;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.records-list {
    display: grid;
    gap: 0.6rem;
}

.record-item {
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 12px;
    padding: 0.75rem;
    background: #fff;
}

.record-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
}

.record-type {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    border-radius: 999px;
    padding: 0.2rem 0.65rem;
    background: rgba(212, 137, 108, 0.14);
    font-weight: 700;
    font-size: 0.86rem;
}

.record-time {
    color: var(--color-muted);
    font-size: 0.85rem;
}

.record-meta {
    display: flex;
    gap: 0.6rem;
    font-size: 0.92rem;
    color: var(--color-text);
    flex-wrap: wrap;
}

.record-note {
    margin-top: 0.45rem;
    font-size: 0.9rem;
    color: var(--color-muted);
}

.record-actions {
    margin-top: 0.6rem;
    display: flex;
    gap: 0.5rem;
}

.row-btn {
    border: 1px solid var(--color-border);
    background: #fff;
    color: var(--color-text);
    border-radius: 10px;
    min-height: 36px;
    padding: 0 0.8rem;
    font-weight: 600;
}

.row-btn.delete {
    border-color: rgba(182, 31, 31, 0.25);
    color: #b61f1f;
}

.empty-text {
    color: var(--color-muted);
    margin: 0;
}

@media (max-width: 520px) {
    .tracker-main {
        padding-bottom: 1rem;
    }

    .quick-panel,
    .summary-panel,
    .timeline-panel {
        border-radius: 14px;
        padding: 0.9rem;
    }

    .submit-btn {
        position: sticky;
        bottom: 0.55rem;
        box-shadow: 0 8px 18px rgba(212, 137, 108, 0.3);
    }

    .export-range {
        grid-template-columns: 1fr;
    }

    .export-actions {
        flex-direction: column;
    }

    .export-actions .ghost-btn {
        width: 100%;
    }
}
