* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #0d0d0d;
  --surface: #1a1a1a;
  --surface2: #252525;
  --border: #333;
  --text: #e0e0e0;
  --text-dim: #888;
  --accent: #5865f2;
  --accent-hover: #4752c4;
  --green: #3ba55c;
  --red: #ed4245;
  --radius: 8px;
  --border-width: 1px;

  /* Icon tokens — unicode symbols, overridable per theme */
  --icon-sound-on: '\266B';
  --icon-sound-off: '\2205';
  --icon-paint: '\2592';
  --icon-gamepad: '\2318';
  --icon-feed: '\25A0';
  --icon-play: '\25B6';
  --icon-stop: '\25A0';
  --icon-close: '\2715';
  --icon-add: '+';
}

body {
  font-family: 'Cabin', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
}

h1, h2, h3 {
  font-family: 'Space Grotesk', sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 800px; margin: 0 auto; padding: 24px; }

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.header h1 { font-size: 15px; font-weight: 700; }
.header h1 span { color: var(--accent); }

.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-badge img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-discord {
  background: var(--accent);
  color: white;
}
.btn-discord:hover { background: var(--accent-hover); }

.btn-primary {
  background: var(--accent);
  color: white;
}
.btn-primary:hover { filter: brightness(0.85); }

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }

.btn-small {
  padding: 6px 12px;
  font-size: 9px;
}

/* Forms */
input, textarea, select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 10px 12px;
  accent-color: var(--accent);
  font-size: 11px;
  width: 100%;
  font-family: inherit;
}

input:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}

label {
  display: block;
  margin-bottom: 6px;
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-dim);
}

.form-group { margin-bottom: 16px; }

/* Landing page */
.landing {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
  min-height: 80dvh;
  text-align: center;
  gap: 24px;
}

.landing h1 { font-size: 36px; }
.landing h1 span { color: var(--accent); }
.landing p { color: var(--text-dim); font-size: 14px; max-width: 500px; line-height: 1.6; }

/* Dashboard */
.dashboard { padding-top: 32px; }

.section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 16px;
  letter-spacing: 0.5px;
}

.room-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  margin-bottom: 12px;
  overflow: hidden;
}

.room-card.clickable { cursor: pointer; transition: border-color 0.15s; position: relative; }
.room-card.clickable:hover { border-color: var(--accent); }

.card-effect-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}

.room-card:hover .card-effect-canvas { opacity: 1; }

.room-card > div { position: relative; z-index: 2; }

.gear-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius);
  opacity: 0;
  transition: opacity 0.15s, background 0.15s;
}
.room-card:hover .gear-btn { opacity: 1; }
.gear-btn:hover { background: var(--surface2); color: var(--text); }

.room-info-popup {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  z-index: 50;
  min-width: 200px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.room-card h3 { margin-bottom: 4px; display: flex; align-items: center; gap: 8px; }
.room-card .meta { font-size: 12px; color: var(--text-dim); }

.unread-badge {
  background: var(--accent);
  color: white;
  font-size: 8px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius);
  white-space: nowrap;
}

.server-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.server-tag {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2px 10px;
  font-size: 8px;
  color: var(--text-dim);
}

.server-tag.shared {
  border-color: var(--accent);
  color: var(--accent);
}

.adjacent-card {
  border-left: 3px solid var(--accent);
}

/* Server picker */
.server-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.server-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s;
}

.server-option.selected { border-color: var(--accent); }

.server-option img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface2);
}

.server-option .name {
  font-size: 10px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Chat */
.room-layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  position: fixed;
  inset: 0;
}

