:root {
  --bg: #11120f;
  --bg-elev: #171914;
  --bg-hover: #1d1f19;
  --line: rgba(244, 240, 230, 0.15);
  --text: #f4f0e6;
  --muted: #c6c0b2;
  --faint: #8f8c81;
  --accent: #dbc06c;
  --accent-text: #211c0c;
  --danger: #ff7a6a;
  --ok: #a5d783;
  --ring: #ecd585;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
  --radius: 14px;
  --radius-sm: 10px;
  --font-display: "Bricolage Grotesque", "Inter", Arial, sans-serif;
  --font-ui: "Inter", Avenir Next, "Segoe UI", sans-serif;
  --font-mono: "DM Mono", ui-monospace, Menlo, monospace;
  --space: 4px;
  --dur: 180ms;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
}
html,
body {
  min-height: 100%;
}
html {
  background: var(--bg);
}
body {
  font-family: var(--font-ui);
  background:
    radial-gradient(900px 610px at 84% 3%, rgba(219, 192, 108, 0.12), transparent 70%),
    radial-gradient(700px 460px at 4% 30%, rgba(219, 192, 108, 0.065), transparent 73%), var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.page-noise {
  position: fixed;
  z-index: 10;
  inset: 0;
  pointer-events: none;
  opacity: 0.15;
  mix-blend-mode: soft-light;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.86' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.7'/%3E%3C/svg%3E");
}

:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 3px;
}

.skip {
  position: absolute;
  left: 12px;
  top: -40px;
  background: var(--accent);
  color: var(--accent-text);
  padding: 8px 12px;
  border-radius: 8px;
  z-index: 20;
  font-weight: 600;
}
.skip:focus {
  top: 12px;
}

.hidden,
[hidden] {
  display: none !important;
}

.wrap {
  position: relative;
  z-index: 1;
  width: min(1080px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.25rem 0 4rem;
}

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 52px;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--line);
}
.mark {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 650;
  letter-spacing: -0.045em;
}
.mark em {
  font-style: italic;
  font-weight: 450;
  color: var(--accent);
}
.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
}
.status-dot::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 99px;
  background: var(--ok);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok) 18%, transparent);
}
.status-dot.bad::before {
  background: var(--danger);
  box-shadow: none;
}

.user-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
}
.user-email {
  color: var(--muted);
  font-size: 0.88rem;
}
.user-ecosystem {
  color: var(--text);
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-style: italic;
}

.gate {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 3rem;
  align-items: center;
  padding-top: 3.5rem;
}

.clock-block {
  min-height: 220px;
}
.clock {
  display: flex;
  align-items: flex-start;
  font-family: var(--font-display);
  font-optical-sizing: auto;
  font-size: clamp(4.2rem, 12vw, 7.2rem);
  font-weight: 620;
  letter-spacing: -0.055em;
  line-height: 0.9;
  font-variant-numeric: tabular-nums;
}
.clock-hh,
.clock-mm {
  min-width: 2.05ch;
  text-align: center;
  letter-spacing: 0.04em;
}
.clock-colon {
  display: inline-block;
  width: 0.38em;
  margin: 0 0.38em;
  text-align: center;
  letter-spacing: 0;
  color: var(--accent);
  opacity: 0.9;
  animation: colon-live 1s steps(1, end) infinite;
}
.clock-ss {
  margin-left: 0.7em;
  padding-top: 0.22em;
  min-width: 1.8em;
  font-family: var(--font-mono);
  font-size: 0.34em;
  font-weight: 400;
  letter-spacing: 0.14em;
  color: var(--faint);
  line-height: 1;
}
@keyframes colon-live {
  0%,
  49% {
    opacity: 0.95;
  }
  50%,
  100% {
    opacity: 0.22;
  }
}
.lede {
  margin-top: 1.25rem;
  max-width: 28rem;
  color: var(--muted);
  font-size: 1.05rem;
}
.manual {
  margin-top: 1.1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elev);
  padding: 0.2rem 1.15rem 0.2rem;
}
.manual summary {
  cursor: pointer;
  list-style: none;
  min-height: 48px;
  display: flex;
  align-items: center;
  font-weight: 600;
  color: var(--muted);
}
.manual summary::-webkit-details-marker {
  display: none;
}
.manual summary::after {
  content: "Show";
  margin-left: auto;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--faint);
}
.manual[open] summary::after {
  content: "Hide";
}
.manual[open] {
  padding-bottom: 1.2rem;
}
.manual .panel-body {
  padding-top: 0.4rem;
}

.agent-panel h2 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 620;
  letter-spacing: -0.045em;
}
.agent-panel p {
  margin-top: 1.25rem;
  max-width: 26rem;
  color: var(--muted);
  font-size: 1.05rem;
}

.panel {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.35rem;
  box-shadow: var(--shadow);
}

