@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Pixelify+Sans:wght@400;500;600;700&display=swap");

:root {
  --bg: #111214;
  --bg-grid: rgba(255, 255, 255, 0.035);
  --surface: #2b2d31;
  --surface-strong: #313338;
  --surface-soft: #232428;
  --surface-raised: #383a40;
  --ink: #f2f3f5;
  --muted: #b5bac1;
  --muted-weak: #838995;
  --line: #44474f;
  --line-soft: #34363c;
  --discord: #5865f2;
  --discord-strong: #4752c4;
  --discord-soft: rgba(88, 101, 242, 0.18);
  --green: #23a559;
  --green-strong: #1f8b4c;
  --yellow: #f0b232;
  --red: #f23f42;
  --red-soft: rgba(242, 63, 66, 0.16);
  --cyan: #3ba7c7;
  --pink: #eb459e;
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.28);
  --pixel-shadow: 5px 5px 0 rgba(0, 0, 0, 0.26);
  --radius: 8px;
  --font-body: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-pixel: "Pixelify Sans", "Courier New", monospace;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(var(--bg-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px),
    linear-gradient(180deg, #1c1d22 0, #111214 360px, #111214 100%);
  background-size: 24px 24px, 24px 24px, auto;
  color: var(--ink);
  font-family: var(--font-body);
  letter-spacing: 0;
}

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

button {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 18px 0 34px;
}

.dashboard[hidden],
.auth-gate[hidden] {
  display: none;
}

.auth-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  align-content: center;
  text-align: center;
  padding: 28px 0;
}

.auth-gate-content {
  width: min(440px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 28px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(43, 45, 49, 0.94);
  box-shadow: var(--shadow), var(--pixel-shadow);
}

.tg-logo-wrapper {
  width: 76px;
  height: 76px;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  background: var(--discord);
  color: #fff;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.22);
}

.tg-logo-wrapper .icon {
  width: 36px;
  height: 36px;
}

.auth-gate h1 {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-pixel);
  font-size: 34px;
  font-weight: 700;
  line-height: 1;
}

.auth-gate-kicker {
  min-height: 24px;
  margin: 4px 0 0;
  padding: 2px 9px;
  border: 1px solid var(--discord);
  border-radius: var(--radius);
  color: #d8dcff;
  background: var(--discord-soft);
  font-family: var(--font-pixel);
  font-size: 16px;
  font-weight: 700;
}

.auth-gate-description {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.55;
}

.auth-gate-actions {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}

.tg-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  width: 100%;
  min-height: 48px;
  padding: 0 18px;
  border: 0;
  border-radius: var(--radius);
  background: #229ed9;
  color: #fff;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.2);
  cursor: pointer;
  font-family: var(--font-pixel);
  font-size: 18px;
  font-weight: 700;
  text-decoration: none;
  transition: background 0.14s ease, transform 0.14s ease, box-shadow 0.14s ease;
}

.tg-button:hover {
  background: #1a8fca;
  transform: translateY(-1px);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.2), 0 10px 22px rgba(34, 158, 217, 0.24);
}

.tg-button:active {
  transform: translateY(0);
}

.tg-button:focus-visible {
  outline: 3px solid rgba(34, 158, 217, 0.28);
  outline-offset: 3px;
}

.tg-button-icon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: 0 0 26px;
  background: #fff;
  color: #229ed9;
}

.tg-button-icon .icon {
  width: 15px;
  height: 15px;
}

.gate-icon {
  width: 54px;
  height: 54px;
  color: var(--green);
}

.topbar {
  min-height: 78px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
}

.brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  border: 1px solid #6f78ff;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  background: var(--discord);
  color: #fff;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.22), 4px 4px 0 rgba(0, 0, 0, 0.22);
}

.brand h1,
.surface-heading h2,
.section-title-row h2,
.modal-heading h2,
.starter-panel h2 {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-pixel);
  font-weight: 700;
  line-height: 1;
}

.brand h1 {
  font-size: clamp(31px, 4vw, 46px);
}

.brand p,
.surface-heading p,
.section-title-row p,
.runtime-strip p {
  margin: 4px 0 0;
  color: var(--muted);
}

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

.icon {
  width: 20px;
  height: 20px;
  display: inline-block;
  flex: 0 0 auto;
  background: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
}

.icon-bot { --icon: url("/icons/bot.svg"); }
.icon-refresh { --icon: url("/icons/refresh-cw.svg"); }
.icon-key { --icon: url("/icons/key.svg"); }
.icon-users { --icon: url("/icons/users.svg"); }
.icon-plug { --icon: url("/icons/plug.svg"); }
.icon-check { --icon: url("/icons/check-circle.svg"); }
.icon-alert { --icon: url("/icons/alert-circle.svg"); }
.icon-shield { --icon: url("/icons/shield.svg"); }
.icon-x { --icon: url("/icons/x.svg"); }
.icon-link { --icon: url("/icons/link.svg"); }
.icon-power { --icon: url("/icons/power.svg"); }
.icon-mic { --icon: url("/icons/mic.svg"); }
.icon-mic-off { --icon: url("/icons/mic-off.svg"); }
.icon-volume { --icon: url("/icons/volume-2.svg"); }
.icon-volume-off { --icon: url("/icons/volume-x.svg"); }
.icon-lock { --icon: url("/icons/lock.svg"); }
.icon-trash { --icon: url("/icons/trash-2.svg"); }
.icon-headphones { --icon: url("/icons/headphones.svg"); }
.icon-clock { --icon: url("/icons/clock-3.svg"); }

