:root {
  color-scheme: dark;
  --bg: #111316;
  --surface: #191d22;
  --surface-2: #20262d;
  --surface-3: #252d35;
  --line: #37404a;
  --muted: #97a3af;
  --text: #eef2f5;
  --accent: #48c7b8;
  --accent-2: #8fb4ff;
  --warning: #f0b45d;
  --danger: #ff7b8a;
  --ok: #7bd88f;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
}

button:hover:not(:disabled) {
  border-color: var(--accent);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

button.primary {
  border-color: rgba(72, 199, 184, 0.7);
  background: #1e6f68;
}

button.active {
  background: #273846;
  border-color: var(--accent-2);
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #101317;
  color: var(--text);
}

textarea {
  resize: vertical;
}

hr {
  width: 100%;
  border: 0;
  border-top: 1px solid var(--line);
  margin: 18px 0;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto auto 1fr;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 22px;
  background: rgba(17, 19, 22, 0.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
}

.brand small,
.node-badge small,
.node-card small,
.chat-head small,
.conversation span,
dd,
.empty,
.lede,
.status-panel p,
.explain-panel p,
.recovery-card p,
.details p {
  color: var(--muted);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: #1e6f68;
  color: white;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
  text-align: left;
}

nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

main {
  min-width: 0;
}

.notice {
  margin: 14px auto 0;
  width: min(1120px, calc(100% - 32px));
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.notice.error {
  border-color: rgba(255, 123, 138, 0.55);
  color: #ffd5da;
}

.notice.warn {
  border-color: rgba(240, 180, 93, 0.6);
  color: #ffe1b5;
}

.landing-grid,
.form-page,
.settings-grid {
  width: min(1120px, calc(100% - 32px));
  margin: 28px auto;
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
  gap: 18px;
}

.hero-panel,
.status-panel,
.form-panel,
.explain-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 24px;
}

.hero-panel {
  min-height: 360px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0;
  font-size: 0.78rem;
  font-weight: 700;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 12px;
  font-size: 4.2rem;
  line-height: 0.95;
  letter-spacing: 0;
}

h2 {
  font-size: 1rem;
  margin-bottom: 12px;
}

.lede {
  max-width: 640px;
  line-height: 1.6;
}

.hero-actions,
.section-head {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.local-section {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto 32px;
}

.section-head {
  justify-content: space-between;
}

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

.node-grid {
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
}

.node-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 12px;
}

.node-card strong,
.peer-id {
  word-break: break-word;
}

.node-card small,
.node-card strong {
  display: block;
}

.node-profile {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.form-page {
  align-items: start;
}

.stack {
  display: grid;
  gap: 14px;
}

.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.security-note {
  color: var(--muted);
  line-height: 1.5;
}

.transfer-output {
  margin-top: 16px;
}

.transfer-code {
  min-height: 150px;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 0.78rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
}

.checkbox-line {
  grid-template-columns: auto 1fr;
  align-items: center;
}

.checkbox-line input {
  width: auto;
}

.link-button {
  margin-top: 12px;
  border: 0;
  padding-left: 0;
  background: transparent;
  color: var(--accent-2);
}

.recovery-key {
  display: block;
  margin: 18px 0;
  padding: 18px;
  border: 1px solid var(--warning);
  border-radius: 8px;
  background: #201a12;
  color: #ffdc9a;
  font-size: 1.75rem;
  text-align: center;
  word-break: break-word;
}

.progress {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #101317;
  border: 1px solid var(--line);
}

.progress span {
  display: block;
  height: 100%;
  background: var(--accent);
  transition: width 120ms linear;
}

.messenger {
  height: calc(100vh - 74px);
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 280px;
  overflow: hidden;
}

.sidebar,
.details {
  min-width: 0;
  overflow: auto;
  border-right: 1px solid var(--line);
  background: var(--surface);
  padding: 14px;
}

.details {
  border-right: 0;
  border-left: 1px solid var(--line);
}

.node-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.presence-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--muted);
}

.presence-dot.online {
  background: var(--ok);
}

.search-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.search-results,
.conversation-list {
  display: grid;
  gap: 8px;
  margin: 12px 0;
}

.conversation-filter {
  margin-top: 8px;
}

.conversation {
  display: grid;
  justify-items: start;
  gap: 4px;
  height: auto;
  min-height: 62px;
  text-align: left;
}

.conversation.selected {
  border-color: var(--accent);
  background: #1d3535;
}

.chat {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: #14171b;
}

.vault-import {
  align-self: center;
  justify-self: center;
  width: min(560px, calc(100% - 32px));
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.chat-head h1 {
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.2;
}

.messages {
  min-height: 0;
  overflow: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.message {
  width: min(72%, 640px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--surface-2);
}

.message.out {
  align-self: flex-end;
  background: #173f3c;
  border-color: rgba(72, 199, 184, 0.45);
}

.message p {
  margin-bottom: 8px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  color: var(--muted);
  font-size: 0.78rem;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.details dl {
  display: grid;
  grid-template-columns: 95px minmax(0, 1fr);
  gap: 8px 12px;
  margin: 0 0 18px;
}

dt {
  color: var(--muted);
}

dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.empty-state,
.empty {
  display: grid;
  place-items: center;
  min-height: 120px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 18px;
  text-align: center;
}

@media (max-width: 980px) {
  .landing-grid,
  .form-page,
  .settings-grid,
  .messenger {
    grid-template-columns: 1fr;
  }

  .messenger {
    height: auto;
    overflow: visible;
  }

  .sidebar,
  .details {
    border: 0;
    border-bottom: 1px solid var(--line);
  }

  .chat {
    min-height: 70vh;
  }
}

@media (max-width: 640px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hero-panel,
  .status-panel,
  .form-panel,
  .explain-panel {
    padding: 18px;
  }

  h1 {
    font-size: 2.6rem;
  }

  .recovery-key {
    font-size: 1.2rem;
  }

  .message {
    width: 94%;
  }

  .composer,
  .search-box {
    grid-template-columns: 1fr;
  }
}
