:root {
  color-scheme: light;
  --surface: #f8faf3;
  --surface-low: #f2f4ed;
  --surface-container: #edefe7;
  --surface-high: #e7e9e2;
  --surface-highest: #e1e3dc;
  --card: #ffffff;
  --ink: #191c18;
  --muted: #41493f;
  --quiet: #71796e;
  --line: #c1c9bc;
  --primary: #346a38;
  --primary-ui: #4c834e;
  --primary-soft: #90cb8f;
  --primary-fixed: #b5f2b2;
  --secondary: #4e644c;
  --secondary-soft: #d0eaca;
  --tertiary: #fca3c0;
  --danger: #ba1a1a;
  --danger-soft: #ffdad6;
  --shadow: 0 10px 28px rgba(76, 131, 78, 0.12);
  --shadow-soft: 0 4px 18px rgba(76, 131, 78, 0.08);
  font-family: Manrope, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 90% 8%, rgba(252, 163, 192, 0.13), transparent 28%),
    radial-gradient(circle at 12% 52%, rgba(144, 203, 143, 0.16), transparent 32%),
    var(--surface);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.app-shell {
  min-height: 100vh;
  padding-bottom: calc(112px + env(safe-area-inset-bottom));
}

.app-shell svg * {
  fill: none;
  stroke: currentColor;
}

.topbar {
  width: min(720px, 100%);
  margin: 0 auto;
  padding: calc(32px + env(safe-area-inset-top)) 20px 18px;
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--primary);
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 44px;
}

.brand-lockup svg {
  width: 32px;
  height: 32px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.page-heading {
  display: grid;
  gap: 10px;
}

.page-heading h1,
.topbar h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 650;
  line-height: 32px;
  letter-spacing: 0;
}

.page-heading p,
.topbar p {
  margin: 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 26px;
  letter-spacing: 0;
}

.topbar .view-actions {
  margin-top: 18px;
}

.main {
  width: min(720px, 100%);
  margin: 0 auto;
  padding: 0 20px 22px;
}

.grid {
  display: grid;
  gap: 16px;
}

