:root {
  --bg-deep: #fff5f8;
  --bg-card: rgba(255, 255, 255, 0.88);
  --border: rgba(236, 72, 153, 0.18);
  --text: #3d1f4d;
  --muted: #7c6b8a;
  --accent: #e91e8c;
  --accent-dim: rgba(233, 30, 140, 0.12);
  --joy-orange: #ff7a3d;
  --joy-yellow: #ffd54d;
  --joy-mint: #34d399;
  --joy-blue: #38bdf8;
  --danger: #f43f5e;
  --success: #10b981;
  --shadow: 0 18px 40px rgba(233, 30, 140, 0.12), 0 8px 24px rgba(255, 122, 61, 0.08);
  --radius: 18px;
  --font: "Noto Sans SC", "DM Sans", system-ui, sans-serif;
  --safe-top: env(safe-area-inset-top);
  --safe-right: env(safe-area-inset-right);
  --safe-bottom: env(safe-area-inset-bottom);
  --safe-left: env(safe-area-inset-left);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg-deep);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
  padding-bottom: var(--safe-bottom);
  overscroll-behavior-y: none;
}

.bg-gradient {
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(ellipse 90% 60% at 10% 0%, rgba(255, 213, 77, 0.55), transparent 55%),
    radial-gradient(ellipse 70% 50% at 95% 15%, rgba(56, 189, 248, 0.4), transparent 50%),
    radial-gradient(ellipse 60% 45% at 50% 100%, rgba(233, 30, 140, 0.2), transparent 45%),
    radial-gradient(ellipse 50% 40% at 30% 80%, rgba(52, 211, 153, 0.35), transparent 50%),
    var(--bg-deep);
}

.noise {
  position: fixed;
  inset: 0;
  z-index: -1;
  opacity: 0.018;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.header {
  max-width: 1320px;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 0.75rem;
}

.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.person-quick {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.person-menu {
  position: relative;
}

.person-menu summary {
  list-style: none;
}

.person-menu summary::-webkit-details-marker {
  display: none;
}

.person-menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 0.35rem);
  min-width: 220px;
  z-index: 30;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(236, 72, 153, 0.25);
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(233, 30, 140, 0.14);
  padding: 0.6rem;
}

.person-menu-actions {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.45rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.btn-entry-pill {
  flex-shrink: 0;
  padding: 0.55rem 1.15rem;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(255, 245, 251, 0.98));
  border: 1px solid rgba(236, 72, 153, 0.35);
  color: #9d174d;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(233, 30, 140, 0.12);
  transition: transform 0.15s, box-shadow 0.2s;
}

.btn-entry-pill:hover {
  box-shadow: 0 6px 20px rgba(233, 30, 140, 0.2);
}

.btn-entry-pill:active {
  transform: scale(0.98);
}

.panel-entry-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}

.btn-text-close {
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: #9d174d;
  background: rgba(233, 30, 140, 0.08);
  border: none;
  border-radius: 8px;
  padding: 0.35rem 0.75rem;
  cursor: pointer;
}

.btn-text-close:hover {
  background: rgba(233, 30, 140, 0.14);
}

.brand-icon {
  font-size: 1.75rem;
  color: var(--accent);
  filter: drop-shadow(0 2px 8px rgba(233, 30, 140, 0.35));
}

