:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #1c2430;
  --muted: #5b6775;
  --line: #d5dce3;
  --accent: #0b6e99;
  --accent-hover: #09587a;
  --danger: #a33b3b;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: "IBM Plex Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

.topbar,
main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.25rem 1rem 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  align-items: flex-end;
  padding-bottom: 0.5rem;
}

h1,
h2 {
  margin: 0 0 0.35rem;
}

h1 {
  font-size: 1.45rem;
}

h2 {
  font-size: 1.05rem;
}

p {
  margin: 0;
  color: var(--muted);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem 1.1rem;
  margin: 1rem auto;
  max-width: 1400px;
}

textarea,
input[type="password"],
input[type="number"] {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  color: var(--text);
  background: #fff;
}

textarea {
  resize: vertical;
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9rem;
  line-height: 1.45;
}

textarea::placeholder,
input::placeholder {
  color: #c5ccd3;
  opacity: 1;
}

.password-field {
  min-width: 220px;
  color: var(--muted);
  font-size: 0.9rem;
}

.row,
.results-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
}

.results-header {
  justify-content: space-between;
  margin-top: 0;
  margin-bottom: 0.5rem;
}

.controls label {
  color: var(--muted);
  font-size: 0.9rem;
}

.controls input[type="number"] {
  width: 6rem;
}

button {
  border: 0;
  border-radius: 8px;
  padding: 0.55rem 0.9rem;
  background: var(--accent);
  color: #fff;
  font: inherit;
  cursor: pointer;
}

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

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

.view-toggle button {
  background: #e8eef2;
  color: var(--text);
}

.view-toggle button.active {
  background: var(--accent);
  color: #fff;
}

.status,
.empty {
  color: var(--muted);
  font-size: 0.92rem;
}

.error {
  color: var(--danger);
  background: #f8ecec;
  border: 1px solid #e4c8c8;
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  margin-bottom: 1rem;
  white-space: pre-wrap;
  position: sticky;
  top: 0;
  z-index: 10;
}

.warning {
  color: #7a5b10;
  background: #fbf5e6;
  border: 1px solid #e6d7a8;
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  margin: 0.65rem 0 0;
  font-size: 0.92rem;
  line-height: 1.4;
}

#table-wrap {
  overflow-x: auto;
  max-width: 100%;
}

#json-wrap {
  overflow: auto;
  max-height: 70vh;
}

#results-json {
  margin: 0;
  padding: 0.75rem 0.85rem;
  background: #fafcfd;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem;
  line-height: 1.45;
  white-space: pre;
  color: var(--text);
}

#results-table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

th,
td {
  border-bottom: 1px solid var(--line);
  text-align: left;
  padding: 0.45rem 0.5rem;
  vertical-align: top;
  max-width: 28rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

th {
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

#graph {
  height: 70vh;
  min-height: 480px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafcfd;
}

.app-nav {
  display: flex;
  gap: 0.9rem;
  margin-top: 0.55rem;
}

.app-nav a {
  color: var(--muted);
  font-size: 0.92rem;
  text-decoration: none;
}

.app-nav a[aria-current="page"] {
  color: var(--accent);
  font-weight: 600;
}

.schema-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

#schema-search {
  width: min(24rem, 100%);
  margin-top: 0;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  color: var(--text);
  background: #fff;
}

.schema-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 0.75rem;
  align-items: stretch;
}

#schema-graph {
  height: 75vh;
  min-height: 520px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafcfd;
}

.schema-detail {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafcfd;
  padding: 0.85rem 0.9rem;
  overflow: auto;
  max-height: 75vh;
}

.schema-detail h3 {
  margin: 0 0 0.3rem;
  font-size: 1.05rem;
}

.schema-detail h4 {
  margin: 0.85rem 0 0.3rem;
  font-size: 0.78rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
}

.schema-detail ul {
  margin: 0;
  padding-left: 1.1rem;
}

.schema-detail li {
  margin: 0.2rem 0;
  font-size: 0.88rem;
}

.schema-detail .status,
.schema-detail .empty {
  margin-top: 0.15rem;
}

#schema-hint {
  margin-top: 0.65rem;
}

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

  .password-field {
    min-width: 0;
  }

  .schema-body {
    grid-template-columns: 1fr;
  }

  .schema-detail {
    max-height: 40vh;
  }
}
