:root {
  color-scheme: dark;
  --page: #000000;
  --panel: #101010;
  --panel-soft: #050505;
  --text: #ffffff;
  --muted: #a7a7a7;
  --line: #2b2b2b;
  --input: #080808;
  --accent: #ffffff;
  --accent-strong: #d8d8d8;
  --button-text: #000000;
  --secondary: #d0d0d0;
  --danger: #ffffff;
  --shadow: rgba(0, 0, 0, 0.36);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
}

body {
  min-height: 100svh;
  margin: 0;
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  letter-spacing: 0;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.07), transparent 34%),
    linear-gradient(315deg, rgba(255, 255, 255, 0.045), transparent 34%),
    var(--page);
}

button,
input,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  color: var(--button-text);
  background: var(--accent);
  cursor: pointer;
  white-space: nowrap;
}

button:hover {
  background: var(--accent-strong);
}

button:focus-visible,
input:focus,
textarea:focus,
a:focus-visible {
  outline: 3px solid rgba(255, 255, 255, 0.26);
  outline-offset: 2px;
}

input,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--input);
}

input {
  height: 44px;
  padding: 0 12px;
}

textarea {
  min-height: 78px;
  resize: vertical;
  padding: 10px 12px;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
}

a {
  color: inherit;
}

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

.auth-page {
  display: grid;
  place-items: center;
  padding: 32px 16px;
}

.auth-shell {
  width: min(100%, 380px);
}

.auth-panel {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 32px;
  background: var(--panel);
  box-shadow: 0 22px 60px var(--shadow);
}

.auth-panel h1 {
  margin-bottom: 28px;
  font-size: 28px;
  line-height: 1.15;
  font-weight: 650;
}

.auth-form,
.field {
  display: grid;
}

.auth-form {
  gap: 14px;
}

.field {
  gap: 8px;
}

label {
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

.auth-error {
  margin: 0;
  color: var(--danger);
  font-size: 14px;
}

.app-page {
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  width: min(1180px, 100%);
  margin: 0 auto 22px;
}

.topbar h1 {
  margin-bottom: 0;
  font-size: 30px;
  line-height: 1.1;
  font-weight: 680;
}

.eyebrow {
  margin-bottom: 3px;
  color: var(--secondary);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.workspace {
  width: min(1180px, 100%);
  margin: 0 auto;
}

.summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.summary div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: rgba(16, 19, 18, 0.86);
}

.summary span {
  display: block;
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
}

.summary small {
  color: var(--muted);
}

.add-root {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 520px);
  gap: 16px;
  align-items: end;
  margin-bottom: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: rgba(16, 19, 18, 0.9);
}

.add-primary {
  width: 100%;
}

.add-root h2,
.empty-state h2,
.edit-dialog h2 {
  margin-bottom: 6px;
  font-size: 20px;
  line-height: 1.2;
}

.add-root p,
.empty-state p {
  margin-bottom: 0;
  color: var(--muted);
}

.mindmap {
  display: grid;
  gap: 24px;
  padding-bottom: 32px;
}

.map-track {
  position: relative;
  min-width: 0;
}

.structure-track {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: rgba(11, 13, 12, 0.74);
}

.children {
  display: grid;
  gap: 18px;
  margin-top: 18px;
  padding-left: 28px;
}

.map-step {
  min-width: 0;
}

.map-connector {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin: 0 0 8px 18px;
  color: var(--accent);
  font-weight: 700;
}

.note-connector {
  margin-top: 10px;
}

.node-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 58px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  padding: 12px;
  background: var(--panel);
  box-shadow: 0 8px 24px var(--shadow);
}

.region-card {
  border-left-color: var(--secondary);
}

.contact-card {
  border-left-color: var(--accent);
}

.note-card {
  border-left-color: var(--secondary);
}

.node-copy {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.node-type {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.node-copy strong {
  overflow-wrap: anywhere;
  font-size: 17px;
  line-height: 1.25;
}

.phone-link {
  width: fit-content;
  max-width: 100%;
  color: var(--accent);
  font-weight: 650;
  overflow-wrap: anywhere;
  text-decoration: none;
}

.phone-link:hover {
  text-decoration: underline;
}

.note-copy {
  display: grid;
  gap: 3px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.note-copy span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.note-copy p {
  margin: 0;
  color: var(--text);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.note-text {
  margin: 0;
  color: var(--text);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.muted-phone {
  color: var(--muted);
}

.node-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.icon-button {
  width: 36px;
  min-width: 36px;
  min-height: 36px;
  height: 36px;
  padding: 0;
  color: var(--text);
  border: 1px solid var(--line);
  background: var(--panel-soft);
}

.icon-button:hover {
  color: var(--button-text);
  border-color: var(--accent);
  background: var(--accent);
}

.danger-button {
  color: var(--danger);
}

.danger-button:hover {
  border-color: var(--danger);
  background: var(--danger);
}

.secondary-button {
  color: var(--accent);
  border: 1px solid var(--line);
  background: var(--panel-soft);
}

.secondary-button:hover {
  color: var(--button-text);
  border-color: var(--accent);
  background: var(--accent);
}

.compact-button {
  min-height: 40px;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 28px;
  background: rgba(16, 19, 18, 0.62);
}

.edit-dialog {
  width: min(420px, calc(100% - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  color: var(--text);
  background: var(--panel);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.52);
}

.edit-dialog::backdrop {
  background: rgba(0, 0, 0, 0.7);
}

.edit-dialog form {
  display: grid;
  gap: 14px;
  padding: 22px;
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 4px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

@media (prefers-reduced-motion: no-preference) {
  button,
  input,
  textarea,
  a {
    transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
  }
}

@media (max-width: 780px) {
  .app-page {
    padding: 18px 14px;
  }

  .topbar {
    align-items: flex-start;
  }

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

  .add-root {
    grid-template-columns: 1fr;
  }

  .children {
    padding-left: 20px;
  }
}

@media (max-width: 480px) {
  .auth-page {
    padding: 24px 14px;
  }

  .auth-panel {
    padding: 24px 18px;
  }

  .auth-panel h1 {
    margin-bottom: 24px;
    font-size: 26px;
  }

  .topbar {
    flex-direction: column;
  }

  .topbar form,
  .compact-button {
    width: 100%;
  }

  .summary {
    grid-template-columns: 1fr;
  }

  .structure-track {
    padding: 12px;
  }

  .node-card {
    grid-template-columns: minmax(0, 1fr);
  }

  .node-actions {
    justify-content: flex-end;
  }
}
