:root {
  --bg: #090e18;
  --panel: rgba(20, 28, 43, 0.92);
  --panel-strong: #151f31;
  --line: rgba(148, 163, 184, 0.16);
  --text: #f1f5f9;
  --muted: #94a3b8;
  --blue: #38bdf8;
  --blue-deep: #2563eb;
  --green: #4ade80;
  --amber: #fbbf24;
  --red: #fb7185;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Microsoft JhengHei", "Noto Sans TC", system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 0%, rgba(37, 99, 235, 0.15), transparent 35%),
    linear-gradient(180deg, #0b1220 0%, var(--bg) 46%, #080c14 100%);
}

button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.ambient {
  position: fixed;
  width: 260px;
  height: 260px;
  border-radius: 999px;
  filter: blur(90px);
  pointer-events: none;
  opacity: 0.15;
}
.ambient-one { top: -100px; right: -80px; background: #0ea5e9; }
.ambient-two { bottom: 10%; left: -180px; background: #2563eb; }

.shell {
  position: relative;
  width: min(100%, 720px);
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 16px max(34px, env(safe-area-inset-bottom));
}

.hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 4px 22px;
}

.eyebrow, .section-kicker {
  margin: 0 0 5px;
  color: var(--blue);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.12em;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 5px; font-size: clamp(2rem, 8vw, 2.8rem); letter-spacing: -0.04em; }
h2 { margin-bottom: 0; font-size: 1.15rem; }
.subtitle, .muted { color: var(--muted); }
.subtitle { margin: 0; font-size: 0.82rem; }

.connection-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
  margin-top: 4px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(15, 23, 42, 0.72);
  font-size: 0.72rem;
}
.connection-pill.online { color: #bbf7d0; border-color: rgba(74, 222, 128, 0.3); }

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 10px currentColor;
}
.online .status-dot, .status-dot.safe { background: var(--green); }

.card {
  margin-bottom: 13px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.status-card { overflow: hidden; }
.card-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 17px; }
.card-heading.compact { margin-bottom: 11px; }
.badge, .safe-label {
  padding: 6px 9px;
  border-radius: 999px;
  color: #bae6fd;
  background: rgba(14, 165, 233, 0.13);
  border: 1px solid rgba(56, 189, 248, 0.2);
  font-size: 0.7rem;
  font-weight: 700;
}
.safe-label { color: #bbf7d0; background: rgba(74, 222, 128, 0.09); border-color: rgba(74, 222, 128, 0.18); }

.status-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.metric {
  min-width: 0;
  padding: 12px;
  border-radius: 13px;
  background: rgba(8, 15, 28, 0.62);
  border: 1px solid rgba(148, 163, 184, 0.1);
}
.metric.wide { grid-column: 1 / -1; }
.metric span { display: block; margin-bottom: 4px; color: var(--muted); font-size: 0.68rem; }
.metric strong { display: block; overflow: hidden; color: #e2e8f0; font-size: 0.82rem; text-overflow: ellipsis; white-space: nowrap; }

.attention {
  display: flex;
  gap: 11px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid rgba(251, 191, 36, 0.25);
  border-radius: 13px;
  color: #fde68a;
  background: rgba(146, 64, 14, 0.14);
}
.attention-icon { display: grid; place-items: center; width: 22px; height: 22px; flex: 0 0 auto; border-radius: 50%; background: var(--amber); color: #422006; font-weight: 900; }
.attention p { margin: 3px 0 0; color: #fcd34d; font-size: 0.76rem; line-height: 1.5; }

.actions { display: grid; grid-template-columns: 1.5fr 1fr 0.85fr; gap: 8px; margin-bottom: 13px; }
.button {
  min-height: 48px;
  padding: 11px 13px;
  border: 0;
  border-radius: 13px;
  color: white;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.14s ease, filter 0.14s ease, opacity 0.14s ease;
}
.button:active { transform: scale(0.97); }
.button:disabled { cursor: wait; opacity: 0.55; }
.button-icon { margin-right: 5px; opacity: 0.85; }
.primary { background: linear-gradient(135deg, var(--blue-deep), #0284c7); }
.secondary { background: #334155; }
.danger { background: linear-gradient(135deg, #9f1239, #be123c); }
.outline { color: #bae6fd; border: 1px solid rgba(56, 189, 248, 0.28); background: rgba(14, 165, 233, 0.08); }

.stream-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 14px; }
.stream-actions .button { width: 100%; }
.live-button { color: #bbf7d0; border: 1px solid rgba(74, 222, 128, 0.28); background: rgba(22, 101, 52, 0.28); }
.live-button.active { color: white; border-color: rgba(251, 113, 133, 0.32); background: linear-gradient(135deg, #9f1239, #be123c); }
.live-status { margin: 9px 2px 0; color: var(--muted); font-size: 0.69rem; }
.live-status.active { color: #86efac; }

.screenshot-card .muted { margin: 7px 0 0; font-size: 0.76rem; line-height: 1.5; }
.screenshot-frame { margin: 14px 0 0; overflow: hidden; border: 1px solid var(--line); border-radius: 13px; background: #05080e; }
.image-stage { position: relative; width: fit-content; max-width: 100%; margin: 0 auto; line-height: 0; }
.screenshot-frame img { display: block; width: auto; max-width: 100%; height: auto; max-height: 68vh; object-fit: contain; touch-action: manipulation; }
.screenshot-frame figcaption { padding: 9px 11px; color: var(--muted); font-size: 0.68rem; }
.screenshot-frame.selectable img { cursor: crosshair; }
.click-marker {
  position: absolute;
  width: 30px;
  height: 30px;
  border: 3px solid white;
  border-radius: 50%;
  background: rgba(251, 113, 133, 0.3);
  box-shadow: 0 0 0 3px rgba(190, 18, 60, 0.75), 0 0 18px rgba(251, 113, 133, 0.9);
  pointer-events: none;
  transform: translate(-50%, -50%);
}
.click-marker::before, .click-marker::after { content: ""; position: absolute; background: white; }
.click-marker::before { top: 11px; left: -8px; width: 40px; height: 2px; }
.click-marker::after { top: -8px; left: 11px; width: 2px; height: 40px; }
.intervention-panel { margin-top: 12px; padding: 13px; border: 1px solid rgba(251, 191, 36, 0.28); border-radius: 13px; background: rgba(146, 64, 14, 0.13); }
.intervention-title { margin: 0 0 4px; color: #fde68a; font-size: 0.82rem; font-weight: 800; }
.intervention-panel .muted { margin: 0; }
.intervention-warning { margin: 8px 0 0; color: #fcd34d; font-size: 0.7rem; line-height: 1.5; }
.intervention-actions { display: grid; grid-template-columns: 0.8fr 1.2fr; gap: 8px; margin-top: 11px; }
.intervention-actions .button { min-height: 43px; font-size: 0.76rem; }
.confirm-click { color: white; background: linear-gradient(135deg, #b45309, #d97706); }
.intervention-hint { margin: 10px 2px 0; color: #93c5fd; font-size: 0.69rem; line-height: 1.5; }

.switch-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.switch-row:nth-last-of-type(1) { border-bottom: 0; }
.switch-row strong, .switch-row small { display: block; }
.switch-row strong { font-size: 0.88rem; }
.switch-row small { margin-top: 4px; color: var(--muted); font-size: 0.69rem; }
.switch-row input { position: absolute; opacity: 0; pointer-events: none; }
.switch { position: relative; width: 44px; height: 25px; flex: 0 0 auto; border-radius: 99px; background: #334155; transition: background 0.18s ease; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 19px; height: 19px; border-radius: 50%; background: #e2e8f0; transition: transform 0.18s ease; }
input:checked + .switch { background: #0284c7; }
input:checked + .switch::after { transform: translateX(19px); }
input:focus-visible + .switch { outline: 2px solid var(--blue); outline-offset: 3px; }
.safety-note { margin: 10px 0 0; padding-top: 11px; border-top: 1px solid var(--line); color: #fcd34d; font-size: 0.7rem; line-height: 1.55; }

.policy-help { margin: 0 0 12px; font-size: 0.72rem; line-height: 1.5; }
.compact-form { display: grid; grid-template-columns: minmax(0, 1fr) 76px auto; gap: 8px; }
.compact-form.forbidden-form { grid-template-columns: minmax(0, 1fr) auto; }
.compact-form input {
  min-width: 0;
  height: 46px;
  padding: 0 12px;
  border: 1px solid #334155;
  border-radius: 12px;
  outline: 0;
  color: var(--text);
  background: #0b1220;
}
.compact-form input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.12); }
.compact-form .button { min-height: 46px; white-space: nowrap; }
.policy-list { display: grid; gap: 7px; margin-top: 11px; }
.policy-row { display: flex; align-items: center; gap: 8px; padding: 10px; border-radius: 12px; background: rgba(8, 15, 28, 0.58); }
.policy-row-main { min-width: 0; flex: 1; }
.policy-row-main strong, .policy-row-main small { display: block; }
.policy-row-main strong { overflow: hidden; font-size: 0.78rem; text-overflow: ellipsis; white-space: nowrap; }
.policy-row-main small { margin-top: 3px; color: var(--muted); font-size: 0.67rem; }
.mini-button { min-height: 34px; padding: 7px 10px; border: 0; border-radius: 9px; color: white; background: #334155; font-size: 0.68rem; font-weight: 800; }
.mini-button.cancel { color: #fecdd3; background: rgba(159, 18, 57, 0.45); }
.policy-divider { height: 1px; margin: 15px 0; background: var(--line); }

.icon-button { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); background: rgba(15, 23, 42, 0.8); cursor: pointer; }
.event-list { display: grid; gap: 8px; }
.event { display: grid; grid-template-columns: 8px 1fr; gap: 10px; padding: 11px; border-radius: 12px; background: rgba(8, 15, 28, 0.58); }
.event-mark { width: 7px; height: 7px; margin-top: 5px; border-radius: 50%; background: var(--blue); }
.event.attention-event .event-mark { background: var(--amber); }
.event strong { display: block; margin-bottom: 3px; font-size: 0.78rem; }
.event p { margin: 0; color: var(--muted); font-size: 0.7rem; line-height: 1.45; }
.event time { display: block; margin-top: 5px; color: #64748b; font-size: 0.64rem; }
.empty { margin: 8px 0; color: var(--muted); font-size: 0.78rem; }

footer { display: flex; justify-content: center; align-items: center; gap: 8px; padding: 17px 6px 3px; color: #64748b; font-size: 0.67rem; text-align: center; }

.overlay { position: fixed; z-index: 10; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(3, 7, 18, 0.86); backdrop-filter: blur(12px); }
.pairing-panel { width: min(100%, 390px); padding: 26px; border: 1px solid var(--line); border-radius: 22px; background: #111827; box-shadow: 0 28px 70px rgba(0, 0, 0, 0.5); }
.pairing-mark { display: grid; place-items: center; width: 50px; height: 50px; margin-bottom: 18px; border-radius: 14px; color: white; background: linear-gradient(135deg, #2563eb, #0ea5e9); font-weight: 900; }
.pairing-panel .muted { margin: 9px 0 17px; font-size: 0.78rem; line-height: 1.55; }
.pairing-panel input { width: 100%; height: 49px; margin-bottom: 7px; padding: 0 14px; border: 1px solid #334155; border-radius: 12px; outline: 0; color: var(--text); background: #0b1220; text-transform: uppercase; }
.pairing-panel input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.12); }
.pairing-panel .button { width: 100%; margin-top: 8px; }
.form-error { min-height: 18px; margin: 0; color: #fda4af; font-size: 0.72rem; }

.toast { position: fixed; z-index: 20; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); max-width: calc(100% - 32px); padding: 11px 15px; border: 1px solid var(--line); border-radius: 12px; color: var(--text); background: #1e293b; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transform: translate(-50%, 16px); transition: 0.2s ease; font-size: 0.78rem; text-align: center; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.hidden { display: none !important; }

@media (max-width: 520px) {
  .shell { padding-left: 12px; padding-right: 12px; }
  .hero { align-items: flex-end; }
  .hero .subtitle { max-width: 250px; }
  .actions { grid-template-columns: 1fr 1fr; }
  .actions .primary { grid-column: 1 / -1; }
  .card { padding: 16px; border-radius: 16px; }
  .stream-actions { grid-template-columns: 1fr; }
  .compact-form { grid-template-columns: minmax(0, 1fr) 68px; }
  .compact-form .button { grid-column: 1 / -1; }
  .compact-form.forbidden-form { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
