@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  --bg-0: #f4f4f4;
  --bg-1: #ededed;
  --bg-2: #e6e6e6;
  --bg-3: #dfdfdf;
  --line: rgba(0, 0, 0, 0.22);
  --line-soft: rgba(0, 0, 0, 0.12);
  --text-1: #171717;
  --text-2: #404040;
  --text-3: #666666;
  --ok: #2d2d2d;
  --danger: #3a3a3a;
  --glass-bg: rgba(255, 255, 255, 0.56);
  --panel-bg: rgba(255, 255, 255, 0.44);
  --soft-fill: rgba(0, 0, 0, 0.03);
  --hover-fill: rgba(0, 0, 0, 0.07);
  --code-bg: rgba(0, 0, 0, 0.06);
  --brand-grad-start: #1f1f1f;
  --brand-grad-end: #8a8a8a;
  --bg-layer-a: rgba(255, 255, 255, 0.52);
  --bg-layer-b: rgba(255, 255, 255, 0.34);
  --bg-grad-start: #fafafa;
  --bg-grad-mid: #f0f0f0;
  --bg-grad-end: #e7e7e7;
  --toast-bg: rgba(255, 255, 255, 0.88);
  --pill-active-start: #1f1f1f;
  --pill-active-end: #505050;
  --pill-active-border: rgba(0, 0, 0, 0.52);
  --pill-active-text: #ffffff;
  --pill-focus: rgba(56, 97, 182, 0.38);
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-0: #0a1018;
    --bg-1: #111a25;
    --bg-2: #172231;
    --bg-3: #1e2a3b;
    --line: rgba(170, 194, 225, 0.42);
    --line-soft: rgba(170, 194, 225, 0.25);
    --text-1: #f4f7fc;
    --text-2: #d3deed;
    --text-3: #acbdd4;
    --ok: #f3f7ff;
    --danger: #f6f1f1;
    --glass-bg: rgba(12, 18, 28, 0.72);
    --panel-bg: rgba(12, 18, 28, 0.64);
    --soft-fill: rgba(149, 179, 221, 0.13);
    --hover-fill: rgba(149, 179, 221, 0.24);
    --code-bg: rgba(149, 179, 221, 0.18);
    --brand-grad-start: #eef5ff;
    --brand-grad-end: #95abcc;
    --bg-layer-a: rgba(111, 151, 207, 0.22);
    --bg-layer-b: rgba(137, 172, 219, 0.16);
    --bg-grad-start: #070c13;
    --bg-grad-mid: #0f1723;
    --bg-grad-end: #182233;
    --toast-bg: rgba(10, 16, 25, 0.93);
    --pill-active-start: #2f7dff;
    --pill-active-end: #5da7ff;
    --pill-active-border: rgba(146, 194, 255, 0.88);
    --pill-active-text: #081324;
    --pill-focus: rgba(141, 190, 255, 0.66);
  }
}

* {
  box-sizing: border-box;
  box-shadow: none !important;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

*::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg-0);
  color: var(--text-1);
  font-family: 'Space Grotesk', system-ui, sans-serif;
}

body {
  min-height: 100dvh;
  overflow: auto;
}

input,
textarea,
select,
button {
  font: inherit;
  color: var(--text-1);
}

button {
  cursor: pointer;
}

code {
  font-family: 'IBM Plex Mono', monospace;
  background: var(--code-bg);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 0 6px;
}

.bg-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(1200px 420px at -15% -20%, var(--bg-layer-a), transparent 60%),
    radial-gradient(900px 360px at 100% 120%, var(--bg-layer-b), transparent 65%),
    linear-gradient(140deg, var(--bg-grad-start) 0%, var(--bg-grad-mid) 45%, var(--bg-grad-end) 100%);
}

.glass {
  background: var(--glass-bg);
  border: 1px solid var(--line-soft);
  backdrop-filter: blur(14px) saturate(130%);
  -webkit-backdrop-filter: blur(14px) saturate(130%);
}

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-panel {
  width: min(560px, calc(100% - 36px));
  border-radius: var(--radius-lg);
  padding: 28px;
}

.login-panel h1 {
  margin: 0 0 8px;
  font-size: 1.6rem;
}

.login-panel p {
  margin: 0;
  color: var(--text-2);
}

.app-shell {
  position: relative;
  z-index: 2;
  display: block;
  height: 100dvh;
  padding: 14px 16px 116px;
  overflow: auto;
}

.chrome-row {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100vw - 20px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  z-index: 60;
}

.liquid-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 6px;
  border: 1px solid var(--line);
  max-width: calc(100vw - 24px);
  overflow: auto;
}

.nav-btn {
  width: 38px;
  height: 38px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
}

.nav-btn svg {
  width: 20px;
  height: 20px;
}