.source-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.card {
  position: relative;
  background: var(--card);
  border: 1px solid rgba(193, 201, 188, 0.34);
  border-radius: 24px;
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.source-card {
  display: grid;
  align-content: space-between;
  gap: 16px;
  min-height: 150px;
  padding: 20px 18px;
  text-align: left;
  color: inherit;
}

.source-card::after {
  content: "";
  position: absolute;
  inset: auto -34px -46px auto;
  width: 126px;
  height: 126px;
  border-radius: 999px;
  background: rgba(237, 239, 231, 0.7);
  pointer-events: none;
}

.source-drinks::after {
  inset: -42px -38px auto auto;
  background: rgba(252, 163, 192, 0.14);
}

.source-trips {
  grid-column: 1 / -1;
  min-height: 132px;
  background:
    linear-gradient(90deg, #ffffff 0 50%, rgba(255, 255, 255, 0.68)),
    linear-gradient(120deg, rgba(52, 106, 56, 0.1), rgba(144, 203, 143, 0.03));
}

.source-intimacy_records {
  background: var(--surface-container);
}

.source-icon,
.metric-icon,
.setting-icon {
  display: inline-grid;
  place-items: center;
  color: var(--primary);
}

.source-icon svg {
  width: 32px;
  height: 32px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.card-head {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.card-title {
  margin: 0;
  font-size: 19px;
  font-weight: 560;
  line-height: 26px;
  letter-spacing: 0;
}

.card-subtitle,
.muted {
  color: var(--muted);
  font-size: 13px;
  line-height: 18px;
  letter-spacing: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--secondary-soft);
  color: var(--secondary);
  font-size: 12px;
  white-space: nowrap;
}

.metric-row {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.metric {
  min-height: 86px;
  padding: 16px;
  border: 0;
  border-radius: 20px;
  background: var(--card);
}

.metric b {
  display: block;
  margin-top: 12px;
  font-size: 28px;
  font-weight: 650;
  line-height: 34px;
  letter-spacing: 0;
}

.source-card .metric {
  min-height: auto;
  padding: 0;
  background: transparent;
  box-shadow: none;
}

.source-card .metric b {
  margin: 0 0 2px;
  font-size: 16px;
  line-height: 20px;
}

.source-card .metric-row {
  display: none;
}

.mini-chart {
  display: none;
}

.trend-chart {
  width: 100%;
  height: 220px;
  display: block;
  background: var(--card);
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 20;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  width: min(720px, 100%);
  padding: 16px 34px calc(16px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(193, 201, 188, 0.8);
  border-bottom: 0;
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -8px 28px rgba(65, 73, 63, 0.08);
  backdrop-filter: blur(18px);
}

.nav-btn {
  display: grid;
  place-items: center;
  gap: 6px;
  min-height: 66px;
  border-radius: 999px;
  background: transparent;
  color: #30382f;
  font-size: 15px;
  line-height: 20px;
}

.nav-btn svg,
.icon-btn svg,
.plain-btn svg,
.primary-btn svg,
.danger-btn svg,
.ghost-btn svg,
.setting-row svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.55;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-btn.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 650;
}

.fab {
  position: fixed;
  right: max(22px, calc((100vw - 720px) / 2 + 22px));
  bottom: calc(134px + env(safe-area-inset-bottom));
  z-index: 25;
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: #2f7338;
  color: #ffffff;
  box-shadow: 0 8px 24px rgba(76, 131, 78, 0.24);
}

.fab svg {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.view-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.plain-btn,
.danger-btn,
.primary-btn,
.ghost-btn,
.icon-btn {
  min-height: 46px;
  border-radius: 999px;
  padding: 0 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.compact-btn {
  min-height: 42px;
}

.primary-btn {
  background: var(--primary-ui);
  color: #ffffff;
}

.plain-btn {
  background: rgba(78, 100, 76, 0.1);
  color: var(--secondary);
}

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

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

.icon-btn {
  width: 46px;
  padding: 0;
  background: var(--surface-container);
  color: var(--muted);
}

.record-list {
  display: grid;
  gap: 12px;
}

.record-card {
  padding: 18px;
}

.record-main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.record-main h3 {
  margin: 0 0 5px;
  font-size: 18px;
  font-weight: 620;
  line-height: 25px;
}

.record-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 14px;
}

.empty {
  padding: 34px 22px;
  text-align: center;
}

.empty h2 {
  margin: 0 0 8px;
  font-size: 20px;
  line-height: 28px;
}

.modal-layer {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: end center;
  padding: 18px 12px 0;
  background: rgba(25, 28, 24, 0.22);
}

.modal {
  width: min(720px, 100%);
  max-height: min(780px, calc(100vh - 22px));
  overflow: auto;
  background: var(--surface);
  border: 1px solid rgba(193, 201, 188, 0.48);
  border-radius: 28px 28px 0 0;
  box-shadow: 0 -12px 36px rgba(76, 131, 78, 0.15);
}

.modal-header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: grid;
  grid-template-columns: 46px 1fr 46px;
  align-items: center;
  gap: 10px;
  padding: 18px 20px;
  background: rgba(248, 250, 243, 0.96);
  backdrop-filter: blur(16px);
}

.modal-header h2 {
  grid-column: 2;
  margin: 0;
  text-align: center;
  font-size: 22px;
  font-weight: 650;
  line-height: 30px;
}

.modal-header .icon-btn {
  grid-column: 1;
  grid-row: 1;
  background: transparent;
}

.modal-body {
  padding: 18px 20px 24px;
}

.form-grid {
  display: grid;
  gap: 18px;
}

.field {
  display: grid;
  gap: 8px;
}

.field label,
.field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 560;
  line-height: 18px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 58px;
  border: 0;
  border-radius: 18px;
  padding: 14px 16px;
  background: var(--surface-container);
  color: var(--ink);
  outline: 1px solid transparent;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline-color: var(--primary-soft);
  background: var(--surface-low);
}

.field textarea {
  min-height: 128px;
  resize: vertical;
}

.form-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 24px;
}

.form-actions .primary-btn,
.form-actions .danger-btn {
  min-height: 60px;
}

.form-actions .plain-btn {
  order: 2;
}

.type-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.type-btn {
  min-height: 104px;
  padding: 16px;
  border-radius: 20px;
  background: var(--card);
  color: inherit;
  text-align: left;
  box-shadow: var(--shadow-soft);
}

.type-btn b {
  display: block;
  margin-bottom: 6px;
  font-size: 17px;
  line-height: 24px;
}

.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px;
  border-radius: 18px;
  background: var(--surface-container);
}

.segmented button {
  min-height: 42px;
  padding: 0 16px;
  border-radius: 14px;
  background: transparent;
  color: var(--muted);
}

.segmented button.active {
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--shadow-soft);
}

