﻿:root {
  --bg: #fdf6f4;
  --card: rgba(255, 255, 255, 0.86);
  --ink: #24202a;
  --muted: #7d7686;
  --line: rgba(36, 32, 42, 0.09);
  --pink: #ec678a;
  --pink-soft: #ffe3ea;
  --mint: #4fbf9f;
  --orange: #f3a35c;
  --danger: #e2576d;
  --shadow: 0 18px 44px rgba(90, 54, 72, 0.12);
  --radius: 22px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 800px at 10% -10%, #ffe9ee 0%, transparent 55%),
    radial-gradient(900px 700px at 110% 10%, #e7f8f1 0%, transparent 50%),
    linear-gradient(160deg, #fffaf7 0%, #f7f4ff 100%);
  min-height: 100vh;
}

.app {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 18px 16px 40px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 4px 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.account-wrap {
  position: relative;
  margin-left: auto;
  margin-right: 8px;
}

.account-chip {
  max-width: 220px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 5px 10px;
  border: 0;
  border-radius: 999px;
  background: #fdeaf1;
  color: #b24a5f;
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.account-chip::after {
  content: "▾";
  font-size: 10px;
  line-height: 1;
  opacity: 0.7;
}

.account-chip[aria-expanded="true"]::after {
  transform: rotate(180deg);
}

.account-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 50;
  min-width: 150px;
  padding: 4px;
  border: 0;
  border-radius: 10px;
  background: #fdeaf1;
  box-shadow: none;
}

.account-menu-item {
  display: block;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #b24a5f;
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.account-menu-item + .account-menu-item {
  margin-top: 2px;
}

.account-menu-item:hover {
  background: #fbdce7;
}

.account-menu-item.danger {
  color: #c23452;
}

.brand-mark {
  display: block;
  width: 34px;
  height: 34px;
  object-fit: contain;
  border-radius: 10px;
  box-shadow: 0 8px 20px rgba(236, 103, 138, 0.28);
}

.brand-name {
  font-weight: 800;
  letter-spacing: 0.3px;
}

.brand-badge {
  font-size: 11px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 8px;
}

main {
  display: grid;
  gap: 14px;
}

.card {
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  backdrop-filter: blur(14px);
}

.card.hero {
  background: linear-gradient(135deg, #fff1e8 0%, #ffe5ef 45%, #eee6ff 100%);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  letter-spacing: -0.4px;
}

h2 {
  font-size: 17px;
}

h3 {
  font-size: 14px;
}

.sub {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  margin-top: 4px;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.stack {
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  font-size: 12px;
  color: var(--muted);
}

.password-wrap {
  position: relative;
  display: block;
}

.password-wrap input {
  padding-right: 46px;
}

.password-eye {
  position: absolute;
  top: 50%;
  right: 6px;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  box-shadow: none;
  color: var(--muted);
  transform: translateY(-50%);
  cursor: pointer;
}

.password-eye:hover {
  color: var(--ink);
  background: rgba(68, 38, 58, 0.06);
}

.password-eye svg {
  width: 18px;
  height: 18px;
}

.password-eye .eye-off,
.password-eye.is-visible .eye-open {
  display: none;
}

.password-eye.is-visible .eye-off {
  display: block;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  border-radius: 14px;
  padding: 13px 14px;
  font-size: 16px;
  outline: none;
}

textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  border-radius: 14px;
  padding: 11px 12px;
  font: inherit;
  font-size: 14px;
  outline: none;
  resize: vertical;
}

textarea:focus,
select:focus,
input:focus {
  border-color: rgba(236, 103, 138, 0.55);
  box-shadow: 0 0 0 4px rgba(236, 103, 138, 0.12);
}

.grid2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.grid2 label,
.stack > label {
  display: grid;
  gap: 5px;
  font-size: 11px;
  color: var(--muted);
}

.checkline {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--ink);
  margin-top: 10px;
}

.checkline input {
  width: auto;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 28px;
  flex: 0 0 auto;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}

.switch i {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #d9d5de;
  transition: background 0.18s ease;
  pointer-events: none;
}

.switch i::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 2px 7px rgba(36, 32, 42, 0.22);
  transition: transform 0.18s ease;
}

.switch input:checked + i {
  background: linear-gradient(135deg, #f27c9c, #e2577d);
}

.switch input:checked + i::after {
  transform: translateX(20px);
}

.bedtime-fields {
  transition: opacity 0.18s ease, filter 0.18s ease;
}

.bedtime-fields.disabled {
  opacity: 0.4;
  filter: grayscale(0.2);
  pointer-events: none;
}

.play-start-fields {
  transition: opacity 0.18s ease, filter 0.18s ease;
}

.play-start-fields.disabled {
  opacity: 0.4;
  filter: grayscale(0.2);
  pointer-events: none;
}

.play-start-fields > label {
  grid-column: 1 / 2;
}

.rules-dirty-note {
  display: inline-flex;
  align-self: flex-start;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(194, 74, 108, 0.12);
  color: #a33758;
  font-size: 11px;
  font-weight: 700;
}

.time-settings {
  position: relative;
  overflow: hidden;
}

.time-settings::after {
  content: "";
  position: absolute;
  left: -18px;
  bottom: -20px;
  width: 170px;
  height: 150px;
  background: url("/assets/kids/bedtime-bunny.png") center / contain no-repeat;
  opacity: 0.09;
  pointer-events: none;
}

.time-settings > * {
  position: relative;
  z-index: 1;
}

.segmented {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 14px;
  background: rgba(236, 103, 138, 0.08);
  border: 1px solid rgba(236, 103, 138, 0.16);
}

.seg-btn {
  flex: 1;
  padding: 9px 8px;
  border-radius: 11px;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
  font-size: 12px;
  font-weight: 700;
  transition: color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.seg-btn:hover {
  color: var(--ink);
}

.seg-btn.active {
  color: #ffffff;
  background: linear-gradient(135deg, var(--pink), #f28ba3);
  box-shadow: 0 8px 18px rgba(236, 103, 138, 0.32);
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.time-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 13px 15px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  color: var(--ink);
  box-shadow: none;
}

.time-pill .time-value {
  font-size: 21px;
  font-weight: 800;
  letter-spacing: 1px;
}

.time-pill .time-hint {
  font-size: 9.5px;
  color: var(--muted);
  font-weight: 500;
}

.limit-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-top: 4px;
}

.alloc-row {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  margin-top: 10px;
}

.device-select-label {
  display: block;
  margin-top: 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.device-select-label select {
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
}

#device-allocations .tp-select-selected .tp-select-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}

#device-allocations .tp-select-selected .tp-select-icon svg {
  width: 15px;
  height: 15px;
}

.device-panel h3 {
  margin: 2px 0 8px;
  font-size: 14px;
}

.device-panel .switch-row {
  margin-top: 10px;
}

.device-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.device-tab {
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.device-tab.active {
  background: #fdeaf1;
  border-color: #f6ccd8;
  color: #b24a5f;
}

.device-panel {
  display: none;
  margin-top: 12px;
}

.device-panel.active {
  display: block;
}

.alloc-name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  margin-bottom: 8px;
}

.limit-list {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.limit-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
}

.limit-app {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-avatar {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  border-radius: 8px;
  object-fit: cover;
  background: rgba(68, 38, 58, 0.06);
}

.app-avatar.placeholder {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, #ffb08a, #ec678a);
}

.limit-app-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stepper {
  display: flex;
  align-items: center;
  gap: 6px;
}

.stepper button {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 999px;
  background: var(--pink-soft);
  color: var(--pink);
  box-shadow: none;
  font-size: 14px;
}

.stepper span {
  min-width: 56px;
  text-align: center;
  font-size: 11px;
}

.limit-remove {
  padding: 6px;
  background: transparent;
  color: var(--danger);
  box-shadow: none;
  font-size: 10px;
}

.limit-add {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.limit-add select {
  flex: 1;
}

.limit-add button {
  width: auto;
  flex: 0 0 auto;
  padding: 10px 16px;
}

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(20, 16, 24, 0.42);
  backdrop-filter: blur(8px);
}

.sheet {
  width: min(380px, calc(100vw - 32px));
  max-height: 86vh;
  overflow: auto;
  padding: 16px;
  border-radius: 20px;
  background: #ffffff;
  box-shadow: 0 24px 80px rgba(36, 32, 42, 0.28);
  animation: dialog-in 0.18s ease;
}

@keyframes dialog-in {
  from {
    transform: scale(0.96);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sheet-time {
  margin: 8px 0 2px;
  text-align: center;
  font-size: 28px;
  font-weight: 900;
  letter-spacing: 2px;
}

.wheels {
  position: relative;
  display: flex;
  gap: 10px;
  height: 176px;
  justify-content: center;
}

.wheels::after {
  content: "";
  position: absolute;
  left: 10%;
  right: 10%;
  top: 50%;
  height: 44px;
  transform: translateY(-50%);
  border-radius: 14px;
  background: rgba(236, 103, 138, 0.08);
  border: 1px solid rgba(236, 103, 138, 0.16);
  pointer-events: none;
}

.wheel {
  flex: 1;
  overflow-y: auto;
  padding: 66px 0;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
}

.wheel::-webkit-scrollbar {
  display: none;
}

.wheel-item {
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  scroll-snap-align: center;
  border-radius: 12px;
  color: var(--muted);
  font-size: 18px;
}

.wheel-item.active {
  color: var(--pink);
  font-weight: 800;
}

.quick-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 0 2px;
}

.quick-chip {
  flex: 0 0 auto;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--pink-soft);
  color: var(--pink);
  box-shadow: none;
  font-size: 11px;
}

.sheet-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 6px;
}

.sheet-actions button {
  flex: 0 0 auto;
  min-width: 112px;
  padding: 9px 18px;
  border-radius: 12px;
  font-size: 13px;
  box-shadow: none;
}

.scan-video {
  width: 100%;
  max-height: 56vh;
  border-radius: 18px;
  background: #000000;
  object-fit: cover;
}

.scan-hint {
  margin-top: 10px;
  text-align: center;
  font-size: 11px;
  color: var(--muted);
}

.msg-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  max-height: 220px;
  overflow: auto;
}

.chat-card {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  height: min(640px, 70vh);
  min-height: 380px;
}

.chat-head {
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--line);
}

.chat-head h3 {
  margin-bottom: 2px;
}

.chat-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 16px 16px 12px;
  display: flex;
  flex-direction: column;
}

.chat-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: auto;
}

.chat-group {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  width: 100%;
}

.chat-group.me {
  align-items: flex-end;
}

.chat-day {
  display: flex;
  justify-content: center;
  padding: 2px 0;
}

.chat-day span {
  padding: 3px 10px;
  border-radius: 999px;
  background: #f7eef2;
  color: #a58c99;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.chat-row {
  display: flex;
  width: 100%;
}

.chat-row.me {
  justify-content: flex-end;
}

.chat-row .bubble-wrap {
  max-width: 82%;
  display: flex;
  flex-direction: column;
}

.chat-row.me .bubble-wrap {
  align-items: flex-end;
}

.chat-row .bubble {
  padding: 10px 13px;
  border-radius: 17px;
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.55;
  word-break: break-word;
  white-space: pre-wrap;
}

.chat-row.them .bubble {
  background: #ffffff;
  border: 1px solid #f3e6ec;
  border-bottom-left-radius: 7px;
  box-shadow: 0 2px 8px rgba(77, 48, 63, 0.05);
}

.chat-row.me .bubble {
  color: #ffffff;
  background: linear-gradient(135deg, #f887a5, #e75d83);
  border-bottom-right-radius: 7px;
  box-shadow: 0 6px 16px rgba(226, 87, 125, 0.18);
}

.chat-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 5px 3px 0;
  color: #a58c99;
  font-size: 10.5px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.chat-row.them .chat-meta {
  justify-content: flex-start;
}

.chat-row.me .chat-meta {
  justify-content: flex-end;
}

.chat-delivered {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.chat-delivered::before {
  content: "✓";
  font-size: 10px;
  color: #4bbf8a;
}

.chat-input {
  display: flex;
  gap: 9px;
  align-items: flex-end;
  padding: 11px 14px 13px;
  border-top: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.4), rgba(255, 250, 252, 0.95));
}

.chat-input textarea {
  flex: 1;
  min-height: 42px;
  max-height: 96px;
  padding: 10px 15px;
  border-radius: 18px;
  background: #fff;
  font-size: 13px;
  line-height: 1.5;
  resize: none;
}

.chat-input button {
  width: auto;
  flex: 0 0 auto;
  padding: 11px 16px;
  border-radius: 14px;
}

.chat-input .mic-btn {
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 50%;
  background: var(--pink-soft);
  color: var(--pink);
  font-size: 18px;
  box-shadow: none;
}

.chat-input .mic-btn.recording {
  color: var(--danger);
  background: #ffe3e8;
  animation: rec-pulse 1s infinite;
}

.chat-input .mic-btn.active {
  color: #fff;
  background: var(--pink);
}

.chat-input .voice-hold {
  flex: 1 1 auto;
  width: 100%;
  min-height: 45px;
  padding: 0 12px;
  border-radius: 14px;
  border: 1px solid var(--pink-soft);
  background: #fff;
  color: var(--pink);
  font-size: 13px;
  font-weight: 700;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.chat-input .voice-hold.cancel {
  color: #fff;
  background: var(--danger);
  border-color: var(--danger);
}

.voice-hold.recording {
  color: #fff;
  background: var(--pink);
  border-color: var(--pink);
}

.recording-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-top: 1px solid var(--line);
  background: rgba(226, 87, 109, 0.08);
  color: var(--danger);
  font-size: 11px;
}

.recording-bar .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  animation: rec-pulse 1s infinite;
}

