:root {
  color-scheme: dark;
  font-family:
    -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
    "PingFang SC", "Helvetica Neue", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  --app-height: 100vh;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --ink: #f7f8ff;
  --ink-soft: rgba(233, 237, 251, 0.72);
  --ink-faint: rgba(218, 225, 244, 0.48);
  --page: #0b1020;
  --surface: rgba(21, 29, 49, 0.78);
  --surface-solid: #171f34;
  --surface-light: rgba(255, 255, 255, 0.075);
  --outline: rgba(221, 227, 249, 0.13);
  --outline-strong: rgba(221, 227, 249, 0.22);
  --accent: #e9ebff;
  --accent-ink: #202947;
  --good: #9edcbc;
  --danger: #f1aaa7;
  --warning: #eccb9e;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.3);
  --radius-xl: 30px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --nav-height: 76px;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  min-height: -webkit-fill-available;
  margin: 0;
  overflow: hidden;
  background: #060914;
}

body {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
}

button,
[role="button"] {
  -webkit-user-select: none;
  user-select: none;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid rgba(211, 219, 255, 0.92);
  outline-offset: 3px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.app-frame {
  width: 100%;
  height: var(--app-height, 100vh);
  min-height: -webkit-fill-available;
  display: flex;
  justify-content: center;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 0%, rgba(73, 80, 131, 0.15), transparent 40%),
    #060914;
}

.app-shell {
  position: relative;
  isolation: isolate;
  width: 100%;
  max-width: 480px;
  height: var(--app-height, 100vh);
  min-height: -webkit-fill-available;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  overflow: hidden;
  background: var(--page);
  color: var(--ink);
}