.gate-icon.icon {
  width: 54px;
  height: 54px;
}

.brand-mark .icon {
  width: 25px;
  height: 25px;
}

.main-grid {
  display: grid;
  gap: 16px;
}

.starter-panel {
  position: relative;
  min-height: 164px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 12px),
    var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow), var(--pixel-shadow);
  overflow: hidden;
}

.starter-panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: linear-gradient(90deg, var(--discord), var(--green), var(--yellow), var(--pink));
}

.starter-copy {
  min-width: 0;
}

.starter-eyebrow {
  display: inline-flex;
  align-items: center;
  min-height: 27px;
  padding: 1px 9px;
  border: 1px solid var(--discord);
  border-radius: var(--radius);
  background: var(--discord-soft);
  color: #d8dcff;
  font-family: var(--font-pixel);
  font-size: 16px;
  font-weight: 700;
}

.starter-panel h2 {
  max-width: 720px;
  margin-top: 12px;
  font-size: 31px;
}

.starter-panel p {
  max-width: 790px;
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.starter-actions {
  min-width: 196px;
  display: grid;
  gap: 10px;
}

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

.metric-card {
  min-height: 118px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 8px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(43, 45, 49, 0.94);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.18);
}

.metric-card:nth-child(1) .metric-icon { color: var(--discord); }
.metric-card:nth-child(2) .metric-icon { color: var(--green); }
.metric-card:nth-child(3) .metric-icon { color: var(--cyan); }
.metric-card:nth-child(4) .metric-icon { color: var(--red); }

.metric-label {
  color: var(--muted);
  font-family: var(--font-pixel);
  font-size: 17px;
  font-weight: 600;
}

.metric-card strong {
  color: var(--ink);
  font-family: var(--font-pixel);
  font-size: 42px;
  line-height: 0.9;
}

.runtime-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid rgba(240, 178, 50, 0.42);
  border-radius: var(--radius);
  background: rgba(240, 178, 50, 0.12);
  color: var(--yellow);
}

.runtime-strip.enabled {
  border-color: rgba(35, 165, 89, 0.48);
  background: rgba(35, 165, 89, 0.13);
  color: var(--green);
}

.runtime-strip strong {
  color: var(--ink);
  font-family: var(--font-pixel);
  font-size: 19px;
}

.runtime-strip p {
  font-size: 14px;
}

.control-surface,
.accounts-section {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(43, 45, 49, 0.96);
  box-shadow: var(--shadow);
}

.surface-heading,
.section-title-row,
.modal-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.surface-heading h2,
.section-title-row h2,
.modal-heading h2 {
  font-size: 27px;
}

.channel-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  gap: 10px;
  margin-top: 18px;
}

.input-wrap,
.field input {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  color: var(--muted-weak);
}

.input-wrap:focus-within,
.field input:focus {
  border-color: var(--discord);
  box-shadow: 0 0 0 3px rgba(88, 101, 242, 0.22);
}

.input-wrap input,
.field input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

.input-wrap input::placeholder,
.field input::placeholder {
  color: #747b87;
}

.primary-button,
.secondary-button,
.ghost-button,
.chip-button,
.icon-button {
  min-height: 42px;
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: inherit;
  font-family: var(--font-pixel);
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  transition: background 0.14s ease, color 0.14s ease, box-shadow 0.14s ease, transform 0.14s ease, border-color 0.14s ease;
}

.primary-button {
  padding: 0 16px;
  background: var(--discord);
  color: #fff;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.2);
}

.secondary-button {
  padding: 0 16px;
  background: var(--surface-raised);
  color: var(--ink);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.18);
}

.secondary-button.compact {
  min-height: 38px;
}

.primary-button.large,
.secondary-button.large {
  min-height: 46px;
  padding: 0 18px;
}

.ghost-button {
  padding: 0 12px;
  background: transparent;
  color: var(--muted);
}

.danger {
  color: #ff8d8f;
}

.icon-button {
  width: 42px;
  padding: 0;
  background: var(--surface-raised);
  color: var(--ink);
}

.primary-button:hover {
  background: var(--discord-strong);
  transform: translateY(-1px);
}

.secondary-button:hover,
.icon-button:hover,
.chip-button:hover {
  background: #42454d;
}

.ghost-button:hover {
  background: var(--surface-raised);
}

.primary-button:disabled,
.secondary-button:disabled,
.ghost-button:disabled,
.chip-button:disabled,
.icon-button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.chip-button {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--ink);
}

