:root {
  color-scheme: dark;
  --bg: #100c14;
  --panel: transparent;
  --panel-solid: #121019;
  --panel-2: #111b24;
  --panel-3: #142734;
  --line: rgba(122, 145, 161, 0.08);
  --text: #f7f3fb;
  --muted: #a4b2c1;
  --muted-2: #6f8096;
  --accent: #06b6d4;
  --accent-strong: #22d3ee;
  --accent-2: #0ea5e9;
  --danger: #ff6b7a;
  --blue: #6ea8ff;
  --violet: #d58cff;
  --shadow: none;
  --shadow-soft: none;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, #100c14 0%, #0d1018 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.72;
  transform: none;
}

button,
input,
select {
  transition:
    border-color 160ms var(--ease),
    background-color 160ms var(--ease),
    color 160ms var(--ease),
    box-shadow 160ms var(--ease),
    transform 160ms var(--ease);
}

button:hover {
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid rgba(49, 208, 170, 0.55);
  outline-offset: 2px;
}

.auth,
.onboarding,
.dashboard {
  width: min(1180px, calc(100vw - 28px));
  margin: 0 auto;
}

.auth,
.onboarding {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px 0;
}

.auth-box,
.onboarding-box,
.panel,
.modal form {
  background: var(--panel);
  border: 0;
  border-radius: 0;
  box-shadow: var(--shadow);
  backdrop-filter: none;
}

.auth-box,
.onboarding-box {
  width: min(440px, 100%);
  padding: 28px;
}

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

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 6px;
  font-size: clamp(2rem, 7vw, 4.8rem);
  line-height: 0.9;
  letter-spacing: 0;
  text-wrap: balance;
}

h2 {
  margin-bottom: 10px;
  font-size: 1.15rem;
  letter-spacing: 0.01em;
}

h3 {
  margin-bottom: 6px;
  font-size: 1rem;
}

.muted,
.error,
.hint {
  color: var(--muted);
}

.error {
  min-height: 20px;
  color: var(--danger);
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  margin-bottom: 18px;
  background: rgba(9, 13, 20, 0.8);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.tabs button,
.range button {
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  min-height: 38px;
}

.tabs button:hover,
.range button:hover {
  color: var(--text);
  background: rgba(147, 163, 184, 0.08);
}

.tabs button.active,
.range button.active {
  color: var(--text);
  background: var(--panel-2);
}

form {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.9rem;
}

input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid rgba(147, 163, 184, 0.2);
  border-radius: 7px;
  padding: 0 12px;
  background: rgba(10, 15, 24, 0.92);
  color: var(--text);
}

input:hover,
select:hover {
  border-color: rgba(147, 163, 184, 0.34);
}

input:focus,
select:focus {
  border-color: rgba(49, 208, 170, 0.58);
  box-shadow: 0 0 0 4px rgba(49, 208, 170, 0.08);
}

input[type="file"] {
  padding: 10px 12px;
}

.primary,
.secondary,
.ghost {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 0 16px;
  color: #04110d;
  background: var(--accent);
  font-weight: 750;
}

.primary:hover {
  background: var(--accent-strong);
  box-shadow: 0 10px 24px rgba(49, 208, 170, 0.2);
}

.secondary {
  color: var(--text);
  background: var(--panel-2);
  border-color: var(--line);
}

.secondary:hover,
.ghost:hover {
  border-color: rgba(147, 163, 184, 0.36);
  background: var(--panel-3);
}

.danger-button {
  min-height: 44px;
  border: 1px solid rgba(255, 107, 122, 0.38);
  border-radius: 7px;
  padding: 0 16px;
  color: #fff5f6;
  background: rgba(255, 107, 122, 0.22);
  font-weight: 750;
}

.danger-button:hover {
  background: rgba(255, 107, 122, 0.34);
}

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

.dashboard {
  padding: 12px 0 96px;
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 16px;
  margin-bottom: 14px;
}

.topbar h1 {
  font-size: clamp(2rem, 5vw, 3.6rem);
  font-weight: 800;
}

.brand-title {
  display: flex;
  align-items: center;
  gap: 0.14em;
  line-height: 0.92;
}

.brand-title img {
  width: auto;
  height: 0.9em;
  object-fit: contain;
  flex: 0 0 auto;
  transform: translateY(0.02em);
}

.account-menu {
  position: relative;
  align-self: flex-start;
}

.menu-button {
  min-width: 44px;
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  color: var(--text);
  background: var(--panel-2);
  font-weight: 800;
}

.menu-button:hover {
  background: var(--panel-3);
}

.menu-list {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 20;
  display: none;
  width: 210px;
  padding: 6px;
  background: rgba(10, 15, 24, 0.96);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  transform-origin: top right;
  animation: menuIn 140ms var(--ease);
}

.menu-list.open {
  display: grid;
  gap: 4px;
}

.menu-list button {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  padding: 0 10px;
  color: var(--text);
  background: transparent;
  text-align: left;
}

.menu-list button:hover {
  background: var(--panel-2);
}