.app-main {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.app-main::-webkit-scrollbar {
  display: none;
}

.page {
  position: relative;
  z-index: 1;
  width: 100%;
  min-width: 0;
  min-height: 100%;
  padding:
    calc(20px + var(--safe-top))
    max(20px, calc(20px + var(--safe-right)))
    28px
    max(20px, calc(20px + var(--safe-left)));
}

.page-header {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.page-kicker {
  margin: 0 0 7px;
  color: var(--ink-faint);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.page-title {
  margin: 0;
  max-width: 310px;
  font-family:
    ui-serif, "New York", "Songti SC", "STSong", Georgia, serif;
  font-size: clamp(27px, 8vw, 34px);
  font-weight: 500;
  line-height: 1.24;
  letter-spacing: -0.035em;
}

.page-subtitle {
  margin: 9px 0 0;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.55;
}

.page-action {
  flex: 0 0 auto;
  min-width: 44px;
  min-height: 44px;
  border: 1px solid var(--outline);
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.055);
  color: var(--ink);
}

.page-action svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.loading-state,
.fatal-state {
  min-height: 100%;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 18px;
  padding: 32px;
  text-align: center;
}

.loading-state p,
.fatal-state p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 13px;
}

.loading-mark {
  width: 58px;
  height: 58px;
  border: 1px solid var(--outline);
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(150deg, #263456, #12192b);
}

.loading-mark span {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #f4d8aa;
  box-shadow: 0 0 24px rgba(244, 216, 170, 0.58);
}

.bottom-nav {
  position: relative;
  z-index: 30;
  width: 100%;
  min-width: 0;
  min-height: calc(var(--nav-height) + var(--safe-bottom));
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: start;
  padding:
    9px max(12px, var(--safe-right))
    max(10px, var(--safe-bottom))
    max(12px, var(--safe-left));
  border-top: 1px solid var(--outline);
  background: rgba(10, 15, 28, 0.94);
  -webkit-backdrop-filter: saturate(145%) blur(22px);
  backdrop-filter: saturate(145%) blur(22px);
}

.nav-item {
  min-width: 0;
  min-height: 55px;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: transparent;
  color: rgba(213, 220, 241, 0.43);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.nav-item.is-active {
  color: #f5f6ff;
  background: rgba(255, 255, 255, 0.055);
}

.nav-icon {
  width: 23px;
  height: 23px;
  display: grid;
  place-items: center;
}

.nav-icon svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
}

.connection-status {
  position: absolute;
  z-index: 35;
  top: calc(10px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  min-height: 30px;
  padding: 7px 12px;
  border: 1px solid rgba(236, 203, 158, 0.25);
  border-radius: 999px;
  background: rgba(32, 28, 29, 0.9);
  color: #f2d5ad;
  font-size: 11px;
  white-space: nowrap;
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}

.connection-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 6px;
  border-radius: 50%;
  background: #efc995;
}

/* Today */
.today-page {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #11172d;
}

.atmosphere {
  position: absolute;
  z-index: -2;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  transition: background 240ms ease;
}

.atmosphere::before,
.atmosphere::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.atmosphere.night {
  background:
    radial-gradient(circle at 84% 19%, rgba(236, 222, 194, 0.18), transparent 20%),
    linear-gradient(180deg, #0e142a 0%, #242b4f 58%, #9d7474 112%);
}

.atmosphere.night::before {
  inset: 0 0 36%;
  opacity: 0.52;
  background-image:
    radial-gradient(circle, rgba(245, 246, 227, 0.86) 0 0.7px, transparent 0.9px),
    radial-gradient(circle, rgba(219, 225, 255, 0.62) 0 0.6px, transparent 0.8px);
  background-position: 5px 8px, 22px 25px;
  background-size: 43px 43px, 57px 57px;
  -webkit-mask-image: linear-gradient(#000 15%, transparent 100%);
  mask-image: linear-gradient(#000 15%, transparent 100%);
}

.atmosphere.night::after {
  width: 74px;
  height: 74px;
  top: 78px;
  right: 40px;
  border-radius: 50%;
  background: #f0efd5;
  box-shadow: 0 0 48px rgba(236, 234, 201, 0.25);
  opacity: 0.92;
}

.atmosphere.morning {
  background:
    radial-gradient(circle at 4% 15%, rgba(255, 241, 194, 0.58), transparent 27%),
    linear-gradient(180deg, #7f96bd 0%, #d6ab92 53%, #eed0a7 100%);
}

.atmosphere.morning::before {
  width: 280px;
  height: 280px;
  top: -95px;
  left: -112px;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(255, 244, 197, 0.94),
    rgba(247, 198, 143, 0.3) 45%,
    transparent 70%
  );
}

.atmosphere.day {
  background:
    radial-gradient(circle at 12% 10%, rgba(254, 229, 177, 0.3), transparent 26%),
    linear-gradient(180deg, #657da8 0%, #a88e8a 58%, #c49a82 100%);
}

.atmosphere.sleeping {
  background:
    radial-gradient(circle at 80% 16%, rgba(214, 218, 239, 0.14), transparent 22%),
    linear-gradient(180deg, #0a1023 0%, #171f3a 70%, #242844 100%);
}

.moon-cut {
  position: absolute;
  z-index: -1;
  top: 68px;
  right: 28px;
  width: 77px;
  height: 77px;
  border-radius: 50%;
  background: #17203c;
  transform: translate(-18px, -8px);
}

.today-header {
  min-height: 126px;
  margin-bottom: 4px;
}

.today-header .page-kicker,
.today-header .page-subtitle {
  color: rgba(244, 239, 242, 0.64);
}

.morning-copy {
  color: #202943;
}

.morning-copy .page-kicker,
.morning-copy .page-subtitle {
  color: rgba(35, 45, 68, 0.64);
}

.orbit-stage {
  position: relative;
  flex: 0 0 auto;
  width: min(72vw, 286px);
  height: min(72vw, 286px);
  margin: 2px auto 0;
  display: grid;
  place-items: center;
}

.orbit-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  padding: 2px;
  background: conic-gradient(
    from 215deg,
    rgba(223, 229, 255, 0.92) 0 94deg,
    rgba(255, 255, 255, 0.11) 94deg 322deg,
    rgba(255, 255, 255, 0.35) 322deg 360deg
  );
  box-shadow: 0 0 55px rgba(157, 170, 231, 0.14);
}

.morning-mode .orbit-ring {
  background: conic-gradient(
    from 215deg,
    rgba(47, 64, 103, 0.9) 0 168deg,
    rgba(48, 61, 91, 0.14) 168deg 360deg
  );
  box-shadow: none;
}

.orbit-ring::before {
  content: "";
  position: absolute;
  inset: 2px;
  border-radius: 50%;
  background: rgba(17, 23, 44, 0.78);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}

.morning-mode .orbit-ring::before {
  background: rgba(240, 216, 184, 0.76);
}

.orbit-ticks {
  position: absolute;
  inset: 20px;
  border: 1px dashed rgba(226, 231, 252, 0.14);
  border-radius: 50%;
}

.morning-mode .orbit-ticks {
  border-color: rgba(46, 59, 88, 0.16);
}

.orbit-marker {
  position: absolute;
  z-index: 2;
  top: 38px;
  right: 40px;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.54);
  border-radius: 50%;
  background: #f3f1dc;
  box-shadow: 0 0 20px rgba(247, 241, 207, 0.65);
}

.morning-mode .orbit-marker {
  border-color: rgba(41, 54, 83, 0.2);
  background: #35496f;
  box-shadow: none;
}

.orbit-label {
  position: absolute;
  z-index: 2;
  color: rgba(231, 235, 250, 0.55);
  font-size: 9px;
  font-weight: 600;
}

.morning-mode .orbit-label {
  color: rgba(46, 59, 87, 0.6);
}

.orbit-label.start {
  top: 74px;
  right: 7px;
}

.orbit-label.end {
  bottom: 31px;
  left: 39px;
}

.orbit-center {
  position: relative;
  z-index: 3;
  width: 72%;
  text-align: center;
}

.orbit-eyebrow {
  display: block;
  margin-bottom: 7px;
  color: rgba(224, 230, 249, 0.55);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.12em;
}

.morning-mode .orbit-eyebrow {
  color: rgba(48, 60, 88, 0.58);
}

.orbit-value {
  display: block;
  margin: 0;
  font-size: clamp(42px, 13vw, 56px);
  font-weight: 640;
  line-height: 1;
  letter-spacing: -0.065em;
}

.morning-mode .orbit-value {
  color: #253451;
}

.orbit-note {
  display: block;
  margin-top: 9px;
  color: rgba(226, 231, 248, 0.6);
  font-size: 10px;
}

.morning-mode .orbit-note {
  color: rgba(47, 60, 88, 0.62);
}

.sleep-chip {
  position: relative;
  z-index: 2;
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  margin: -2px 0 8px;
  padding: 7px 11px;
  border: 1px solid rgba(53, 65, 87, 0.13);
  border-radius: 999px;
  background: rgba(255, 245, 221, 0.38);
  color: rgba(37, 48, 73, 0.68);
  font-size: 10px;
}

.sleep-chip strong {
  color: #293653;
  font-size: 11px;
}

.today-actions {
  position: relative;
  z-index: 3;
  width: 100%;
  margin-top: auto;
  padding-top: 20px;
}

.context-row {
  min-height: 18px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin: 0 2px 12px;
  color: rgba(239, 232, 238, 0.66);
  font-size: 10px;
}

.morning-mode .context-row {
  color: rgba(37, 48, 71, 0.64);
}

.primary-button,
.secondary-button,
.danger-button {
  width: 100%;
  min-height: 52px;
  border-radius: 17px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 700;
  transition:
    transform 160ms ease,
    opacity 160ms ease,
    background 160ms ease;
}

.primary-button:active,
.secondary-button:active,
.danger-button:active {
  transform: scale(0.985);
}

.primary-button {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow:
    inset 0 1px rgba(255, 255, 255, 0.62),
    0 11px 28px rgba(9, 14, 29, 0.2);
}

.morning-mode .primary-button {
  background: #293a5f;
  color: #f7f5ed;
}

.secondary-button {
  border: 1px solid var(--outline);
  background: rgba(255, 255, 255, 0.055);
  color: var(--ink);
}

.danger-button {
  border: 1px solid rgba(241, 170, 167, 0.24);
  background: rgba(241, 170, 167, 0.09);
  color: #f2b7b4;
}

.button-note {
  margin: 9px 0 0;
  color: rgba(238, 231, 237, 0.48);
  font-size: 9px;
  text-align: center;
}

.morning-mode .button-note {
  color: rgba(41, 52, 76, 0.54);
}

.pushup-counter {
  display: grid;
  grid-template-columns: 48px minmax(90px, 1fr) 48px;
  align-items: center;
  gap: 12px;
  margin: 10px auto 4px;
}

.counter-button {
  width: 48px;
  height: 48px;
  border: 1px solid rgba(44, 57, 86, 0.21);
  border-radius: 50%;
  background: rgba(255, 248, 229, 0.24);
  color: #354260;
  font-size: 25px;
  font-weight: 350;
}

.counter-input-wrap {
  min-width: 0;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
}

.counter-input {
  width: 104px;
  border: 0;
  border-bottom: 1px solid transparent;
  background: transparent;
  color: #253250;
  font-size: clamp(58px, 18vw, 76px);
  font-weight: 650;
  line-height: 1;
  letter-spacing: -0.075em;
  text-align: center;
  -moz-appearance: textfield;
}

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

.counter-input:focus {
  border-bottom-color: rgba(37, 50, 80, 0.32);
  outline: 0;
}

.counter-unit {
  color: rgba(43, 56, 83, 0.64);
  font-size: 12px;
}

.completed-value {
  font-size: clamp(76px, 23vw, 96px);
}

.completed-value::after {
  content: "次";
  margin-left: 9px;
  color: rgba(43, 56, 83, 0.64);
  font-size: 14px;
  letter-spacing: 0;
}

.result-line {
  margin-top: 11px;
  color: rgba(41, 53, 79, 0.68);
  font-size: 10px;
}

.result-line strong {
  color: #2a3b5d;
}

.sleep-summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.sleep-summary-card {
  min-width: 0;
  padding: 13px 14px;
  border: 1px solid rgba(47, 59, 83, 0.1);
  border-radius: 16px;
  background: rgba(255, 246, 224, 0.35);
}

.sleep-summary-card span {
  display: block;
  color: rgba(43, 55, 80, 0.56);
  font-size: 9px;
}

.sleep-summary-card strong {
  display: block;
  margin-top: 3px;
  color: #293754;
  font-size: 20px;
  letter-spacing: -0.03em;
}

.sleeping-mark {
  width: 82px;
  height: 82px;
  margin: 7px auto 15px;
  border: 1px solid rgba(225, 231, 249, 0.16);
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.035);
  box-shadow: 0 0 60px rgba(141, 157, 222, 0.12);
}

.sleeping-mark svg {
  width: 40px;
  height: 40px;
  fill: none;
  stroke: rgba(237, 239, 219, 0.84);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.4;
}

/* Records */
.records-page,
.settings-page {
  background:
    radial-gradient(circle at 100% 0%, rgba(81, 90, 142, 0.16), transparent 35%),
    linear-gradient(180deg, #0c1223, #0a101e);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 3px;
  border: 1px solid var(--outline);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
}

.segment {
  min-height: 36px;
  border-radius: 11px;
  background: transparent;
  color: var(--ink-faint);
  font-size: 11px;
  font-weight: 650;
}

.segment.is-active {
  background: rgba(255, 255, 255, 0.1);
  color: var(--ink);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.07);
}

.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 16px 0;
}

.metric-card {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--outline);
  border-radius: 18px;
  background: var(--surface);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}

.metric-card span {
  display: block;
  color: var(--ink-faint);
  font-size: 10px;
}

.metric-card strong {
  display: block;
  margin-top: 5px;
  color: var(--ink);
  font-size: clamp(20px, 6vw, 25px);
  font-weight: 620;
  letter-spacing: -0.035em;
}

.records-table-wrap {
  width: 100%;
  min-width: 0;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  border: 1px solid var(--outline);
  border-radius: 18px;
  background: rgba(17, 24, 41, 0.76);
  -webkit-overflow-scrolling: touch;
}

.records-table {
  width: 100%;
  min-width: 356px;
  border-collapse: collapse;
  table-layout: fixed;
}

.records-table th,
.records-table td {
  overflow: hidden;
  padding: 12px 8px;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.records-table th {
  color: var(--ink-faint);
  font-size: 9px;
  font-weight: 600;
}

.records-table td {
  border-top: 1px solid rgba(221, 227, 249, 0.075);
  color: rgba(239, 242, 253, 0.78);
  font-size: 11px;
}

.records-table th:first-child,
.records-table td:first-child {
  padding-left: 14px;
}

.records-table th:last-child,
.records-table td:last-child {
  padding-right: 14px;
  text-align: right;
}

.record-row {
  cursor: pointer;
}

.record-row:focus-visible {
  outline: 2px solid rgba(211, 219, 255, 0.8);
  outline-offset: -2px;
}

.record-row.is-today {
  background: rgba(166, 178, 236, 0.055);
}

.goal-time {
  color: var(--good) !important;
}

.empty-card {
  min-height: 210px;
  border: 1px solid var(--outline);
  border-radius: 22px;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  padding: 28px;
  background: var(--surface);
  text-align: center;
}

.empty-card svg {
  width: 42px;
  height: 42px;
  fill: none;
  stroke: var(--ink-faint);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.25;
}

.empty-card strong {
  font-size: 15px;
}

.empty-card p {
  max-width: 250px;
  margin: 0;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.6;
}

/* Settings */
.settings-stack {
  display: grid;
  gap: 14px;
}

.settings-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--outline);
  border-radius: 21px;
  background: var(--surface);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}

.settings-card-header {
  padding: 16px 16px 10px;
}

.settings-card-header h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 650;
}

