:root {
  color-scheme: dark;
  --bg: #0b0e14;
  --surface: #131823;
  --surface-2: #1a2130;
  --border: #283246;
  --text: #eef2f8;
  --muted: #93a1b8;
  --accent: #6366f1;
  --accent-hover: #7c7ff6;
  --success: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --rar: #a855f7;
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: radial-gradient(circle at top right, #171e31 0%, var(--bg) 55%);
  color: var(--text);
  line-height: 1.45;
}

.app-shell {
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px 20px 48px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

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

.brand-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--rar));
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.9rem;
  letter-spacing: 0.04em;
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.3);
}

h1 {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 700;
}

.subtitle {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.status-cluster {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface);
}

.pill-ok {
  color: #86efac;
  border-color: rgba(34, 197, 94, 0.35);
  background: rgba(34, 197, 94, 0.1);
}

.pill-warn {
  color: #fde68a;
  border-color: rgba(245, 158, 11, 0.35);
  background: rgba(245, 158, 11, 0.1);
}

.pill-bad {
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.1);
}

.pill-muted {
  color: var(--muted);
}

.card {
  background: rgba(19, 24, 35, 0.9);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
}

.hidden {
  display: none !important;
}

.waiting-wrap {
  display: flex;
  justify-content: center;
  padding: 28px 0 12px;
}

.waiting-card {
  width: 100%;
  max-width: 460px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 24px;
}

.waiting-header h2 {
  font-size: 1.25rem;
}

.waiting-desc {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.input-with-btn {
  display: flex;
  gap: 8px;
}

.input-with-btn input {
  flex: 1;
}

.btn-block {
  width: 100%;
  padding: 12px 16px;
  font-size: 0.95rem;
  margin-top: 4px;
}

.waiting-error {
  margin: 0;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.84rem;
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
}

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

.room-bar {
  display: grid;
  grid-template-columns: repeat(3, minmax(140px, 1fr)) auto;
  gap: 12px;
  align-items: end;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
}

.optional {
  font-weight: 400;
  opacity: 0.75;
}

input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.92rem;
  outline: none;
  transition: border-color 0.15s;
}

input:focus {
  border-color: var(--accent);
}

.room-actions {
  display: flex;
  gap: 8px;
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 10px 15px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.08s ease, background-color 0.15s ease, opacity 0.15s ease;
  white-space: nowrap;
}

.btn:active {
  transform: translateY(1px);
}

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

.btn-primary {
  background: var(--accent);
  color: #fff;
}

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

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

.btn-secondary:hover:not(:disabled) {
  border-color: #3c4a66;
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.35);
}

.btn-danger:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.25);
}

.btn-sm {
  padding: 7px 11px;
  font-size: 0.8rem;
  border-radius: 8px;
}

.peers-strip {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 2px 4px;
}

.peers-label {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 600;
}

.peers-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.peer-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  background: var(--surface);
  border: 1px solid var(--border);
}

.peer-chip.is-me {
  border-color: rgba(99, 102, 241, 0.55);
  color: #c7d2fe;
}

.peer-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

h2 {
  margin: 0;
  font-size: 1.06rem;
}

.count-badge {
  min-width: 26px;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.78rem;
  font-weight: 700;
  display: grid;
  place-items: center;
  color: var(--muted);
}

.drop-zone {
  border: 2px dashed #33405c;
  border-radius: 12px;
  padding: 28px 18px;
  text-align: center;
  cursor: pointer;
  background: rgba(26, 33, 48, 0.45);
  transition: border-color 0.15s, background-color 0.15s;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.1);
}

.drop-icon {
  font-size: 2rem;
  margin-bottom: 6px;
}

.drop-title {
  margin: 0;
  font-size: 0.98rem;
}

.drop-hint {
  margin: 6px 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.tab-notice {
  margin: 10px 0 14px;
  font-size: 0.8rem;
  color: var(--muted);
}

.file-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

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

.file-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.file-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.file-info {
  min-width: 0;
  flex: 1;
}

.file-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.ext-badge {
  flex-shrink: 0;
  font-size: 0.68rem;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 6px;
  text-transform: uppercase;
  background: rgba(147, 161, 184, 0.16);
  color: #cbd5e1;
}

.ext-badge.is-rar {
  background: rgba(168, 85, 247, 0.22);
  color: #e9d5ff;
  border: 1px solid rgba(168, 85, 247, 0.45);
}

.file-name {
  font-weight: 600;
  font-size: 0.92rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-meta {
  margin-top: 3px;
  font-size: 0.78rem;
  color: var(--muted);
}

.file-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.transfer-box {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.progress-track {
  width: 100%;
  height: 7px;
  border-radius: 999px;
  background: #0e131d;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--rar));
  transition: width 0.12s linear;
}

.progress-fill.is-done {
  background: var(--success);
}

.transfer-stats {
  display: flex;
  justify-content: space-between;
  font-size: 0.76rem;
  color: var(--muted);
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 14, 0.75);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 40;
}

.modal.hidden {
  display: none;
}

.modal-card {
  width: 100%;
  max-width: 390px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-card h3 {
  margin: 0;
}

.modal-desc {
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted);
}

.modal-error {
  margin: 0;
  font-size: 0.82rem;
  color: #fca5a5;
}

.modal-error.hidden {
  display: none;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.toast-container {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 50;
}

.toast {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.84rem;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}

@media (max-width: 840px) {
  .room-bar {
    grid-template-columns: 1fr;
  }

  .grid {
    grid-template-columns: 1fr;
  }
}
