:root {
  color-scheme: light;
  --bg: #f2f2f7;
  --group: #ffffff;
  --separator: #d7d7dc;
  --text: #1c1c1e;
  --muted: #6e6e73;
  --blue: #007aff;
  --green: #34c759;
  --orange: #ff9500;
  --red: #ff3b30;
  --purple: #af52de;
  --teal: #30b0c7;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
}

body {
  overflow: hidden;
  touch-action: manipulation;
  user-select: none;
}

button,
input,
textarea {
  font: inherit;
}

.phone-shell {
  position: relative;
  width: 100vw;
  height: 100dvh;
  min-height: 640px;
  background: var(--bg);
  overflow: hidden;
}

.page {
  position: absolute;
  inset: 0;
  padding-top: var(--safe-top);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--bg);
}

.settings-page {
  padding-top: calc(var(--safe-top) + 66px);
}

.page.with-nav {
  padding-top: calc(44px + var(--safe-top));
}

.nav,
.settings-nav {
  position: fixed;
  inset: var(--safe-top) 0 auto 0;
  z-index: 22;
  height: 44px;
  display: grid;
  grid-template-columns: 96px 1fr 96px;
  align-items: center;
  padding: 0 10px;
  background: rgba(242, 242, 247, 0.92);
  backdrop-filter: blur(22px);
}

.settings-nav {
  height: calc(54px + var(--safe-top));
  padding-top: var(--safe-top);
  inset: 0 0 auto 0;
  background: rgba(242, 242, 247, 0);
}

.nav-title {
  overflow: hidden;
  text-align: center;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 17px;
  font-weight: 600;
  opacity: 0;
}

.nav.scrolled,
.settings-nav.scrolled {
  border-bottom: 0.5px solid rgba(60, 60, 67, 0.22);
  background: rgba(247, 247, 250, 0.94);
}

.nav.scrolled .nav-title,
.settings-nav.scrolled .nav-title {
  opacity: 1;
}

.back-btn,
.plain-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--blue);
  padding: 7px 3px;
  text-align: left;
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  font-size: 17px;
}

.chevron-left {
  width: 12px;
  height: 12px;
  border-left: 2.25px solid currentColor;
  border-bottom: 2.25px solid currentColor;
  transform: rotate(45deg);
}

.content {
  padding: 0 16px calc(34px + var(--safe-bottom));
}

.large-title {
  margin: 0 0 22px;
  padding: 0 1px;
  font-size: 38px;
  line-height: 45px;
  font-weight: 700;
  letter-spacing: 0;
}

.page.with-nav .large-title {
  margin-top: 22px;
  margin-bottom: 12px;
  font-size: 34px;
  line-height: 41px;
}

.group {
  margin: 0 0 34px;
  background: var(--group);
  border-radius: 10px;
  overflow: hidden;
}

.single-group {
  margin-bottom: 34px;
}

.cell {
  width: 100%;
  min-height: 54px;
  appearance: none;
  border: 0;
  background: var(--group);
  display: grid;
  grid-template-columns: 29px 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 0 12px 0 14px;
  color: var(--text);
  text-align: left;
}

.cell.no-icon {
  grid-template-columns: 1fr auto;
  padding-left: 16px;
}

.cell + .cell .cell-label,
.cell + .cell .value-wrap,
.cell + .cell .detail-wrap {
  border-top: 0.5px solid var(--separator);
}

.cell-label,
.value-wrap,
.detail-wrap {
  min-height: 54px;
  display: flex;
  align-items: center;
}

.cell-label {
  min-width: 0;
  font-size: 20px;
  line-height: 24px;
}