.settings-card-header p {
  margin: 5px 0 0;
  color: var(--ink-faint);
  font-size: 10px;
  line-height: 1.5;
}

.setting-row {
  min-height: 58px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  border-top: 1px solid rgba(221, 227, 249, 0.075);
}

.setting-row label,
.setting-row .setting-label {
  min-width: 0;
  color: rgba(241, 243, 253, 0.86);
  font-size: 12px;
}

.setting-row small {
  display: block;
  margin-top: 3px;
  color: var(--ink-faint);
  font-size: 9px;
  line-height: 1.4;
}

.setting-control {
  min-width: 92px;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--outline);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--ink);
  font-size: 12px;
  text-align: center;
}

.setting-link {
  min-height: 44px;
  padding: 0 4px 0 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  color: #cbd3f5;
  font-size: 12px;
}

.setting-link svg,
.primary-button svg,
.secondary-button svg,
.danger-button svg,
.fatal-state svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
}

.setting-link.danger {
  color: #f0aaa7;
}

.settings-footnote {
  margin: 8px 4px 0;
  color: var(--ink-faint);
  font-size: 9px;
  line-height: 1.55;
  text-align: center;
}

/* Sheet and toast */
.sheet-root {
  position: absolute;
  z-index: 60;
  inset: 0;
  pointer-events: none;
}

