@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --font-primary: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --gradient-sky: linear-gradient(180deg, #fdfbf6 0%, #eef6ea 40%, #f7efe0 100%);
    --background: #f6faf4;
    --surface: rgba(255, 255, 255, 0.85);
    --surface-strong: rgba(255, 255, 255, 0.95);
    --border: rgba(55, 92, 70, 0.18);
    --text-primary: #263323;
    --text-secondary: #5b6d57;
    --primary-color: #67b457;
    --primary-dark: #4a8c3f;
    --accent-sun: #f2c14e;
    --accent-mist: #90c4b8;
    --accent-leaf: #67b457;
    --accent-grove: #3f9e6b;
    --danger: #ff6b6b;
    --warning: #f7a917;
    --success: #63c178;
    --shadow: 0 25px 60px rgba(53, 87, 77, 0.18);
    --shadow-soft: 0 12px 35px rgba(70, 96, 79, 0.18);
}

body.theme-dark {
    --gradient-sky: linear-gradient(180deg, #0f1b2b 0%, #1c2a2f 45%, #11151d 100%);
    --background: #0d1621;
    --surface: rgba(19, 28, 34, 0.9);
    --surface-strong: rgba(28, 40, 48, 0.95);
    --border: rgba(255, 255, 255, 0.08);
    --text-primary: #f4f7fb;
    --text-secondary: #c5d0d5;
    --primary-color: #50d092;
    --primary-dark: #31a46a;
    --accent-sun: #f4ce73;
    --accent-mist: #7dd4c4;
    --accent-leaf: #50d092;
    --accent-grove: #3fbf9f;
    --danger: #ff8d8d;
    --warning: #f7b267;
    --success: #5ee4ad;
    --shadow: 0 25px 50px rgba(0, 0, 0, 0.6);
    --shadow-soft: 0 15px 35px rgba(0, 0, 0, 0.45);
}

body {
    font-family: var(--font-primary);
    background: var(--gradient-sky);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    transition: background 0.4s ease, color 0.3s ease;
    padding-bottom: env(safe-area-inset-bottom);
}

a {
    color: inherit;
}

.screen {
    min-height: 100vh;
    padding: 1.5rem 1rem 3rem;
}

.screen.hidden {
    display: none;
}

.floating-theme-toggle {
    position: fixed;
    top: 1rem;
    right: 1rem;
    background: var(--surface-strong);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 46px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-soft);
    cursor: pointer;
    z-index: 200;
    transition: transform 0.2s ease, background 0.2s ease;
}

.floating-theme-toggle:hover {
    transform: translateY(-2px);
}

header {
    max-width: 960px;
    margin: 0 auto;
}

.header-card {
    background: var(--surface-strong);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-soft);
}

.header-card h1 {
    font-size: 1.35rem;
    margin: 0;
}

.hero-header {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.8), rgba(244, 250, 244, 0.65));
    border: 1px solid var(--border);
    border-radius: 36px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    position: relative;
    overflow: hidden;
}

.hero-header::after {
    content: '';
    position: absolute;
    inset: 15% auto auto 60%;
    width: 280px;
    height: 280px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.45), transparent 70%);
    filter: blur(15px);
    pointer-events: none;
}

.hero-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    position: relative;
    z-index: 2;
}

.hero-profile {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.avatar-pill {
    width: 64px;
    height: 64px;
    border-radius: 22px;
    background: linear-gradient(145deg, #f7c768, #f2a65a);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #4a3812;
    font-size: 1rem;
}

.eyebrow {
    font-size: 0.85rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.hero-subtitle {
    margin: 0;
    color: var(--text-secondary);
}

h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
}

.icon-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.65rem 1rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.4);
    color: var(--text-primary);
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.icon-chip:hover {
    transform: translateY(-2px);
}

.hero-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    position: relative;
    z-index: 2;
}

.stat-card {
    background: rgba(255, 255, 255, 0.65);
    border-radius: 28px;
    padding: 1.25rem;
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.stat-value {
    font-size: 2.2rem;
    font-weight: 700;
    line-height: 1.2;
}

.hero-action-row {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    position: relative;
    z-index: 2;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.6);
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.9rem;
}

.pill.success {
    background: rgba(99, 193, 120, 0.18);
    color: var(--primary-dark);
}

.btn-primary,
.btn-secondary,
.btn-danger {
    cursor: pointer;
    border-radius: 18px;
    font-size: 1rem;
    font-weight: 600;
    padding: 0.9rem 1.25rem;
    border: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    width: 100%;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--accent-grove));
    color: #fff;
    box-shadow: var(--shadow-soft);
}

.btn-primary:hover {
    transform: translateY(-2px);
}

.btn-secondary {
    background: transparent;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-link {
    background: none;
    border: none;
    color: var(--primary-color);
    font-weight: 600;
    text-decoration: underline;
    cursor: pointer;
}

.btn-back {
    background: none;
    border: none;
    color: var(--primary-color);
    font-size: 1.35rem;
    cursor: pointer;
}

.hero-cta {
    width: auto;
    align-self: flex-start;
    padding: 0.95rem 1.75rem;
}

.home-section {
    max-width: 960px;
    margin: 2rem auto 0;
}

.section-header {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    margin-bottom: 1.5rem;
}

.segmented-control {
    display: inline-flex;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 999px;
    padding: 0.2rem;
    border: 1px solid var(--border);
    align-self: flex-start;
}

.segmented {
    border: none;
    background: transparent;
    padding: 0.4rem 1.1rem;
    border-radius: 999px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
}

.segmented.active {
    background: #fff;
    color: var(--text-primary);
    box-shadow: var(--shadow-soft);
}

.home-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.25rem;
}