.cell-label span {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.value-wrap {
  position: relative;
  color: #8e8e93;
  font-size: 19px;
  justify-content: flex-end;
  gap: 8px;
  white-space: nowrap;
}

.chevron {
  width: 10px;
  height: 10px;
  border-right: 2.4px solid #c7c7cc;
  border-top: 2.4px solid #c7c7cc;
  transform: rotate(45deg);
}

.icon {
  width: 29px;
  height: 29px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 17px;
  font-weight: 600;
  flex: 0 0 29px;
}

.icon svg {
  width: 24px;
  height: 24px;
}

.icon.orange { background: #ff9500; }
.icon.blue { background: #007aff; }
.icon.green { background: #34c759; }
.icon.red { background: #ff3b30; }
.icon.pink { background: #ff2d55; }
.icon.purple { background: #af52de; }
.icon.indigo { background: #5856d6; }
.icon.gray { background: #8e8e93; }
.icon.black { background: #1c1c1e; }
.icon.cyan { background: #30b0c7; }

.image-icon.siri {
  background:
    radial-gradient(circle at 65% 30%, rgba(255,255,255,.85), transparent 12%),
    radial-gradient(circle at 35% 70%, #00e5ff, transparent 23%),
    radial-gradient(circle at 65% 68%, #ff2d55, transparent 24%),
    radial-gradient(circle at 40% 35%, #34c759, transparent 24%),
    radial-gradient(circle at 52% 52%, #ffffff, transparent 16%),
    #111;
}

.image-icon.game {
  background:
    radial-gradient(circle at 35% 35%, #ff3b30 0 16%, transparent 17%),
    radial-gradient(circle at 60% 34%, #ffcc00 0 16%, transparent 17%),
    radial-gradient(circle at 45% 58%, #34c759 0 17%, transparent 18%),
    radial-gradient(circle at 67% 60%, #007aff 0 16%, transparent 17%),
    radial-gradient(circle at 30% 67%, #af52de 0 17%, transparent 18%),
    #fff;
  border: 0.5px solid #e0e0e4;
}

.image-icon.icloud {
  background: #fff;
  border: 0.5px solid #e0e0e4;
}

.image-icon.icloud::before {
  content: "";
  width: 23px;
  height: 15px;
  display: block;
  background:
    radial-gradient(circle at 37% 60%, #72d4ff 0 42%, transparent 43%),
    radial-gradient(circle at 55% 44%, #2aa8ff 0 45%, transparent 46%),
    radial-gradient(circle at 70% 63%, #0087ff 0 38%, transparent 39%);
  border-radius: 12px;
}

.badge {
  min-width: 26px;
  height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: #ff3b30;
  color: #fff;
  font-size: 18px;
  line-height: 26px;
  font-weight: 600;
}

.has-switch .value-wrap::before {
  content: "";
  width: 51px;
  height: 31px;
  border-radius: 999px;
  background: #e9e9ea;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.04);
}

.has-switch .value-wrap::after {
  content: "";
  position: absolute;
  width: 27px;
  height: 27px;
  right: 39px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.2);
}

.profile {
  min-height: 94px;
  grid-template-columns: 56px 1fr auto;
  padding-top: 14px;
  padding-bottom: 14px;
}

.avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(180deg, #d7d7dc, #8e8e93);
  font-size: 30px;
  font-weight: 600;
}

.profile .cell-label {
  min-height: 56px;
  display: block;
  padding-top: 3px;
}

.profile-name {
  display: block;
  font-size: 21px;
  line-height: 26px;
  font-weight: 600;
}

.profile-subtitle {
  display: block;
  color: var(--muted);
  font-size: 17px;
  line-height: 22px;
  white-space: normal;
}

.account-suggestion {
  min-height: 53px;
}

.hero-card {
  margin: 0 0 28px;
  padding: 19px 17px 18px;
  background: var(--group);
  border-radius: 10px;
}

.hero-subtitle {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 18px;
}

.hero-time {
  margin: 0;
  font-size: 34px;
  line-height: 40px;
  font-weight: 700;
  letter-spacing: 0;
}

.hero-note {
  margin: 7px 0 17px;
  color: var(--muted);
  font-size: 13px;
  line-height: 18px;
}

.chart {
  height: 156px;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 9px;
  align-items: end;
  padding-top: 8px;
}

.bar-day {
  min-width: 0;
}

.bar-stack {
  height: 116px;
  display: flex;
  flex-direction: column-reverse;
  justify-content: flex-start;
  gap: 2px;
}

.bar-piece {
  border-radius: 3px 3px 1px 1px;
  min-height: 2px;
}

.bar-label {
  margin-top: 9px;
  color: #8e8e93;
  text-align: center;
  font-size: 11px;
  line-height: 12px;
}

.legend {
  display: flex;
  gap: 16px;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.section-title {
  margin: -14px 16px 7px;
  color: #6e6e73;
  font-size: 13px;
  line-height: 18px;
  text-transform: uppercase;
}

.screen-cell {
  grid-template-columns: 1fr auto;
  padding-left: 16px;
}

.screen-cell .cell-label {
  display: block;
  padding: 9px 0;
}

.cell-title {
  display: block;
  font-size: 17px;
  line-height: 22px;
}

.cell-subtitle {
  display: block;
  color: var(--muted);
  font-size: 13px;
  line-height: 18px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 28px;
}

.metric {
  min-height: 93px;
  padding: 12px 14px;
  background: var(--group);
  border-radius: 10px;
}

.metric-label {
  color: var(--muted);
  font-size: 13px;
  line-height: 18px;
}

.metric-value {
  margin-top: 6px;
  font-size: 30px;
  line-height: 36px;
  font-weight: 700;
}

.metric-foot {
  color: var(--muted);
  font-size: 12px;
  line-height: 16px;
}

.app-row {
  min-height: 54px;
  grid-template-columns: 32px 1fr auto;
}

.app-icon {
  width: 32px;
  height: 32px;
  border-radius: 7px;
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 15px;
  font-weight: 700;
}

.app-name {
  display: block;
  font-size: 16px;
  line-height: 22px;
}

.app-category {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 16px;
}

.usage-value {
  color: var(--muted);
  font-size: 15px;
}

.activity-list {
  background: var(--group);
  border-radius: 10px;
  overflow: hidden;
}

.activity-row {
  display: grid;
  grid-template-columns: 32px 1fr 68px;
  gap: 11px;
  align-items: center;
  min-height: 58px;
  padding: 6px 12px 6px 16px;
}

.activity-row + .activity-row .activity-main,
.activity-row + .activity-row .activity-time {
  border-top: 0.5px solid var(--separator);
}

.activity-main,
.activity-time {
  min-height: 58px;
  display: flex;
  align-items: center;
}

.activity-main {
  min-width: 0;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
}

.mini-track {
  height: 5px;
  margin-top: 6px;
  background: #ececf1;
  border-radius: 999px;
  overflow: hidden;
}

.mini-fill {
  height: 100%;
  border-radius: inherit;
}

.activity-time {
  justify-content: flex-end;
  color: var(--muted);
  font-size: 15px;
}

.admin-page {
  padding: calc(58px + var(--safe-top)) 16px calc(30px + var(--safe-bottom));
  min-height: 100dvh;
  overflow: auto;
}

.admin-title {
  margin: 0 0 12px;
  font-size: 28px;
  line-height: 34px;
}

.admin-hint {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 14px;
  line-height: 20px;
}

.form-card {
  margin-bottom: 16px;
  padding: 14px;
  background: #fff;
  border-radius: 10px;
}

.form-card h2 {
  margin: 0 0 11px;
  font-size: 17px;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 11px;
}

.field label {
  color: var(--muted);
  font-size: 13px;
}

.field input,
.field textarea {
  width: 100%;
  border: 0.5px solid #c6c6cc;
  border-radius: 8px;
  padding: 10px 11px;
  background: #fff;
  color: var(--text);
  font-size: 16px;
  user-select: text;
}

.field textarea {
  min-height: 132px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 18px;
}

.admin-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.action-btn {
  appearance: none;
  border: 0;
  border-radius: 10px;
  min-height: 44px;
  background: var(--blue);
  color: #fff;
  font-size: 17px;
  font-weight: 600;
}

.action-btn.secondary {
  background: #e4e4ea;
  color: var(--blue);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(26px + var(--safe-bottom));
  z-index: 50;
  transform: translateX(-50%);
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(28, 28, 30, 0.88);
  color: #fff;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.toast.show {
  opacity: 1;
}

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

  .phone-shell {
    width: 390px;
    height: 844px;
    min-height: 844px;
    border-radius: 46px;
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.38);
  }

  .status-bar,
  .nav {
    position: absolute;
  }
}
