:root {
  --bg: #f5f5f8;
  --surface: #ffffff;
  --text: #17171c;
  --muted: #6b6b78;
  --border: #e3e3ea;
  --accent: #5b4bd6;
  --accent-hover: #4a3bc0;
  --accent-soft: #eeebfc;
  --danger: #c73a3a;
  --danger-soft: #fbeaea;
  --shadow: 0 1px 2px rgb(20 20 40 / 6%), 0 4px 16px rgb(20 20 40 / 6%);
  --radius: 12px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131318;
    --surface: #1c1c23;
    --text: #ececf1;
    --muted: #9a9aa8;
    --border: #2c2c36;
    --accent: #8576f0;
    --accent-hover: #9a8df3;
    --accent-soft: #2a2550;
    --danger: #ef7070;
    --danger-soft: #3a2024;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 4px 16px rgb(0 0 0 / 25%);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }

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

[hidden] { display: none !important; }
code { font: 13px ui-monospace, SFMono-Regular, Menlo, monospace; }
.muted { color: var(--muted); }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 17px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid transparent;
  font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:disabled { opacity: .6; cursor: default; }
.btn:focus-visible, .name-input:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--accent-soft); border-color: transparent; }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--border); }
.btn-danger:hover { background: var(--danger-soft); border-color: transparent; }

.form-error { margin: 0; color: var(--danger); font-size: 14px; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: min(360px, 100%); display: flex; flex-direction: column; gap: 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 28px; box-shadow: var(--shadow);
}
.login-card .brand { margin-bottom: 12px; }
.login-card label { font-size: 13px; color: var(--muted); }
.login-card input {
  height: 44px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font: inherit;
}
.login-card .btn { margin-top: 8px; height: 44px; }

.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: 12px max(16px, calc((100vw - 960px) / 2)); background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
}

.admin { max-width: 960px; margin: 0 auto; padding: 24px 16px 64px; display: flex; flex-direction: column; gap: 16px; }

.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center;
  padding: 32px 16px; border: 1.5px dashed var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--muted); cursor: pointer; transition: border-color .15s, background .15s;
}
.dropzone strong { color: var(--text); font-size: 16px; }
.dropzone svg { color: var(--accent); margin-bottom: 4px; }
.dropzone:hover, .dropzone.is-over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone.is-busy { opacity: .6; pointer-events: none; }

.list-title { margin: 16px 0 0; font-size: 18px; font-weight: 600; }
.list-title .muted { font-weight: 400; }

.proto-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.proto {
  display: grid; grid-template-columns: 72px 1fr auto; gap: 16px; align-items: center;
  padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.proto.is-new { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.proto-thumb {
  position: relative; width: 72px; height: 96px; border-radius: 8px; overflow: hidden;
  background: var(--bg); border: 1px solid var(--border);
}
.proto-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }
.proto-thumb--desktop img { object-position: top left; }
.device-badge {
  position: absolute; left: 4px; bottom: 4px; padding: 0 6px; border-radius: 6px;
  background: rgb(0 0 0 / 60%); color: #fff; font-size: 10px; line-height: 18px;
}
.proto-body { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.proto-name { font-weight: 600; font-size: 16px; }
.name-link { color: var(--text); text-decoration: none; }
.name-link:hover { color: var(--accent); text-decoration: underline; }
.name-input {
  width: 100%; height: 34px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--accent);
  background: var(--bg); color: var(--text); font: inherit;
}
.proto-meta { font-size: 13px; }
.proto-url code { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.proto-links { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; margin-top: 4px; font-size: 13px; }
.comments-link { color: var(--muted); }
.comments-link.has-open { color: var(--accent); font-weight: 600; }
.versions summary { cursor: pointer; color: var(--muted); }
.versions[open] summary { color: var(--text); }
.version-list { margin: 6px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 2px; }
.version-list a { color: var(--accent); font-weight: 600; }
.version-list .link-danger {
  margin-left: 8px; padding: 0; border: 0; background: none; color: var(--danger); font: inherit; font-size: 12px;
  cursor: pointer; text-decoration: underline;
}
.proto-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; max-width: 280px; }

.empty { text-align: center; padding: 32px 0; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 20;
  padding: 10px 16px; border-radius: 10px; background: var(--text); color: var(--bg);
  font-size: 14px; box-shadow: var(--shadow);
}

@media (max-width: 640px) {
  .proto { grid-template-columns: 56px 1fr; }
  .proto-thumb { width: 56px; height: 76px; }
  .proto-links { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; margin-top: 4px; font-size: 13px; }
.comments-link { color: var(--muted); }
.comments-link.has-open { color: var(--accent); font-weight: 600; }
.versions summary { cursor: pointer; color: var(--muted); }
.versions[open] summary { color: var(--text); }
.version-list { margin: 6px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 2px; }
.version-list a { color: var(--accent); font-weight: 600; }
.version-list .link-danger {
  margin-left: 8px; padding: 0; border: 0; background: none; color: var(--danger); font: inherit; font-size: 12px;
  cursor: pointer; text-decoration: underline;
}
.proto-actions { grid-column: 1 / -1; justify-content: flex-start; max-width: none; }
}