.auth-title {
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 620;
  letter-spacing: -0.045em;
  margin-bottom: 0.25rem;
}
.auth-sub {
  color: var(--muted);
  font-size: 0.92rem;
  margin-bottom: 1.15rem;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.row {
  display: flex;
  gap: 0.65rem;
  align-items: center;
  flex-wrap: wrap;
}

button,
input,
select {
  font-family: var(--font-ui);
  font-size: 0.95rem;
  color: inherit;
}
button {
  cursor: pointer;
  border: 0;
  border-radius: 0.55rem;
  min-height: 44px;
  padding: 0.7rem 1.15rem;
  font-weight: 700;
  transition:
    background var(--dur) var(--ease),
    color var(--dur) var(--ease),
    opacity var(--dur) var(--ease);
}
button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
button:active:not(:disabled) {
  opacity: 0.88;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
}
.btn-primary:hover:not(:disabled) {
  filter: brightness(1.05);
}
.btn-ghost {
  background: transparent;
  color: var(--muted);
  min-height: 40px;
  padding: 0.4rem 0.7rem;
}
.btn-ghost:hover:not(:disabled) {
  color: var(--text);
  background: var(--bg-hover);
}
.btn-ghost.danger:hover:not(:disabled) {
  color: var(--danger);
}

.btn-oauth {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-weight: 600;
}
.btn-oauth:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: color-mix(in srgb, var(--text) 22%, var(--line));
}
.btn-oauth svg {
  flex-shrink: 0;
}
.btn-oauth .hint {
  display: block;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--faint);
  margin-top: 1px;
}

.divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--faint);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 0.15rem 0;
}
.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  background: var(--bg);
  border-radius: 12px;
  margin-bottom: 0.85rem;
}
.toggle button {
  min-height: 40px;
  background: transparent;
  color: var(--muted);
  border-radius: 10px;
}
.toggle button.active {
  background: var(--bg-elev);
  color: var(--text);
  box-shadow: 0 0 0 1px var(--line);
}

label.field {
  display: block;
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.35rem;
}
input,
select {
  width: 100%;
  min-height: 44px;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  outline: none;
  transition: border-color var(--dur) var(--ease);
}
input:hover,
select:hover {
  border-color: color-mix(in srgb, var(--text) 18%, var(--line));
}
input:focus,
select:focus {
  border-color: var(--accent);
}

.err {
  color: var(--danger);
  font-size: 0.86rem;
  min-height: 1.2rem;
}
.err[role="alert"] {
  font-weight: 550;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  border: 0;
  padding: 0;
  margin: 0;
  min-inline-size: 0;
}
.chip {
  min-height: 36px;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}
.chip:hover {
  color: var(--text);
  border-color: var(--accent);
}

.next {
  padding: 2rem 0 0.4rem;
}
.kicker {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.next-time {
  font-family: var(--font-display);
  font-size: clamp(3.2rem, 9vw, 5.4rem);
  font-weight: 620;
  letter-spacing: -0.055em;
  line-height: 0.92;
  font-variant-numeric: tabular-nums;
}
.next-label {
  color: var(--accent);
  font-size: 1.02rem;
  margin-top: 0.35rem;
}

.tabs {
  display: flex;
  gap: 1.25rem;
  margin: 1.6rem 0 0.9rem;
  border-bottom: 1px solid var(--line);
}
.tabs button {
  background: none;
  border-radius: 0;
  min-height: 44px;
  padding: 0.7rem 0;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tabs button.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}
.tab {
  display: none;
  animation: fade var(--dur) var(--ease);
}
.tab.active {
  display: block;
}

.alarm {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.4rem 1rem;
  padding: 1rem 0;
  border-top: 1px solid var(--line);
  animation: fade var(--dur) var(--ease);
}
.alarm:first-child {
  border-top: 0;
}
.alarm .name {
  font-size: 1.05rem;
  font-weight: 600;
}
.meta {
  color: var(--muted);
  font-size: 0.88rem;
}
.status {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  text-align: right;
}
.status.created {
  color: var(--accent);
}
.status.fired,
.status.rang {
  color: var(--danger);
}
.status.delivered {
  color: var(--ok);
}
.status.acknowledged {
  color: var(--ok);
}
.status.cancelled {
  color: var(--faint);
}
.kind {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
}
.kind.message {
  color: var(--ok);
}
.kind.alarm {
  color: var(--accent);
}
.history-message {
  color: var(--muted);
  font-size: 0.95rem;
  margin-top: 0.15rem;
}
.delivery-fail {
  color: var(--danger);
}
.history-filters {
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.8rem;
}
.history-filters .field {
  margin-bottom: 0.25rem;
}

.kv {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem 0;
  border-top: 1px solid var(--line);
}
.kv:first-child {
  border-top: 0;
}

.device-row {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  padding: 0.85rem 0;
  color: inherit;
  min-height: 0;
}
.device-row:first-child {
  border-top: 0;
}
.device-row.selected {
  color: var(--text);
}
.device-row.selected strong {
  color: var(--accent);
}
.device-detail code,
#device-detail code {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--faint);
}

.empty {
  padding: 1.4rem 0;
  color: var(--muted);
}
pre {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  background: var(--bg);
  padding: 0.8rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
}

.check {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  cursor: pointer;
  font-size: 0.92rem;
  font-weight: 500;
}
.check input {
  width: auto;
  min-height: 0;
  accent-color: var(--accent);
}

.toast {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  left: 1.25rem;
  max-width: 24rem;
  margin-left: auto;
  z-index: 30;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  animation: fade var(--dur) var(--ease);
}
.toast.ok {
  border-color: color-mix(in srgb, var(--ok) 55%, var(--line));
}
.toast.bad {
  border-color: color-mix(in srgb, var(--danger) 55%, var(--line));
}

@keyframes fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
  .clock-colon {
    opacity: 0.7;
  }
}

@media (max-width: 820px) {
  .gate {
    grid-template-columns: 1fr;
    gap: 2rem;
    padding-top: 1.75rem;
  }
  .clock {
    font-size: clamp(3.6rem, 18vw, 5.2rem);
  }
}
