/* 管理頁:沿用 draw.css 的字型、色彩與分類欄,這裡只放管理專用的部分。
   管理頁不從照片取色,背景維持固定的中性色。 */

.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;
}

input, select, button { font: inherit; color: inherit; }
input:not([type="checkbox"]), select {
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid color-mix(in oklab, var(--ink) 28%, transparent);
  border-radius: 8px;
  background: var(--paper);
  color: #1f1e1c;
}

.text-btn {
  background: none;
  border: 0;
  padding: 8px 0;
  min-height: 44px;
  cursor: pointer;
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-thickness: 1px;
}
.text-btn.quiet { color: var(--mute); }
.text-btn.danger { color: var(--danger); }
.text-btn:disabled { color: var(--mute); text-decoration: none; cursor: default; opacity: .7; }
.btn.small { min-height: 40px; padding: 0 14px; font-size: 14px; }
.btn.danger { color: var(--danger); }
.btn.danger-fill { background: var(--danger); border-color: var(--danger); color: #fff; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- 分類欄補充 ---------- */
.rail-tools { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; }
.rail-tools .quota, .rail-tools .new-deck { align-self: stretch; }
.rail-foot { display: flex; align-items: center; gap: 16px; }
.rail-foot .text-btn { min-height: 0; padding: 2px 0; font-size: 14px; }
.new-deck { display: flex; flex-direction: column; gap: 8px; font-size: 13px; color: var(--mute); }
.quota { font-size: 12px; color: var(--mute); font-variant-numeric: tabular-nums; }
.quota-track { margin-top: 6px; height: 3px; background: var(--rule); border-radius: 2px; overflow: hidden; }
.quota-fill { height: 100%; background: var(--ink); }
.quota.is-full { color: var(--danger); }
.quota.is-full .quota-fill { background: var(--danger); }

@media (max-width: 899px) {
  .rail-tools { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px 16px; }
  .new-deck { flex-basis: 100%; }
  .rail-foot { position: absolute; top: 12px; right: 16px; }
  .rail-foot .upload-link { position: static; }
}
@media (min-width: 900px) {
  .rail-foot { margin-top: auto; }
  .manage .rail { gap: 28px; }
}

/* ---------- 主區 ---------- */
.desk {
  min-width: 0;
  padding: 8px 16px calc(96px + env(safe-area-inset-bottom));
}
@media (min-width: 900px) {
  .desk { padding: 40px 48px 120px; max-width: 1180px; }
}
.desk h2 {
  margin: 0 0 14px;
  font: 500 15px/1.4 var(--sans);
  color: var(--mute);
}

/* ---------- 密碼 ---------- */
.lock { max-width: 360px; padding-top: 6vh; }
.lock h1 { font: 500 34px/1.1 var(--serif); margin: 0 0 24px; }
.lock form { display: flex; flex-direction: column; gap: 10px; }
.lock label { font-size: 14px; }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; min-height: 44px; }
.check input { width: 18px; height: 18px; accent-color: var(--ink); }
.form-error { margin: 0; min-height: 1.6em; color: var(--danger); font-size: 14px; }

/* ---------- 上傳 ---------- */
.intake { margin-bottom: 48px; }
.drop {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  min-height: 140px;
  padding: 24px;
  border: 1.5px dashed color-mix(in oklab, var(--ink) 40%, transparent);
  border-radius: 8px;
  background: color-mix(in oklab, var(--paper) 55%, transparent);
  cursor: pointer;
}
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop:focus-within { outline: 2px solid var(--ink); outline-offset: 3px; }
.drop.is-over { border-style: solid; border-color: var(--ink); background: var(--paper); }
.drop-main { font: 400 22px/1.35 var(--serif); }
.drop-sub { font-size: 13px; color: var(--mute); }

.target { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 14px 0 0; font-size: 14px; }
.target input { width: 200px; }
.target-note { font-size: 13px; color: var(--mute); }