.recording-bar .rec-cancel {
  margin-left: auto;
  padding: 4px 8px;
  background: transparent;
  color: var(--danger);
  box-shadow: none;
  font-size: 11px;
}

@keyframes rec-pulse {
  50% {
    opacity: 0.45;
  }
}

.voice-bubble {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 112px;
  padding: 10px 14px;
  border-radius: 16px;
  box-shadow: none;
  font-weight: 600;
  text-align: left;
}

.chat-row.me .voice-bubble {
  flex-direction: row-reverse;
  color: #ffffff;
  background: linear-gradient(135deg, #f887a5, #e75d83);
  border-bottom-right-radius: 7px;
  box-shadow: 0 6px 16px rgba(226, 87, 125, 0.18);
}

.chat-row.them .voice-bubble {
  color: var(--ink);
  background: #ffffff;
  border: 1px solid #f3e6ec;
  border-bottom-left-radius: 7px;
  box-shadow: 0 2px 8px rgba(77, 48, 63, 0.05);
}

.voice-icon {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
}

.chat-row.them .voice-icon {
  color: var(--pink);
}

.chat-row.me .voice-icon {
  color: #ffffff;
  transform: scaleX(-1);
}

.voice-duration {
  font-size: 11px;
  opacity: 0.9;
  white-space: nowrap;
}

.voice-bubble.playing .vw1,
.voice-bubble.playing .vw2 {
  animation: voice-wave 0.9s ease-in-out infinite;
}

.voice-bubble.playing .vw2 {
  animation-delay: 0.15s;
}

@keyframes voice-wave {
  0%,
  100% {
    opacity: 0.3;
  }
  50% {
    opacity: 1;
  }
}

.msg {
  border-radius: 14px;
  padding: 9px 11px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--line);
}

