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

      body {
        min-height: 100vh;
        background: #f5f0ea;
        font-family: "Georgia", "Times New Roman", serif;
        overflow-x: hidden;
        color: #3d3530;
      }

      @keyframes fadeIn {
        from {
          opacity: 0;
          transform: translateY(8px);
        }
        to {
          opacity: 1;
          transform: translateY(0);
        }
      }
      @keyframes slideDown {
        from {
          opacity: 0;
          transform: translateY(-6px);
        }
        to {
          opacity: 1;
          transform: translateY(0);
        }
      }
      @keyframes bounce {
        0%,
        100% {
          transform: translate(-50%, -50%) scale(1);
        }
        50% {
          transform: translate(-50%, -52%) scale(1.05);
        }
      }

      .fade-in {
        animation: fadeIn 0.4s ease forwards;
      }
      .slide-down {
        animation: slideDown 0.3s ease forwards;
      }

      /* ── Layout ── */
      #app {
        max-width: 800px;
        margin: 0 auto;
        padding: 36px 24px 60px;
      }

      /* ── Header ── */
      #header {
        background: white;
        padding: 18px 32px;
        border-bottom: 1px solid #ede8e0;
        display: flex;
        align-items: center;
        justify-content: space-between;
        box-shadow: 0 1px 8px rgba(0, 0, 0, 0.04);
        position: sticky;
        top: 0;
        z-index: 100;
      }
      .header-logo {
        display: flex;
        align-items: center;
        gap: 10px;
      }
      .header-icon {
        width: 32px;
        height: 32px;
        border-radius: 50%;
        background: linear-gradient(135deg, #7bbfb5, #a8d4a0);
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 15px;
      }
      .header-name {
        font-family: "Playfair Display", serif;
        font-size: 18px;
        color: #3d3530;
        letter-spacing: 0.01em;
      }
      .header-date {
        font-family: "Lato", sans-serif;
        font-size: 13px;
        color: #aaa;
        font-weight: 300;
      }
      .header-avatar {
        width: 34px;
        height: 34px;
        border-radius: 50%;
        background: #e8c87a;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 15px;
        font-family: "Lato", sans-serif;
      }

      /* ── Cards ── */
      .card {
        background: white;
        border-radius: 24px;
        padding: 32px 36px;
        margin-bottom: 24px;
        box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
        position: relative;
        overflow: hidden;
      }

      /* ── Section labels ── */
      .section-label {
        font-family: "Lato", sans-serif;
        font-size: 12px;
        letter-spacing: 0.12em;
        text-transform: uppercase;
        color: #5a9e94;
        margin-bottom: 4px;
        font-weight: 400;
      }
      .section-title {
        font-family: "Playfair Display", serif;
        font-size: 22px;
        color: #3d3530;
        font-weight: 400;
      }

      /* ── Buttons ── */
      .btn-primary {
        background: #5a9e94;
        color: white;
        border: none;
        padding: 12px 36px;
        border-radius: 50px;
        font-size: 15px;
        font-family: "Lato", sans-serif;
        font-weight: 400;
        letter-spacing: 0.05em;
        cursor: pointer;
        transition: all 0.25s ease;
        box-shadow: 0 4px 16px rgba(90, 158, 148, 0.3);
      }
      .btn-primary:hover {
        background: #4a8e84;
        transform: translateY(-1px);
        box-shadow: 0 6px 20px rgba(90, 158, 148, 0.4);
      }
      .btn-primary:disabled {
        opacity: 0.4;
        cursor: default;
        transform: none;
        box-shadow: none;
      }

      .btn-outline {
        background: #5a9e94;
        color: white;
        border: none;
        padding: 9px 20px;
        border-radius: 50px;
        font-family: "Lato", sans-serif;
        font-size: 13px;
        cursor: pointer;
        transition: all 0.2s;
        letter-spacing: 0.03em;
      }
      .btn-outline.open {
        background: #eef7f6;
        color: #5a9e94;
        border: 1.5px solid #5a9e94;
      }

      /* ── Slider ── */
      #slider-track {
        position: relative;
        height: 10px;
        border-radius: 10px;
        background: #ede8e0;
        cursor: pointer;
        margin: 32px 0 16px;
        box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.08);
      }
      #slider-fill {
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        border-radius: 10px;
        background: linear-gradient(to right, #e8a598 0%, #e8a598 20%, #e8c87a 40%, #a8d4a0 65%, #7bbfb5 100%);
        pointer-events: none;
        transition: width 0.04s;
      }
      #slider-bg-hint {
        position: absolute;
        inset: 0;
        border-radius: 10px;
        background: linear-gradient(to right, #e8a598 0%, #e8a598 20%, #e8c87a 40%, #a8d4a0 65%, #7bbfb5 100%);
        opacity: 0.2;
        pointer-events: none;
      }
      #emoji-handle {
        position: absolute;
        top: 50%;
        transform: translate(-50%, -50%);
        width: 58px;
        height: 58px;
        border-radius: 50%;
        background: white;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 30px;
        cursor: grab;
        user-select: none;
        z-index: 3;
        border: 3px solid white;
        transition: box-shadow 0.15s;
      }
      #emoji-handle.dragging {
        cursor: grabbing;
        transform: translate(-50%, -50%) scale(1.14);
      }
      #emoji-ghost {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 50px;
        height: 50px;
        border-radius: 50%;
        background: white;
        border: 2px dashed #ccc;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 24px;
        cursor: grab;
        animation: bounce 2s ease-in-out infinite;
        opacity: 0.6;
      }
      .tick-row {
        display: flex;
        justify-content: space-between;
      }
      .tick {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 3px;
        width: 20px;
      }
      .tick-line {
        width: 1.5px;
        height: 5px;
        border-radius: 2px;
        background: #ddd;
        transition: background 0.15s;
      }
      .tick-num {
        font-family: "Lato", sans-serif;
        font-size: 11px;
        font-weight: 300;
        color: #ccc;
        transition: color 0.15s;
      }

      /* ── Mood label ── */
      #mood-label-wrap {
        min-height: 38px;
        display: flex;
        align-items: center;
        margin-bottom: 4px;
      }
      #mood-label {
        display: flex;
        align-items: center;
        gap: 10px;
      }
      #mood-dot {
        width: 8px;
        height: 8px;
        border-radius: 50%;
      }
      #mood-text {
        font-family: "Playfair Display", serif;
        font-size: 20px;
      }
      #mood-score {
        font-family: "Lato", sans-serif;
        font-size: 13px;
        color: #bbb;
        font-weight: 300;
      }
      #mood-placeholder {
        font-family: "Lato", sans-serif;
        font-size: 14px;
        color: #ccc;
        font-style: italic;
        font-weight: 300;
      }

      /* ── Submitted state ── */
      #submitted-view {
        text-align: center;
        padding: 16px 0;
      }
      #submitted-emoji {
        font-size: 52px;
        margin-bottom: 12px;
      }
      #submitted-title {
        font-family: "Playfair Display", serif;
        font-size: 26px;
        color: #3d3530;
        margin-bottom: 6px;
        font-weight: 400;
      }
      #submitted-sub {
        font-family: "Lato", sans-serif;
        font-size: 14px;
        color: #aaa;
        font-weight: 300;
      }
      #btn-update {
        margin-top: 18px;
        background: none;
        border: 1.5px solid #ddd;
        border-radius: 30px;
        padding: 8px 24px;
        font-family: "Lato", sans-serif;
        font-size: 13px;
        color: #999;
        cursor: pointer;
      }
      #btn-update:hover {
        border-color: #5a9e94;
      }

      /* ── Weekly chart ── */
      #chart-header {
        display: flex;
        justify-content: space-between;
        align-items: flex-end;
        margin-bottom: 28px;
      }
      #avg-score-wrap {
        font-family: "Lato", sans-serif;
        font-size: 12px;
        color: #bbb;
        font-weight: 300;
        text-align: right;
      }
      #avg-score-num {
        font-size: 22px;
        color: #5a9e94;
        font-family: "Playfair Display", serif;
      }
      #bar-chart {
        display: flex;
        align-items: flex-end;
        justify-content: space-between;
        gap: 8px;
        height: 120px;
        padding: 0 4px;
      }
      .bar-wrap {
        flex: 1;
        height: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: flex-end;
        gap: 6px;
        position: relative;
        cursor: default;
      }
      .bar {
        width: 28px;
        border-radius: 6px 6px 2px 2px;
        transition: filter 0.2s;
      }
      .bar-wrap:hover .bar {
        filter: brightness(1.08);
      }
      .bar-day {
        font-family: "Lato", sans-serif;
        font-size: 12px;
        font-weight: 300;
      }
      .bar-dot {
        width: 6px;
        height: 6px;
        border-radius: 50%;
        margin-top: -2px;
      }
      .bar-tooltip {
        display: none;
        position: absolute;
        bottom: calc(100% + 10px);
        left: 50%;
        transform: translateX(-50%);
        background: #333;
        color: white;
        padding: 5px 10px;
        border-radius: 8px;
        font-size: 11px;
        font-family: "Lato", sans-serif;
        white-space: nowrap;
        z-index: 10;
      }
      .bar-tooltip::after {
        content: "";
        position: absolute;
        top: 100%;
        left: 50%;
        transform: translateX(-50%);
        border: 5px solid transparent;
        border-top-color: #333;
      }
      .bar-wrap:hover .bar-tooltip {
        display: block;
      }

      #chart-legend {
        display: flex;
        gap: 20px;
        margin-top: 20px;
        flex-wrap: wrap;
        padding-top: 16px;
        border-top: 1px solid #f0ece6;
      }
      .legend-item {
        display: flex;
        align-items: center;
        gap: 6px;
      }
      .legend-dot {
        width: 10px;
        height: 10px;
        border-radius: 2px;
      }
      .legend-lbl {
        font-family: "Lato", sans-serif;
        font-size: 11px;
        color: #aaa;
        font-weight: 300;
      }

      /* ── Medications ── */
      #med-header-row {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        margin-bottom: 24px;
      }
      #med-form {
        background: #fdfcfb;
        border: 1.5px solid #e8e0d8;
        border-radius: 16px;
        padding: 24px;
        margin-bottom: 24px;
        display: none;
      }
      #med-form.open {
        display: block;
      }
      #med-form p.italic {
        font-family: "Playfair Display", serif;
        font-size: 16px;
        color: #3d3530;
        margin-bottom: 18px;
        font-style: italic;
      }
      .form-label {
        font-family: "Lato", sans-serif;
        font-size: 11px;
        color: #bbb;
        letter-spacing: 0.08em;
        text-transform: uppercase;
        margin-bottom: 6px;
        display: block;
      }
      .form-grid-2 {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 12px;
        margin-bottom: 12px;
      }
      .form-grid-4 {
        display: grid;
        grid-template-columns: 1fr 80px 1fr 1fr;
        gap: 12px;
        margin-bottom: 16px;
      }
      .med-input,
      .med-select {
        width: 100%;
        border: 1.5px solid #e0dbd3;
        border-radius: 12px;
        padding: 10px 14px;
        font-family: "Lato", sans-serif;
        font-size: 14px;
        color: #444;
        outline: none;
        background: #fdfcfb;
        transition: border-color 0.2s;
      }
      .med-input::placeholder {
        color: #bbb;
        font-style: italic;
      }
      .med-input:focus,
      .med-select:focus {
        border-color: #5a9e94;
      }
      .med-select {
        cursor: pointer;
        appearance: none;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23bbb' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: right 12px center;
        padding-right: 30px;
      }
      .color-swatches {
        display: flex;
        gap: 10px;
      }
      .color-swatch {
        width: 24px;
        height: 24px;
        border-radius: 50%;
        cursor: pointer;
        border: 2.5px solid transparent;
        transition:
          transform 0.15s,
          border-color 0.15s;
        flex-shrink: 0;
      }
      .color-swatch:hover {
        transform: scale(1.15);
      }
      .color-swatch.selected {
        border-color: #444;
      }
      .form-footer {
        display: flex;
        justify-content: flex-end;
        margin-top: 16px;
      }

      #ghost-add {
        border: 2px dashed #ddd;
        border-radius: 16px;
        padding: 20px;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        cursor: pointer;
        transition: all 0.2s;
        color: #ccc;
        font-family: "Lato", sans-serif;
        font-size: 13px;
        margin-bottom: 12px;
      }
      #ghost-add:hover {
        border-color: #5a9e94;
        color: #5a9e94;
        background: #f7fdfc;
      }

      #active-meds,
      #inactive-meds {
        display: flex;
        flex-direction: column;
        gap: 10px;
      }
      .inactive-title {
        font-family: "Lato", sans-serif;
        font-size: 11px;
        letter-spacing: 0.1em;
        text-transform: uppercase;
        color: #bbb;
        margin: 18px 0 10px;
        font-weight: 400;
      }

      .med-card {
        border-radius: 16px;
        overflow: hidden;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
        background: white;
        transition: box-shadow 0.2s;
      }
      .med-card:hover {
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
      }
      .med-card.inactive {
        opacity: 0.55;
      }
      .med-card-header {
        display: flex;
        align-items: center;
        gap: 14px;
        padding: 18px 20px;
        cursor: pointer;
      }
      .med-dot {
        width: 14px;
        height: 14px;
        border-radius: 50%;
        flex-shrink: 0;
      }
      .med-meta {
        flex: 1;
      }
      .med-name-row {
        display: flex;
        align-items: center;
        gap: 8px;
        flex-wrap: wrap;
      }
      .med-name {
        font-family: "Playfair Display", serif;
        font-size: 16px;
        color: #3d3530;
      }
      .med-name.dim {
        font-size: 15px;
        color: #888;
      }
      .med-pill {
        display: inline-flex;
        align-items: center;
        gap: 4px;
        padding: 2px 10px;
        border-radius: 20px;
        font-size: 11px;
        font-family: "Lato", sans-serif;
        letter-spacing: 0.06em;
        text-transform: uppercase;
        font-weight: 400;
      }
      .med-sub {
        font-family: "Lato", sans-serif;
        font-size: 12px;
        color: #bbb;
        margin-top: 3px;
        font-weight: 300;
      }
      .med-chevron {
        font-size: 13px;
        color: #ccc;
        margin-left: 4px;
        user-select: none;
      }

      .med-detail {
        padding: 0 20px 18px;
        border-top: 1px solid #f5f0ea;
      }
      .med-detail-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
        margin-top: 14px;
      }
      .med-detail-item {
        display: flex;
        flex-direction: column;
        gap: 2px;
      }
      .det-label {
        font-family: "Lato", sans-serif;
        font-size: 11px;
        color: #bbb;
        letter-spacing: 0.08em;
        text-transform: uppercase;
      }
      .det-val {
        font-family: "Lato", sans-serif;
        font-size: 14px;
        color: #555;
      }
      .med-detail-footer {
        display: flex;
        justify-content: flex-end;
        margin-top: 16px;
      }
      .btn-remove {
        background: none;
        border: 1.5px solid #f0dbd8;
        border-radius: 30px;
        padding: 6px 18px;
        font-family: "Lato", sans-serif;
        font-size: 12px;
        color: #e8a598;
        cursor: pointer;
        transition: all 0.2s;
      }
      .btn-remove:hover {
        background: #fff5f4;
      }

      /* Toggle switch */
      .toggle-switch {
        position: relative;
        width: 36px;
        height: 20px;
        flex-shrink: 0;
        display: inline-block;
      }
      .toggle-switch input {
        opacity: 0;
        width: 0;
        height: 0;
      }
      .toggle-slider {
        position: absolute;
        cursor: pointer;
        inset: 0;
        border-radius: 20px;
        background: #ddd;
        transition: 0.25s;
      }
      .toggle-slider::before {
        content: "";
        position: absolute;
        height: 14px;
        width: 14px;
        left: 3px;
        bottom: 3px;
        border-radius: 50%;
        background: white;
        transition: 0.25s;
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
      }
      .toggle-switch input:checked + .toggle-slider {
        background: #5a9e94;
      }
      .toggle-switch input:checked + .toggle-slider::before {
        transform: translateX(16px);
      }

      /* ── Diary ── */
      #diary-header-row {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        margin-bottom: 24px;
      }
      #diary-form {
        background: #fdfcfb;
        border: 1.5px solid #e8e0d8;
        border-radius: 16px;
        padding: 24px;
        margin-bottom: 24px;
        display: none;
      }
      #diary-form.open {
        display: block;
      }
      #diary-form p.italic {
        font-family: "Playfair Display", serif;
        font-size: 16px;
        color: #3d3530;
        margin-bottom: 14px;
        font-style: italic;
      }
      .tag-select {
        display: flex;
        gap: 8px;
        flex-wrap: wrap;
        margin: 10px 0 16px;
      }
      .tag-btn {
        padding: 5px 14px;
        border-radius: 20px;
        border: 1.5px solid #ddd;
        background: white;
        font-size: 12px;
        font-family: "Lato", sans-serif;
        cursor: pointer;
        transition: all 0.15s;
        color: #777;
      }
      .tag-btn.active {
        border-color: #5a9e94;
        background: #eef7f6;
        color: #5a9e94;
      }
      #diary-textarea {
        width: 100%;
        border: 1.5px solid #e0dbd3;
        border-radius: 12px;
        padding: 14px 16px;
        font-family: "Georgia", serif;
        font-size: 14px;
        color: #444;
        resize: none;
        outline: none;
        background: #fdfcfb;
        line-height: 1.7;
        transition: border-color 0.2s;
      }
      #diary-textarea:focus {
        border-color: #5a9e94;
      }
      #diary-textarea::placeholder {
        color: #bbb;
        font-style: italic;
      }
      #diary-form-footer {
        display: flex;
        justify-content: flex-end;
        margin-top: 14px;
      }

      #diary-entries {
        display: flex;
        flex-direction: column;
        gap: 14px;
      }
      .diary-card {
        background: white;
        border-radius: 16px;
        padding: 20px 24px;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
        border-left: 4px solid #e8c87a;
      }
      .diary-card-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 8px;
      }
      .diary-card-left {
        display: flex;
        align-items: center;
        gap: 10px;
      }
      .diary-date {
        font-family: "Lato", sans-serif;
        font-size: 13px;
        color: #888;
        font-weight: 300;
      }
      .tag-chip {
        display: inline-block;
        padding: 3px 12px;
        border-radius: 20px;
        font-size: 11px;
        font-family: "Lato", sans-serif;
        letter-spacing: 0.08em;
        text-transform: uppercase;
        background: #f0ede8;
        color: #888;
        font-weight: 400;
      }
      .diary-emoji {
        font-size: 18px;
      }
      .diary-content {
        font-family: "Georgia", serif;
        font-size: 14px;
        color: #555;
        line-height: 1.7;
      }

      #diary-empty {
        text-align: center;
        padding: 40px 0;
        font-family: "Playfair Display", serif;
        font-size: 16px;
        color: #ccc;
        font-style: italic;
      }

      /* hero deco */
      .hero-deco {
        position: absolute;
        top: -40px;
        right: -40px;
        width: 200px;
        height: 200px;
        border-radius: 50%;
        background: radial-gradient(circle, #e8f4f2 0%, transparent 70%);
        pointer-events: none;
      }