.home-button {
    background: var(--surface-strong);
    border-radius: 32px;
    padding: 1.5rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-soft);
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    color: var(--text-primary);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.home-button:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow);
}

.home-button .subtitle {
    margin: 0;
}

.home-card-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.button-icon {
    font-size: 2.4rem;
}

.home-button[data-tone="leaf"] {
    background: linear-gradient(145deg, rgba(143, 214, 141, 0.6), rgba(255, 255, 255, 0.9));
}

.home-button[data-tone="sunrise"] {
    background: linear-gradient(145deg, rgba(255, 204, 128, 0.6), rgba(255, 255, 255, 0.9));
}

.home-button[data-tone="citrus"] {
    background: linear-gradient(145deg, rgba(255, 198, 142, 0.55), rgba(255, 255, 255, 0.9));
}

.home-button[data-tone="mist"] {
    background: linear-gradient(145deg, rgba(170, 216, 210, 0.6), rgba(255, 255, 255, 0.9));
}

.home-button[data-tone="grove"] {
    background: linear-gradient(145deg, rgba(136, 201, 155, 0.65), rgba(255, 255, 255, 0.9));
}

.home-button[data-tone="dusk"] {
    background: linear-gradient(145deg, rgba(206, 177, 255, 0.55), rgba(255, 255, 255, 0.9));
}

.subtitle {
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.home-footer {
    max-width: 960px;
    margin: 2rem auto 0;
    text-align: center;
    color: var(--text-secondary);
}

.form-container,
.history-container,
.settings-content {
    max-width: 760px;
    margin: 1.5rem auto;
    padding: 1.5rem;
    background: var(--surface);
    border-radius: 28px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-soft);
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 600;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.85rem 1rem;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: var(--surface-strong);
    color: var(--text-primary);
    font-size: 1rem;
}

.form-group textarea {
    min-height: 120px;
    resize: vertical;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: 2px solid var(--primary-color);
    border-color: transparent;
}

.slider-container {
    margin: 1rem 0;
}

.slider-label {
    display: flex;
    justify-content: space-between;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.slider {
    width: 100%;
    height: 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid var(--border);
    appearance: none;
}

.slider::-webkit-slider-thumb {
    appearance: none;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--primary-color);
    border: 3px solid #fff;
    box-shadow: var(--shadow-soft);
}

.slider::-moz-range-thumb {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--primary-color);
    border: 3px solid #fff;
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.4rem;
}

.tag-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tag-button {
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 0.4rem 1rem;
    background: rgba(255, 255, 255, 0.7);
    font-weight: 600;
    cursor: pointer;
}

.tag-button.selected {
    background: var(--primary-color);
    color: #fff;
    border-color: transparent;
}

.safety-content,
.pin-content {
    max-width: 720px;
    margin: 0 auto;
    padding: 2rem 1.25rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 1.5rem;
}

.safety-text {
    background: var(--surface);
    border-radius: 28px;
    padding: 1.5rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-soft);
}

.pin-input-container {
    margin: 1.5rem 0;
}

.pin-input {
    width: 100%;
    padding: 1rem;
    font-size: 1.5rem;
    text-align: center;
    letter-spacing: 0.6rem;
    border-radius: 18px;
    border: 1px solid var(--border);
    background: var(--surface-strong);
}

.pin-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.pin-buttons button {
    flex: 1;
}

.history-item,
.graph-container,
.settings-section {
    background: var(--surface-strong);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-soft);
}

.history-item {
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.history-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.history-item-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.35rem;
}

.history-item-preview {
    color: var(--text-secondary);
}

.graph {
    height: 200px;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    position: relative;
}

.graph-line {
    position: absolute;
    inset: auto 0 12px;
    height: 2px;
    background: var(--border);
}

.graph-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--primary-color);
    border: 3px solid #fff;
    position: relative;
}

.warning-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.error-message {
    color: var(--danger);
    font-size: 0.9rem;
    margin-top: 0.75rem;
}

.error-message.hidden {
    display: none;
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.nav-tabs {
    display: flex;
    position: sticky;
    top: 0;
    z-index: 10;
    background: rgba(246, 250, 244, 0.86);
    backdrop-filter: blur(10px);
    border-radius: 999px;
    padding: 0.25rem;
    margin: 1.5rem auto;
    max-width: 760px;
}

.nav-tab {
    flex: 1;
    border: none;
    background: transparent;
    padding: 0.75rem 1rem;
    border-radius: 999px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
}

.nav-tab.active {
    background: #fff;
    color: var(--text-primary);
    box-shadow: var(--shadow-soft);
}

@media (min-width: 720px) {
    .hero-action-row {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }

    .segmented-control {
        align-self: center;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
}

