:root {
  color-scheme: dark;
  --background: #081018;
  --surface: #101c27;
  --surface-raised: #162634;
  --text: #f4f8fa;
  --muted: #8fa4b3;
  --accent: #27c6d9;
  --accent-strong: #5ce1e6;
  --success: #45d483;
  --warning: #efba68;
  --border: rgba(255, 255, 255, 0.08);
  --radius: 20px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 0;
  background: var(--background);
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background:
    radial-gradient(
      circle at 85% -10%,
      rgba(39, 198, 217, 0.11),
      transparent 30rem
    ),
    var(--background);
  color: var(--text);
  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "SF Pro Display",
    "Segoe UI",
    sans-serif;
  -webkit-font-smoothing: antialiased;
}

button {
  font: inherit;
}

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

.app-shell {
  width: 100%;
  max-width: 1120px;
  min-width: 0;
  margin: 0 auto;
  padding:
    max(24px, env(safe-area-inset-top))
    max(18px, env(safe-area-inset-right))
    max(44px, env(safe-area-inset-bottom))
    max(18px, env(safe-area-inset-left));
}

.app-header,
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.app-header > *,
.section-heading > *,
.module-view-header > div {
  min-width: 0;
}

.app-header {
  padding: 8px 0 30px;
}

.brand {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 14px;
  font-size: clamp(42px, 12vw, 62px);
  font-weight: 780;
  letter-spacing: -0.06em;
  line-height: 0.9;
}

.brand-mark {
  width: 58px;
  height: 58px;
  flex: 0 0 auto;
  fill: rgba(39, 198, 217, 0.08);
  stroke: var(--accent);
}

.brand-shell {
  stroke-width: 2;
}

.brand-core,
.brand-wave {
  fill: none;
  stroke: var(--accent-strong);
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brand-core {
  stroke-width: 4;
}

.brand-wave {
  stroke-width: 2;
}

.environment-badge,
.module-state {
  color: var(--accent);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.environment-badge {
  flex: 0 0 auto;
  max-width: 42%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.025);
}

.intro {
  min-width: 0;
  padding: 18px 0 30px;
}

.view[hidden] {
  display: none;
}

.view,
.activity,
.activity-list,
.activity-card,
.status-panel,
.setup-panel,
.setup-panel form {
  min-width: 0;
  max-width: 100%;
}

.setup-panel[hidden] {
  display: none;
}

.setup-panel {
  margin-bottom: 28px;
  padding: 18px;
  border: 1px solid rgba(39, 198, 217, 0.28);
  border-radius: var(--radius);
  background: var(--surface);
}

.setup-heading h2 {
  margin: 0;
  font-size: clamp(24px, 7vw, 32px);
  letter-spacing: -0.04em;
  line-height: 1.08;
}

.setup-heading > p:last-child {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.setup-panel form {
  display: grid;
  gap: 9px;
  margin-top: 20px;
}

.setup-panel label {
  margin-top: 5px;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

.setup-panel input {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  outline: none;
  background: var(--surface-raised);
  color: var(--text);
  font: inherit;
  font-size: 16px;
}

.setup-panel input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(39, 198, 217, 0.12);
}

.setup-error {
  min-height: 18px;
  margin: 2px 0 0;
  color: var(--warning);
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.connect-button {
  min-height: 48px;
  padding: 0 18px;
  border: 0;
  border-radius: 14px;
  background: var(--accent);
  color: var(--background);
  cursor: pointer;
  font-weight: 800;
  touch-action: manipulation;
}

.connect-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.module-view-header {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 20px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.back-button {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-raised);
  color: var(--accent);
  cursor: pointer;
  touch-action: manipulation;
}

.module-view-header h1 {
  margin: 0;
  font-size: clamp(28px, 8vw, 42px);
  letter-spacing: -0.045em;
}

.module-view-header p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.intro h1 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(34px, 9vw, 58px);
  letter-spacing: -0.055em;
  line-height: 1;
}

.intro > p:last-child {
  max-width: 640px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.module-card {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 148px;
  flex-direction: column;
  justify-content: flex-end;
  padding: 17px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
  touch-action: manipulation;
}

.module-card:not(:disabled) {
  cursor: pointer;
}

.module-card:disabled {
  opacity: 0.52;
}

.module-state {
  position: absolute;
  top: 17px;
  right: 17px;
  max-width: calc(100% - 34px);
  overflow-wrap: anywhere;
  text-align: right;
}

.module-card strong {
  font-size: 20px;
}

.module-card > span:last-child {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.activity {
  margin-top: 42px;
}

.section-heading {
  align-items: flex-end;
  margin-bottom: 14px;
}

.section-heading h2 {
  margin: 0;
  font-size: clamp(24px, 6vw, 32px);
  letter-spacing: -0.04em;
}

.section-heading > span {
  color: var(--muted);
  font-size: 12px;
}

.activity-list {
  display: grid;
  gap: 10px;
}

.activity-card,
.status-panel {
  border: 1px solid var(--border);
  background: var(--surface);
}

.activity-card {
  padding: 17px;
  border-radius: var(--radius);
}

.activity-id {
  margin-bottom: 7px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.08em;
  overflow-wrap: anywhere;
  text-transform: uppercase;
}

.activity-card h3 {
  margin: 0;
  font-size: 16px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.activity-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
}

.activity-meta > span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.empty-state,
.loading-state {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.status-panel {
  display: grid;
  gap: 4px;
  margin-top: 28px;
  padding: 14px 16px;
  border-radius: 16px;
}

.status-panel strong {
  color: var(--accent);
  font-size: 13px;
}

.status-panel span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.status-panel[data-state="connected"] strong {
  color: var(--success);
}

.status-panel[data-state="error"] strong {
  color: var(--warning);
}

@media (min-width: 700px) {
  .app-shell {
    padding-right: 28px;
    padding-left: 28px;
  }

  .module-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 420px) {
  .app-header {
    gap: 12px;
    padding-bottom: 22px;
  }

  .brand-mark {
    width: 50px;
    height: 50px;
  }

  .environment-badge {
    max-width: 92px;
    text-align: center;
  }

  .section-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }
}

@media (max-width: 340px) {
  .module-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

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