main.weight-entry-screen,
main.weight-index-screen {
  min-height: 100dvh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  padding: 0;
  padding-bottom: calc(env(safe-area-inset-bottom) + 80px);
  align-items: stretch !important;
  justify-content: flex-start;
}

main.weight-entry-screen {
  height: calc(100dvh - 52px - env(safe-area-inset-bottom, 0px));
  min-height: 0;
  padding-bottom: 0;
  overflow-y: auto;
}

body.native-app main.weight-entry-screen {
  height: 100dvh;
}

body.has-tab-bar main.weight-entry-screen {
  padding-top: 0;
}

.weight-entry-screen header,
.weight-index-screen header {
  position: static;
  padding: 0;
}

.weight-entry-screen .weight-entry-header {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-5) var(--space-6);
  flex-shrink: 0;
}

.weight-entry-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  color: var(--text);
  flex-shrink: 0;
}

.weight-entry-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.weight-entry-form {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.weight-stepper-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  background: radial-gradient(ellipse 70% 55% at 50% 42%, rgba(0, 112, 243, 0.09), transparent 70%);
}

.weight-stepper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 420px;
}

.weight-date-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  min-height: 36px;
  background: var(--gray-900);
  border: 1px solid var(--gray-800);
  border-radius: 999px;
  color: var(--gray-300);
  font-size: 0.8125rem;
  font-weight: 600;
  font-family: "Geist Mono", monospace;
  cursor: pointer;
  margin-bottom: var(--space-5);
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.weight-date-pill:hover {
  background: var(--gray-800);
  color: var(--text);
}

.weight-date-pill:active {
  border-color: var(--gray-700);
}

.weight-date-pill svg:last-child {
  color: var(--gray-500);
}

.weight-stepper-buttons {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-12);
  margin-top: var(--space-8);
}

.weight-step-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--gray-900);
  border: 1px solid var(--gray-800);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.weight-step-btn:hover {
  background: var(--gray-800);
  border-color: var(--gray-700);
}

.weight-step-btn:active {
  transform: scale(0.92);
  background: var(--gray-800);
  border-color: var(--blue-500);
}

.weight-stepper-value {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: var(--space-2);
  min-width: 0;
  max-width: 100%;
}

.weight-stepper-caption {
  margin: var(--space-2) 0 0;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--gray-500);
  font-family: "Geist Mono", monospace;
  min-height: 1.2em;
}

.weight-stepper-value .weight-value-input {
  width: 5ch;
  max-width: 100%;
  background: none;
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
  color: var(--text);
  font-family: "Geist Mono", monospace;
  font-size: 4rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  text-align: center;
  caret-color: var(--blue-500);
  -moz-appearance: textfield;
  appearance: textfield;
}

.weight-stepper-value .weight-value-input:focus {
  outline: none;
  background: none;
  border: none;
  box-shadow: none;
}

.weight-stepper-value .weight-value-input::-webkit-outer-spin-button,
.weight-stepper-value .weight-value-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.weight-stepper-unit {
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--gray-500);
  font-family: "Geist Mono", monospace;
}

.weight-entry-errors {
  margin: 0 var(--space-6) var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: color-mix(in srgb, var(--danger) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 25%, transparent);
  border-radius: var(--radius-md);
}

.weight-entry-errors p {
  margin: 0;
  color: var(--danger);
  font-size: 0.8125rem;
  font-family: "Geist Mono", monospace;
}

.weight-entry-footer {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-6);
  padding-bottom: calc(var(--space-5) + env(safe-area-inset-bottom));
  flex-shrink: 0;
}

body.has-tab-bar .weight-entry-footer {
  padding-bottom: var(--space-5);
}

.weight-add-btn {
  flex: 1;
  height: 56px;
  background: var(--blue-500);
  color: #fff;
  border: none;
  border-radius: 28px;
  font-size: 1rem;
  font-weight: 600;
  font-family: "Geist Mono", monospace;
  cursor: pointer;
  transition: background 0.2s ease, opacity 0.2s ease;
  -webkit-appearance: none;
  appearance: none;
}