.viewer-pill {
  display: inline-block;
  margin-top: 8px;
  padding: 5px 8px;
  border: 1px solid rgba(255, 189, 89, 0.35);
  border-radius: 999px;
  color: var(--accent-2);
  font-size: 0.82rem;
}

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

.stat {
  min-height: 50px;
  padding: 9px 10px;
  background: #101e29;
  border: 0;
  border-radius: 9px;
  box-shadow: var(--shadow-soft);
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
}

.stat b {
  display: block;
  margin-top: 3px;
  font-size: clamp(0.9rem, 1.6vw, 1.08rem);
  line-height: 1.15;
  overflow-wrap: anywhere;
}

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

.panel {
  min-width: 0;
  padding: 0;
  transition: border-color 180ms var(--ease), transform 180ms var(--ease), box-shadow 180ms var(--ease);
}

.panel:hover {
  border-color: transparent;
  box-shadow: none;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
  margin-bottom: 10px;
}

.panel-head .muted {
  margin-bottom: 0;
  font-size: 0.86rem;
}

.panel-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}


.range {
  display: grid;
  grid-template-columns: repeat(3, minmax(62px, 1fr));
  gap: 4px;
  padding: 4px;
  background: #0b1018;
  border: 0;
  border-radius: 999px;
}

.range-four {
  grid-template-columns: repeat(4, minmax(50px, 1fr));
}

.range button {
  min-height: 32px;
  padding: 0 8px;
  font-size: 0.82rem;
  border-radius: 999px;
}

canvas {
  display: block;
  width: 100%;
  height: 275px;
  border-radius: 8px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.015) 1px, transparent 1px),
    #090e15;
  background-size: 100% 34px;
}

.chart-wrap {
  position: relative;
}

.chart-marker {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  pointer-events: none;
  opacity: 0;
  background: rgba(238, 244, 255, 0.3);
  box-shadow: 0 0 0 1px rgba(238, 244, 255, 0.08), 0 0 18px rgba(238, 244, 255, 0.1);
  transition: opacity 120ms var(--ease), left 80ms linear;
}

.chart-marker.visible {
  opacity: 1;
}

.chart-note {
  min-height: 20px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.chart-tooltip {
  position: absolute;
  top: 12px;
  z-index: 4;
  min-width: 112px;
  padding: 7px 9px;
  border: 1px solid rgba(6, 182, 212, 0.28);
  border-radius: 8px;
  color: var(--text);
  background: rgba(12, 18, 27, 0.94);
  box-shadow: var(--shadow-soft);
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(-4px);
  transition: opacity 120ms var(--ease), transform 120ms var(--ease);
}

.chart-tooltip.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.chart-tooltip b,
.chart-tooltip span {
  display: block;
  white-space: nowrap;
  font-size: 0.78rem;
}

.chart-tooltip span {
  color: var(--accent-strong);
}

.timeline-panel {
  margin-top: 14px;
}

@media (min-width: 821px) {
  .timeline-panel {
    width: min(100%, 980px);
    margin-left: auto;
    margin-right: auto;
  }
}

.weight-summary-panel {
  align-self: start;
  padding: 16px;
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.012)),
    rgba(10, 7, 14, 0.78);
}

.summary-list {
  display: grid;
  gap: 10px;
}

.summary-group {
  display: grid;
  gap: 2px;
  padding: 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.026);
}

.summary-group p {
  margin: 0 0 4px;
  color: var(--accent-strong);
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.summary-row {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.15;
}

.summary-row > span {
  white-space: nowrap;
}

.summary-row + .summary-row {
  border-top: 1px solid rgba(122, 145, 161, 0.055);
}

.summary-row b {
  color: var(--text);
  font-weight: 750;
  font-size: 0.8rem;
}

.summary-value {
  display: grid;
  grid-template-columns: 76px 72px 62px;
  gap: 5px;
  justify-content: end;
  align-items: baseline;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.summary-main,
.summary-delta,
.summary-percent {
  text-align: right;
}

.summary-delta:not(:empty),
.summary-percent:not(:empty) {
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.045);
  text-align: center;
}

.sign-up {
  color: var(--danger);
  font-weight: 850;
}

.sign-down {
  color: #20d6a3;
  font-weight: 850;
}

.timeline-list {
  display: grid;
  gap: 2px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) max-content;
  gap: 7px;
  align-items: center;
  padding: 5px 4px;
  border: 0;
  border-radius: 8px;
  background: rgba(11, 16, 24, 0.46);
}

.timeline-item + .timeline-item {
  border-top: 1px solid rgba(122, 145, 161, 0.045);
}

.timeline-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--blue);
  box-shadow: 0 0 0 3px rgba(110, 168, 255, 0.12);
}

.timeline-item.shot .timeline-dot {
  background: #20d6a3;
  box-shadow: 0 0 0 3px rgba(32, 214, 163, 0.13);
}

.timeline-date {
  display: block;
  color: var(--muted);
  font-size: 0.66rem;
}