.source-tabs {
  overflow-x: auto;
  flex-wrap: nowrap;
}

.source-tabs button {
  flex: 0 0 auto;
}

.stats-layout {
  display: grid;
  gap: 24px;
}

.stats-controls {
  display: grid;
  gap: 14px;
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  overflow: visible;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.stat-metric {
  display: grid;
  align-content: start;
  gap: 4px;
}

.metric-icon svg {
  width: 22px;
  height: 22px;
}

.chart-card,
.setting-card {
  padding: 20px;
}

.quiet-dots {
  color: var(--quiet);
  font-weight: 700;
}

.table-like {
  display: grid;
  gap: 18px;
  margin-top: 18px;
}

.table-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
  align-items: center;
}

.table-row span {
  font-size: 16px;
}

.table-row b {
  font-weight: 560;
}

.table-row i {
  grid-column: 1 / -1;
  display: block;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary) var(--bar), var(--surface-highest) var(--bar));
}

.settings-list {
  display: grid;
  gap: 18px;
}

.section-label {
  margin: 8px 16px -4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  line-height: 18px;
}

.settings-group {
  display: grid;
}

.setting-row {
  width: 100%;
  min-height: 78px;
  display: grid;
  grid-template-columns: 42px 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  background: transparent;
  color: inherit;
  text-align: left;
}

.setting-row + .setting-row {
  border-top: 1px solid rgba(193, 201, 188, 0.45);
}

.setting-row b,
.setting-row small {
  display: block;
}

.setting-row b {
  font-size: 17px;
  font-weight: 560;
  line-height: 24px;
}

.setting-row small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
  line-height: 18px;
}

.mini-segmented {
  padding: 3px;
  justify-content: flex-end;
}

.mini-segmented button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

.danger-group {
  border-color: rgba(186, 26, 26, 0.22);
}

.danger-row {
  color: var(--danger);
}

.danger-row small {
  color: #6f3d39;
}

.hidden-input {
  display: none;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(190px + env(safe-area-inset-bottom));
  z-index: 80;
  transform: translateX(-50%);
  width: min(420px, calc(100% - 32px));
  padding: 13px 16px;
  border-radius: 999px;
  background: var(--ink);
  color: #ffffff;
  text-align: center;
  box-shadow: var(--shadow);
}

@media (min-width: 760px) {
  .source-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .source-trips {
    grid-column: span 2;
  }

  .form-grid.two-col {
    grid-template-columns: repeat(2, 1fr);
  }

  .field.full {
    grid-column: 1 / -1;
  }

  .form-actions {
    grid-template-columns: auto auto;
    justify-content: end;
  }

  .form-actions .plain-btn {
    order: initial;
  }
}

@media (max-width: 420px) {
  .brand-lockup {
    font-size: 26px;
    margin-bottom: 36px;
  }

  .source-card {
    min-height: 142px;
    padding: 18px 16px;
  }

  .card-title {
    font-size: 18px;
  }

  .bottom-nav {
    padding-left: 18px;
    padding-right: 18px;
  }

  .nav-btn {
    font-size: 14px;
  }

  .setting-row {
    grid-template-columns: 38px 1fr;
  }

  .setting-row > svg,
  .setting-row .mini-segmented {
    grid-column: 2;
  }
}