.weight-add-btn:hover {
  background: var(--blue-600);
}

.weight-add-btn:active {
  opacity: 0.85;
}

.weight-calendar-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.weight-calendar-modal.open {
  opacity: 1;
  pointer-events: auto;
}

.weight-calendar-backdrop {
  position: absolute;
  inset: 0;
  background: var(--backdrop);
}

.weight-calendar-sheet {
  position: relative;
  z-index: 1;
  background: var(--bg);
  padding: var(--space-6);
  padding-bottom: calc(var(--space-6) + env(safe-area-inset-bottom));
  transform: translateY(30px);
  transition: transform 0.3s ease;
}

.weight-calendar-modal.open .weight-calendar-sheet {
  transform: translateY(0);
}

.cal-selected-date {
  margin-bottom: var(--space-4);
}

.cal-year {
  font-size: 0.875rem;
  color: var(--gray-500);
  margin: 0 0 var(--space-1);
  font-family: "Geist Mono", monospace;
}

.cal-dayname {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
  font-family: "Geist Mono", monospace;
}

.cal-panel {
  background: var(--gray-900);
  border: 1px solid var(--gray-800);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}

.cal-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.cal-prev,
.cal-next {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  color: var(--gray-300);
  cursor: pointer;
  padding: 0;
}

.cal-next:disabled {
  color: var(--gray-600);
  cursor: default;
}

.cal-month-year {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
  font-family: "Geist Mono", monospace;
  flex: 1;
  text-align: center;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0;
}

.cal-header {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--gray-500);
  text-align: center;
  padding: var(--space-2) 0;
  font-family: "Geist Mono", monospace;
}

.cal-day {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  text-align: center;
  padding: 10px 0;
  border-radius: 50%;
  cursor: pointer;
  font-family: "Geist Mono", monospace;
  transition: background 0.15s ease;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cal-day:not(.cal-future):not(.cal-empty):hover {
  background: var(--gray-800);
}

.cal-day.cal-future {
  color: var(--gray-600);
  cursor: default;
}

.cal-day.cal-empty {
  pointer-events: none;
}

.cal-day.cal-today {
  color: var(--blue-500);
  font-weight: 700;
}

.cal-day.cal-selected {
  background: var(--blue-500);
  color: #fff;
  font-weight: 700;
}

.cal-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-6);
  margin-top: var(--space-4);
}

.cal-btn-cancel,
.cal-btn-ok {
  background: none;
  border: none;
  font-size: 0.875rem;
  font-weight: 700;
  font-family: "Geist Mono", monospace;
  color: var(--blue-500);
  cursor: pointer;
  padding: var(--space-2) 0;
  min-height: 44px;
  letter-spacing: 0.05em;
}

.weight-index-screen .weight-index-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + var(--space-5)) var(--space-5) var(--space-4);
  flex-shrink: 0;
}

.weight-index-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.weight-index-actions {
  display: flex;
  gap: var(--space-4);
}

.weight-index-actions form {
  display: contents;
}

.weight-index-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  color: var(--gray-300);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-decoration: none;
}

.weight-index-action-btn:hover {
  color: var(--text);
}

.weight-timeframe {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: var(--space-3) var(--space-4) var(--space-4);
  border-bottom: 1px solid var(--gray-800);
}

.weight-timeframe-label {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
  font-family: "Geist Mono", monospace;
}

.weight-timeframe-select {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--blue-500);
  font-size: 0.9375rem;
  font-weight: 600;
  font-family: "Geist Mono", monospace;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  min-height: 44px;
}

.weight-chart-wrap {
  padding: var(--space-2) 0;
  background: var(--bg);
}

.weight-chart-svg {
  width: 100%;
  height: 160px;
  display: block;
}

.weight-current-display {
  padding: var(--space-8) var(--space-6) var(--space-4);
  text-align: center;
}

.weight-current-value {
  font-size: 3rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 var(--space-2);
  font-family: "Geist Mono", monospace;
  letter-spacing: -0.03em;
}