.nav-btn:hover {
  background: var(--soft-fill);
  border-color: var(--line-soft);
  color: var(--text-1);
}

.nav-btn.active {
  border-color: var(--line);
  color: var(--text-1);
  background: var(--hover-fill);
}

.workspace {
  border: none;
  background: transparent;
  padding: 6px 2px 20px;
  min-height: 0;
  overflow: visible;
}

.pane {
  display: none;
}

.pane.active {
  display: grid;
  gap: 12px;
}

.pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid var(--line-soft);
  padding-bottom: 8px;
}

.pane-head h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 650;
  letter-spacing: 0.01em;
}

.head-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.head-actions.standalone {
  padding-top: 2px;
}

.btn {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: var(--soft-fill);
  color: var(--text-1);
  padding: 8px 12px;
  white-space: nowrap;
}

.btn:hover {
  border-color: var(--line);
  background: var(--hover-fill);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.btn.danger {
  border-color: var(--line);
}

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

.field {
  display: grid;
  gap: 6px;
}

.field span {
  font-size: 0.76rem;
  color: var(--text-3);
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.field input,
.field textarea,
.field select,
.inline-form input,
.inline-form textarea,
.inline-form select {
  width: 100%;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: var(--soft-fill);
  padding: 8px 10px;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-3);
  opacity: 0.88;
}

.field input:focus,
.field textarea:focus,
.field select:focus,
.inline-form input:focus,
.inline-form textarea:focus,
.inline-form select:focus {
  outline: none;
  border-color: var(--line);
  background: var(--hover-fill);
}

.field small {
  color: var(--text-3);
  font-size: 0.75rem;
}

.field-full {
  grid-column: 1 / -1;
}

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

.split-col {
  border: none;
  border-radius: 0;
  padding: 0;
  background: transparent;
}

.split-col h3 {
  margin: 0 0 8px;
  font-size: 0.84rem;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.tool-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tool-item {
  appearance: none;
  cursor: pointer;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--soft-fill);
  color: var(--text-2);
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.12s ease;
}

.tool-item:hover {
  border-color: var(--line);
  background: var(--hover-fill);
  color: var(--text-1);
}

.tool-item:focus-visible {
  outline: 2px solid var(--pill-focus);
  outline-offset: 2px;
}

.tool-item:active {
  transform: translateY(1px);
}

.tool-item.is-active {
  border-color: var(--pill-active-border);
  background: linear-gradient(145deg, var(--pill-active-start), var(--pill-active-end));
  color: var(--pill-active-text);
}

.inline-form {
  display: grid;
  gap: 8px;
  border: none;
  border-radius: 0;
  padding: 0;
  background: transparent;
}

.inline-form.tight {
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  align-items: end;
}

.inline-form.tight label {
  display: grid;
  gap: 6px;
}

.inline-form.tight label span {
  font-size: 0.74rem;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.table-wrap {
  overflow: auto;
  border: none;
  border-radius: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  border-bottom: 1px solid var(--line-soft);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--text-3);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 600;
  background: transparent;
  border-top: 1px solid var(--line-soft);
}

tbody tr:hover {
  background: var(--soft-fill);
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.row-actions .btn {
  padding: 5px 9px;
  font-size: 0.8rem;
}

.row-current {
  font-weight: 700;
  font-family: 'IBM Plex Mono', monospace;
  color: var(--ok);
}

.list-wrap {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
  border: none;
  border-radius: 0;
  padding: 2px 0;
  background: transparent;
}

.model-item {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: var(--soft-fill);
  padding: 8px 10px;
  text-align: left;
}

.model-item.active {
  border-color: var(--line);
  background: var(--hover-fill);
}

.log-panel {
  border: 1px dashed var(--line-soft);
  border-radius: 12px;
  background: transparent;
  padding: 10px;
  min-height: 72px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.83rem;
  color: var(--text-2);
}

.pagination-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%) translateY(10px);
  border-radius: 999px;
  border: 1px solid var(--line-soft);
  background: var(--toast-bg);
  padding: 8px 14px;
  color: var(--text-1);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 100;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.error {
  border-color: var(--line);
}

@media (max-width: 1150px) {
  .field-grid,
  .split-block,
  .inline-form.tight {
    grid-template-columns: 1fr;
  }

  .chrome-row {
    left: 10px;
    right: 10px;
    transform: none;
    width: auto;
    justify-content: center;
    align-items: center;
    gap: 0;
  }

  .liquid-nav {
    max-width: calc(100vw - 20px);
    padding: 5px;
    gap: 5px;
  }

  .nav-btn {
    width: 34px;
    height: 34px;
    border-radius: 11px;
  }

  .nav-btn svg {
    width: 18px;
    height: 18px;
  }
}
