:root {
  --bg: #f3efe7;
  --bg-accent: #e8f1eb;
  --surface: #fffdf9;
  --surface-strong: #ffffff;
  --ink: #1f2a22;
  --muted: #68756b;
  --line: #d8ddd6;
  --brand: #215f48;
  --brand-2: #bb7a35;
  --danger: #a33d3d;
  --shadow: 0 20px 50px rgba(32, 46, 38, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "Hiragino Sans", "Yu Gothic", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(187, 122, 53, 0.12), transparent 28%),
    linear-gradient(180deg, var(--bg-accent), var(--bg));
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-wrap {
  width: min(100%, 460px);
}

.login-card,
.card {
  background: rgba(255, 253, 249, 0.94);
  border: 1px solid rgba(216, 221, 214, 0.9);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.login-card {
  padding: 28px;
}

.shell {
  width: min(1120px, calc(100% - 32px));
  margin: 24px auto 40px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  margin-bottom: 20px;
}

.topbar h1,
.login-card h1,
.card h2 {
  margin: 0;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.muted,
.hint,
.shot-date,
.user-name {
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 18px;
}

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

.card {
  padding: 22px;
}

.stack {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 8px;
  font-weight: 700;
}

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

input,
select,
textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  color: var(--ink);
}

textarea {
  resize: vertical;
  min-height: 110px;
}

button,
a.ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 16px;
  border-radius: 999px;
  border: 1px solid transparent;
  text-decoration: none;
  cursor: pointer;
}

.primary {
  background: linear-gradient(135deg, var(--brand), #2f7c60);
  color: #fff;
}

.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
}

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

.flash {
  margin-bottom: 18px;
  padding: 14px 16px;
  border-radius: 16px;
  background: #eef8f1;
  border: 1px solid #b6d2bf;
  white-space: pre-wrap;
}

.flash.error {
  background: #fff1f1;
  border-color: #efc2c2;
}

.upload-status {
  min-height: 24px;
  margin: 0;
  color: var(--muted);
}

.upload-status[data-tone="working"] {
  color: var(--brand-2);
}

.upload-status[data-tone="ok"] {
  color: var(--brand);
}

.upload-status[data-tone="error"] {
  color: var(--danger);
}

.facts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.facts span {
  padding: 7px 10px;
  border-radius: 999px;
  background: #edf3ef;
  font-size: 13px;
}

.summary {
  font-size: 18px;
  line-height: 1.7;
}

.history-item,
.shot-card {
  border-top: 1px solid var(--line);
  padding-top: 14px;
  margin-top: 14px;
}

.history-item:first-of-type,
.shot-card:first-of-type {
  border-top: 0;
  padding-top: 0;
  margin-top: 0;
}

.history-top,
.section-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.range-switch {
  display: inline-flex;
  gap: 8px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.75);
}

.range-switch a {
  padding: 8px 14px;
  border-radius: 999px;
  text-decoration: none;
  color: var(--muted);
}

.range-switch a.active {
  color: #fff;
  background: linear-gradient(135deg, var(--brand), #2f7c60);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
}

.stats-grid.compact {
  margin-top: 12px;
}

.stat-card {
  padding: 14px;
  border-radius: 18px;
  background: #f6f7f4;
  border: 1px solid var(--line);
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.stat-card strong {
  font-size: 24px;
}

.balance-card {
  padding: 16px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(246, 247, 244, 0.92));
  display: grid;
  gap: 12px;
}

.balance-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  color: var(--muted);
}

.balance-head strong {
  color: var(--ink);
}

.balance-bars {
  display: flex;
  width: 100%;
  height: 18px;
  overflow: hidden;
  border-radius: 999px;
  background: #e9ede7;
  border: 1px solid var(--line);
}

.balance-segment {
  min-width: 4px;
}

.balance-segment.protein,
.dot.protein {
  background: linear-gradient(180deg, #63b38f, #2f7c60);
}

.balance-segment.fat,
.dot.fat {
  background: linear-gradient(180deg, #c98bb6, #9d5a88);
}

.balance-segment.carb,
.dot.carb {
  background: linear-gradient(180deg, #8dc6d6, #4c93aa);
}

.balance-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.balance-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
}

.chart-panel {
  display: grid;
  gap: 12px;
}

.chart-row {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 10px;
  align-items: stretch;
}

.chart-label {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 700;
}

.chart-bars {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(28px, 1fr);
  gap: 8px;
  align-items: end;
  overflow-x: auto;
  padding-bottom: 4px;
}

.bar-slot {
  display: grid;
  gap: 6px;
  justify-items: center;
}

.bar-track {
  position: relative;
  width: 100%;
  height: 132px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(232, 241, 235, 0.6), rgba(255, 255, 255, 0.9));
  border: 1px solid var(--line);
  overflow: hidden;
}

.bar-fill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 16px 16px 0 0;
}

.bar-fill.calorie {
  background: linear-gradient(180deg, #edb55b, #cf7f31);
}

.bar-fill.protein {
  background: linear-gradient(180deg, #63b38f, #2f7c60);
}

.bar-fill.carb {
  background: linear-gradient(180deg, #8dc6d6, #4c93aa);
}

.bar-fill.fat {
  background: linear-gradient(180deg, #c98bb6, #9d5a88);
}

.bar-slot span {
  font-size: 12px;
  color: var(--muted);
}

.manual-text {
  margin: 8px 0 0;
  color: var(--muted);
  background: #f7f7f3;
  border: 1px dashed var(--line);
  border-radius: 14px;
  padding: 10px 12px;
}

.latest-balance {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 10px 0 12px;
  color: var(--muted);
}

.latest-balance strong {
  color: var(--ink);
  padding-right: 4px;
}

.commit-score {
  display: grid;
  justify-items: end;
  gap: 4px;
  color: var(--muted);
}

.commit-score strong {
  color: var(--ink);
  font-size: 28px;
}

.analysis-block,
.advice-list {
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: 18px;
  background: #f7f8f4;
  border: 1px solid var(--line);
}

.analysis-block strong,
.advice-list strong {
  display: block;
  margin-bottom: 8px;
}

.analysis-block p {
  margin: 0;
  line-height: 1.7;
}

.advice-list ul {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 8px;
}

.health-history {
  display: grid;
  gap: 12px;
}

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

.shot-card {
  display: grid;
  gap: 12px;
}

.shot-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: #f4f4f4;
}

.shot-body p {
  margin: 0 0 10px;
}

@media (max-width: 900px) {
  .grid {
    grid-template-columns: 1fr;
  }

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

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

  .topbar {
    align-items: start;
    flex-direction: column;
  }

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

  .chart-label {
    justify-items: start;
  }

  .commit-score {
    justify-items: start;
  }
}