.weight-current-change {
  font-size: 0.9375rem;
  font-weight: 500;
  margin: 0;
  font-family: "Geist Mono", monospace;
}

.weight-current-change.positive {
  color: var(--blue-500);
}

.weight-current-change.negative {
  color: var(--danger);
}

.hidden {
  display: none !important;
}

.weight-entry-list {
  padding: var(--space-2) var(--space-4) 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.weight-list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: var(--gray-900);
  border: 1px solid var(--gray-800);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  min-height: 60px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.weight-list-row:hover {
  border-color: var(--gray-700);
}

.weight-list-row.selected {
  border-color: var(--blue-500);
  background: #0070f310;
}

.weight-list-date {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text);
  font-family: "Geist Mono", monospace;
}

.weight-list-right {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.weight-list-value {
  font-size: 0.875rem;
  color: var(--gray-400);
  font-family: "Geist Mono", monospace;
}

.weight-list-checkbox {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-600);
  flex-shrink: 0;
}

.weight-list-row .checkbox-checked {
  display: none;
}

.weight-list-row.selected .checkbox-empty {
  display: none;
}

.weight-list-row.selected .checkbox-checked {
  display: block;
}

.weight-fab {
  position: fixed;
  bottom: calc(72px + env(safe-area-inset-bottom));
  right: var(--space-5);
  width: 48px;
  height: 48px;
  background: var(--blue-500);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 4px 20px rgba(0, 112, 243, 0.4);
  transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
  z-index: 50;
}

.weight-fab:hover {
  background: var(--blue-600);
  box-shadow: 0 6px 24px rgba(0, 112, 243, 0.5);
  transform: translateY(-1px);
}

.weight-fab:active {
  transform: scale(0.96);
}

.weight-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-5);
  padding: var(--space-16) var(--space-6);
  color: var(--gray-500);
  font-size: 0.9375rem;
  text-align: center;
}

.weight-timeframe-label {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
  font-family: "Geist Mono", monospace;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  transition: color 0.2s ease;
}

.weight-timeframe-label::after {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--blue-500);
  opacity: 0;
  transform: scale(0);
  transition: opacity 0.2s ease, transform 0.2s ease;
  flex-shrink: 0;
}

.weight-timeframe-label--table {
  color: var(--blue-500);
}

.weight-timeframe-label--table::after {
  opacity: 1;
  transform: scale(1);
}

.weight-chart-region {
  transition: opacity 0.3s ease, transform 0.3s ease, max-height 0.35s ease;
  max-height: 400px;
  opacity: 1;
  transform: translateY(0);
  overflow: hidden;
}

.weight-table-region {
  transition: opacity 0.3s ease, transform 0.3s ease, max-height 0.35s ease;
  max-height: 0;
  opacity: 0;
  transform: translateY(-12px);
  overflow: hidden;
  pointer-events: none;
}

.weight-list-region {
  transition: opacity 0.25s ease;
  opacity: 1;
}

[data-view="table"] .weight-chart-region {
  max-height: 0;
  opacity: 0;
  transform: translateY(-8px);
}

[data-view="table"] .weight-table-region {
  max-height: 2000px;
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

[data-view="table"] .weight-list-region {
  opacity: 0;
  pointer-events: none;
}

.weight-table-wrap {
  padding: var(--space-3) var(--space-4) var(--space-4);
}

.weight-table-card {
  border: 1px solid var(--gray-800);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--gray-900);
}

.weight-table {
  width: 100%;
  border-collapse: collapse;
  font-family: "Geist Mono", monospace;
  font-size: 0.75rem;
  table-layout: fixed;
}

.weight-table thead tr {
  border-bottom: 1px solid var(--gray-800);
  background: var(--gray-900);
}

.weight-table th {
  padding: var(--space-3) var(--space-4);
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gray-600);
  white-space: nowrap;
}

.weight-table th.wt-col-week,
.weight-table td.wt-col-week   { width: 40px; text-align: center; }

.weight-table th.wt-col-period,
.weight-table td.wt-col-period { text-align: left; }

.weight-table th.wt-col-avg,
.weight-table td.wt-col-avg    { width: 72px; text-align: right; }