.msg .bubble {
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg .meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 5px;
  font-size: 9.5px;
  color: var(--muted);
}

button {
  font: inherit;
  border: 0;
  cursor: pointer;
  border-radius: 14px;
  padding: 13px 16px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #f27c9c, #e2577d);
  box-shadow: 0 10px 24px rgba(226, 87, 125, 0.24);
}

button.secondary {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--line);
  box-shadow: none;
}

button.ghost {
  color: var(--muted);
  background: transparent;
  box-shadow: none;
  padding: 8px 10px;
}

button.danger {
  background: linear-gradient(135deg, #ef7b8c, #d94b63);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

button:active {
  transform: translateY(1px);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--line);
  white-space: nowrap;
}

.chip.ok {
  color: #23866f;
  background: rgba(79, 191, 159, 0.12);
  border-color: rgba(79, 191, 159, 0.24);
}

.chip.off {
  color: var(--danger);
  background: rgba(226, 87, 109, 0.1);
  border-color: rgba(226, 87, 109, 0.2);
}

.device-list {
  display: grid;
  gap: 12px;
}

.family-hero {
  display: grid;
  gap: 4px;
  background:
    radial-gradient(420px 200px at 0% 0%, #ffe3ee 0%, transparent 70%),
    radial-gradient(420px 200px at 100% 20%, #e9e0ff 0%, transparent 70%),
    rgba(255, 255, 255, 0.86);
}

.family-hero h2 {
  margin: 0;
  font-size: 30px;
  letter-spacing: -0.5px;
}

.family-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  color: var(--muted);
  font-size: 12px;
}

.family-stats b {
  color: var(--ink);
}

.family-usage {
  display: grid;
  gap: 10px;
}

.family-usage-row {
  display: grid;
  gap: 5px;
  cursor: pointer;
}

.family-usage-meta {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
}

.family-usage-track {
  height: 6px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}

.family-usage-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ffb3c6, #ec678a);
}

.device-switch {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0 10px;
  scrollbar-width: none;
}

.global-tabs {
  margin: 10px 0 12px;
}

.device-switch::-webkit-scrollbar {
  display: none;
}

.device-pill {
  flex: 0 0 auto;
  width: auto;
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.8);
  color: var(--muted);
  font-size: 12px;
  box-shadow: none;
}