.brand h1 {
  margin: 0;
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.tagline {
  margin: 0.2rem 0 0;
  font-size: 0.875rem;
  color: var(--muted);
}

.layout {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 1.5rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.entry-slot {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 1.5rem;
  box-sizing: border-box;
}

.entry-slot .panel-entry:not([hidden]) {
  margin-bottom: 1.25rem;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
}

.card-title {
  margin: 0 0 0.35rem;
  font-size: 1.15rem;
  font-weight: 600;
}

.panel-display > .display-head .card-title {
  font-size: 1.4rem;
  font-weight: 700;
}

.card-hint {
  margin: 0 0 1.25rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.card-hint .inline-code {
  font-size: 0.78em;
  padding: 0.1em 0.35em;
  border-radius: 4px;
  background: rgba(233, 30, 140, 0.1);
  color: #c2185b;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.field.span-2 {
  grid-column: span 2;
}

.field label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
}

input[type="number"],
input[type="datetime-local"],
select,
textarea {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  border: 1px solid rgba(236, 72, 153, 0.25);
  background: rgba(255, 255, 255, 0.95);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  -webkit-appearance: none;
  appearance: none;
  touch-action: manipulation;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: rgba(233, 30, 140, 0.45);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

textarea {
  resize: vertical;
  min-height: 2.8rem;
}

.actions {
  margin-top: 0.25rem;
}

.btn {
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.75rem 1.25rem;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s, background 0.2s;
  min-height: 0;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: linear-gradient(135deg, #ff2d92, #ff7a3d);
  color: #fff;
  box-shadow: 0 8px 24px rgba(233, 30, 140, 0.35);
}

.btn-primary:hover {
  box-shadow: 0 12px 32px rgba(255, 122, 61, 0.4);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.85);
  color: #9d174d;
  border: 1px solid rgba(236, 72, 153, 0.35);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 1);
}

.btn-block {
  width: 100%;
}

.actions-split {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.display-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.range-tabs {
  display: flex;
  gap: 0.35rem;
  padding: 0.3rem;
  background: rgba(255, 255, 255, 0.65);
  border-radius: 14px;
  border: 1px solid rgba(236, 72, 153, 0.22);
}

.tab {
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.45rem 0.9rem;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.2s, background 0.2s, transform 0.15s;
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  background: linear-gradient(135deg, rgba(233, 30, 140, 0.18), rgba(255, 213, 77, 0.35));
  color: #9d174d;
  box-shadow: 0 2px 8px rgba(233, 30, 140, 0.15);
}

.range-hint {
  margin: 0 0 0.85rem;
  font-size: 0.78rem;
  line-height: 1.55;
  color: var(--muted);
}

.range-hint strong {
  color: #831843;
  font-weight: 600;
}

.chart-toolbar {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.45rem 0.65rem;
  margin-bottom: 1rem;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 0.15rem;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
}

.toolbar-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
  scroll-snap-align: start;
}

.custom-range-panel {
  margin-bottom: 1rem;
  padding: 1rem 1.1rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(236, 72, 153, 0.2);
}

.custom-range-row {
  margin-bottom: 0.65rem;
}

.custom-range-row:last-of-type {
  margin-bottom: 0;
}

.custom-range-flex {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
}

.custom-range-note {
  margin: 0.5rem 0 0;
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.45;
}

.chart-range-stats {
  margin: 0 0 0.85rem;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.5;
}

.chart-range-stats strong {
  color: #831843;
  font-weight: 600;
}

.goal-focus-card,
.checkin-card {
  margin: 0;
  padding: 0.9rem 1rem;
  border-radius: 14px;
  border: 1px solid rgba(236, 72, 153, 0.2);
  background: rgba(255, 255, 255, 0.72);
  line-height: 1.55;
  font-size: 0.86rem;
}

.goal-focus-card {
  background: linear-gradient(140deg, rgba(255, 255, 255, 0.92), rgba(255, 245, 251, 0.95));
  border-width: 2px;
  box-shadow: 0 10px 24px rgba(233, 30, 140, 0.12);
}

.goal-focus-title,
.checkin-title {
  margin: 0 0 0.35rem;
  color: #831843;
  font-size: 0.92rem;
  font-weight: 700;
}

.goal-focus-card p,
.checkin-card p {
  margin: 0.15rem 0;
}

.goal-focus-card p {
  line-height: 1.75;
  margin: 0.32rem 0;
}

.goal-focus-card .strong,
.checkin-card .strong {
  color: #831843;
  font-weight: 700;
}

.goal-focus-card .up {
  color: var(--danger);
}

.goal-focus-card .down {
  color: var(--success);
}

.focus-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.9rem;
  margin: 0 0 0.9rem;
}

@media (min-width: 900px) {
  .focus-row {
    grid-template-columns: 1.25fr 1fr;
    align-items: stretch;
  }
}

.checkin-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.6rem;
  margin: 0.25rem 0 0.5rem;
}

.checkin-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.22rem 0.6rem;
  border-radius: 999px;
  border: 1px solid rgba(236, 72, 153, 0.28);
  background: linear-gradient(120deg, rgba(255, 255, 255, 0.95), rgba(255, 238, 248, 0.95));
  color: #9d174d;
  font-size: 0.76rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.checkin-badge:hover {
  background: linear-gradient(120deg, rgba(255, 255, 255, 1), rgba(255, 225, 240, 0.98));
  box-shadow: 0 6px 16px rgba(236, 72, 153, 0.16);
  transform: translateY(-1px);
}

.checkin-badge:active {
  transform: translateY(0);
}

.badge-preview-img {
  display: block;
  width: min(100%, 320px);
  margin: 0.7rem auto 0.1rem;
  border-radius: 12px;
  border: 1px solid rgba(236, 72, 153, 0.2);
  box-shadow: 0 10px 22px rgba(17, 24, 39, 0.15);
}