.sheet-root.is-open {
  pointer-events: auto;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 7, 14, 0.56);
  opacity: 0;
  transition: opacity 190ms ease;
}

.sheet-root.is-open .sheet-backdrop {
  opacity: 1;
}

.sheet-panel {
  position: absolute;
  right: max(8px, var(--safe-right));
  bottom: max(8px, var(--safe-bottom));
  left: max(8px, var(--safe-left));
  max-height: calc(var(--app-height, 100vh) - var(--safe-top) - 20px);
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--outline-strong);
  border-radius: 28px;
  background: rgba(21, 29, 49, 0.97);
  color: var(--ink);
  box-shadow: var(--shadow);
  transform: translateY(calc(100% + 20px));
  transition: transform 230ms cubic-bezier(0.22, 0.9, 0.3, 1);
  -webkit-backdrop-filter: saturate(135%) blur(28px);
  backdrop-filter: saturate(135%) blur(28px);
  -webkit-overflow-scrolling: touch;
}

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

.sheet-grabber {
  width: 38px;
  height: 5px;
  margin: 9px auto 2px;
  border-radius: 999px;
  background: rgba(219, 226, 247, 0.2);
}

.sheet-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  align-items: start;
  gap: 10px;
  padding: 17px 20px 9px;
}

.sheet-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.025em;
}

