:root {
      --bg: #f7f3eb;
      --panel: #fffaf2;
      --panel-2: #f0e9dd;
      --panel-3: #f4eee4;
      --text: #211f1a;
      --muted: #746f66;
      --line: #ded4c5;
      --line-2: #e7dccd;
      --accent: #c96442;
      --accent-dark: #9f452c;
      --danger: #b24035;
      --danger-soft: #f3d8d3;
      --shadow: 0 16px 40px rgba(42, 31, 17, 0.10);
      --shadow-soft: 0 10px 26px rgba(42, 31, 17, 0.075);
      --ring: rgba(201, 100, 66, 0.16);
    }

    * {
      box-sizing: border-box;
      -webkit-tap-highlight-color: transparent;
    }

    html {
      scroll-behavior: smooth;
    }

    body {
      margin: 0;
      background:
        radial-gradient(circle at top left, rgba(201, 100, 66, 0.12), transparent 34%),
        var(--bg);
      color: var(--text);
      font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Display",
        "Segoe UI", Roboto, Arial, sans-serif;
      animation: appFadeIn 420ms ease both;
    }

    .app {
      width: 100%;
      max-width: 720px;
      margin: 0 auto;
      min-height: 100dvh;
      padding: 14px 14px calc(92px + env(safe-area-inset-bottom));
    }

    .top {
      position: sticky;
      top: 0;
      z-index: 10;
      padding: calc(10px + env(safe-area-inset-top)) 0 12px;
      background: linear-gradient(to bottom, var(--bg) 78%, rgba(247, 243, 235, 0));
      backdrop-filter: blur(14px);
    }

    .brand-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      margin-bottom: 12px;
    }

    .brand {
      display: flex;
      flex-direction: row;
      align-items: center;
      gap: 10px;
      min-width: 0;
    }

    .brand-mark {
      width: 44px;
      height: 44px;
      flex: 0 0 44px;
      display: grid;
      place-items: center;
    }

    .brand-mark img {
      width: 44px;
      height: 44px;
      display: block;
      object-fit: contain;
      filter: drop-shadow(0 8px 14px rgba(42, 31, 17, 0.16));
    }

    .brand-copy {
      display: flex;
      flex-direction: column;
      gap: 2px;
      min-width: 0;
    }

    .brand h1 {
      margin: 0;
      font-size: 28px;
      letter-spacing: -0.04em;
      font-weight: 850;
    }

    .brand span {
      color: var(--muted);
      font-size: 13px;
    }

    .top-actions {
      display: flex;
      gap: 8px;
      align-items: center;
      flex-shrink: 0;
    }

    button, input, select {
      font: inherit;
    }

    button {
      border: 0;
      border-radius: 16px;
      padding: 12px 14px;
      background: var(--panel-2);
      color: var(--text);
      cursor: pointer;
      font-weight: 750;
    }

    button:active {
      transform: scale(0.985);
    }

    .primary {
      background: var(--accent);
      color: white;
    }

    .primary:active {
      background: var(--accent-dark);
    }

    .dark {
      background: var(--text);
      color: var(--panel);
    }

    .danger {
      background: var(--danger-soft);
      color: var(--danger);
    }

    .ghost {
      background: transparent;
      border: 1px solid var(--line);
    }

    .small {
      padding: 8px 10px;
      border-radius: 12px;
      font-size: 13px;
    }

    .tiny {
      padding: 7px 9px;
      border-radius: 999px;
      font-size: 12px;
    }

    .nav {
      position: fixed;
      left: 50%;
      bottom: calc(12px + env(safe-area-inset-bottom));
      transform: translateX(-50%);
      z-index: 20;
      width: calc(100% - 28px);
      max-width: 520px;
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 6px;
      padding: 6px;
      background: rgba(255, 250, 242, 0.86);
      border: 1px solid rgba(222, 212, 197, 0.9);
      border-radius: 22px;
      box-shadow: 0 20px 45px rgba(42, 31, 17, 0.18);
      backdrop-filter: blur(18px);
    }

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

    .nav button.active {
      background: var(--text);
      color: var(--panel);
    }

    .page {
      display: block;
    }

    .hidden {
      display: none !important;
    }

    .day-card, .status-card, .imex-card {
      background: rgba(255, 250, 242, 0.88);
      border: 1px solid rgba(222, 212, 197, 0.9);
      border-radius: 28px;
      padding: 15px;
      margin: 14px 0;
      box-shadow: var(--shadow);
    }

    .day-head {
      display: grid;
      grid-template-columns: 1fr auto;
      gap: 12px;
      align-items: start;
      margin-bottom: 12px;
    }

    .day-title {
      margin: 0;
      font-size: 24px;
      letter-spacing: -0.05em;
      font-weight: 900;
      line-height: 1.05;
    }

    .date-line {
      color: var(--muted);
      font-size: 16px;
      margin-top: 7px;
    }

    .score-side {
      display: flex;
      flex-direction: column;
      align-items: flex-end;
      gap: 8px;
    }

    .score-pill {
      background: var(--text);
      color: var(--panel);
      padding: 14px 22px;
      border-radius: 999px;
      font-weight: 900;
      font-size: 22px;
      line-height: 1;
      white-space: nowrap;
      min-width: 86px;
      text-align: center;
    }

    .day-tools {
      display: flex;
      gap: 8px;
      flex-wrap: wrap;
      justify-content: flex-end;
    }

    .chips {
      display: grid;
      grid-template-columns: repeat(5, minmax(96px, 1fr));
      gap: 8px;
      overflow-x: auto;
      padding-bottom: 2px;
    }

    .chip {
      background: #f1eadf;
      border: 1px solid #e3d8c9;
      border-radius: 20px;
      padding: 14px;
      min-width: 96px;
    }

    .chip b {
      display: block;
      font-size: 13px;
      color: var(--muted);
      margin-bottom: 8px;
      letter-spacing: 0.02em;
    }

    .chip span {
      font-size: 24px;
      font-weight: 900;
      letter-spacing: -0.04em;
    }

    .day-details {
      margin-top: 12px;
      border-top: 1px solid var(--line);
      padding-top: 12px;
    }

    .form {
      background: var(--panel-3);
      border: 1px solid #e2d8c8;
      border-radius: 22px;
      padding: 10px;
      display: grid;
      grid-template-columns: 1fr;
      gap: 8px;
    }

    .form-row {
      display: grid;
      grid-template-columns: 1fr 92px;
      gap: 8px;
    }

    input, select {
      width: 100%;
      border: 1px solid #ddd0bf;
      background: #fffdf8;
      color: var(--text);
      border-radius: 16px;
      padding: 13px 12px;
      outline: none;
      min-height: 46px;
    }

    input:focus, select:focus {
      border-color: var(--accent);
      box-shadow: 0 0 0 3px rgba(201, 100, 66, 0.14);
    }

    .actions {
      margin-top: 12px;
      max-height: 280px;
      overflow-y: auto;
      display: grid;
      gap: 8px;
      padding-right: 2px;
    }

    .action {
      display: grid;
      grid-template-columns: 1fr auto;
      gap: 10px;
      align-items: center;
      background: #fffdf8;
      border: 1px solid var(--line-2);
      border-radius: 20px;
      padding: 11px;
    }

    .action-main {
      min-width: 0;
    }

    .action-name {
      font-weight: 820;
      overflow-wrap: anywhere;
      letter-spacing: -0.01em;
    }

    .muted {
      color: var(--muted);
      font-size: 13px;
    }

    .tag {
      display: inline-flex;
      align-items: center;
      padding: 4px 8px;
      border-radius: 999px;
      background: #eee4d6;
      color: #554f46;
      font-size: 12px;
      font-weight: 800;
      margin-right: 6px;
    }

    .action-score {
      text-align: right;
      font-size: 18px;
      font-weight: 900;
    }

    .action-buttons {
      grid-column: 1 / -1;
      display: flex;
      gap: 8px;
      justify-content: flex-end;
    }

    .bottom-actions {
      display: grid;
      grid-template-columns: 1fr;
      gap: 8px;
      margin-top: 14px;
    }

    .empty {
      text-align: center;
      color: var(--muted);
      padding: 26px 12px;
      background: rgba(255,255,255,0.35);
      border: 1px dashed var(--line);
      border-radius: 22px;
      margin-top: 14px;
    }

    .hero-stats {
      display: grid;
      grid-template-columns: 1.3fr 1fr 1fr;
      gap: 8px;
      margin: 12px 0 14px;
    }

    .hero-box {
      background: var(--panel);
      border: 1px solid var(--line);
      border-radius: 24px;
      padding: 14px;
      box-shadow: var(--shadow);
    }

    .hero-box b {
      display: block;
      color: var(--muted);
      font-size: 12px;
      margin-bottom: 6px;
    }

    .hero-box span {
      font-size: 24px;
      font-weight: 900;
      letter-spacing: -0.04em;
    }

    .chart-wrap {
      background: #fffdf8;
      border: 1px solid var(--line-2);
      border-radius: 22px;
      padding: 10px;
      overflow: hidden;
    }

    canvas {
      width: 100%;
      height: 280px;
      display: block;
      border-radius: 18px;
      background: #fffaf2;
    }

    .small-chart {
      height: 220px;
      margin-top: 10px;
    }

    .weeks {
      display: grid;
      gap: 10px;
      margin-top: 12px;
    }

    .week-row {
      background: #fffdf8;
      border: 1px solid var(--line-2);
      border-radius: 22px;
      padding: 12px;
    }

    .week-click {
      cursor: pointer;
    }

    .week-title-row {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 10px;
      margin-bottom: 8px;
    }

    .week-title {
      font-weight: 850;
      letter-spacing: -0.02em;
    }

    .week-grid {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 8px;
    }

    .week-metric {
      background: #f3ece1;
      border-radius: 16px;
      padding: 10px;
    }

    .week-metric b {
      display: block;
      color: var(--muted);
      font-size: 11px;
      margin-bottom: 4px;
    }

    .week-metric span {
      font-weight: 900;
      font-size: 18px;
    }

    .note {
      color: var(--muted);
      font-size: 13px;
      line-height: 1.45;
      margin: 8px 0 0;
    }

    .imex-grid {
      display: grid;
      gap: 10px;
      margin-top: 14px;
    }

    .imex-button {
      display: grid;
      grid-template-columns: 1fr auto;
      gap: 10px;
      align-items: center;
      width: 100%;
      text-align: left;
      background: #fffdf8;
      border: 1px solid var(--line-2);
      border-radius: 22px;
      padding: 14px;
    }

    .imex-button strong {
      display: block;
      font-size: 16px;
      margin-bottom: 3px;
    }

    .imex-button span {
      color: var(--muted);
      font-size: 13px;
      font-weight: 500;
    }

    .imex-button .arrow {
      font-size: 20px;
      font-weight: 900;
      color: var(--accent);
    }

    .storage-box {
      margin-top: 14px;
      background: #f3ece1;
      border: 1px solid var(--line);
      border-radius: 20px;
      padding: 12px;
      color: var(--muted);
      font-size: 13px;
      line-height: 1.45;
    }

    @media (max-width: 430px) {
      .app {
        padding-left: 10px;
        padding-right: 10px;
      }

      .brand h1 {
        font-size: 25px;
      }

      .brand-mark {
        width: 40px;
        height: 40px;
        flex-basis: 40px;
      }

      .brand-mark img {
        width: 40px;
        height: 40px;
      }

      .top-actions {
        gap: 6px;
      }

      .top-actions button {
        padding: 9px 10px;
        font-size: 13px;
      }

      .day-card, .status-card, .imex-card {
        border-radius: 24px;
        padding: 12px;
      }

      .day-title {
        font-size: 21px;
      }

      .date-line {
        font-size: 15px;
      }

      .score-pill {
        font-size: 20px;
        min-width: 76px;
        padding: 13px 18px;
      }

      .chips {
        grid-template-columns: repeat(5, 110px);
      }

      .chip {
        padding: 12px;
      }

      .chip span {
        font-size: 22px;
      }

      .hero-stats {
        grid-template-columns: 1fr;
      }

      .form-row {
        grid-template-columns: 1fr;
      }

      .week-grid {
        grid-template-columns: 1fr 1fr 1fr;
      }
    }


    /* Claude-like polish + motion */
    @keyframes appFadeIn {
      from { opacity: 0; }
      to { opacity: 1; }
    }

    @keyframes cardEnter {
      from {
        opacity: 0;
        transform: translateY(10px) scale(0.992);
      }
      to {
        opacity: 1;
        transform: translateY(0) scale(1);
      }
    }

    @keyframes softPop {
      from {
        opacity: 0;
        transform: translateY(8px);
      }
      to {
        opacity: 1;
        transform: translateY(0);
      }
    }

    @keyframes glowPulse {
      0%, 100% { box-shadow: 0 16px 40px rgba(42, 31, 17, 0.10); }
      50% { box-shadow: 0 18px 48px rgba(201, 100, 66, 0.14); }
    }

    .day-card,
    .status-card,
    .imex-card,
    .week-row,
    .hero-box {
      animation: cardEnter 340ms cubic-bezier(.2, .8, .2, 1) both;
    }

    .day-card {
      transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
    }

    .day-card:hover {
      transform: translateY(-1px);
      box-shadow: 0 18px 42px rgba(42, 31, 17, 0.12);
      border-color: rgba(201, 100, 66, 0.22);
    }

    .day-details,
    .actions,
    .chart-wrap,
    .imex-grid,
    .weeks {
      animation: softPop 260ms ease both;
    }

    button {
      transition:
        transform 140ms ease,
        background 160ms ease,
        color 160ms ease,
        box-shadow 160ms ease,
        border-color 160ms ease;
    }

    button:hover {
      box-shadow: 0 8px 18px rgba(42, 31, 17, 0.08);
    }

    .primary:hover {
      background: var(--accent-dark);
      box-shadow: 0 12px 24px rgba(201, 100, 66, 0.22);
    }

    .dark:hover {
      box-shadow: 0 12px 24px rgba(33, 31, 26, 0.16);
    }

    .ghost:hover {
      background: rgba(255, 250, 242, 0.74);
      border-color: rgba(201, 100, 66, 0.30);
    }

    input,
    select {
      transition:
        border-color 150ms ease,
        box-shadow 150ms ease,
        background 150ms ease;
    }

    .score-pill {
      box-shadow: 0 10px 24px rgba(33, 31, 26, 0.14);
    }

    .chip,
    .week-metric,
    .action,
    .imex-button {
      transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
    }

    .chip:hover,
    .week-metric:hover,
    .action:hover,
    .imex-button:hover {
      transform: translateY(-1px);
      border-color: rgba(201, 100, 66, 0.24);
    }

    .welcome-card {
      overflow: hidden;
      position: relative;
      animation: cardEnter 380ms cubic-bezier(.2, .8, .2, 1) both, glowPulse 4s ease-in-out infinite;
    }

    .welcome-card::before {
      content: "";
      position: absolute;
      inset: 0;
      background:
        radial-gradient(circle at top right, rgba(201, 100, 66, 0.18), transparent 35%),
        radial-gradient(circle at bottom left, rgba(33, 31, 26, 0.08), transparent 42%);
      pointer-events: none;
    }

    .welcome-content {
      position: relative;
      z-index: 1;
    }

    .welcome-kicker {
      display: inline-flex;
      padding: 6px 10px;
      border-radius: 999px;
      background: #eee4d6;
      color: #554f46;
      font-weight: 900;
      font-size: 11px;
      letter-spacing: 0.07em;
      margin-bottom: 14px;
    }

    .welcome-title {
      margin: 0;
      font-size: 30px;
      letter-spacing: -0.055em;
      font-weight: 950;
      line-height: 1.02;
    }

    .welcome-actions {
      display: flex;
      gap: 8px;
      flex-wrap: wrap;
      margin-top: 16px;
    }

    .welcome-mini-grid {
      display: grid;
      grid-template-columns: repeat(4, minmax(112px, 1fr));
      gap: 8px;
      overflow-x: auto;
      margin-top: 14px;
      padding-bottom: 2px;
    }

    .welcome-mini {
      background: rgba(241, 234, 223, 0.82);
      border: 1px solid #e3d8c9;
      border-radius: 18px;
      padding: 12px;
      min-width: 112px;
      transition: transform 160ms ease, border-color 160ms ease;
    }

    .welcome-mini:hover {
      transform: translateY(-1px);
      border-color: rgba(201, 100, 66, 0.28);
    }

    .welcome-mini b {
      display: block;
      color: var(--muted);
      font-size: 11px;
      margin-bottom: 5px;
    }

    .welcome-mini span {
      font-weight: 900;
      font-size: 14px;
      line-height: 1.16;
      display: block;
    }

    @media (prefers-reduced-motion: reduce) {
      *,
      *::before,
      *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
      }
    }


