:root {
  color-scheme: light dark;
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1d2330;
  --muted: #6b7385;
  --border: #d9dde5;
  --accent: #2f6fed;
  --accent-hover: #2159c9;
  --ok: #1f9d55;
  --err: #d64545;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171d;
    --card: #1d2129;
    --text: #e6e9ef;
    --muted: #9aa3b5;
    --border: #323846;
  }
}

* { box-sizing: border-box; }

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

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 1rem 4rem;
}

h1 { margin: 0; font-size: 2rem; }
.sub { margin: .25rem 0 .5rem; color: var(--muted); }
.notice {
  margin: 0 0 1.5rem;
  padding: .5rem .75rem;
  border-left: 3px solid var(--accent);
  background: var(--card);
  border-radius: 6px;
  font-size: .9rem;
}

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .25rem;
  padding: 2.5rem 1rem;
  border: 2px dashed var(--border);
  border-radius: 12px;
  background: var(--card);
  cursor: pointer;
  text-align: center;
  transition: border-color .15s, background .15s;
}
.dropzone span { color: var(--muted); }
.dropzone:hover, .dropzone.dragover { border-color: var(--accent); }

.options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
  padding: 1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.field { display: flex; flex-direction: column; gap: .35rem; }
.field label { font-size: .9rem; color: var(--muted); }
.field select, .field input[type=number] {
  padding: .45rem .5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
.field input[type=color] { width: 100%; height: 2.2rem; border: none; background: none; padding: 0; }

.actions { display: flex; flex-wrap: wrap; gap: .5rem; }
button {
  padding: .6rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover:not(:disabled) { background: var(--accent-hover); }
button:disabled { opacity: .5; cursor: not-allowed; }

.status { min-height: 1.5em; color: var(--muted); }

.file-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .5rem; }
.file-item {
  display: grid;
  grid-template-columns: 64px 1fr auto auto;
  gap: .75rem;
  align-items: center;
  padding: .6rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.file-item img {
  width: 64px; height: 64px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--bg);
}
.file-info { min-width: 0; }
.file-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-meta { font-size: .85rem; color: var(--muted); }
.file-meta .ok { color: var(--ok); }
.file-meta .err { color: var(--err); }
.file-item a.download {
  padding: .45rem .8rem;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-size: .9rem;
  white-space: nowrap;
}

.file-item .remove {
  width: 2.2rem;
  height: 2.2rem;
  padding: 0;
  font-size: 1.2rem;
  line-height: 1;
  color: var(--muted);
}
.file-item .remove:hover { color: var(--err); border-color: var(--err); }

.server-section { margin-top: 2.5rem; }
.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
}
.section-head h2 { margin: 0; font-size: 1.3rem; }
.file-item.server { grid-template-columns: 64px 1fr auto; }
.server-actions { display: flex; flex-wrap: wrap; gap: .4rem; justify-content: flex-end; }
.server-actions button, .server-actions a.download { padding: .45rem .8rem; font-size: .9rem; }
button.danger { color: var(--err); }
button.danger:hover:not(:disabled), button.danger.confirm { background: var(--err); border-color: var(--err); color: #fff; }

@media (max-width: 700px) {
  .file-item.server { grid-template-columns: 64px 1fr; }
  .server-actions { grid-column: 1 / -1; justify-content: stretch; }
  .server-actions > * { flex: 1; text-align: center; }
}

@media (max-width: 480px) {
  .file-item.server { grid-template-columns: 48px 1fr; }
  .file-item { grid-template-columns: 48px 1fr auto; }
  .file-item img { width: 48px; height: 48px; }
  .file-item .slot { grid-column: 1 / -1; grid-row: 2; }
  .file-item a.download { display: block; text-align: center; }
}