.badge-preview-placeholder {
  width: min(100%, 320px);
  height: 220px;
  margin: 0.7rem auto 0.1rem;
  border: 2px dashed rgba(236, 72, 153, 0.5);
  border-radius: 12px;
  background: rgba(255, 245, 251, 0.7);
  color: #9d174d;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0.8rem;
}

.checkin-cheer {
  margin-top: 0.35rem;
  color: #7e22ce;
  font-weight: 600;
}

.input-month {
  padding: 0.4rem 0.55rem;
  border-radius: 10px;
  border: 1px solid rgba(236, 72, 153, 0.25);
  background: rgba(255, 255, 255, 0.95);
  color: var(--text);
  font-family: inherit;
  font-size: 0.88rem;
}

.chart-zoom-btn {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  z-index: 3;
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.35rem 0.65rem;
  border-radius: 8px;
  border: 1px solid rgba(236, 72, 153, 0.35);
  background: rgba(255, 255, 255, 0.95);
  color: #9d174d;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(233, 30, 140, 0.12);
}

.chart-reset-btn {
  position: absolute;
  top: 0.4rem;
  right: 3.6rem;
  z-index: 3;
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.35rem 0.65rem;
  border-radius: 8px;
  border: 1px solid rgba(56, 189, 248, 0.42);
  background: rgba(255, 255, 255, 0.95);
  color: #0f766e;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(56, 189, 248, 0.15);
}

.chart-reset-btn:hover:not(:disabled) {
  background: rgba(56, 189, 248, 0.1);
}

.chart-reset-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.chart-zoom-btn:hover:not(:disabled) {
  background: rgba(233, 30, 140, 0.1);
}

.chart-zoom-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.chart-zoom-overlay {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(1rem + var(--safe-top)) 1rem calc(1rem + var(--safe-bottom));
  background: rgba(61, 31, 77, 0.4);
  backdrop-filter: blur(8px);
}

.chart-zoom-overlay[hidden] {
  display: none;
}

.chart-zoom-dialog {
  position: relative;
  width: 100%;
  max-width: min(96vw, 1000px);
  max-height: 92vh;
  padding: 1.25rem 1.25rem 1.5rem;
  background: linear-gradient(165deg, #fff 0%, #fff8fc 100%);
  border: 1px solid rgba(236, 72, 153, 0.28);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.chart-zoom-title {
  margin: 0 0 0.75rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: #831843;
}

.chart-zoom-canvas-wrap {
  position: relative;
  height: min(78vh, 640px);
  min-height: 320px;
}

.muted {
  font-size: 0.8rem;
  color: var(--muted);
}

.select-sm {
  width: auto;
  min-width: 4.4rem;
  padding: 0.36rem 0.55rem;
  font-size: 0.82rem;
}

.toolbar-item--height .input-height {
  width: 5.6rem;
  padding: 0.36rem 0.5rem;
  border-radius: 10px;
  border: 1px solid rgba(236, 72, 153, 0.25);
  background: rgba(255, 255, 255, 0.95);
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
}

.toolbar-item--goal {
  flex-wrap: nowrap;
}

.toolbar-item--person {
  flex-wrap: nowrap;
}

.input-person-name {
  width: 5rem;
  min-width: 5rem;
}

.btn-person-mini {
  padding: 0.34rem 0.52rem;
  font-size: 0.74rem;
  line-height: 1;
  border-radius: 8px;
  border: 1px solid rgba(236, 72, 153, 0.28);
  background: rgba(255, 255, 255, 0.95);
  color: #831843;
}

.btn-person-mini:hover {
  background: rgba(255, 240, 248, 0.96);
}

.btn-person-del {
  border-color: rgba(244, 63, 94, 0.35);
  color: #be123c;
}

.charts-grid {
  display: grid;
  gap: 1.25rem;
  margin-bottom: 1rem;
}

.chart-wrap {
  position: relative;
  cursor: default;
  background: rgba(255, 255, 255, 0.75);
  border-radius: 16px;
  border: 1px solid rgba(236, 72, 153, 0.2);
  padding: 0.5rem 0.65rem 0.85rem;
  box-shadow: 0 8px 28px rgba(233, 30, 140, 0.08);
}

.chart-wrap--line {
  border-top: 4px solid #e91e8c;
}

.bmi-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.85rem;
  margin-bottom: 1.25rem;
  padding: 0.65rem 0.85rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(236, 72, 153, 0.15);
  font-size: 0.78rem;
  color: var(--muted);
}

.bmi-legend-title {
  margin-right: 0.25rem;
}

.bmi-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
}