.sheet-header p {
  margin: 6px 0 0;
  color: var(--ink-soft);
  font-size: 11px;
  line-height: 1.5;
}

.sheet-close {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.07);
  color: var(--ink-soft);
  font-size: 20px;
}

.sheet-form {
  display: grid;
  gap: 13px;
  padding: 10px 20px calc(20px + var(--safe-bottom));
}

.form-grid {
  display: grid;
  grid-template-columns: 1.25fr 0.75fr;
  gap: 10px;
}

.field {
  min-width: 0;
  display: grid;
  gap: 7px;
}

.field > span {
  color: var(--ink-faint);
  font-size: 10px;
  font-weight: 600;
}

.field input,
.field select {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  padding: 11px 12px;
  border: 1px solid var(--outline);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--ink);
  font-size: 14px;
  color-scheme: dark;
}

.form-error {
  min-height: 17px;
  margin: 0;
  color: #f1aaa7;
  font-size: 11px;
  line-height: 1.45;
}

.sheet-actions {
  display: grid;
  grid-template-columns: 0.85fr 1.6fr;
  gap: 9px;
}

.sheet-actions.single {
  grid-template-columns: 1fr;
}

.sheet-actions .secondary-button,
.sheet-actions .primary-button,
.sheet-actions .danger-button {
  min-height: 48px;
  border-radius: 15px;
}

