* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: #f4f4f5;
  color: #1f2328;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

a { color: #1f6feb; }

h1, h2, h3 { margin: 0 0 4px; font-weight: 600; }

.top-bar {
  background: #fff;
  border-bottom: 1px solid #d9dce1;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.top-bar h1 { font-size: 16px; }
.top-bar .sub { font-size: 12px; color: #6b7280; }

.page-shell { max-width: 1100px; margin: 0 auto; padding: 0 20px 60px; }

/* ---------- buttons / inputs ---------- */

.btn {
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid #c6cbd2;
  background: #fff;
  color: #1f2328;
  padding: 7px 14px;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.btn:hover { background: #f0f1f3; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: #1f6feb; border-color: #1f6feb; color: #fff; }
.btn-primary:hover { background: #1a5fd0; }
.btn-danger { color: #b91c1c; border-color: #f0b4b4; }
.btn-danger:hover { background: #fdf0f0; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

label { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; color: #6b7280; }
input[type="text"], input[type="password"], textarea {
  font-family: inherit;
  font-size: 13.5px;
  border: 1px solid #c6cbd2;
  border-radius: 6px;
  padding: 8px 10px;
  background: #fff;
  width: 100%;
  resize: vertical;
}
input:focus, textarea:focus { outline: 2px solid #1f6feb33; border-color: #1f6feb; }
textarea { min-height: 64px; }
.field { display: flex; flex-direction: column; gap: 4px; }
form.stacked { display: flex; flex-direction: column; gap: 10px; }

.divider { border: none; border-top: 1px solid #e2e5e9; margin: 16px 0; }

/* ---------- login gate ---------- */

.login-shell {
  max-width: 340px;
  margin: 80px auto;
  background: #fff;
  border: 1px solid #d9dce1;
  border-radius: 8px;
  padding: 28px;
}
.login-shell h2 { font-size: 18px; margin-bottom: 4px; }
.login-shell p.hint { color: #6b7280; font-size: 12.5px; margin: 0 0 16px; }
.login-error { color: #b91c1c; font-size: 12.5px; margin-top: 4px; min-height: 16px; }
.login-disabled {
  background: #fff8e6;
  border: 1px solid #f2d98b;
  color: #7a5b00;
  padding: 12px 14px;
  border-radius: 6px;
  font-size: 12.5px;
}

/* ---------- workbench layout ---------- */

.admin-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 20px;
  align-items: start;
  margin-top: 20px;
}
@media (max-width: 820px) { .admin-shell { grid-template-columns: 1fr; } }

.panel {
  background: #fff;
  border: 1px solid #d9dce1;
  border-radius: 8px;
  padding: 16px;
}
.panel h2 { font-size: 15px; margin-bottom: 10px; }

.comic-list { list-style: none; margin: 0 0 14px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.comic-list li { border: 1px solid #e2e5e9; border-radius: 6px; background: #fafbfc; }
.comic-list li.active { background: #eaf2ff; border-color: #1f6feb55; }
.comic-list button.select {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 8px 10px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 500;
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}
.comic-list .count { font-size: 11px; color: #6b7280; }

.workbench-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; flex-wrap: wrap; }
.workbench-header h2 { font-size: 20px; }
.workbench-header .desc { font-size: 12.5px; color: #6b7280; max-width: 60ch; margin-top: 2px; }

.dropzone {
  border: 2px dashed #c6cbd2;
  border-radius: 8px;
  padding: 22px 14px;
  text-align: center;
  margin: 16px 0;
  background: #fafbfc;
  cursor: pointer;
  display: block;
}
.dropzone.dragover { background: #eaf2ff; border-color: #1f6feb; }
.dropzone strong { font-size: 13.5px; }
.dropzone p { font-size: 12px; color: #6b7280; margin: 4px 0 0; }
.dropzone input { display: none; }

.page-board { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 12px; margin-top: 14px; }
.page-tile {
  border: 1px solid #d9dce1;
  border-radius: 6px;
  background: #fff;
  overflow: hidden;
  cursor: grab;
  position: relative;
}
.page-tile.dragging { opacity: 0.4; }
.page-tile.drop-target { outline: 2px solid #1f6feb; outline-offset: 1px; }
.page-tile img { width: 100%; aspect-ratio: 3/4; object-fit: cover; display: block; }
.page-tile .tile-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 6px; background: #f4f4f5; border-top: 1px solid #e2e5e9;
}
.page-tile .num { font-size: 11px; color: #6b7280; }
.page-tile .cover-badge { font-size: 9px; background: #1f6feb; color: #fff; padding: 1px 5px; border-radius: 3px; }
.page-tile .tile-actions { position: absolute; top: 4px; right: 4px; display: flex; gap: 4px; opacity: 0; }
.page-tile:hover .tile-actions { opacity: 1; }
.page-tile .tile-actions button {
  width: 22px; height: 22px; border-radius: 50%;
  border: 1px solid #d9dce1; background: #fff; font-size: 11px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.page-tile .tile-actions button.set-cover.is-cover { background: #ffe58a; border-color: #e0b400; }

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(6px);
  background: #1f2328;
  color: #fff;
  padding: 9px 16px;
  border-radius: 6px;
  font-size: 12.5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: #b91c1c; }

.hint { font-size: 11.5px; color: #6b7280; margin-top: 2px; }
.placeholder-note { padding: 26px 10px; text-align: center; color: #6b7280; }

/* ---------- mobile ---------- */

@media (max-width: 640px) {
  .top-bar { padding: 10px 14px; flex-wrap: wrap; gap: 8px; }
  .top-bar h1 { font-size: 14px; }
  .page-shell { padding: 0 12px 40px; }
  .login-shell { margin: 40px auto; padding: 20px; width: calc(100% - 24px); max-width: 340px; }
  .page-board { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
  .workbench-header { flex-direction: column; align-items: stretch; }
  .workbench-header > div:last-child { display: flex; flex-wrap: wrap; }
}