.accounts-section {
  display: grid;
  gap: 14px;
}

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

.token-row,
.account-row {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--surface-soft);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.025);
}

.token-row {
  min-height: 54px;
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(120px, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
}

.account-list {
  display: grid;
  gap: 10px;
}

.account-row {
  min-height: 74px;
  display: grid;
  grid-template-columns: minmax(170px, 1.35fr) minmax(120px, 0.8fr) minmax(120px, 0.8fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
}

.account-main {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 42px;
  height: 42px;
  border: 1px solid rgba(88, 101, 242, 0.34);
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  background: rgba(88, 101, 242, 0.16);
  color: #d8dcff;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.subtle {
  color: var(--muted-weak);
  font-size: 13px;
}

.status-badge {
  width: fit-content;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-family: var(--font-pixel);
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
}

.status-stored,
.status-ready,
.status-connecting {
  border-color: rgba(240, 178, 50, 0.34);
  background: rgba(240, 178, 50, 0.14);
  color: #ffd37a;
}

.status-connected {
  border-color: rgba(35, 165, 89, 0.36);
  background: rgba(35, 165, 89, 0.16);
  color: #6ce69a;
}

.status-error {
  border-color: rgba(242, 63, 66, 0.38);
  background: var(--red-soft);
  color: #ff9a9c;
}

.voice-state {
  display: flex;
  align-items: center;
  gap: 6px;
}

.voice-state .icon-button {
  width: 36px;
  min-height: 36px;
}

.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.empty-state {
  min-height: 188px;
  border: 1px dashed #5d6270;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
  padding: 22px;
  background: var(--surface-soft);
}

.empty-state-content {
  max-width: 420px;
  display: grid;
  justify-items: center;
  gap: 10px;
}

.empty-state-icon {
  width: 46px;
  height: 46px;
  border: 1px solid rgba(88, 101, 242, 0.34);
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  background: rgba(88, 101, 242, 0.16);
  color: #d8dcff;
}

.empty-state-icon .icon {
  width: 23px;
  height: 23px;
}

.empty-state h3,
.empty-state p {
  margin: 0;
}

.empty-state h3 {
  color: var(--ink);
  font-family: var(--font-pixel);
  font-size: 23px;
}

.empty-token-list {
  min-height: 62px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px dashed #5d6270;
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--muted);
}

.empty-token-list p {
  margin: 0;
}

.modal {
  width: min(470px, calc(100% - 26px));
  border: 0;
  border-radius: var(--radius);
  padding: 0;
  background: transparent;
}

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

.modal-box {
  display: grid;
  gap: 16px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow), var(--pixel-shadow);
}

.field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
}

.field span {
  color: var(--ink);
  font-family: var(--font-pixel);
  font-size: 18px;
  font-weight: 700;
}

.field input {
  padding: 0 12px;
  color: var(--ink);
}

.field small {
  color: var(--muted-weak);
  line-height: 1.35;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100% - 36px));
  padding: 13px 15px;
  border: 1px solid rgba(35, 165, 89, 0.38);
  border-radius: var(--radius);
  background: #193d2a;
  color: #d7ffe6;
  box-shadow: var(--shadow);
  transform: translateY(24px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast.error {
  border-color: rgba(242, 63, 66, 0.42);
  background: #512326;
  color: #ffd7d8;
}

@media (max-width: 900px) {
  .starter-panel {
    grid-template-columns: 1fr;
  }

  .starter-actions {
    grid-template-columns: 1fr 1fr;
    min-width: 0;
  }

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

  .channel-form,
  .account-row {
    grid-template-columns: 1fr;
  }

  .row-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 18px, 1180px);
    padding-top: 10px;
  }

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

  .topbar-actions {
    flex: 0 0 auto;
  }

  .brand {
    gap: 10px;
  }

  .brand-mark {
    width: 40px;
    height: 40px;
    flex-basis: 40px;
  }

  .brand h1 {
    font-size: 31px;
  }

  .metrics {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .starter-panel {
    min-height: 0;
    padding: 18px;
  }

  .starter-panel h2 {
    font-size: 25px;
  }

  .starter-actions {
    grid-template-columns: 1fr;
  }

  .metric-card {
    min-height: 104px;
    padding: 14px;
  }

  .metric-card strong {
    font-size: 36px;
  }

  .surface-heading h2,
  .section-title-row h2,
  .modal-heading h2 {
    font-size: 25px;
  }

  .control-surface,
  .accounts-section {
    padding: 14px;
  }

  .surface-heading,
  .section-title-row {
    align-items: flex-start;
  }

  .section-title-row {
    flex-direction: column;
  }

  .section-title-row .secondary-button {
    width: 100%;
  }

  .primary-button,
  .secondary-button,
  .ghost-button,
  .chip-button,
  .tg-button {
    white-space: normal;
    text-align: center;
  }

  .token-row {
    grid-template-columns: 1fr auto;
  }

  .token-row code {
    grid-column: 1 / -1;
  }
}
