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

:root {
  --bg: #f6f3ee;
  --surface: #ffffff;
  --sunken: #f3efe8;
  --line: #e8e2d8;
  --ink: #1f1c17;
  --soft: #7a7268;
  --accent: #4f46e5;
  --accent-ink: #ffffff;
  --accent-wash: #eceafd;
  --good: #15803d;
  --good-wash: #e5f4ea;
  --bad: #c2410c;
  --bad-wash: #fdece3;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(31, 28, 23, .04), 0 8px 24px rgba(31, 28, 23, .06);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Space Grotesk", var(--font);
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15130f;
    --surface: #1d1a16;
    --sunken: #25221c;
    --line: #322e27;
    --ink: #f1ece4;
    --soft: #a29a8e;
    --accent: #a5b4fc;
    --accent-ink: #1e1b4b;
    --accent-wash: #25234a;
    --good: #4ade80;
    --good-wash: #15301f;
    --bad: #fb923c;
    --bad-wash: #3a2214;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.55 var(--font); -webkit-font-smoothing: antialiased; }
.hidden, [hidden] { display: none !important; }
h1, h2, h3 { font-family: var(--display); letter-spacing: -.01em; margin: 0; }
p { margin: 0; }
.soft { color: var(--soft); }
.small { font-size: 13px; }
code, .mono { font-family: var(--mono); font-size: 13px; }

input, textarea {
  width: 100%; font: inherit; color: inherit;
  background: var(--sunken); border: 1px solid transparent; border-radius: 12px;
  padding: 10px 12px; transition: border-color .15s, background .15s;
}
textarea { resize: vertical; }
input:focus, textarea:focus { outline: none; border-color: var(--accent); background: var(--surface); }
button {
  font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
  border: 0; border-radius: 12px; padding: 10px 18px;
  background: var(--sunken); color: var(--ink);
  transition: transform .06s, opacity .15s, background .15s;
}
button:active { transform: scale(.98); }
button:disabled { opacity: .4; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-ink); }
button.small { padding: 6px 12px; font-size: 13px; border-radius: 10px; }
button.link { background: none; padding: 4px 6px; color: var(--soft); font-weight: 500; }
button.link:hover { color: var(--ink); }
button.link.danger:hover { color: var(--bad); }

/* Topo */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 14px 28px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px);
}
.brand { font-family: var(--display); font-weight: 700; font-size: 18px; display: flex; align-items: center; gap: 10px; margin-right: auto; }
.brand .mark { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); font-size: 15px; }
.class-name { display: inline-block; font: 600 13px/1.4 var(--font); color: var(--accent); background: var(--accent-wash); border-radius: 999px; padding: 3px 11px; }

main { max-width: 1160px; margin: 0 auto; padding: 12px 28px 80px; }