.bmi-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 2px;
  flex-shrink: 0;
}

.bmi-chip--thin .bmi-dot {
  background: #0ea5e9;
}

.bmi-chip--normal .bmi-dot {
  background: #16a34a;
}

.bmi-chip--over .bmi-dot {
  background: #d97706;
}

.bmi-chip--obese .bmi-dot {
  background: #dc2626;
}

.bmi-detail-panel {
  margin-bottom: 1.25rem;
  padding: 0.85rem 1rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid rgba(236, 72, 153, 0.2);
  font-size: 0.82rem;
  line-height: 1.55;
  color: var(--text);
}

.bmi-detail-panel p {
  margin: 0;
}

.bmi-detail-panel p + p {
  margin-top: 0.55rem;
}

.bmi-detail-panel strong {
  color: #831843;
  font-weight: 600;
}

.sub-title {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

.chart-canvas {
  position: relative;
  height: min(56vh, 560px);
  min-height: 320px;
}

.chart-canvas.is-empty canvas {
  opacity: 0;
  pointer-events: none;
}

.chart-canvas.is-empty .chart-msg:empty::before {
  content: "";
  display: block;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  border: 2px dashed rgba(233, 30, 140, 0.22);
}

.chart-msg {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted);
  padding: 0 .75rem;
  text-align: center;
  pointer-events: none;
  z-index: 0;
}

.chart-canvas > canvas {
  position: relative;
  z-index: 1;
}

.chart-msg[hidden] {
  display: none !important;
}

.analysis-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
}

.sub-card {
  background: rgba(255, 255, 255, 0.55);
  border-radius: 14px;
  border: 1px solid rgba(56, 189, 248, 0.22);
  padding: 1rem;
}

.analysis-list {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.88rem;
}

.analysis-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--border);
}

.analysis-list li:last-child {
  border-bottom: none;
}

.analysis-list strong {
  color: #a21caf;
  font-weight: 600;
}

.compare-box {
  font-size: 0.88rem;
  line-height: 1.65;
}

.compare-box .highlight {
  color: #a21caf;
  font-weight: 600;
}

.compare-box .up {
  color: var(--danger);
}

.compare-box .down {
  color: var(--success);
}

.compare-total {
  margin: 0 0 0.75rem;
  font-size: 0.88rem;
}

.compare-heading {
  margin: 0.65rem 0 0.35rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: #831843;
}

.compare-breakdown {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.82rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.45);
  border: 1px solid rgba(236, 72, 153, 0.12);
}

.compare-breakdown li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.4rem 0.65rem;
  border-bottom: 1px solid rgba(236, 72, 153, 0.08);
}

.compare-breakdown li:last-child {
  border-bottom: none;
}

.compare-sub {
  margin: 0.45rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.55;
}

.recent-wrap {
  margin-top: 1.25rem;
}

