/* Admin widgets: thumbnails and gallery cards, the text-line editor, the
   Inputs bindings, the Help steps, the cheat sheet, toasts and the modal.
   Tokens only (theme.css), so the dark theme covers all of it. */

.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.thumb {
  position: relative; border: 2px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--outline); cursor: pointer; aspect-ratio: 4 / 3;
  transition: transform .18s var(--ease), box-shadow .18s, border-color .15s;
}
.thumb:hover { transform: translateY(-2px); box-shadow: var(--shadow-card); border-color: var(--ink-3); }
.thumb.active { border-color: var(--yellow-deep); box-shadow: 0 0 0 2px var(--yellow); }
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .name {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 3px 6px; font-size: 11px; color: #fff;
  background: linear-gradient(to top, rgba(0, 0, 0, .7), rgba(0, 0, 0, .35)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.thumb .del {
  position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border: 0; border-radius: 999px;
  background: rgba(228, 72, 91, .95); color: #fff; font-weight: 700; cursor: pointer; line-height: 1; opacity: .85; transition: opacity .15s, transform .15s;
}
.thumb .del:hover { opacity: 1; transform: scale(1.1); }
.thumbs.photos { grid-template-columns: repeat(auto-fill, minmax(172px, 1fr)); }
/* Gallery cards (0.8): the picture with a selection tick, then a tools row. */
.thumb.photo { aspect-ratio: auto; display: grid; grid-template-rows: auto auto; background: var(--surface); cursor: default; animation: card-in .35s var(--ease) both; }
@keyframes card-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.thumb.photo .pic { position: relative; aspect-ratio: 16 / 10; background: var(--outline); cursor: pointer; }
.thumb.photo.selected { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.thumb.photo .tick {
  position: absolute; top: 4px; left: 4px; width: 22px; height: 22px; border-radius: 999px; border: 2px solid #fff;
  background: rgba(0, 0, 0, .45); display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 13px; line-height: 1;
  transition: background .15s, transform .2s var(--ease);
}
.thumb.photo.selected .tick { background: var(--blue); border-color: var(--blue); animation: tick-pop .3s var(--ease); }
@keyframes tick-pop { 0% { transform: scale(.6); } 60% { transform: scale(1.2); } 100% { transform: scale(1); } }
.thumb.photo.selected .tick::before { content: "\2713"; }
.thumb.photo .tools { display: flex; gap: 4px; padding: 4px; }
.thumb.photo .tools .btn { flex: 1; padding: 3px 4px; white-space: nowrap; }
.scope { display: flex; gap: 4px; margin: 0 0 8px; }
.scope .btn[aria-pressed="true"] { background: var(--blue-soft); border-color: var(--blue); color: var(--blue-deep); }

.text-line-form { border-top: 1px dashed var(--line); padding-top: 8px; margin-top: 8px; }
.text-line-form:first-child { border-top: 0; padding-top: 0; margin-top: 0; }

#cheatsheet {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 60;
  background: var(--surface); color: var(--ink); border-radius: 16px; padding: 18px 22px;
  box-shadow: var(--shadow); border-top: 6px solid var(--yellow); min-width: 380px; max-width: 90vw;
  animation: modal-in .25s var(--ease) both;
}
#cheatsheet h2 { margin: 0 0 10px; font-size: 18px; font-weight: 800; }
#cheatsheet table, .panel table.chords { border-collapse: collapse; font-size: 13.5px; }
#cheatsheet td, .panel table.chords td { padding: 4px 12px 4px 0; vertical-align: top; }
#cheatsheet td:first-child { white-space: nowrap; }
#cheatsheet tr + tr td, .panel table.chords tr + tr td { border-top: 1px dashed var(--line); }
#cheatsheet .hint { margin-top: 10px; }

#toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 70; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 10px; padding: 10px 16px 10px 14px; border-radius: 10px; background: var(--outline); color: #fff; font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow); border-left: 4px solid var(--blue); animation: toast-in .3s var(--ease) both;
}
.toast::before { content: ""; width: 8px; height: 8px; border-radius: 999px; background: var(--blue); flex: none; }
.toast.error { border-left-color: var(--danger); }
.toast.error::before { background: var(--danger); }
.toast.ok { border-left-color: var(--ok); }
.toast.ok::before { background: var(--ok); }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(.96); } to { opacity: 1; transform: none; } }

#modal-root { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; background: rgba(20, 22, 43, .5); backdrop-filter: blur(3px); animation: fade-in .2s ease both; }
.modal {
  background: var(--surface); color: var(--ink); border-radius: 16px; padding: 20px 22px; min-width: 340px; max-width: 520px;
  box-shadow: var(--shadow); border-top: 6px solid var(--blue); animation: modal-in .25s var(--ease) both;
}
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
#cheatsheet { animation-name: sheet-in; }
@keyframes sheet-in { from { opacity: 0; transform: translate(-50%, -48%) scale(.97); } to { opacity: 1; transform: translate(-50%, -50%); } }
.modal h2 { margin: 0 0 8px; font-size: 18px; font-weight: 800; }
.modal p { margin: 0 0 14px; color: var(--ink-2); line-height: 1.45; }
.modal .actions { justify-content: flex-end; }