.device-pill.active {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, #ec678a, #b58cff);
}

.message-device {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 14px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
}

.message-device-text strong {
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
}

.message-device-text {
  flex: 1;
  display: grid;
  gap: 2px;
}

.message-device-text small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.message-device .chevron {
  color: var(--muted);
  font-size: 20px;
}

.device-head {
  padding: 0 4px 4px;
}

.device-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
}

.menu-wrap {
  position: relative;
}

.icon-menu {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  box-shadow: none;
  font-size: 18px;
  line-height: 1;
}

.menu-popover {
  position: absolute;
  right: 0;
  top: 38px;
  z-index: 20;
  min-width: 132px;
  padding: 6px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 16px 40px rgba(36, 32, 42, 0.18);
}

.menu-popover button {
  width: 100%;
  padding: 9px 10px;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  box-shadow: none;
  text-align: left;
  font-size: 12px;
}

.menu-popover .menu-danger {
  color: var(--danger);
}

.tabbar {
  display: flex;
  gap: 6px;
  padding: 4px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.66);
  border: 1px solid var(--line);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 4px;
  z-index: 5;
}

.tab-btn {
  flex: 1;
  min-width: 0;
  padding: 9px 6px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  background: transparent;
  box-shadow: none;
  white-space: nowrap;
}