.room-header {
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.room-header h2 {
  font-size: 12px;
  font-family: var(--heading-font, inherit);
  font-weight: var(--heading-weight, inherit);
  font-style: var(--heading-style, normal);
}
.room-header .origin { font-size: 9px; color: var(--text-dim); }
.room-header .via-more { color: var(--accent); cursor: pointer; text-decoration: underline; text-decoration-style: dotted; }
.room-header .via-more:hover { color: var(--accent-hover); }

.messages-wrapper {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.messages {
  position: relative;
  z-index: 1;
  height: 100%;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.has-canvas .messages {
  height: 100%;
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: auto;
  cursor: none;
  user-select: none;
  padding: 8px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
}

.has-canvas .message {
  background: var(--canvas-msg-bg, rgba(13, 13, 13, 0.8));
  border: var(--border-width, 1px) solid var(--border);
  border-radius: var(--radius);
  padding: 6px 8px;
  pointer-events: auto;
  user-select: text;
  cursor: text;
  width: fit-content;
}

.has-canvas .message img {
  pointer-events: auto;
  cursor: pointer;
  user-select: none;
}

.has-canvas .messages-wrapper {
  cursor: default;
}

.canvas-focused .messages {
  opacity: 0.1;
  pointer-events: none;
}

.canvas-focused .presence {
  opacity: 0.1;
}

.message {
  display: flex;
  gap: 10px;
  padding: 6px 0;
}

.message img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  margin-top: 2px;
  flex-shrink: 0;
  cursor: pointer;
  position: relative;
}

.message .body { flex: 1; }

.message .author {
  font-size: 10px;
  font-weight: var(--heading-weight, 600);
  font-family: var(--heading-font, inherit);
  font-style: var(--heading-style, normal);
  margin-bottom: 2px;
}

.msg-popover {
  position: absolute;
  left: 42px;
  top: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  z-index: 50;
  min-width: 160px;
  font-size: 10px;
}
.msg-popover a { display: block; padding: 4px 0; color: var(--accent); text-decoration: none; }
.msg-popover a:hover { text-decoration: underline; }
.msg-popover .pop-via { font-size: 8px; color: var(--text-dim); margin-bottom: 6px; }

.message .author .via {
  font-weight: 400;
  color: var(--text-dim);
  font-size: 8px;
  margin-left: 6px;
}

.ban-link {
  font-weight: 400;
  font-size: 8px;
  color: var(--red);
  margin-left: 8px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}

.message:hover .ban-link {
  opacity: 0.6;
}

.ban-link:hover {
  opacity: 1 !important;
  text-decoration: underline;
}

.message .author .time {
  font-weight: 400;
  color: var(--text-dim);
  font-size: 8px;
  margin-left: 8px;
}

.message .text {
  font-size: 11px;
  line-height: 1.4;
  word-break: break-word;
}

.chat-input-area {
  padding: 12px 20px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.chat-input-area form { display: flex; gap: 8px; }

.chat-input-area input {
  flex: 1;
}

/* Presence sidebar */
.presence {
  padding: 8px 20px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  font-size: 9px;
  color: var(--text-dim);
}

/* Bio snippet */
.bio-snippet {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 16px;
}

.bio-snippet pre {
  background: var(--surface2);
  padding: 12px;
  border-radius: var(--radius);
  font-size: 10px;
  white-space: pre-wrap;
  margin: 8px 0;
  color: var(--text);
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: 90%;
  max-width: 500px;
  max-height: 80vh;
  overflow-y: auto;
}

.modal h2 { margin-bottom: 16px; }

/* Gate screen */
.gate {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  text-align: center;
  gap: 16px;
}

.gate h2 { font-size: 18px; }
.gate p { color: var(--text-dim); max-width: 400px; font-size: 11px; }

.gate .server-list {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
  margin: 8px 0;
}

.denied {
  background: var(--red);
  color: white;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-weight: 600;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px 20px;
  font-size: 10px;
  color: var(--text);
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  z-index: 200;
  pointer-events: none;
  white-space: nowrap;
}
.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Settings toggle */
.toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 9px;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
}
.toggle-label input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* By Lucian Labs */
.by-ll {
  position: fixed;
  bottom: 12px;
  left: 16px;
  font-size: 8px;
  color: #555;
  z-index: 10;
}
.by-ll a {
  color: #555;
  text-decoration: none;
  transition: color 0.15s;
}
.by-ll a:hover {
  color: var(--text-dim);
}

/* Settings panel */
.settings-panel {
  position: fixed;
  top: 52px;
  right: 16px;
  width: min(320px, calc(100vw - 32px));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  z-index: 50;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.settings-section {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.settings-section .section-title {
  margin-bottom: 10px;
}

/* Deploy cards */
.deploy-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 8px;
  transition: border-color 0.15s;
}
.deploy-card:hover { border-color: var(--accent); }
.deploy-card.deploy-fail { border-left: 3px solid var(--red); }
.deploy-card.deploy-ok { border-left: 3px solid var(--green); }

.deploy-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 11px;
}

.deploy-meta {
  font-size: 10px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.deploy-info {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.deploy-steps {
  font-size: 8px;
  font-family: monospace;
  color: var(--text-dim);
  background: var(--surface2);
  padding: 2px 8px;
  border-radius: var(--radius);
}

.deploy-time {
  font-size: 8px;
  color: var(--text-dim);
}

.deploy-branch {
  font-size: 8px;
  font-family: monospace;
  color: var(--accent);
  background: var(--surface2);
  padding: 2px 8px;
  border-radius: var(--radius);
}

.deploy-detail-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 8px;
  font-size: 10px;
}
.deploy-detail-row label {
  min-width: 70px;
  font-size: 8px;
  margin-bottom: 0;
}

.deploy-error {
  background: var(--surface2);
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 9px;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--red);
  width: 100%;
  margin: 0;
}

/* Paint panel (graffiti chat toy) */
.paint-panel {
  position: fixed;
  top: 52px;
  right: 16px;
  width: min(220px, calc(100vw - 32px));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  z-index: 50;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  padding: 12px;
}

.brush-sizes {
  display: flex;
  gap: 4px;
}

.brush-sizes button {
  flex: 1;
  padding: 6px 0;
  font-size: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.brush-sizes button:hover { background: var(--border); }
.brush-sizes button.active {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.paint-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
  padding: 4px 8px;
  transition: border-color 0.15s, color 0.15s;
}
.paint-toggle:hover { border-color: var(--accent); color: var(--text); }
.paint-toggle.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--surface2);
}

.paint-color-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.paint-color-row input[type="color"] {
  width: 32px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px;
  cursor: pointer;
  background: var(--surface2);
}

.paint-color-row label {
  margin-bottom: 0;
  font-size: 8px;
}

/* Prevent iOS zoom on input focus */
@media (max-width: 768px) {
  input, textarea, select { font-size: 16px; }
}

/* Responsive */
@media (max-width: 600px) {
  .landing h1 { font-size: 24px; }
  .server-grid { grid-template-columns: 1fr; }
  .container { padding: 16px; }
  .header { padding: 10px 16px; }
  .room-header { padding: 8px 12px; }
  .messages { padding: 8px 12px; }
  .chat-input-area { padding: 8px 12px; }
  .presence { padding: 6px 12px; }
  .modal { padding: 16px; width: 95%; }
  .gear-btn { opacity: 0.6; }
  .ban-link { opacity: 0.4; }
  .message img { width: 24px; height: 24px; }
}
