:root {
  --bg: #f2f2f7;
  --card: #ffffff;
  --ink: #1c1c1e;
  --muted: rgba(60, 60, 67, 0.6);
  --faint: rgba(60, 60, 67, 0.36);
  --blue: #007aff;
  --blue-press: #0063d1;
  --green: #34c759;
  --green-soft: rgba(52, 199, 89, 0.12);
  --red: #ff3b30;
  --sep: rgba(60, 60, 67, 0.12);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.06);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    "Helvetica Neue", Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

body {
  min-height: 100dvh;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
}

.hidden {
  display: none !important;
}

.app {
  position: relative;
  min-height: 100dvh;
  max-width: 430px;
  margin: 0 auto;
  padding: calc(8px + var(--safe-top)) 20px calc(20px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
}

.brand-word {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: var(--blue);
  display: grid;
  place-items: center;
}

.icon-btn:active {
  background: rgba(0, 122, 255, 0.1);
}

.screen {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.auth-hero {
  width: 100%;
  margin-top: 48px;
}

.auth-hero h1 {
  font-size: 40px;
  font-weight: 700;
  letter-spacing: -0.04em;
}

.auth-hero p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.4;
}

.auth-form {
  width: 100%;
  margin-top: 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.auth-form input {
  width: 100%;
  min-height: 52px;
  padding: 0 14px;
  border: 0;
  border-radius: 14px;
  background: var(--card);
  box-shadow: var(--shadow);
  color: var(--ink);
  font: inherit;
  font-size: 17px;
}

.auth-form input:focus {
  outline: 2px solid rgba(0, 122, 255, 0.35);
}

.auth-error {
  color: var(--red);
  font-size: 14px;
}

.kicker {
  margin-top: 36px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 500;
}

.orb {
  width: 220px;
  height: 220px;
  margin: 48px 0 36px;
  border-radius: 50%;
}

.orb-core {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: #fff;
  background: var(--blue);
  box-shadow: 0 10px 28px rgba(0, 122, 255, 0.28);
}

.orb:active .orb-core {
  background: var(--blue-press);
  transform: scale(0.98);
}

.orb-title {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.orb-sub {
  font-size: 13px;
  font-weight: 500;
  opacity: 0.8;
}

.home-stats {
  width: 100%;
  margin-top: auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.stat,
.hero-card,
.tile,
.panel {
  width: 100%;
  background: var(--card);
  border-radius: 16px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.stat .lbl,
.hero-card .lbl,
.tile .lbl,
.panel-head span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.stat .val,
.tile .val,
.hero-card .val {
  margin-top: 6px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.timer-block {
  flex: 1;
  display: grid;
  place-items: center;
  text-align: center;
}

.timer {
  text-align: center;
}

.timer-main {
  font-size: clamp(36px, 11vw, 60px);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 0.95;
  font-variant-numeric: tabular-nums;
}

.timer-sub {
  margin-top: 8px;
  color: var(--muted);
  font-size: 22px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.timer-note {
  margin-top: 14px;
  max-width: 240px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.35;
}

.mood-card {
  width: 100%;
  margin: 8px 0 14px;
  padding: 14px 12px 12px;
  background: var(--card);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.mood-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  margin-bottom: 10px;
}

.moods {
  display: flex;
  justify-content: space-between;
  gap: 6px;
}

.mood-btn {
  flex: 1;
  min-height: 64px;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: #f2f2f7;
}

.mood-btn span:first-child {
  font-size: 24px;
  line-height: 1;
}

.mood-btn span:last-child {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
}

.mood-btn:active,
.mood-btn.pick {
  background: var(--blue);
}

.mood-btn:active span:last-child,
.mood-btn.pick span:last-child {
  color: #fff;
}

.mood-last {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
}

.mood-last.hidden {
  display: none;
}

.mood-last .text {
  font-size: 15px;
  font-weight: 600;
}

.mood-last .fix {
  color: var(--blue);
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
}

.mood-live {
  margin-top: 10px;
}

.mood-spark {
  display: block;
  width: 100%;
  height: 44px;
}

.mood-log {
  list-style: none;
}

.mood-log li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 0;
  border-top: 0.5px solid var(--sep);
  cursor: pointer;
}

.mood-log li:first-child {
  border-top: 0;
}

.mood-log .left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mood-log .emoji {
  font-size: 22px;
}

.mood-log .name {
  font-size: 16px;
  font-weight: 600;
}

.mood-log .when {
  color: var(--muted);
  font-size: 13px;
}

.history li {
  cursor: pointer;
}

.actions {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn {
  width: 100%;
  min-height: 52px;
  border-radius: 14px;
  font-size: 17px;
  font-weight: 600;
}

.btn-paper {
  background: var(--blue);
  color: #fff;
}

.btn-paper:active {
  background: var(--blue-press);
}

.btn-danger {
  background: var(--red);
  color: #fff;
}

.btn-ghost {
  background: rgba(60, 60, 67, 0.08);
  color: var(--ink);
}

.text-btn {
  min-height: 44px;
  color: var(--blue);
  font-size: 17px;
}

.text-btn.danger {
  margin: 4px 0 16px;
  color: var(--red);
}

#stats-screen {
  align-items: stretch;
  gap: 12px;
  padding-top: 12px;
}

.stats-intro h1 {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.stats-intro p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.4;
}

.hero-card .val {
  font-size: 34px;
}

.hero-card .sub {
  margin-top: 8px;
  color: var(--green);
  font-size: 15px;
  font-weight: 500;
}

.tiles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 14px;
}

.panel h2,
.panel-head h2 {
  font-size: 17px;
  font-weight: 600;
}

.chart-wrap {
  width: 100%;
}

.line-chart {
  display: block;
  width: 100%;
  height: 168px;
}

.chart-dot {
  cursor: pointer;
}

.line-chart .axis {
  fill: rgba(60, 60, 67, 0.45);
  font-size: 10px;
  font-family: var(--font);
}

.day-chart {
  height: 132px;
  display: flex;
  align-items: flex-end;
  gap: 3px;
}

.day-col {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.day-bar {
  width: 100%;
  border-radius: 4px 4px 1px 1px;
  background: rgba(60, 60, 67, 0.12);
}

.day-bar.on {
  background: var(--blue);
}

.day-col span {
  color: var(--muted);
  font-size: 8px;
  transform: rotate(-55deg);
  transform-origin: center;
  white-space: nowrap;
  height: 18px;
}

.sheet {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: flex-end;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.32);
}

.sheet-card {
  position: relative;
  width: 100%;
  padding: 22px 20px calc(16px + var(--safe-bottom));
  background: var(--card);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.12);
}

.sheet-card h3 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.sheet-card p {
  margin: 8px 0 18px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.4;
}

.sheet-card .btn + .btn {
  margin-top: 8px;
}

#mood-sheet .moods {
  margin-bottom: 16px;
}

.edit-hint {
  margin: 8px 0 14px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
}

.edit-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.edit-field input {
  width: 100%;
  min-height: 48px;
  padding: 0 12px;
  border: 0;
  border-radius: 12px;
  background: #f2f2f7;
  color: var(--ink);
  font: inherit;
  font-size: 17px;
}

.edit-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.edit-preview {
  margin: 4px 0 14px;
  font-size: 17px;
  font-weight: 600;
}

.chart-empty,
.history-empty {
  color: var(--muted);
  font-size: 15px;
  padding: 6px 0;
}

.history {
  list-style: none;
}

.history li {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 12px 0;
  border-top: 0.5px solid var(--sep);
}

.history li:first-child {
  border-top: 0;
}

.history .dur {
  font-size: 17px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.history .when {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

.history .tag {
  font-size: 13px;
  color: var(--muted);
}

.history .tag.ok {
  color: #248a3d;
}

.del-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: var(--faint);
  font-size: 20px;
}

.toast {
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: calc(18px + var(--safe-bottom));
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(28, 28, 30, 0.92);
  color: #fff;
  font-size: 15px;
  font-weight: 500;
  backdrop-filter: blur(20px);
}

.install {
  width: 100%;
  margin-top: 12px;
  padding: 14px 16px 8px;
  border-radius: 16px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.install p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.install-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.install .text-btn {
  padding: 0 8px;
  white-space: nowrap;
}

@media (max-height: 720px) {
  .kicker {
    margin-top: 16px;
  }

  .orb {
    width: 176px;
    height: 176px;
    margin: 24px 0 20px;
  }

  .orb-title {
    font-size: 19px;
  }
}

@media (min-width: 480px) {
  body {
    display: grid;
    place-items: center;
    background: #e5e5ea;
  }

  .app {
    min-height: min(100dvh, 860px);
    border-radius: 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.12);
  }
}
