:root {
  color-scheme: dark;
  --bg: #050505;
  --panel: #0d0d0d;
  --panel-2: #141414;
  --line: #2c2c2c;
  --line-strong: #f5f5f5;
  --text: #f4f4f4;
  --muted: #a8a8a8;
  --soft: #1d1d1d;
  --danger: #ff6565;
  --ok: #ffffff;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 184px minmax(0, 1fr);
  width: 100vw;
  height: 100vh;
  background: var(--bg);
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
  padding: 18px 14px;
  border-right: 1px solid var(--line);
  background: #070707;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0;
}

.brand-mark {
  width: 22px;
  height: 22px;
  border: 2px solid var(--text);
  border-radius: 50%;
  box-shadow:
    inset 0 0 0 5px var(--bg),
    0 0 0 1px var(--bg);
}

.tool-list {
  display: grid;
  gap: 8px;
}

.tool-button,
.ghost-button,
.primary-button,
.icon-button {
  border: 1px solid var(--line);
  background: var(--panel);
  cursor: pointer;
  transition:
    background 120ms ease,
    border-color 120ms ease,
    transform 120ms ease;
}

.tool-button {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 42px;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--muted);
  text-align: left;
}

.tool-button:hover,
.ghost-button:hover,
.primary-button:hover,
.icon-button:hover {
  border-color: #777;
  background: var(--panel-2);
}

.tool-button.active {
  border-color: var(--line-strong);
  background: var(--text);
  color: var(--bg);
}

.tool-icon {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
}

.tool-icon {
  font-size: 15px;
}

.tool-icon svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar-footer {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: auto;
}

.ghost-button,
.primary-button {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 8px;
}

.primary-button {
  border-color: var(--text);
  background: var(--text);
  color: var(--bg);
  font-weight: 700;
}

.ghost-button {
  background: transparent;
  color: var(--muted);
}

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

.workspace {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #050505;
}

#board {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

.top-strip {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}

.status-text,
.network-stats,
.toast {
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(5, 5, 5, 0.78);
  color: var(--muted);
  backdrop-filter: blur(12px);
}

.status-text,
.network-stats {
  min-height: 34px;
  padding: 8px 10px;
  font-size: 13px;
  white-space: nowrap;
}

.inspector {
  position: absolute;
  right: 16px;
  bottom: 16px;
  width: min(360px, calc(100% - 32px));
  max-height: min(560px, calc(100% - 96px));
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(12, 12, 12, 0.92);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.inspector.hidden,
.toast.hidden {
  display: none;
}

.inspector-inner {
  display: grid;
  gap: 14px;
  padding: 14px;
}

.inspector header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.inspector h2,
.modal h2 {
  margin: 0;
  font-size: 16px;
  line-height: 1.3;
}

.inspector .subtle {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

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

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

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

.field label {
  color: var(--muted);
  font-size: 12px;
}

.field input,
.field select {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  padding: 0 10px;
  outline: none;
}

.field input:focus,
.field select:focus {
  border-color: var(--text);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.button-row button {
  flex: 1 1 auto;
}

.toast {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  padding: 10px 12px;
  color: var(--text);
  box-shadow: var(--shadow);
}

.modal {
  width: min(420px, calc(100vw - 32px));
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.72);
}

.modal-card {
  display: grid;
  gap: 14px;
  margin: 0;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: #0b0b0b;
  padding: 16px;
  box-shadow: var(--shadow);
}

.modal-card header,
.modal-card footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.modal-card footer {
  justify-content: flex-end;
}

.modal-body {
  display: grid;
  gap: 12px;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 50%;
}

.choice-list {
  display: grid;
  gap: 8px;
  max-height: 260px;
  overflow: auto;
}

.choice-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
  min-height: 42px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
}

.ratio-result {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
}

.ratio-value {
  font-size: 24px;
  font-weight: 800;
}

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 74px minmax(0, 1fr);
  }

  .sidebar {
    padding: 12px 8px;
  }

  .brand span:last-child,
  .tool-button span:last-child {
    display: none;
  }

  .tool-button {
    grid-template-columns: 1fr;
    justify-items: center;
    padding: 8px;
  }

  .sidebar-footer {
    grid-template-columns: 1fr;
  }

  .top-strip {
    align-items: flex-start;
    flex-direction: column;
  }
}