/* v3 DayScore refinements */
.form-title {
  font-weight: 900;
  letter-spacing: -0.02em;
  margin: 4px 4px 2px;
}

.form-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.form-actions button {
  width: 100%;
  padding: 12px 14px;
  border-radius: 16px;
}

.add-day-card,
.action-form,
.note-form {
  animation: cardEnter 260ms cubic-bezier(.2, .8, .2, 1) both;
}

.compact-score-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  overflow-x: visible;
}

.compact-score-grid .chip {
  min-width: 0;
  padding: 11px;
}

.compact-score-grid .chip b {
  font-size: 12px;
  margin-bottom: 4px;
}

.compact-score-grid .chip span {
  font-size: 20px;
  line-height: 1;
}

.compact-score-grid .chip small {
  display: block;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.15;
  margin-top: 5px;
}

.day-note-preview {
  margin: 0 0 12px;
  color: var(--muted);
  background: rgba(241, 234, 223, 0.72);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.4;
}

.add-day-form input[type="date"] {
  max-width: 240px;
}

/* Softer animation override: closer to DebtPal, less flashy */
.welcome-card {
  animation: cardEnter 320ms cubic-bezier(.2, .8, .2, 1) both !important;
}

.day-card,
.status-card,
.imex-card,
.week-row,
.hero-box {
  animation-duration: 280ms !important;
}

.day-card:hover {
  transform: translateY(-0.5px);
}

@media (max-width: 430px) {
  .compact-score-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .compact-score-grid .chip {
    min-width: 0;
  }

  .compact-score-grid .chip span {
    font-size: 19px;
  }

  .compact-score-grid .chip small {
    font-size: 10px;
  }
}