/* Cartões */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 480px), 1fr)); gap: 20px; align-items: start; }
.card { background: var(--surface); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.server { display: flex; flex-direction: column; gap: 14px; }
.server.mine { box-shadow: 0 0 0 2px var(--accent), var(--shadow); }
.server-head { display: flex; align-items: flex-start; gap: 12px; }
.server-head h2 { font-family: var(--mono); font-size: 17px; font-weight: 700; word-break: break-all; }
.server-head .authors { color: var(--soft); font-size: 14px; }
.server-head .actions { margin-left: auto; display: flex; gap: 2px; }
.status { width: 10px; height: 10px; border-radius: 50%; background: var(--soft); margin-top: 8px; flex: none; }
.status.on { background: var(--good); box-shadow: 0 0 0 4px var(--good-wash); }
.status.off { background: var(--bad); box-shadow: 0 0 0 4px var(--bad-wash); }
.status.wait { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.description { white-space: pre-wrap; }
.connect { display: flex; gap: 8px; }
.connect input { flex: 1; min-width: 0; }

.counts { display: flex; gap: 8px; flex-wrap: wrap; }
.count { font-size: 13px; font-weight: 600; padding: 4px 12px; border-radius: 999px; background: var(--sunken); color: var(--soft); border: 0; cursor: pointer; }
.count.active { background: var(--accent-wash); color: var(--accent); }
.count:disabled { cursor: default; opacity: .6; }
.items { display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.item { padding: 10px 0; border-bottom: 1px solid var(--line); }
.item .sig { font-family: var(--mono); font-size: 13px; font-weight: 600; word-break: break-all; }
.item .sig .arg { color: var(--soft); font-weight: 400; }
.item p { color: var(--soft); font-size: 13.5px; margin-top: 2px; white-space: pre-wrap; }

.foot { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--soft); }
.foot .error { color: var(--bad); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.foot button { margin-left: auto; }

.empty { grid-column: 1 / -1; text-align: center; padding: 60px 20px; color: var(--soft); }

/* Formulário */
.modal { position: fixed; inset: 0; z-index: 40; background: rgba(20, 17, 12, .45); display: grid; place-items: center; padding: 16px; }
.modal .card { max-width: 560px; width: 100%; max-height: calc(100vh - 32px); overflow: auto; }
.modal form { display: flex; flex-direction: column; gap: 4px; margin-top: 14px; }
.field-label { font-weight: 600; font-size: 14px; margin-top: 10px; }
.field-label .soft { font-weight: 400; }
.modal .buttons { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.error-text { color: var(--bad); font-size: 14px; min-height: 1em; }

.toast { position: fixed; top: 76px; left: 50%; transform: translateX(-50%); z-index: 50; background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-weight: 600; font-size: 14px; box-shadow: var(--shadow); }
.toast.bad { background: var(--bad); color: #fff; }

@media (max-width: 640px) {
  .top { padding: 12px 16px; }
  main { padding: 8px 16px 60px; }
  .connect { flex-wrap: wrap; }
  .connect input { flex-basis: 100%; }
}

/* Sessão e entrada */
.session { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }
.login { min-height: calc(100vh - 80px); display: grid; place-items: center; padding: 16px; }
.login .card { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 12px; }
.login h1 { font-size: 26px; }
.login form { display: flex; flex-direction: column; gap: 8px; }
.code-input { font-family: var(--mono); text-transform: uppercase; letter-spacing: .15em; }
.switcher { display: flex; gap: 4px; background: var(--sunken); padding: 4px; border-radius: 12px; }
.switcher button { flex: 1; background: none; padding: 7px 10px; color: var(--soft); border-radius: 9px; }
.switcher button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.invite-text { margin: 8px 0 14px; }

/* Abas, alinhadas com a grade de cartões */
.bar { display: flex; align-items: flex-end; gap: 16px; margin-top: 18px; border-bottom: 1px solid var(--line); }
.tabs { display: flex; gap: 4px; margin-right: auto; }
.tab {
  background: none; border-radius: 0; padding: 12px 6px; margin-right: 18px; margin-bottom: -1px;
  font-family: var(--display); font-size: 22px; font-weight: 600; color: var(--soft);
  border-bottom: 3px solid transparent;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--ink); border-bottom-color: var(--accent); }
.tab-count { font: 600 13px/1 var(--font); color: var(--soft); background: var(--sunken); border-radius: 999px; padding: 3px 9px; margin-left: 6px; vertical-align: 3px; }
.tab.active .tab-count { color: var(--accent); background: var(--accent-wash); }
.bar #publish { margin-bottom: 10px; }
.summary { color: var(--soft); margin: 14px 0 20px; max-width: 760px; }

/* Admin */
.admin { display: grid; grid-template-columns: 320px 1fr; gap: 24px; margin-top: 18px; }
.admin-code { display: flex; flex-direction: column; gap: 8px; }
.join-code { font: 700 34px/1.2 var(--mono); letter-spacing: .2em; color: var(--accent); text-align: center; background: var(--accent-wash); border-radius: 12px; padding: 8px; }
.join-code.closed { opacity: .35; }
.admin-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.admin-buttons button { flex: 1; }
.admin-groups { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
#groups { display: flex; flex-direction: column; max-height: 220px; overflow: auto; }
.group-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.group-row b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-row button:first-of-type { margin-left: auto; }

/* Skills */
.skill-mark { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; background: var(--accent-wash); color: var(--accent); flex: none; font-size: 14px; margin-top: 2px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 13px; color: var(--soft); }
.chip { display: inline-flex; align-items: center; gap: 6px; font: 600 13px/1.4 var(--mono); color: var(--ink); padding: 4px 10px; border-radius: 999px; background: var(--sunken); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--soft); }
.dot.on { background: var(--good); }
.dot.off { background: var(--bad); }
pre.body { margin: 0; padding: 14px; border-radius: 12px; background: var(--sunken); font: 13px/1.5 var(--mono); white-space: pre-wrap; word-break: break-word; max-height: 360px; overflow: auto; }
.modal .card.wide { max-width: 760px; }

@media (max-width: 640px) {
  .admin { grid-template-columns: 1fr; }
  .bar { flex-wrap: wrap; }
  .tab { font-size: 18px; margin-right: 10px; }
  .bar #publish { width: 100%; order: 3; }
}