.toast-root {
  position: absolute;
  z-index: 80;
  right: 14px;
  bottom: calc(var(--nav-height) + var(--safe-bottom) + 12px);
  left: 14px;
  display: grid;
  justify-items: center;
  pointer-events: none;
}

.toast {
  max-width: 340px;
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border: 1px solid var(--outline-strong);
  border-radius: 14px;
  background: rgba(20, 28, 47, 0.96);
  color: #f3f5ff;
  box-shadow: 0 14px 35px rgba(0, 0, 0, 0.3);
  font-size: 11px;
  opacity: 0;
  transform: translateY(8px);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  border-color: rgba(241, 170, 167, 0.25);
}

.toast-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--good);
}

.toast.error .toast-dot {
  background: var(--danger);
}

@media (min-width: 560px) and (min-height: 720px) {
  .app-frame {
    padding: 18px;
  }

  .app-shell {
    height: calc(var(--app-height, 100vh) - 36px);
    border: 1px solid rgba(226, 231, 250, 0.12);
    border-radius: 34px;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.4);
  }
}

@media (max-height: 690px) {
  .page {
    padding-top: calc(14px + var(--safe-top));
    padding-bottom: 18px;
  }

  .today-header {
    min-height: 92px;
  }

  .page-title {
    font-size: 25px;
  }

  .page-subtitle {
    margin-top: 5px;
  }

  .orbit-stage {
    width: min(58vw, 220px);
    height: min(58vw, 220px);
  }

  .orbit-ring::before {
    inset: 2px;
  }

  .orbit-ticks {
    inset: 15px;
  }

  .orbit-marker {
    top: 28px;
    right: 29px;
  }

  .orbit-label {
    display: none;
  }

  .orbit-value {
    font-size: 43px;
  }

  .today-actions {
    padding-top: 14px;
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  .app-shell {
    max-width: 844px;
    grid-template-columns: minmax(0, 1fr) 78px;
    grid-template-rows: minmax(0, 1fr);
  }

  .bottom-nav {
    grid-column: 2;
    grid-row: 1;
    grid-template-columns: 1fr;
    grid-template-rows: repeat(3, 1fr);
    min-height: 0;
    padding:
      max(10px, var(--safe-top)) max(8px, var(--safe-right))
      max(10px, var(--safe-bottom)) 8px;
    border-top: 0;
    border-left: 1px solid var(--outline);
  }

  .app-main {
    grid-column: 1;
    grid-row: 1;
  }

  .page {
    min-height: 100%;
  }

  .today-page {
    display: grid;
    grid-template-columns: minmax(250px, 0.9fr) minmax(260px, 1.1fr);
    align-items: center;
    gap: 18px;
  }

  .today-header {
    min-height: 0;
    margin: 0;
  }

  .orbit-stage {
    position: absolute;
    right: 42px;
    width: 250px;
    height: 250px;
  }

  .today-actions {
    grid-column: 1;
    max-width: 300px;
    margin-top: 10px;
  }

  .sleep-chip {
    grid-column: 1;
  }

  .sheet-panel {
    right: calc(86px + var(--safe-right));
    left: auto;
    width: min(420px, calc(100% - 110px));
  }

  .toast-root {
    right: calc(92px + var(--safe-right));
    bottom: calc(14px + var(--safe-bottom));
  }
}

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

@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .bottom-nav,
  .sheet-panel,
  .metric-card,
  .settings-card,
  .orbit-ring::before,
  .toast {
    background: var(--surface-solid);
  }
}
