:root {
  color-scheme: dark;
  font-family: system-ui, sans-serif;
  --bg: #111;
  --panel: #191919;
  --line: #333;
  --text: #eee;
  --muted: #aaa;
  --accent: #8de8bf;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

button, input, textarea { font: inherit; }

button {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  padding: .55rem .85rem;
  cursor: pointer;
  font-weight: 650;
}

button:disabled { cursor: wait; opacity: .6; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

main {
  width: min(1100px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0;
}

h1, h2, h3, h4, p { margin-top: 0; }
h1 { margin: 0; font-size: 1.6rem; }
h2 { margin-bottom: 0; }
h3 { margin: 0; font-size: 1rem; }

.topbar,
.project-heading,
.files-heading,
.dialog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.topbar { margin-bottom: 1rem; }

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

.secondary {
  border: 1px solid var(--line);
  background: #242424;
  color: var(--text);
}

.danger {
  border: 1px solid #673b3b;
  background: #2d1c1c;
  color: #ffb5b5;
}

.workspace {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  min-height: 600px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel);
}

aside {
  padding: 1rem;
  border-right: 1px solid var(--line);
  background: #151515;
}

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

.project-list {
  display: grid;
  gap: .35rem;
}

.project-button {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.project-button:hover { background: #222; }
.project-button[aria-current="true"] { border-color: #426b59; background: #1c3028; }

.project-button-row {
  display: flex;
  justify-content: space-between;
  gap: .75rem;
}

.project-button strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-button span { color: var(--muted); font-size: .75rem; }

.project-panel { min-width: 0; padding: 1.5rem; }

.empty-state {
  display: grid;
  place-items: center;
  align-content: center;
  min-height: 500px;
  text-align: center;
}

.empty-state p { margin: .5rem 0 1rem; color: var(--muted); }

.project-heading { align-items: baseline; }
.project-heading strong { color: var(--muted); }

progress {
  width: 100%;
  height: 6px;
  margin: 1rem 0 2rem;
  border: 0;
  border-radius: 4px;
  overflow: hidden;
  background: #333;
}

progress::-webkit-progress-bar { background: #333; }
progress::-webkit-progress-value { background: var(--accent); }
progress::-moz-progress-bar { background: var(--accent); }

.files-heading { margin-bottom: 1rem; }
.add-file-form, .upload-form, .slot-actions { display: flex; align-items: center; gap: .5rem; }
.add-file-form input { width: 210px; }

input, textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #111;
  color: var(--text);
  padding: .55rem .65rem;
}

textarea { resize: vertical; line-height: 1.5; }

.file-list { display: grid; gap: .5rem; }

.file-slot {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) minmax(140px, .9fr) auto;
  align-items: center;
  gap: 1rem;
  padding: .9rem;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #202020;
}

.slot-title { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.slot-title h4, .file-info strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot-title h4 { margin: 0; }

.state-dot {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #666;
}

.state-dot.ready { background: var(--accent); }

.file-info { min-width: 0; }
.file-info strong { display: block; font-size: .85rem; }
.file-info span { color: var(--muted); font-size: .72rem; }

.slot-actions { justify-content: flex-end; flex-wrap: wrap; }
.slot-actions a { color: var(--accent); font-size: .8rem; font-weight: 650; }
.slot-button, .preview-button, .upload-form button { min-height: 34px; padding: .4rem .6rem; font-size: .78rem; }
.upload-form input[type="file"] { width: 170px; min-height: auto; padding: .35rem; font-size: .72rem; }

dialog {
  width: min(520px, calc(100% - 2rem));
  max-height: calc(100vh - 2rem);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  padding: 1.25rem;
}

dialog::backdrop { background: rgba(0, 0, 0, .75); }
dialog form { display: grid; gap: .6rem; }
dialog label { margin-top: .6rem; font-size: .85rem; font-weight: 650; }

.dialog-heading { margin-bottom: .75rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .75rem; }

.icon-button {
  width: 40px;
  padding: 0;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 1.4rem;
}

.form-error { margin: .5rem 0 0; color: #ffaaaa; }

.preview-dialog { width: min(900px, calc(100% - 2rem)); }
.preview-content {
  display: grid;
  place-items: center;
  min-height: 280px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #080808;
}

.preview-content img, .preview-content video { display: block; max-width: 100%; max-height: 70vh; }
.preview-content audio { width: min(500px, 90%); }
.preview-content iframe { width: 100%; height: min(70vh, 680px); border: 0; background: white; }

.status-message {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  max-width: min(380px, calc(100% - 2rem));
  border: 1px solid #426b59;
  border-radius: 7px;
  background: #1c3028;
  padding: .75rem 1rem;
}

.status-message.error { border-color: #774444; background: #351d1d; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 800px) {
  .workspace { grid-template-columns: 1fr; }
  aside { border-right: 0; border-bottom: 1px solid var(--line); }
  .project-list { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
  .file-slot { grid-template-columns: 1fr; }
  .slot-actions { justify-content: flex-start; flex-wrap: wrap; }
}

@media (max-width: 520px) {
  main { width: min(100% - 1rem, 1100px); padding: 1rem 0; }
  .project-panel { padding: 1rem; }
  .files-heading { align-items: stretch; flex-direction: column; }
  .add-file-form, .add-file-form input { width: 100%; }
  .upload-form { width: 100%; align-items: stretch; flex-direction: column; }
  .upload-form input[type="file"] { width: 100%; }
}