.tab-btn.active {
  color: var(--ink);
  background: #ffffff;
  box-shadow: 0 4px 14px rgba(90, 54, 72, 0.12);
}

.tab-btn:active {
  transform: none;
}

.device {
  display: grid;
  gap: 8px;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.device:active {
  transform: scale(0.995);
}

.device .name {
  font-size: 16px;
  font-weight: 800;
}

.device-title {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 7px;
  vertical-align: 2px;
}

.status-dot.online {
  background: #2fbf71;
  box-shadow: 0 0 0 3px rgba(47, 191, 113, 0.14);
}

.status-dot.offline {
  background: #b9b3b6;
}

.device-danger {
  margin-top: 12px;
}

.danger-outline {
  width: 100%;
  background: #fff;
  color: var(--danger);
  border: 1px solid rgba(226, 87, 109, 0.35);
  box-shadow: none;
}

.device-title > div {
  min-width: 0;
}

.device-icon {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  color: #7c5cff;
  background: rgba(124, 92, 255, 0.12);
}

.device-icon svg {
  width: 22px;
  height: 22px;
}

.device-icon.unknown {
  color: #8e8e93;
  background: rgba(142, 142, 147, 0.12);
}

.device-icon.tv {
  color: #7c5cff;
  background: rgba(124, 92, 255, 0.12);
}

.battery {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 700;
  color: var(--ink);
}

.battery.low {
  color: #d94848;
}

.battery svg {
  display: block;
}

.battery .battery-shell {
  width: 26px;
  height: 14px;
}

.battery svg:not(.battery-shell) {
  width: 11px;
  height: 11px;
}

.device .meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 3px 8px;
  color: var(--muted);
  font-size: 11px;
}