.timeline-line {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  margin: 0;
  color: var(--muted);
  font-size: 0.68rem;
  line-height: 1.15;
}

.timeline-line b {
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 850;
  white-space: nowrap;
}

.timeline-line span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timeline-actions {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
}

.icon-action {
  width: 24px;
  height: 24px;
  min-height: 24px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}

.icon-action svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
  display: block;
}

.photo-icon {
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
  fill: var(--muted);
  opacity: 0.85;
}

.pagination {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 12px;
}

.pagination button {
  min-width: 34px;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  background: rgba(10, 15, 24, 0.7);
}

.pagination button.active {
  color: #031018;
  background: var(--accent);
}

.pagination button:disabled {
  color: var(--muted-2);
  opacity: 0.42;
}

.small-button {
  min-height: 34px;
  padding: 0 10px;
  font-size: 0.82rem;
}

.timeline-actions .icon-action {
  width: 30px;
  min-width: 30px;
  height: 30px;
  min-height: 30px;
  padding: 0;
}

.timeline-actions .icon-action svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

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

.bottom-actions {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 10;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: min(520px, calc(100vw - 28px));
  padding: 10px;
  background: rgba(8, 10, 15, 0.78);
  border: 0;
  border-radius: 14px;
  backdrop-filter: blur(16px);
  box-shadow: 0 12px 38px rgba(0, 0, 0, 0.34);
}

.modal {
  width: min(460px, calc(100vw - 24px));
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--text);
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.72);
}

.modal form {
  padding: 18px;
  animation: modalIn 180ms var(--ease);
}

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

.modal h2 {
  margin-bottom: 0;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  background: rgba(10, 15, 24, 0.92);
}

.split {
  display: grid;
  grid-template-columns: 1fr 110px;
  gap: 10px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.checkbox-row input {
  width: 18px;
  min-height: 18px;
}

.checkbox-row.disabled {
  color: var(--muted-2);
  opacity: 0.62;
}

.checkbox-row.disabled input {
  cursor: not-allowed;
}

.photo-modal {
  width: min(760px, calc(100vw - 24px));
}

.photo-modal img {
  display: block;
  max-width: 100%;
  max-height: 86vh;
  margin: 0 auto;
  border-radius: 8px;
}

.chart-modal {
  width: min(1120px, calc(100vw - 18px));
}

.chart-modal .expanded-panel {
  padding-top: 46px;
}

.chart-modal canvas {
  height: min(62vh, 560px);
}

@keyframes menuIn {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

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

.floating-close {
  position: absolute;
  top: 10px;
  right: 10px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 88px;
  z-index: 40;
  max-width: min(420px, calc(100vw - 28px));
  padding: 10px 13px;
  border: 1px solid rgba(49, 208, 170, 0.28);
  border-radius: 8px;
  color: var(--text);
  background: rgba(10, 15, 24, 0.94);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px);
  transition: opacity 180ms var(--ease), transform 180ms var(--ease);
  backdrop-filter: blur(18px);
}

.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 820px) {
  .topbar {
    align-items: start;
    grid-template-columns: minmax(0, 1fr) auto;
  }

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

  .topbar h1 {
    font-size: 2rem;
    line-height: 1;
  }

  .brand-title img {
    height: 0.74em;
    transform: translateY(-0.03em);
  }

  .topbar .muted {
    font-size: 0.86rem;
  }

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

  .panel-head {
    flex-direction: column;
    align-items: stretch;
  }

  .panel-tools {
    align-items: stretch;
    justify-content: space-between;
  }

  .range {
    width: 100%;
  }

  canvas {
    height: 245px;
  }

  .summary-row {
    grid-template-columns: minmax(122px, 1fr) auto;
    gap: 6px;
  }

  .summary-value {
    grid-template-columns: 74px 70px 60px;
    gap: 4px;
  }

  .timeline-item {
    grid-template-columns: 10px minmax(0, 1fr) auto;
    gap: 7px;
    padding: 5px 2px;
  }

  .timeline-actions {
    grid-column: auto;
    flex-direction: row;
    align-items: flex-end;
    justify-content: center;
  }
}

@media (max-width: 520px) {
  .auth,
  .onboarding,
  .dashboard {
    width: min(100% - 18px, 1180px);
  }

  .dashboard {
    padding-top: 12px;
  }

  .stats {
    gap: 5px;
  }

  .stat {
    min-height: 46px;
    padding: 7px 7px;
  }

  .stat span {
    font-size: 0.68rem;
  }

  .stat b {
    font-size: 0.82rem;
    white-space: nowrap;
  }

  .panel {
    padding: 12px;
  }

  .weight-summary-panel {
    padding: 12px;
  }

  .summary-group {
    padding: 9px;
  }

  .summary-row {
    font-size: 0.72rem;
  }

  .summary-row b {
    font-size: 0.74rem;
  }

  .summary-value {
    grid-template-columns: 64px 62px 56px;
  }

  .bottom-actions {
    bottom: 10px;
    width: min(100% - 18px, 520px);
  }

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

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