:root {
  color-scheme: dark;
  --bg-top: #0c2b2b;
  --bg-mid: #134e4a;
  --bg-bottom: #0b3330;
  --surface: rgba(255, 255, 255, 0.06);
  --surface-strong: rgba(255, 255, 255, 0.1);
  --border: rgba(255, 255, 255, 0.14);
  --ink: #f0fdfa;
  --muted: #b6f0e6cc;
  --mint: #5eead4;
  --mint-soft: #99f6e4;
  --coral: #fb7185;
  --success: #5eead4;
  --danger: #fb7185;
  --shadow: 0 24px 60px rgba(6, 22, 22, 0.45);
  font-family: Roboto, "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(94, 234, 212, 0.14), transparent 32%),
    radial-gradient(circle at bottom right, rgba(251, 113, 133, 0.08), transparent 40%),
    linear-gradient(180deg, var(--bg-top) 0%, var(--bg-mid) 55%, var(--bg-bottom) 100%);
  background-attachment: fixed;
  color: var(--ink);
}

button,
input {
  font: inherit;
}

.shell {
  width: min(980px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 32px 0 56px;
}

.hero {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.8fr);
  align-items: end;
  margin-bottom: 28px;
}

.hero-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 6px;
}

.hero-logo {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  object-fit: contain;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  padding: 6px;
}

.hero h1,
.section-head h2,
.toolbar h2,
.device-card h3 {
  margin: 0;
  font-family: Roboto, "Segoe UI", Arial, sans-serif;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.hero h1 {
  font-size: clamp(2.1rem, 4.6vw, 3.6rem);
}

.hero-copy,
.muted,
.status-line {
  color: var(--muted);
}

.eyebrow,
.section-label {
  margin: 0 0 6px;
  font-size: 0.76rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--mint);
  font-weight: 700;
}

.page,
.stack {
  display: grid;
  gap: 18px;
}

.panel,
.device-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.panel {
  padding: 24px;
}

.auth-panel {
  max-width: 560px;
}

#appView > .panel {
  padding: 22px 0;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  box-shadow: none;
  backdrop-filter: none;
}

.section-head,
.toolbar,
.device-head,
.meta-row,
.actions,
.register-form,
.form-row,
.editor-toolbar {
  display: flex;
  gap: 12px;
}

.section-head,
.toolbar,
.editor-toolbar,
.device-head {
  justify-content: space-between;
  align-items: flex-start;
}

.toolbar {
  align-items: center;
}

label {
  display: grid;
  gap: 8px;
  color: var(--ink);
}

input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  background: rgba(6, 22, 22, 0.35);
  color: var(--ink);
}

input::placeholder {
  color: var(--muted);
}

input:focus {
  outline: 2px solid rgba(94, 234, 212, 0.28);
  border-color: var(--mint);
}

.btn {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  cursor: pointer;
  transition: transform 0.16s ease, opacity 0.16s ease, background 0.16s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.55;
  cursor: wait;
  transform: none;
}

.btn-primary {
  background: var(--mint);
  color: #063230;
  font-weight: 700;
}

.btn-primary:hover {
  background: var(--mint-soft);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: var(--mint-soft);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}

.btn-danger {
  background: transparent;
  color: var(--coral);
  border: 1px solid rgba(251, 113, 133, 0.5);
}

.status-line {
  min-height: 1.3em;
  margin: 0;
}

.status-line.error {
  color: var(--danger);
}

.status-line.success {
  color: var(--success);
}

.hidden {
  display: none !important;
}

.register-form {
  align-items: end;
  flex-wrap: wrap;
}

.register-form label {
  flex: 1 1 260px;
}

.credential-box {
  display: grid;
  gap: 20px;
  grid-template-columns: auto 1fr;
  align-items: center;
  padding: 20px;
  border-radius: 18px;
  background: rgba(6, 22, 22, 0.35);
  border: 1px dashed var(--border);
}

.qr-box {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 168px;
  height: 168px;
  padding: 10px;
  background: #fff;
  border-radius: 14px;
  flex-shrink: 0;
}

.qr-box img,
.qr-box canvas,
.qr-box table {
  width: 100% !important;
  height: 100% !important;
}

.credential-details {
  display: grid;
  gap: 14px;
}

code {
  display: block;
  overflow-wrap: anywhere;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(6, 22, 22, 0.55);
  color: var(--mint-soft);
}

.devices-block {
  display: grid;
  gap: 16px;
}

.devices-head {
  padding: 0 2px;
}

.device-grid {
  display: grid;
  gap: 0;
  grid-template-columns: 1fr;
}

.device-card {
  padding: 24px 0;
  display: grid;
  gap: 18px;
  background: transparent;
  border: 0;
  border-top: 1px solid var(--border);
  border-radius: 0;
  box-shadow: none;
  backdrop-filter: none;
}

.device-title {
  display: flex;
  gap: 10px;
  justify-content: space-between;
  align-items: center;
}

.mode-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(94, 234, 212, 0.16);
  color: var(--mint);
  font-size: 0.88rem;
  font-weight: 700;
}

.mode-pill.open {
  background: rgba(251, 113, 133, 0.16);
  color: var(--coral);
}

.mode-pill.unknown {
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
}

.meta-grid div {
  padding: 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.05);
}

.meta-grid dt {
  font-size: 0.8rem;
  color: var(--muted);
}

.meta-grid dd {
  margin: 6px 0 0;
  font-weight: 600;
  color: var(--ink);
}

.card-actions,
.editor-toolbar,
.actions {
  flex-wrap: wrap;
}

.inline-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.device-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 0;
}

.action-label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.ghost-button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--mint-soft);
}

.editor {
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.editor[open] summary {
  margin-bottom: 14px;
}

.editor summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--mint-soft);
}

.profile-form {
  display: grid;
  gap: 16px;
}

.form-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-row {
  flex-wrap: wrap;
}

.form-row label {
  flex: 1 1 150px;
}

.app-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.app-box {
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.04);
}

.app-box h4 {
  margin: 0 0 8px;
  font-size: 1rem;
  color: var(--ink);
}

.app-list {
  display: grid;
  gap: 8px;
  max-height: 220px;
  overflow: auto;
  padding-right: 4px;
}

.app-list label {
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 10px;
  font-size: 0.94rem;
}

.app-list input {
  width: auto;
  margin-top: 3px;
}

.empty-state {
  padding: 28px;
  text-align: center;
  border-radius: 22px;
  border: 1px dashed var(--border);
  background: var(--surface);
}

@media (max-width: 820px) {
  .shell {
    width: min(100vw - 20px, 100%);
    padding-top: 20px;
  }

  .hero,
  .app-grid,
  .form-grid,
  .meta-grid {
    grid-template-columns: 1fr;
  }

  .device-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .credential-box {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }

  .panel,
  .device-card {
    padding: 18px;
  }
}