.device .meta > span {
  white-space: nowrap;
}

.parent-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px 2px 6px;
  border-radius: 999px;
  background: rgba(124, 92, 255, 0.1);
  color: #6d4bd8;
  font-size: 10.5px;
  font-weight: 700;
  white-space: nowrap;
}

.parent-chip svg {
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
}

.device .numbers {
  display: flex;
  gap: 18px;
  margin-top: 4px;
}

.device .numbers div {
  display: grid;
  gap: 2px;
}

.device .numbers b {
  font-size: 18px;
}

.device .numbers span {
  font-size: 10px;
  color: var(--muted);
}

.device-rule-line {
  margin-top: 2px;
  font-size: 10.5px;
  color: var(--muted);
}

.state-card {
  display: grid;
  gap: 8px;
  text-align: center;
  padding: 22px 16px;
}

.state-time {
  font-size: 42px;
  font-weight: 900;
  letter-spacing: -1px;
}

.state-title {
  font-size: 12px;
  color: var(--muted);
}

.state-note {
  font-size: 11px;
  color: var(--muted);
}

.actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.actions button {
  padding: 12px 8px;
  font-size: 12px;
  border-radius: 13px;
}

.bars {
  display: flex;
  align-items: stretch;
  gap: 8px;
  height: 120px;
  padding: 8px 8px 6px;
  border-radius: 16px;
  background-color: rgba(255, 255, 255, 0.45);
  background-image: linear-gradient(to top, var(--line) 1px, transparent 1px);
  background-size: 100% 25%;
  border: 1px solid rgba(255, 255, 255, 0.7);
}

.bar-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  min-width: 0;
  height: 100%;
}

.bar-value {
  height: 14px;
  font-size: 10px;
  font-weight: 800;
  color: var(--ink);
}

.bar-track {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.bar {
  width: min(34px, 72%);
  border-radius: 10px 10px 4px 4px;
  background: linear-gradient(180deg, #ffa4ba 0%, #ec678a 100%);
  box-shadow: 0 8px 18px rgba(236, 103, 138, 0.22);
  min-height: 0;
  transition: height 0.35s ease;
}

.bar.today {
  background: linear-gradient(180deg, #7fd6bd 0%, #45b493 100%);
  box-shadow: 0 8px 18px rgba(69, 180, 147, 0.28);
}

.bar-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

.bar-wrap.is-today .bar-label {
  color: #2f9d7a;
  font-weight: 800;
}

.app-row {
  display: grid;
  gap: 5px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.app-row:last-child {
  border-bottom: 0;
}

.app-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
  font-size: 12px;
}

.app-name-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-weight: 600;
}

.app-name-cell > span:last-child {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.app-name-cell .app-avatar {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  border-radius: 7px;
  font-size: 11px;
}

.app-name-cell .app-avatar.placeholder {
  font-size: 11px;
}

.app-meta > span:last-child {
  flex: 0 0 auto;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.app-track {
  height: 7px;
  background: rgba(36, 32, 42, 0.07);
  border-radius: 999px;
  overflow: hidden;
}

.app-track i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #f8a5bb, #b58cff);
}

.event {
  display: flex;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}

.event:last-child {
  border-bottom: 0;
}

.event .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--pink);
  margin-top: 4px;
  flex: 0 0 auto;
}

.event .time {
  color: var(--muted);
  font-size: 10px;
  margin-left: auto;
  white-space: nowrap;
}

.empty {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 18px 0;
}

.hint {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.6;
  background: rgba(255, 255, 255, 0.55);
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 9px 11px;
}

.error {
  color: var(--danger);
  font-size: 12px;
}

.foot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  color: var(--muted);
  font-size: 10px;
  padding-top: 22px;
}

.install-link {
  padding: 0;
  background: transparent;
  box-shadow: none;
  color: var(--pink);
  font-size: 10px;
  font-weight: 700;
}

.topbar #install-top {
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--pink-soft);
  color: var(--pink);
  font-size: 11px;
  line-height: 1;
}

.install-banner {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  z-index: 40;
  width: min(520px, calc(100vw - 24px));
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  box-shadow: 0 18px 48px rgba(90, 54, 72, 0.2);
  backdrop-filter: blur(14px);
}

