:root {
  --bg: #070809;
  --surface: #0d0f11;
  --ink: #f3f4f5;
  --muted: #8a9098;
  --faint: #5c6168;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);
  --accent: #7ee0b8;
  --accent-deep: #3fb98a;
  --accent-soft: rgba(126, 224, 184, 0.14);
  --warm: #e8c4b0;
  --radius: 10px;
  --font: Inter, "Segoe UI", sans-serif;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  letter-spacing: -0.011em;
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

.app {
  width: min(760px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 80px;
  padding-top: calc(28px + env(safe-area-inset-top));
  padding-bottom: calc(168px + env(safe-area-inset-bottom));
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 36px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 10px;
  height: 10px;
  border-radius: 99px;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.brand-name {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.brand-sub,
.hero-kicker,
.scale-label,
.field span,
.history-head h2,
.chart-note,
.hero-delta {
  margin: 0;
  color: var(--muted);
}

.brand-sub,
.hero-kicker,
.scale-label,
.field span,
.history-head h2 {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero {
  margin-bottom: 28px;
}

.hero-value {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 4px 0 8px;
  font-size: clamp(56px, 12vw, 88px);
  font-weight: 500;
  letter-spacing: -0.05em;
  line-height: 0.95;
  font-variant-numeric: tabular-nums;
}

.hero-unit {
  font-family: var(--font);
  font-size: 16px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: -0.02em;
}

.hero-delta {
  font-size: 13px;
}

.hero-delta .is-down {
  color: var(--accent);
}

.hero-delta .is-up {
  color: var(--warm);
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.seg {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  gap: 2px;
}

.seg button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 999px;
  min-height: 32px;
  font-size: 12px;
  font-weight: 500;
}

.seg button[aria-selected="true"],
.seg button[aria-pressed="true"] {
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
}

.chart-wrap {
  margin: 0 0 4px;
}

.chart {
  position: relative;
  height: min(46vh, 420px);
  min-height: 260px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.chart-y {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}

.chart-y span {
  position: absolute;
  left: 14px;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

.chart-x {
  position: absolute;
  left: 52px;
  right: 22px;
  bottom: 10px;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
  z-index: 1;
}

.chart-x span {
  font-size: 11px;
  color: var(--faint);
}

.chart-x span:last-child {
  text-align: right;
}

#chart-svg {
  display: block;
  touch-action: none;
}

#chart-svg:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -8px;
}

.chart-tip {
  position: absolute;
  z-index: 3;
  transform: translate(-50%, 0);
  padding: 8px 10px;
  border-radius: 8px;
  background: #14171a;
  border: 1px solid var(--line-strong);
  font-size: 12px;
  white-space: nowrap;
  pointer-events: none;
}

.chart-tip b {
  font-weight: 500;
  font-size: 16px;
  letter-spacing: -0.03em;
}

.chart-tip small {
  display: block;
  color: var(--muted);
  margin-top: 2px;
}

.chart-note,
.scale-hint {
  margin-top: 10px;
  font-size: 12px;
  min-height: 1.2em;
}

.scale-hint {
  margin: 0 0 22px;
  color: var(--faint);
}

.log {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 8;
  display: grid;
  grid-template-columns: min(760px, calc(100% - 24px));
  justify-content: center;
  gap: 8px;
  padding: 10px 12px calc(12px + env(safe-area-inset-bottom));
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 16px 16px 0 0;
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  backdrop-filter: blur(18px);
}

.log-fields {
  display: grid;
  grid-template-columns: minmax(118px, 140px) minmax(0, 1fr);
  gap: 8px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field input {
  height: 48px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #090a0b;
  padding: 0 12px;
  outline: none;
}

.field-weight input {
  font-size: 28px;
  font-weight: 500;
  letter-spacing: -0.03em;
}

.field input:focus {
  border-color: rgba(126, 224, 184, 0.55);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.log-submit {
  height: 48px;
  width: 100%;
  padding: 0 22px;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: #062016;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.log-submit:hover {
  filter: brightness(1.05);
}

.log-submit:focus-visible,
.seg button:focus-visible,
.text-btn:focus-visible,
.row-del:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.history {
  margin-top: 28px;
}

.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.text-btn,
.row-del {
  border: 0;
  background: none;
  color: var(--muted);
  padding: 6px 0;
  min-height: 32px;
}

.text-btn:hover,
.row-del:hover {
  color: var(--ink);
}

.history-list {
  display: flex;
  flex-direction: column;
}

.history-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.history-row b {
  color: var(--ink);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

th {
  color: var(--muted);
  font-weight: 500;
}

.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;
}

.sample-banner {
  margin: 0 0 20px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--accent-soft);
  color: var(--ink);
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.save-status {
  position: fixed;
  left: 50%;
  bottom: calc(152px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  margin: 0;
  padding: 8px 12px;
  border-radius: 999px;
  background: #14171a;
  border: 1px solid var(--line-strong);
  font-size: 12px;
  color: var(--muted);
  z-index: 5;
}

.lock {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: var(--bg);
  display: grid;
  place-items: center;
  padding: 24px;
}

.lock[hidden] {
  display: none;
}

.lock-card {
  width: min(100%, 400px);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.lock-copy,
.lock-error,
.lock-hint {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.lock-hint {
  font-size: 12px;
  color: var(--faint);
}

.lock-error {
  color: var(--warm);
}

.lock-card .log-submit {
  width: 100%;
}

.lock-card .field input {
  height: 48px;
}

@media (max-width: 640px) {
  .app {
    width: min(100% - 24px, 760px);
    padding-top: calc(20px + env(safe-area-inset-top));
    padding-bottom: calc(176px + env(safe-area-inset-bottom));
  }

  .hero-value {
    font-size: 64px;
  }

  .chart {
    min-height: 240px;
  }

  .field-weight input {
    font-size: 22px;
  }

  .top-actions .text-btn {
    min-height: 44px;
    padding: 6px 8px;
  }
}

@media (min-width: 720px) {
  .app {
    padding-bottom: calc(108px + env(safe-area-inset-bottom));
  }

  .log {
    left: 50%;
    right: auto;
    width: min(760px, calc(100% - 32px));
    transform: translateX(-50%);
    grid-template-columns: 148px minmax(0, 1fr) auto;
    align-items: end;
    border: 1px solid var(--line);
    border-bottom: 0;
  }

  .log-fields {
    display: contents;
  }

  .log-submit {
    width: auto;
  }

  .save-status {
    bottom: calc(96px + env(safe-area-inset-bottom));
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}