/* Inputs panel */
.learn-status { margin: 6px 0 0; padding: 8px 10px; border-radius: 8px; background: var(--yellow-light); color: #1B1F3B; font-weight: 700; animation: learn-pulse 1.4s ease-in-out infinite; }
@keyframes learn-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(245, 196, 0, .5); } 50% { box-shadow: 0 0 0 6px rgba(245, 196, 0, 0); } }
.panel.learning .action-row { opacity: .6; }
.action-row { border-top: 1px dashed var(--line); padding: 8px 0; }
.action-row:first-child { border-top: 0; }
.action-head { display: flex; align-items: center; gap: 6px; }
.bindings { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.binding {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 8px;
  background: var(--surface-2); border: 1px solid var(--line); font-size: 12px;
}
.binding.failed { border-color: var(--danger); }
.binding .sig { font-family: var(--mono); font-weight: 700; color: var(--ink); }
.binding .mini { display: inline-flex; align-items: center; gap: 3px; color: var(--ink-2); }
.binding select.tiny, .binding input.tiny { padding: 2px 4px; font-size: 11px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); color: var(--ink); }
.binding input.tiny { width: 62px; -webkit-user-select: text; user-select: text; }
.binding .unit { color: var(--ink-3); }
.binding .del {
  margin-left: auto; width: 20px; height: 20px; border: 0; border-radius: 999px; background: rgba(228, 72, 91, .9); color: #fff; font-weight: 700; cursor: pointer; line-height: 1;
}
.devices .device { font-family: var(--mono); font-size: 12px; padding: 2px 0; }
.recent { margin: 0; padding: 0 0 0 16px; font-size: 12px; max-height: 120px; overflow: auto; }
.recent code { font-family: var(--mono); color: var(--blue-deep); }

/* Help panel */
.welcome {
  margin: 0 0 12px; padding: 10px 12px; border-radius: var(--r); background: var(--yellow-light); color: #1B1F3B;
  border-left: 4px solid var(--yellow-deep); line-height: 1.45;
}
.welcome kbd { color: #1B1F3B; background: #fff; border-color: #E8D77A; }
.steps { list-style: none; margin: 0; padding: 0; counter-reset: step; }
.step {
  display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: center; padding: 8px 0;
  border-top: 1px dashed var(--line); counter-increment: step;
}
.step:first-child { border-top: 0; }
.step .n {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 12px;
  background: var(--paper-2); color: var(--ink-2); border: 1px solid var(--line); transition: background .2s, color .2s;
}
.step .n::before { content: counter(step); }
.step.done .n { background: var(--ok); border-color: var(--ok); color: #fff; animation: tick-pop .35s var(--ease); }
.step.done .n::before { content: "\2713"; }
.step .what { display: grid; gap: 2px; min-width: 0; }
.step .what strong { font-size: 14px; }
.step .state { font-size: 12px; color: var(--ink-2); word-break: break-word; }
.step .go { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
details.howto { border-top: 1px dashed var(--line); padding: 6px 0; }
details.howto:first-of-type { border-top: 0; }
details.howto summary { color: var(--ink); }
details.howto ol { margin: 4px 0 6px; padding-left: 22px; color: var(--ink-2); font-size: 13px; line-height: 1.45; }
details.howto ol li { margin: 3px 0; }
details.howto .actions { margin: 2px 0 6px; }

/* 0.12 admin PIN pad (admin/pinpad.js): a printed comic panel with big
   inked keys, sized for a finger. Locked: the keys dim under the
   countdown line. */
.modal.pinpad { min-width: 300px; max-width: 360px; text-align: center; }
.pinpad .pin-msg { font-weight: 800; color: var(--ink); min-height: 1.45em; }
.pinpad[data-locked="1"] .pin-msg { color: #fff; background: var(--danger); border: 2px solid var(--ink-line); border-radius: 5px; padding: 4px 8px; }
.pin-dots {
  height: 44px; margin: 0 0 14px; border: 3px solid var(--ink-line); border-radius: 6px; background: var(--yellow); color: #14162B;
  font-size: 22px; letter-spacing: .3em; line-height: 38px; box-shadow: var(--pop);
}
.pin-keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.pin-key {
  min-height: 60px; font: 400 30px/1 var(--display); letter-spacing: .04em; color: var(--ink); background: var(--surface);
  border: 3px solid var(--ink-line); border-radius: 6px; box-shadow: var(--pop); cursor: pointer; touch-action: manipulation;
}
.pin-key.ok { background: var(--blue); color: #fff; }
.pin-key.clear { font-size: 22px; background: var(--yellow); color: #14162B; }
.pin-key:focus-visible { outline: none; box-shadow: var(--pop), 0 0 0 3px var(--yellow); }
.pin-key:disabled { opacity: .45; cursor: default; box-shadow: none; }
.pinpad .actions { justify-content: center; }
.pin-set .pin-state { margin: 0 0 8px; font-weight: 700; }