.install-banner img {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  flex: 0 0 auto;
}

.install-copy {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 2px;
}

.install-copy b {
  font-size: 12.5px;
}

.install-copy span {
  font-size: 10px;
  color: var(--muted);
}

.install-banner button {
  width: auto;
  flex: 0 0 auto;
  padding: 8px 13px;
  border-radius: 12px;
  font-size: 11px;
}

.install-banner .install-close {
  padding: 2px 6px;
  color: var(--muted);
  background: transparent;
  box-shadow: none;
  font-size: 18px;
  line-height: 1;
}

.sheet.guide {
  max-width: 420px;
}

.guide-icon {
  display: grid;
  place-items: center;
  width: 68px;
  height: 68px;
  margin: 2px auto 10px;
  border-radius: 20px;
  background: linear-gradient(135deg, #ffe1ec, #eee6ff);
  font-size: 30px;
}

.guide-steps {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.guide-step {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
}

.guide-step b {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  flex: 0 0 auto;
  background: var(--pink-soft);
  color: var(--pink);
  font-size: 11px;
}

.guide-step span {
  font-size: 12px;
  line-height: 1.5;
  color: var(--ink);
}

.guide-note {
  margin-top: 10px;
  font-size: 10.5px;
  line-height: 1.6;
  color: var(--muted);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 88px;
  transform: translateX(-50%);
  background: rgba(36, 32, 42, 0.92);
  color: #fff;
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 12px;
  max-width: calc(100% - 40px);
  text-align: center;
  z-index: 50;
  transition: opacity 0.2s ease;
}

.hidden {
  display: none !important;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(36, 32, 42, 0.34);
  backdrop-filter: blur(4px);
}

.modal-card {
  width: min(420px, 100%);
  display: grid;
  gap: 10px;
  padding: 20px;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.8);
  background: #fff;
  box-shadow: 0 24px 60px rgba(70, 38, 56, 0.2);
}

.modal-card h3 {
  margin: 0;
  font-size: 17px;
}

.modal-card .sub {
  margin: 0;
  line-height: 1.6;
}

.modal-card input {
  width: 100%;
}

.modal-error {
  margin: 0;
  color: var(--danger);
  font-size: 12px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

.modal-actions button {
  width: auto;
  padding: 10px 16px;
  box-shadow: none;
}

.back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  background: transparent;
  box-shadow: none;
  padding: 0 0 8px;
  font-size: 12px;
}

@media (min-width: 520px) {
  .actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* ---------------------------------------------------------------------------
   Chat tab: fit the visible viewport instead of relying on 100vh.
   Safari counts the collapsed toolbar in 100vh, which pushed the composer
   below the screen on iPhone. --tp-vh is kept in sync from visualViewport.
   --------------------------------------------------------------------------- */

body.chat-mode {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

body.chat-mode .app {
  height: 100vh;
  height: var(--tp-vh, 100dvh);
  display: flex;
  flex-direction: column;
  padding: max(10px, env(safe-area-inset-top)) 16px max(8px, env(safe-area-inset-bottom));
}

body.chat-mode .topbar {
  flex: 0 0 auto;
}

body.chat-mode main {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

body.chat-mode .device-switch,
body.chat-mode .back,
body.chat-mode .device-head,
body.chat-mode .tabbar {
  flex: 0 0 auto;
}

body.chat-mode #tab-content {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

body.chat-mode .chat-card {
  flex: 1 1 auto;
  height: auto;
  min-height: 0;
}

body.chat-mode .foot {
  display: none;
}

@media (max-width: 480px) {
  body.chat-mode .topbar {
    padding-bottom: 8px;
  }

  body.chat-mode .chat-head {
    padding: 10px 14px 8px;
  }

  body.chat-mode .chat-input {
    padding: 8px 10px;
  }
}

@media (max-height: 640px) {
  body.chat-mode .device-switch,
  body.chat-mode .device-head {
    display: none;
  }

  body.chat-mode .chat-head .sub {
    display: none;
  }
}

@media (max-height: 520px) {
  body.chat-mode .back {
    display: none;
  }

  body.chat-mode .device-head {
    padding-bottom: 2px;
  }

  body.chat-mode .chat-head .sub {
    display: none;
  }
}