.recent-list {
  margin: 0;
  padding: 0;
  list-style: none;
  max-height: 260px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.recent-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

.recent-item {
  gap: 0.55rem;
}

.recent-list .time {
  color: var(--muted);
  font-size: 0.78rem;
}

.recent-note {
  display: block;
  margin-top: 0.2rem;
  color: #6b5a7a;
  font-size: 0.76rem;
}

.btn-recent-del {
  margin-left: auto;
  border: 1px solid rgba(244, 63, 94, 0.28);
  background: rgba(255, 255, 255, 0.92);
  color: #be123c;
  border-radius: 8px;
  padding: 0.22rem 0.55rem;
  font-size: 0.75rem;
  cursor: pointer;
}

.btn-recent-del:hover {
  background: rgba(255, 238, 242, 0.95);
}

.empty-hint {
  color: var(--muted);
  font-size: 0.88rem;
  padding: 0.5rem 0;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(1.5rem + var(--safe-top)) 1.5rem calc(1.5rem + var(--safe-bottom));
  background: rgba(61, 31, 77, 0.35);
  backdrop-filter: blur(10px);
  animation: fadeIn 0.25s ease;
}

.modal-overlay[hidden] {
  display: none;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal {
  position: relative;
  width: 100%;
  max-width: 420px;
  padding: 2rem 1.75rem 1.5rem;
  background: linear-gradient(165deg, #fff 0%, #fff5fb 50%, #fff9e6 100%);
  border: 1px solid rgba(236, 72, 153, 0.25);
  border-radius: 20px;
  box-shadow: var(--shadow), 0 0 0 1px rgba(255, 255, 255, 0.8) inset;
  animation: slideUp 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-close {
  position: absolute;
  top: 0.85rem;
  right: 0.85rem;
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: 8px;
  background: rgba(233, 30, 140, 0.08);
  color: var(--muted);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.modal-close:hover {
  background: rgba(233, 30, 140, 0.15);
  color: var(--text);
}

.modal-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #c2185b;
  margin-bottom: 0.5rem;
}

.modal-title {
  margin: 0 0 1rem;
  font-size: 1.25rem;
  font-weight: 700;
}

.modal-body {
  margin: 0 0 1rem;
  font-size: 0.95rem;
  line-height: 1.65;
  color: #5b4b6d;
}

.modal-body .time-ref {
  color: var(--text);
  font-weight: 500;
}

.modal-encourage {
  margin: 0 0 1.25rem;
  font-size: 0.9rem;
  color: var(--muted);
  font-style: italic;
}

@media (max-width: 1024px) {
  .header {
    padding: 1.1rem 1rem 0.6rem;
  }
  .layout,
  .entry-slot {
    padding-left: 1rem;
    padding-right: 1rem;
  }
  .card {
    padding: 1.1rem;
  }
  .chart-canvas {
    height: min(48vh, 420px);
    min-height: 260px;
  }
  .chart-zoom-canvas-wrap {
    min-height: 260px;
    height: min(70vh, 560px);
  }
}

@media (max-width: 768px) {
  input[type="number"],
  input[type="datetime-local"],
  select,
  textarea {
    font-size: 16px;
  }
  .btn {
    min-height: 40px;
  }
  .header-inner {
    gap: 0.7rem;
  }
  .header-actions {
    width: 100%;
    gap: 0.45rem;
  }
  .person-quick {
    width: 100%;
  }
  .person-quick .select-sm {
    flex: 1;
  }
  .person-menu-panel {
    right: auto;
    left: 0;
    min-width: min(90vw, 300px);
  }
  .brand h1 {
    font-size: 1.35rem;
  }
  .tagline {
    font-size: 0.8rem;
  }
  .btn-entry-pill {
    width: 100%;
  }
  .display-head {
    margin-bottom: 0.55rem;
  }
  .range-tabs {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .tab {
    flex: 0 0 auto;
    min-height: 38px;
  }
  .chart-toolbar {
    gap: 0.4rem 0.55rem;
    margin-bottom: 0.7rem;
  }
  .toolbar-item {
    gap: 0.3rem;
  }
  .muted {
    font-size: 0.75rem;
  }
  .input-person-name {
    width: 4.6rem;
    min-width: 4.6rem;
  }
  .toolbar-item--height .input-height {
    width: 5.2rem;
  }
  .select-sm {
    min-width: 4rem;
    font-size: 0.8rem;
  }
  .btn-person-mini {
    min-height: 34px;
    padding: 0.28rem 0.45rem;
  }
  .focus-row {
    grid-template-columns: 1fr;
    gap: 0.65rem;
  }
  .goal-focus-card,
  .checkin-card {
    padding: 0.75rem 0.8rem;
    font-size: 0.8rem;
  }
  .analysis-list li,
  .compare-breakdown li,
  .recent-list li {
    gap: 0.45rem;
  }
  .analysis-list li,
  .compare-breakdown li,
  .recent-list li {
    flex-direction: column;
    align-items: flex-start;
  }
  .recent-list .time {
    margin-top: 0.1rem;
  }
  .chart-canvas {
    min-height: 230px;
    height: min(42vh, 360px);
  }
  .chart-zoom-btn {
    top: 0.3rem;
    right: 0.3rem;
    min-height: 32px;
  }
  .chart-reset-btn {
    top: 0.3rem;
    right: 3.35rem;
    min-height: 32px;
  }
  .modal-overlay {
    padding: calc(0.75rem + var(--safe-top)) 0.75rem calc(0.75rem + var(--safe-bottom));
    align-items: flex-end;
  }
  .modal {
    max-width: 100%;
    border-radius: 14px;
    padding: 1.4rem 1rem 1rem;
    margin-bottom: max(0px, calc(var(--safe-bottom) - 4px));
  }
}

@media (max-width: 420px) {
  .layout,
  .entry-slot {
    padding-left: 0.65rem;
    padding-right: 0.65rem;
  }
  .card {
    padding: 0.85rem;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .field.span-2,
  .actions.span-2 {
    grid-column: span 1;
  }
  .chart-toolbar {
    padding-bottom: 0.25rem;
  }
  .btn {
    min-height: 42px;
  }
}