.queue { list-style: none; margin: 18px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.item {
  padding: 12px 14px;
  border-radius: 8px;
  background: color-mix(in oklab, var(--paper) 70%, transparent);
  border: 1px solid var(--rule);
}
.item-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.item-name { font-weight: 500; overflow-wrap: anywhere; }
.item-state { font-size: 13px; color: var(--mute); text-align: right; flex: none; }
.item.is-ok .item-state { color: var(--ink); }
.item.is-error .item-state { color: var(--danger); }
.item-bar { margin-top: 8px; height: 3px; background: var(--rule); border-radius: 2px; overflow: hidden; }
.item-bar > span { display: block; height: 100%; width: 0; background: var(--ink); transition: width .2s; }
.item.is-error .item-bar > span { background: var(--danger); }

.plan { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; font-size: 14px; }
.plan p { margin: 0; }
.plan input { width: 180px; margin: 0 6px; }
.plan details { color: var(--mute); }
.plan summary { cursor: pointer; min-height: 32px; }
.plan ul { margin: 6px 0 0; padding-left: 18px; max-height: 180px; overflow: auto; }
.plan .err { color: var(--danger); }

/* ---------- 分類內容 ---------- */
.shelf-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 24px; margin-bottom: 4px; }
.title-row { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.deck-title { margin: 0 !important; font: 500 40px/1.1 var(--serif) !important; color: var(--ink) !important; overflow-wrap: anywhere; }
.deck-total { font-size: 14px; color: var(--mute); font-variant-numeric: tabular-nums; }
.rename { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.rename input { font: 500 22px/1 var(--serif); width: 240px; }
.shelf-actions { display: flex; gap: 20px; }
.shelf-note { margin: 0 0 16px; min-height: 1.6em; font-size: 14px; color: var(--mute); }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 12px;
}
@media (min-width: 900px) { .grid { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 16px; } }

.thumb {
  position: relative;
  display: block;
  padding: 5px;
  border: 0;
  border-radius: 6px;
  background: var(--paper);
  cursor: pointer;
  box-shadow: 0 1px 0 color-mix(in oklab, var(--ink) 10%, transparent);
}
.thumb img {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 3px;
  background: color-mix(in oklab, var(--ink) 8%, var(--paper));
}
.thumb .mark {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1.5px solid #fff;
  background: rgb(0 0 0 / .25);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 14px;
  line-height: 1;
}
.thumb[aria-pressed="true"] { outline: 2px solid var(--ink); outline-offset: 2px; }
.thumb[aria-pressed="true"] img { opacity: .82; }
.thumb[aria-pressed="true"] .mark { background: #1f1e1c; border-color: #1f1e1c; }
.thumb[aria-pressed="true"] .mark::after { content: '✓'; }
.thumb .name { display: block; margin-top: 4px; font-size: 11px; color: #4f4b45; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.selbar {
  position: sticky;
  bottom: calc(12px + env(safe-area-inset-bottom));
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-top: 20px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--ink);
  color: var(--base);
}
.selbar .sel-count { font-weight: 500; margin-right: auto; }
.selbar select { min-height: 40px; }
.selbar .btn { flex: none; }
.selbar .btn.primary { background: var(--base); color: var(--ink); border-color: var(--base); }
.selbar .btn.ghost { color: var(--base); border-color: color-mix(in oklab, var(--base) 40%, transparent); }
.selbar .btn.ghost.danger { color: #ffb4ae; border-color: #ffb4ae; }
.selbar .text-btn { color: var(--base); }

/* ---------- 確認視窗 ---------- */
.confirm {
  border: 0;
  border-radius: 10px;
  padding: 24px;
  max-width: min(420px, calc(100vw - 32px));
  background: var(--paper);
  color: #1f1e1c;
}
.confirm::backdrop { background: rgb(0 0 0 / .45); }
.confirm p { margin: 0 0 20px; line-height: 1.7; }
.confirm .btn.ghost { color: #1f1e1c; border-color: rgb(0 0 0 / .2); }
.confirm .row { justify-content: flex-end; }
