:root {
  --bg: #f4f1ea;
  --surface: #fffaf2;
  --surface-strong: #ffffff;
  --ink: #1e2528;
  --muted: #667277;
  --line: #d9d0c4;
  --blue: #315f72;
  --green: #4a7c6e;
  --coral: #c9815e;
  --yellow: #f1c75b;
  --shadow: 0 16px 40px rgba(37, 44, 47, 0.1);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(49, 95, 114, 0.09), transparent 35%),
    linear-gradient(315deg, rgba(201, 129, 94, 0.12), transparent 32%),
    var(--bg);
  color: var(--ink);
}

.is-hidden {
  display: none !important;
}

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

button {
  cursor: pointer;
}

.app {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 20px;
  min-height: 100vh;
  padding: 20px;
}

.auth-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 20px;
}

.auth-card {
  display: grid;
  gap: 22px;
  width: min(560px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 242, 0.94);
  box-shadow: var(--shadow);
  padding: 24px;
}

.auth-copy h2,
.auth-copy p {
  margin: 0;
}

.auth-copy h2 {
  margin-top: 6px;
  font-size: 28px;
  letter-spacing: 0;
}

.auth-copy p:last-child {
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.6;
}

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

.email-auth {
  display: grid;
}

.email-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.auth-warning {
  display: none;
  border: 1px solid rgba(201, 129, 94, 0.4);
  border-radius: 8px;
  background: rgba(201, 129, 94, 0.11);
  color: #74452e;
  padding: 12px;
  font-size: 13px;
  line-height: 1.5;
}

.auth-warning.active {
  display: block;
}

.save-note {
  min-height: 18px;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
}

.save-note.error {
  color: #9b3f2f;
}

.tool-picker {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 10px;
}

.tool-summary {
  min-height: 22px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.tool-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tool-option {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(49, 95, 114, 0.06);
  color: var(--blue);
  padding: 6px 9px;
  font-size: 12px;
  font-weight: 900;
}

.tool-option input {
  width: auto;
  margin: 0;
  accent-color: var(--blue);
}

.sidebar,
.workspace {
  min-width: 0;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 4px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--ink);
  color: var(--yellow);
  font-weight: 900;
  letter-spacing: 0;
}

.brand h1,
.brand p,
.topbar h2,
.topbar p,
.room-header h3,
.room-header p,
.board-header h3,
.board-header p {
  margin: 0;
}

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

.brand p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 242, 0.9);
  box-shadow: var(--shadow);
}

.profile-panel {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--ink);
  outline: none;
  padding: 11px 12px;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(49, 95, 114, 0.14);
}

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

.primary-button,
.ghost-button,
.small-button,
.icon-button,
.tab {
  border: 0;
  border-radius: 8px;
  min-height: 40px;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.primary-button {
  background: var(--ink);
  color: white;
  padding: 0 16px;
  font-weight: 800;
}

.ghost-button,
.small-button {
  border: 1px solid var(--line);
  background: var(--surface-strong);
  color: var(--ink);
  padding: 0 14px;
  font-weight: 800;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  min-height: 36px;
  background: var(--surface-strong);
  color: var(--ink);
  border: 1px solid var(--line);
  font-size: 20px;
}

.primary-button:hover,
.ghost-button:hover,
.small-button:hover,
.icon-button:hover,
.tab:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(37, 44, 47, 0.1);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.65;
  transform: none;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 0 16px 16px;
}

.metrics div {
  display: grid;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 12px;
}

.metrics strong {
  font-size: 20px;
}

.metrics span {
  color: var(--muted);
  font-size: 12px;
}

.workspace {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}

.eyebrow {
  color: var(--coral);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.topbar h2 {
  margin-top: 4px;
  font-size: 28px;
  letter-spacing: 0;
}

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

.tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--line);
}

.tab {
  background: transparent;
  color: var(--muted);
  padding: 0 18px;
  font-weight: 900;
}

.tab.active {
  background: var(--ink);
  color: white;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.room-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 16px;
}

.room-list,
.room-stage {
  padding: 16px;
}

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

.room-card {
  display: grid;
  gap: 8px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 12px;
  text-align: left;
}

.room-card.active {
  border-color: var(--blue);
  box-shadow: inset 4px 0 0 var(--blue);
}

.room-card strong {
  font-size: 14px;
}

.room-card span,
.capacity {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.room-header,
.board-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.capacity {
  display: grid;
  place-items: center;
  min-width: 58px;
  height: 42px;
  border-radius: 8px;
  background: rgba(74, 124, 110, 0.13);
  color: var(--green);
  font-size: 14px;
}

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

.builder-card {
  display: grid;
  min-height: 172px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 12px;
}

.builder-avatar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.avatar-dot {
  display: grid;
  flex: 0 0 36px;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--blue);
  color: white;
  font-weight: 900;
}

.builder-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 900;
}

.status-pill {
  width: fit-content;
  border-radius: 999px;
  background: rgba(241, 199, 91, 0.3);
  padding: 5px 8px;
  color: #705419;
  font-size: 12px;
  font-weight: 900;
}

.builder-card p {
  margin: 4px 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.tools {
  margin-top: auto;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
}

.empty-seat {
  place-items: center;
  border-style: dashed;
  color: var(--muted);
}

.room-bottom {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  margin-top: 18px;
}

.compact-list,
.chat-list,
.match-list {
  display: grid;
  gap: 10px;
}

.compact-item,
.chat-item,
.match-item,
.content-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 12px;
}

.compact-item strong,
.content-card h4 {
  display: block;
  margin: 0 0 6px;
  font-size: 15px;
}

.compact-item p,
.chat-item p,
.content-card p,
.match-item p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.tag {
  border-radius: 999px;
  background: rgba(49, 95, 114, 0.1);
  color: var(--blue);
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 900;
}

.tag.solved {
  background: rgba(74, 124, 110, 0.13);
  color: var(--green);
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-top: 10px;
}

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

.content-card {
  display: grid;
  gap: 8px;
  min-height: 190px;
}

.content-card a {
  color: var(--blue);
  font-weight: 900;
}

.modal {
  width: min(620px, calc(100vw - 24px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: transparent;
}

.modal::backdrop {
  background: rgba(30, 37, 40, 0.42);
}

.modal-card {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 18px;
  box-shadow: var(--shadow);
}

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

.modal-header h3 {
  margin: 0;
}

@media (max-width: 1120px) {
  .app,
  .room-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    order: 2;
  }

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

@media (max-width: 720px) {
  .app {
    padding: 12px;
  }

  .topbar,
  .room-header,
  .board-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions,
  .auth-actions,
  .email-row,
  .field-grid,
  .room-bottom,
  .builder-grid,
  .card-grid {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .topbar-actions {
    display: grid;
  }

  .tabs {
    overflow-x: auto;
  }
}
