:root {
  color-scheme: dark;
  --bg: #111315;
  --panel: #1d2024;
  --panel-strong: #252a30;
  --text: #f4f5f6;
  --muted: #aeb6bf;
  --accent: #3cbf8f;
  --danger: #ff6b6b;
  --border: #343a42;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  min-height: 36px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel-strong);
  color: var(--text);
  padding: 0 14px;
  cursor: pointer;
}

button[aria-pressed="true"],
form button {
  background: var(--accent);
  border-color: var(--accent);
  color: #07110d;
  font-weight: 700;
}

input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #0f1113;
  color: var(--text);
  padding: 8px 12px;
}

.hidden {
  display: none !important;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
  gap: 16px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.topbar strong {
  margin-left: 12px;
}

#statusText,
#connectMessage,
#fileMessage {
  color: var(--muted);
}

.controls {
  display: flex;
  gap: 8px;
}

.connect-panel {
  min-height: calc(100vh - 56px);
  display: grid;
  place-items: center;
  padding: 24px;
}

.connect-panel section {
  width: min(430px, 100%);
  padding: 28px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  margin-bottom: 18px;
  border-radius: 8px;
  background: var(--accent);
  color: #07110d;
  font-weight: 700;
}

h1 {
  margin: 0 0 22px;
  font-size: 26px;
}

label {
  display: block;
  margin: 12px 0 8px;
}

form button {
  width: 100%;
  margin-top: 14px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  height: calc(100vh - 56px);
}

.workspace.files-hidden {
  grid-template-columns: 1fr;
}

.viewer-wrap {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  background: #080909;
}

.viewer {
  min-width: 100%;
  min-height: 100%;
  display: grid;
  place-items: center;
  outline: none;
}

.viewer.control-active {
  cursor: crosshair;
}

#screen {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 56px);
  object-fit: contain;
  user-select: none;
}

.viewer.native-size #screen {
  max-width: none;
  max-height: none;
}

.files-panel {
  min-width: 0;
  overflow: auto;
  border-right: 1px solid var(--border);
  background: var(--panel);
  padding: 16px;
}

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

.panel-head h2 {
  margin: 0;
  font-size: 18px;
}

.upload-form {
  display: grid;
  gap: 10px;
}

.file-list {
  display: grid;
  gap: 8px;
}

.file-item {
  display: block;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
  overflow-wrap: anywhere;
}

@media (max-width: 700px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .controls {
    width: 100%;
  }

  .controls button {
    flex: 1;
    padding: 0 8px;
  }

  .workspace {
    grid-template-columns: 1fr;
    height: auto;
  }

  .files-panel {
    border-right: 0;
    border-top: 1px solid var(--border);
  }
}
