:root {
  color-scheme: light dark;
  --bg: #f5f4f0;
  --surface: #ffffff;
  --text: #1e2422;
  --muted: #5b6662;
  --border: #d5d8d3;
  --accent: #2f5d50;
  --accent-text: #ffffff;
  --accent-soft: #e4eeea;
  --error: #a4262c;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151918;
    --surface: #1f2523;
    --text: #e9ece9;
    --muted: #a3aeaa;
    --border: #3a4340;
    --accent: #7cc4ae;
    --accent-text: #10201b;
    --accent-soft: #24342f;
    --error: #ff9c9c;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

h1, h2, p { margin: 0; }
h1 { font-size: 1.25rem; font-weight: 650; letter-spacing: -0.01em; }
ul { list-style: none; margin: 0; padding: 0; }

.muted { color: var(--muted); }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

button, select, input, textarea { font: inherit; color: inherit; }

button, a.button {
  display: inline-block;
  min-height: 40px;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
}
button:hover, a.button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button.quiet { border-color: transparent; background: transparent; color: var(--muted); }
button.quiet:hover { color: var(--text); }
button.danger { border-color: var(--error); color: var(--error); }
button:disabled { opacity: 0.6; cursor: default; }

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

input, textarea, select {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--muted);
  border-radius: 8px;
  background: var(--surface);
}
textarea { display: block; resize: vertical; }
label { display: block; margin-bottom: 4px; font-weight: 600; font-size: 0.9rem; }

/* Sign-in */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: 100%; max-width: 380px; padding: 28px;
  display: grid; gap: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
}
.login-card label { margin-top: 4px; }
.error { color: var(--error); min-height: 1.5em; font-size: 0.95rem; }

/* Main layout */
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px;
  max-width: 960px; margin: 0 auto; padding: 16px;
}
.topbar-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: 0.9rem; }
.topbar-actions .muted { margin-right: 8px; }
main { max-width: 960px; margin: 0 auto; padding: 0 16px 48px; }

.composer { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.dropzone, .text-form {
  padding: 18px; background: var(--surface); border-radius: 14px; border: 1px solid var(--border);
}
.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  text-align: center; border: 2px dashed var(--muted);
}
.dropzone-title { font-size: 1.1rem; font-weight: 600; }
.dropzone button { margin-top: 8px; }
.text-form-row { display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.inline-label { margin: 0; white-space: nowrap; }
.text-form-row select { width: auto; flex: 1 1 110px; }

.status { min-height: 1.5em; margin: 12px 0 4px; color: var(--muted); }
.status.is-error { color: var(--error); }

.uploads li { margin-bottom: 8px; font-size: 0.9rem; }
.uploads .upload-name { overflow-wrap: anywhere; }
.uploads progress { display: block; width: 100%; height: 8px; accent-color: var(--accent); }

.section-title { margin: 16px 0 10px; font-size: 1rem; font-weight: 650; }
.empty { padding: 24px 0; }

/* Items */
.items { display: grid; gap: 10px; }
.item {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 14px; align-items: start;
  padding: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
}
.thumb {
  width: 56px; height: 56px; border-radius: 8px; object-fit: cover; display: block; background: var(--accent-soft);
}
.badge {
  width: 56px; height: 56px; border-radius: 8px;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--text);
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; overflow: hidden;
}
.item-name { font-weight: 600; overflow-wrap: anywhere; }
.item-meta { color: var(--muted); font-size: 0.85rem; }
.item-text {
  margin: 0 0 4px; font: 0.9rem/1.45 ui-monospace, "Cascadia Mono", Consolas, monospace;
  white-space: pre-wrap; overflow-wrap: anywhere; max-height: 11em; overflow: auto;
}
.item-link { overflow-wrap: anywhere; color: var(--accent); font-weight: 600; }
.item-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }

.item.is-new { animation: arrive 1.6s ease-out; }
@keyframes arrive { from { background: var(--accent-soft); border-color: var(--accent); } }
@media (prefers-reduced-motion: reduce) { .item.is-new { animation: none; } }

.item-leading { display: flex; align-items: center; gap: 10px; }
.select-slot { width: 22px; flex: none; }
.select-slot input { display: block; width: 22px; height: 22px; min-height: 0; padding: 0; margin: 0; accent-color: var(--accent); }
.item-note { color: var(--muted); font-size: 0.85rem; margin-top: 4px; }

.selection-bar {
  position: sticky; top: 8px; z-index: 5;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin-bottom: 10px; padding: 8px 12px;
  background: var(--accent-soft); border: 1px solid var(--accent); border-radius: 10px;
}
.selection-bar span { margin-right: auto; font-weight: 600; }

.live { color: var(--muted); margin-right: 8px; }
.live.is-live::before { content: "\25CF"; color: var(--accent); margin-right: 5px; }

/* Direct transfers */
.direct { margin: 16px 0; padding: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; }
.direct .section-title { margin: 0 0 2px; }
.direct-header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 14px; margin-bottom: 12px; }
.direct-header > div { flex: 1 1 280px; }
.device-form { flex: 0 1 220px; }
.peers, .transfers { display: grid; gap: 8px; }
.peers:empty, .transfers:empty { display: none; }
.transfers { margin-top: 12px; }
.peer {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 12px; border: 1px dashed var(--muted); border-radius: 10px;
}
.peer-name { font-weight: 600; overflow-wrap: anywhere; }
.transfer {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; align-items: center;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; font-size: 0.9rem;
}
.transfer-text { display: grid; }
.transfer-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.transfer progress { grid-column: 1 / -1; width: 100%; height: 8px; accent-color: var(--accent); }
.transfer.is-failed .muted { color: var(--error); }
.incoming { margin-bottom: 10px; padding: 12px; background: var(--accent-soft); border: 1px solid var(--accent); border-radius: 10px; }
.incoming p { overflow-wrap: anywhere; font-weight: 600; }
.incoming-actions { display: flex; gap: 8px; margin-top: 8px; }

/* Shown while dragging. It stays out of the way so devices can still be seen. */
.drop-overlay {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10; padding: 10px 16px; text-align: center;
  background: var(--accent); color: var(--accent-text); font-weight: 650; pointer-events: none;
}

@media (max-width: 680px) {
  .composer { grid-template-columns: 1fr; }
  .item { grid-template-columns: auto minmax(0, 1fr); }
  .item-actions { grid-column: 1 / -1; justify-content: flex-start; }
}
