:root {
  color-scheme: light;
  --bg: #f4eef8;
  --ink: #2c2540;
  --muted: #7a7190;
  --glass: rgba(255, 255, 255, 0.56);
  --glass-border: rgba(255, 255, 255, 0.78);
  --lilac: #b89ae6;
  --green: #34c759;
  --red: #ff4d6d;
  --shadow: 0 16px 40px rgba(90, 64, 130, 0.12);
  font-family: "Avenir Next", "Avenir", ui-rounded, "SF Pro Rounded", "SF Pro Display", -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at 12% -10%, rgba(216, 196, 255, 0.7), transparent 42%),
    radial-gradient(circle at 92% 0%, rgba(255, 206, 228, 0.5), transparent 36%),
    linear-gradient(180deg, #fbf8ff 0%, #efe7f7 100%);
}

body {
  min-height: 100vh;
  min-height: 100dvh;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(18px + env(safe-area-inset-top)) 20px 4px;
}

.brand-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.wordmark {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.6px;
}

.wordmark span {
  background: linear-gradient(120deg, #8f73d4, #e3a0c8);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

main {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: calc(100dvh - 72px);
  padding: 8px 20px calc(28px + env(safe-area-inset-bottom));
}

.status {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 700;
}

.status-mark {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  border: 2px solid;
  border-radius: 6px;
  position: relative;
}

.status.on { color: #1f9d4b; }
.status.on .status-mark {
  background: var(--green);
  border-color: var(--green);
}

.status.on .status-mark::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 2px;
  width: 5px;
  height: 10px;
  border-right: 2.5px solid #fff;
  border-bottom: 2.5px solid #fff;
  transform: rotate(45deg);
}

.status.off { color: var(--red); }
.status.off .status-mark {
  background: transparent;
  border-color: var(--red);
}

.panel, .card, .code-input {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px) saturate(1.35);
  -webkit-backdrop-filter: blur(22px) saturate(1.35);
}

.panel {
  display: grid;
  gap: 14px;
  padding: 22px 20px;
  border-radius: 24px;
}

.panel.setup {
  width: min(100%, 36rem);
}

main:has(.setup),
main:has(.landing) {
  align-items: center;
}

.landing {
  display: grid;
  gap: 16px;
  width: min(100%, 26rem);
  margin: auto;
  padding: 56px 4px 24px;
  text-align: center;
}

.landing h1 {
  font-size: clamp(34px, 9vw, 44px);
  letter-spacing: -1.4px;
}

.landing .hint {
  font-size: 17px;
}

.landing .button {
  margin-top: 10px;
}

.sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  align-items: end;
  padding: 16px;
  background: rgba(44, 37, 64, 0.28);
  backdrop-filter: blur(8px);
}

.panel.sheet {
  width: min(100%, 28rem);
  margin: 0 auto;
  border-radius: 28px 28px 22px 22px;
}

@media (min-width: 720px) {
  .sheet-overlay { align-items: center; }
  .panel.sheet { border-radius: 24px; }
}

h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.8px;
  line-height: 1.1;
}

.watch-hint { margin: -8px 0 0; }

.hint, .note, .relay-note {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.35;
}

.note, .relay-note { color: var(--ink); }
.note:empty, .relay-note:empty { display: none; }

.setup-steps {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: setup;
}

.setup-steps li {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.setup-steps li::before {
  counter-increment: setup;
  content: counter(setup);
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(180deg, #efe6ff, #d5c2f4);
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
}

.setup-steps strong {
  display: block;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.3;
}

.setup-steps p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
}

a.button {
  display: grid;
  place-items: center;
  text-decoration: none;
}

.code-input {
  width: 100%;
  padding: 16px 12px;
  border-radius: 16px;
  color: var(--ink);
  font: inherit;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 4px;
  text-align: center;
}

.code-input:focus {
  outline: 2px solid var(--lilac);
  outline-offset: 2px;
}

.button {
  min-height: 52px;
  width: 100%;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-size: 16px;
  font-weight: 800;
}

.button.primary {
  background: linear-gradient(180deg, #d9c8f6, #b89ae6);
  color: var(--ink);
  box-shadow: 0 10px 24px rgba(139, 108, 201, 0.28);
}

.button.secondary {
  background: transparent;
  color: var(--muted);
  min-height: 44px;
  font-weight: 600;
  box-shadow: none;
}

.button:disabled { opacity: 0.4; }

.activity {
  display: grid;
  flex: 1;
  align-content: start;
  gap: 10px;
}

.card {
  padding: 14px 14px 16px;
  border-radius: 22px;
}

.card-head {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.avatar {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(180deg, #efe6ff, #d5c2f4);
  color: var(--ink);
  font-size: 18px;
  font-weight: 800;
}

.card-copy { min-width: 0; }

.card strong {
  display: block;
  overflow: hidden;
  font-size: 16px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card p {
  margin: 2px 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card time {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.card .media {
  display: block;
  width: calc(100% - 56px);
  max-height: 360px;
  margin: 12px 0 0 56px;
  border-radius: 16px;
  background: rgba(44, 37, 64, 0.08);
  object-fit: contain;
}

.empty {
  padding: 48px 12px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
  text-align: center;
}

.footer-actions {
  display: grid;
  gap: 8px;
  margin-top: auto;
}
