/* Dark by default. The widget card is a replica of the Discord profile widget,
   so the metrics (radii, spacing, type scale) follow Discord's dark theme: card
   surface #1e1f22, borders #2b2d31, primary text #f2f3f5, muted #b5bac1. */

:root {
  --page: #111214;
  --surface: #1e1f22;
  --surface-2: #2b2d31;
  --border: #2b2d31;
  --text: #f2f3f5;
  --muted: #b5bac1;
  --muted-2: #949ba4;
  --accent: #5865f2;
  --ok: #23a55a;
  --err: #f23f43;
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font-family: "gg sans", "Noto Sans", Helvetica, Arial, sans-serif;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

.page {
  max-width: 620px;
  margin: 0 auto;
  padding: 40px 20px 64px;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.page-head > div {
  min-width: 0;
}

.btn.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  font-weight: 500;
  flex: none;
}

.btn.ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}

.page-head h1 {
  margin: 0 0 6px;
  font-size: 20px;
  letter-spacing: -0.01em;
}

.page-head p {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

/* ---------- the widget card ---------- */

.widget {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid #26272b;
  overflow: hidden;
}

.widget-top {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 24px 0;
}

.widget-app-icon {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  flex: none;
}

.widget-app-name {
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 2px 6px;
  margin-left: -6px;
  width: 46%;
  min-width: 120px;
}

.widget-main {
  display: grid;
  grid-template-columns: minmax(0, 55%) minmax(0, 45%);
  gap: 20px;
  padding: 12px 24px 20px;
}

.widget-text {
  min-width: 0;
}

.widget-title {
  font: inherit;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #fff;
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 4px 8px;
  margin: 0 0 4px -8px;
}

.widget-rule {
  width: 32px;
  height: 1px;
  background: #4e5058;
  margin: 6px 0 14px;
}

.widget-quote {
  font: inherit;
  font-size: 14px;
  line-height: 1.4;
  color: #dbdee1;
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 4px 8px;
  margin-left: -8px;
  resize: none;
  overflow: hidden;
}

.widget-hero {
  position: relative;
  display: block;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: #1a1b1e;
  aspect-ratio: 4 / 3;
  width: 100%;
  align-self: start;
  cursor: pointer;
  overflow: hidden;
}

.widget-hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.hero-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted-2);
  font-size: 13px;
}

.hero-veil {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background: rgba(0, 0, 0, 0.55);
  opacity: 0;
  transition: opacity 0.15s ease;
}

.widget-hero:hover .hero-veil,
.widget-hero:focus-visible .hero-veil,
.widget-hero.drag .hero-veil {
  opacity: 1;
}

.widget-hero.drag {
  border-color: var(--accent);
}

/* edit affordances: invisible until hovered or focused */
.widget-title:hover,
.widget-quote:hover,
.widget-app-name:hover {
  background: rgba(255, 255, 255, 0.04);
}

.widget-title:focus,
.widget-quote:focus,
.widget-app-name:focus {
  outline: none;
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--accent);
}

/* ---------- stats grid ---------- */

.widget-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  border-top: 1px solid var(--border);
  padding: 18px 24px 22px;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.stat-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
}

.stat-label img {
  width: 16px;
  height: 16px;
  flex: none;
}

.stat-value {
  font-size: 13px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- controls under the card ---------- */

.controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 18px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid #26272b;
  border-radius: var(--radius);
}

.control {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.control select {
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: #1a1b1e;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  min-width: 140px;
}

.btn {
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 16px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}

.btn:hover {
  background: #35373c;
}

.btn.primary {
  background: var(--accent);
  color: #fff;
}

.btn.primary:hover {
  background: #4752c4;
}

.btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.btn.tiny {
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 500;
}

.status {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  flex-basis: 100%;
  min-height: 18px;
}

.status.success {
  color: var(--ok);
}

.status.error {
  color: var(--err);
}

/* ---------- admin ---------- */

.admin {
  margin-top: 18px;
  background: var(--surface);
  border: 1px solid #26272b;
  border-radius: var(--radius);
  padding: 14px 18px;
}

.admin summary {
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
}

.admin-body {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.admin-row {
  display: flex;
  gap: 10px;
}

.admin-row input {
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: #1a1b1e;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 10px;
  flex: 1;
}

.user-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.user-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--muted);
  border-top: 1px solid #26272b;
  padding-top: 8px;
}

.user-list li code {
  color: var(--text);
  font-size: 12px;
}

.user-list li span {
  flex: 1;
}

/* ---------- gate ---------- */

.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.gate-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid #26272b;
  border-radius: 16px;
  padding: 32px 28px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.gate-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
}

.gate-card h1 {
  margin: 0;
  font-size: 20px;
}

.gate-card p {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

/* ---------- narrow screens ---------- */

@media (max-width: 620px) {
  .page {
    padding: 24px 14px 48px;
  }

  .widget-top,
  .widget-main,
  .widget-stats {
    padding-left: 16px;
    padding-right: 16px;
  }

  .widget-main {
    grid-template-columns: minmax(0, 1fr);
  }

  .widget-hero {
    order: -1;
  }

  .widget-title {
    font-size: 22px;
  }

  .widget-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
