:root {
  --bg: #fff9f5;
  --bg-grid: rgba(226, 164, 177, 0.16);
  --panel: rgba(255, 255, 255, 0.88);
  --panel-border: #f0b6c3;
  --panel-shadow: #efcdd6;
  --text: #5c4254;
  --text-soft: #8e7180;
  --mint: #caefd7;
  --mint-deep: #86bea0;
  --peach: #ffd9c9;
  --rose: #f9d9df;
  --sky: #dbeeff;
  --yellow: #fff2ba;
  --danger: #e97a93;
  --success: #79bf95;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "VT323", monospace;
  font-size: 24px;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 222, 230, 0.8), transparent 28%),
    radial-gradient(circle at bottom right, rgba(214, 240, 223, 0.8), transparent 26%),
    linear-gradient(180deg, #fffdfa 0%, #fff4f1 100%);
}

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

button {
  cursor: pointer;
  border: 0;
}

.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(var(--bg-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
  background-size: 22px 22px;
  pointer-events: none;
}

.app {
  position: relative;
  max-width: 1320px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 24px;
}

.brand {
  display: flex;
  gap: 18px;
  align-items: center;
}

.brand h1,
.section-head h2,
.card-head h2 {
  margin: 0;
  font-family: "Press Start 2P", monospace;
  font-size: 16px;
  line-height: 1.5;
}

.brand p {
  margin: 10px 0 0;
  color: var(--text-soft);
}

.brand-icon {
  width: 38px;
  height: 38px;
  border: 4px solid var(--text);
  background:
    linear-gradient(90deg, transparent 20%, var(--text) 20%, var(--text) 34%, transparent 34%, transparent 66%, var(--text) 66%, var(--text) 80%, transparent 80%),
    linear-gradient(180deg, var(--rose) 0%, var(--peach) 100%);
  box-shadow: 6px 6px 0 0 var(--panel-shadow);
}

.toolbar,
.button-row,
.card-head,
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.lang-toggle {
  display: flex;
  gap: 8px;
}

.lang-btn,
.ghost-btn,
.primary-btn {
  border: 3px solid var(--text);
  border-radius: 0;
  min-height: 44px;
  padding: 8px 14px;
  box-shadow: 4px 4px 0 0 rgba(92, 66, 84, 0.18);
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.lang-btn:hover,
.ghost-btn:hover,
.primary-btn:hover {
  transform: translate(-1px, -1px);
  box-shadow: 6px 6px 0 0 rgba(92, 66, 84, 0.22);
}

.lang-btn.active,
.primary-btn {
  background: var(--rose);
}

.primary-btn.secondary {
  background: var(--mint);
}

.ghost-btn,
.lang-btn {
  background: rgba(255, 255, 255, 0.75);
}

.shell,
.dashboard,
.dashboard-grid,
.auth-grid {
  display: grid;
  gap: 18px;
}

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

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

.panel,
.card {
  background: var(--panel);
  border: 4px solid var(--panel-border);
  box-shadow: 10px 10px 0 0 var(--panel-shadow);
  padding: 18px;
}

.panel-compact {
  min-height: 188px;
}

.panel:nth-child(1) {
  grid-column: span 4;
}

.panel:nth-child(2) {
  grid-column: span 4;
}

.panel:nth-child(3) {
  grid-column: span 4;
}

.panel:nth-child(4) {
  grid-column: span 8;
}

.panel:nth-child(5) {
  grid-column: span 4;
}

.hidden {
  display: none !important;
}

.pixel-pill {
  padding: 6px 10px;
  background: var(--sky);
  border: 3px solid var(--text);
  font-family: "Press Start 2P", monospace;
  font-size: 10px;
  line-height: 1.4;
}

.pixel-pill.mint {
  background: var(--mint);
}

.pixel-pill.peach {
  background: var(--peach);
}

.stats-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 16px;
}

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

.stat-box,
.connection-box {
  border: 3px solid rgba(92, 66, 84, 0.22);
  background: rgba(255, 255, 255, 0.82);
  padding: 12px;
}

.connection-box {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.label {
  display: block;
  color: var(--text-soft);
  font-size: 20px;
}

strong,
code {
  word-break: break-word;
}

.status-dot {
  width: 16px;
  height: 16px;
  background: var(--danger);
  border: 3px solid var(--text);
  display: inline-block;
}

.status-dot.running {
  background: var(--success);
}

.runtime-meta {
  margin-top: 14px;
  display: grid;
  gap: 8px;
}

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

label {
  display: grid;
  gap: 8px;
}

input,
select,
textarea {
  border: 3px solid rgba(92, 66, 84, 0.24);
  background: rgba(255, 255, 255, 0.95);
  min-height: 48px;
  padding: 10px 12px;
  outline: none;
}

textarea {
  min-height: 140px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--mint-deep);
  box-shadow: 0 0 0 4px rgba(134, 190, 160, 0.18);
}

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

.switch {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 3px dashed rgba(92, 66, 84, 0.2);
  padding: 10px 12px;
  min-height: 48px;
}

.switch input {
  min-height: auto;
  margin: 0;
  width: 22px;
  height: 22px;
}

.upload-row {
  display: flex;
  gap: 12px;
  align-items: center;
}

.upload-row input {
  flex: 1;
}

.profile-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.profile-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
  border: 3px solid rgba(92, 66, 84, 0.18);
  background: rgba(255, 255, 255, 0.75);
  padding: 10px 12px;
}

.profile-item code {
  font-size: 20px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(440px, calc(100vw - 40px));
  padding: 14px 16px;
  background: var(--yellow);
  border: 3px solid var(--text);
  box-shadow: 8px 8px 0 0 rgba(92, 66, 84, 0.22);
}

@media (max-width: 1080px) {
  .dashboard-grid,
  .auth-grid,
  .settings-grid,
  .stats-grid,
  .stats-grid.slim {
    grid-template-columns: 1fr;
  }

  .panel:nth-child(1),
  .panel:nth-child(2),
  .panel:nth-child(3),
  .panel:nth-child(4),
  .panel:nth-child(5) {
    grid-column: span 12;
  }
}

@media (max-width: 720px) {
  body {
    font-size: 22px;
  }

  .app {
    padding: 18px 14px 44px;
  }

  .topbar,
  .brand,
  .toolbar,
  .upload-row,
  .button-row {
    flex-direction: column;
    align-items: stretch;
  }

  .brand h1,
  .section-head h2,
  .card-head h2 {
    font-size: 14px;
  }

  .profile-item {
    grid-template-columns: 1fr;
  }
}