.weight-table th.wt-col-diff,
.weight-table td.wt-col-diff   { width: 64px; text-align: right;
                                  padding-right: var(--space-4); }

.wt-summary-row {
  border-bottom: 1px solid var(--gray-800);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.12s ease;
}

.wt-summary-row:last-of-type,
.wt-summary-row--open {
  border-bottom-color: transparent;
}

.wt-summary-row:hover {
  background: var(--gray-800);
}

.wt-summary-row td.wt-col-week {
  position: relative;
}

.wt-summary-row td.wt-col-week::after {
  content: "";
  display: inline-block;
  width: 0;
  height: 0;
  border-left: 3.5px solid transparent;
  border-right: 3.5px solid transparent;
  border-top: 4.5px solid var(--gray-600);
  vertical-align: middle;
  margin-left: 3px;
  transition: transform 0.22s ease;
}

.wt-summary-row--open td.wt-col-week::after {
  transform: rotate(180deg);
}

.weight-table td {
  padding: var(--space-3) var(--space-4);
  color: var(--gray-500);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.weight-table td.wt-col-week {
  color: var(--gray-600);
  font-size: 0.625rem;
  font-weight: 500;
}

.weight-table td.wt-col-period {
  color: var(--gray-400);
  font-size: 0.6875rem;
}

.weight-table td.wt-col-avg {
  color: var(--text);
  font-weight: 700;
  font-size: 0.8125rem;
}

.weight-table td.wt-col-avg.wt-empty {
  color: var(--gray-700);
  font-weight: 400;
}

.weight-table td.wt-col-diff { font-weight: 700; }

.weight-table td.wt-diff-up      { color: var(--blue-500); }
.weight-table td.wt-diff-down    { color: var(--danger); }
.weight-table td.wt-diff-neutral { color: var(--gray-500); }
.weight-table td.wt-col-diff.wt-empty { color: var(--gray-700); font-weight: 400; }

.wt-detail-row {
  border-bottom: 1px solid var(--gray-800);
}

.wt-detail-row:not(.wt-detail-row--open) {
  border-bottom-color: transparent;
}

.wt-detail-cell {
  padding: 0;
}

.wt-detail-grid {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.26s ease;
}

.wt-detail-row--open .wt-detail-grid {
  grid-template-rows: 1fr;
}

.wt-detail-inner {
  overflow: hidden;
}

.wt-detail-days {
  display: flex;
  padding: var(--space-3) var(--space-3) var(--space-4);
}

.wt-day-pill {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.wt-day-name {
  font-size: 0.5625rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gray-600);
}

.wt-day-value {
  font-size: 0.75rem;
  font-weight: 600;
}

.wt-day-pill--has-value .wt-day-value { color: var(--text); }
.wt-day-pill--empty     .wt-day-value { color: var(--gray-700); }

.period-sheet {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.period-sheet.open {
  opacity: 1;
  pointer-events: auto;
}

.period-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: var(--backdrop);
}

.period-sheet-panel {
  position: relative;
  z-index: 1;
  background: var(--gray-900);
  border-top: 1px solid var(--gray-800);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: var(--space-5) var(--space-4);
  padding-bottom: calc(var(--space-5) + env(safe-area-inset-bottom));
  transform: translateY(16px);
  transition: transform 0.25s ease;
}

.period-sheet.open .period-sheet-panel {
  transform: translateY(0);
}

.period-sheet-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--space-3);
  padding: 0 var(--space-2);
}

.period-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: var(--space-4) var(--space-4);
  min-height: 52px;
  font-size: 1rem;
  font-weight: 500;
  font-family: "Geist Mono", monospace;
  color: var(--gray-200);
  border-radius: var(--radius-md);
  text-decoration: none;
  transition: background 0.1s ease, color 0.1s ease;
}

.period-option:hover {
  background: var(--gray-800);
  color: var(--text);
}

.period-option--active {
  color: var(--blue-500);
  font-weight: 600;
}

.period-option--active::after {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--blue-500);
  flex-shrink: 0;
}
