:root {
  --bg: #0b0f17;
  --surface: #121826;
  --surface-2: #192234;
  --border: #25324a;
  --text: #e6edf7;
  --muted: #8b9bb4;
  --primary: #38bdf8;
  --primary-hover: #0ea5e9;
  --accent: #34d399;
  --danger: #f87171;
  --warn: #fbbf24;
  --radius: 14px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  background: radial-gradient(circle at top, #131c2e 0%, var(--bg) 60%);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app-shell {
  max-width: 980px;
  margin: 0 auto;
  padding: 18px 16px 48px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.brand-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 10px transparent;
  transition: background 0.2s, box-shadow 0.2s;
}

.brand-dot.online {
  background: var(--accent);
  box-shadow: 0 0 10px rgba(52, 211, 153, 0.7);
}

.brand-dot.connecting {
  background: var(--warn);
  box-shadow: 0 0 10px rgba(251, 191, 36, 0.6);
}

.brand-name {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-tag {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--primary);
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.28);
  padding: 2px 8px;
  border-radius: 999px;
}

.icon-btn {
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 0.85rem;
  cursor: pointer;
  touch-action: manipulation;
}

.icon-btn:hover {
  color: var(--text);
  border-color: var(--primary);
}

.settings-drawer {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 12px;
  text-align: left;
}

.advanced-footer {
  margin-top: 40px;
  text-align: center;
}

.advanced-toggle {
  background: transparent;
  color: var(--muted);
  border: none;
  font-size: 0.8rem;
  cursor: pointer;
  padding: 6px 10px;
  opacity: 0.72;
}

.advanced-toggle:hover {
  opacity: 1;
  color: var(--text);
}

.hero {
  text-align: center;
  margin: 28px auto 34px;
  max-width: 580px;
}

.hero h1 {
  font-size: clamp(1.75rem, 4vw, 2.4rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 10px;
}

.hero p {
  color: var(--muted);
  font-size: 1rem;
}

.role-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.role-card {
  text-align: left;
  background: linear-gradient(160deg, var(--surface-2) 0%, var(--surface) 100%);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 26px 24px;
  color: var(--text);
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
  touch-action: manipulation;
}

.role-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.35);
}

.role-card h2 {
  font-size: 1.3rem;
  margin: 12px 0 6px;
}

.role-card p {
  color: var(--muted);
  font-size: 0.93rem;
}

.role-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--primary);
  background: rgba(56, 189, 248, 0.12);
  padding: 4px 10px;
  border-radius: 999px;
}

.role-badge.accent {
  color: var(--accent);
  background: rgba(52, 211, 153, 0.12);
}

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

.status-pill {
  font-size: 0.85rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
}

.status-pill.connected {
  color: var(--accent);
  border-color: rgba(52, 211, 153, 0.4);
  background: rgba(52, 211, 153, 0.08);
}

.status-pill.error {
  color: var(--danger);
  border-color: rgba(248, 113, 113, 0.4);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
}

.host-room-layout {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 24px;
}

.qr-box {
  width: 184px;
  height: 184px;
  background: #ffffff;
  border-radius: 12px;
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.qr-box svg,
.qr-box img,
.qr-box canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.qr-placeholder {
  color: #475569;
  font-size: 0.82rem;
  text-align: center;
}

.room-info {
  flex: 1;
  min-width: 230px;
}

.room-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: clamp(2rem, 6vw, 2.9rem);
  font-weight: 800;
  letter-spacing: 0.16em;
  color: var(--primary);
  margin: 4px 0 14px;
}

.field-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 8px;
}

.hint-text {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 8px;
}

.inline-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

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

input[type="text"],
input[type="url"],
textarea {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 13px;
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}

input:focus,
textarea:focus {
  border-color: var(--primary);
}

.inline-row input {
  flex: 1;
  min-width: 180px;
}

.code-input {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 1.45rem !important;
  font-weight: 700;
  letter-spacing: 0.25em;
  text-align: center;
  max-width: 220px;
}

.btn {
  min-height: 42px;
  padding: 9px 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: #06121e;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--primary);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--border);
}

.btn-ghost:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--muted);
}

.workspace-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 20px;
}

.panel h3 {
  font-size: 1.05rem;
  margin-bottom: 12px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.panel-header h3 {
  margin-bottom: 0;
}

.toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.82rem;
  color: var(--muted);
  cursor: pointer;
}

.dropzone {
  border: 2px dashed var(--border);
  border-radius: 12px;
  background: rgba(11, 15, 23, 0.55);
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  margin-bottom: 14px;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--primary);
  background: rgba(56, 189, 248, 0.08);
}

.drop-title {
  font-weight: 600;
  font-size: 0.95rem;
}

.text-send-box {
  margin-top: 14px;
}

.progress-wrap {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 14px;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 7px;
}

.progress-meta span:first-child {
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress-track {
  height: 7px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--primary);
  transition: width 0.08s linear;
}

.progress-fill.accent-fill {
  background: var(--accent);
}

.zip-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
  font-size: 0.88rem;
}

.feed-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 400px;
  overflow-y: auto;
}

.empty-state {
  color: var(--muted);
  font-size: 0.88rem;
  padding: 20px;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: 10px;
}

.feed-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.feed-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.feed-title {
  font-weight: 600;
  font-size: 0.9rem;
  word-break: break-word;
}

.feed-meta {
  font-size: 0.78rem;
  color: var(--muted);
}

.feed-text-body {
  font-size: 0.9rem;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--surface);
  border-radius: 8px;
  padding: 9px 10px;
  border: 1px solid var(--border);
}

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--primary);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.88rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  z-index: 100;
}

.hidden {
  display: none !important;
}

@media (max-width: 600px) {
  .host-room-layout {
    justify-content: center;
    text-align: center;
  }
  .btn-row {
    justify-content: center;
  }
  .code-input {
    max-width: none;
  }
}
