/* ===================================================================
   Gallery admin — contact sheet
   One roll of 486 frames, cut into properties. Frames are printed on a
   graphite sheet, selection is marked in china-pencil yellow, and cuts
   are made on the perforation line between two frames.
   =================================================================== */

:root {
  --bg:        #17191d;
  --panel:     #1e2126;
  --panel-2:   #252930;
  --line:      #343a44;
  --line-soft: #2a2e35;
  --text:      #e8e6e1;
  --dim:       #949aa5;
  --dimmer:    #6d737d;
  --mark:      #f2c14e;   /* china pencil — selection */
  --cut:       #e0614a;   /* the cut line, and destructive actions */

  --display: 'Archivo Narrow', 'Segoe UI Semibold', 'Segoe UI', system-ui, sans-serif;
  --body:    system-ui, 'Segoe UI', Roboto, sans-serif;
  --mono:    'JetBrains Mono', Consolas, 'SF Mono', ui-monospace, monospace;

  --bar-h:  52px;
  --rail-w: 310px;
  --r: 3px;
}

* { box-sizing: border-box; }

/* several blocks below set display, which would otherwise beat the attribute */
[hidden] { display: none !important; }

html, body {
  margin: 0; height: 100%;
  background: var(--bg); color: var(--text);
  font: 15px/1.5 var(--body);
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }

::selection { background: var(--mark); color: #1a1a1a; }

:focus-visible {
  outline: 2px solid var(--mark);
  outline-offset: 2px;
}

/* ---- shared bits ------------------------------------------------- */

.eyebrow, .rail-head h2, .sheet-head .eyebrow, .selcount, .frame-strip {
  font-family: var(--display);
  text-transform: uppercase;
  letter-spacing: .12em;
}

.btn {
  display: inline-flex; align-items: center; gap: .4em;
  padding: 6px 11px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  color: var(--text);
  font-family: var(--display);
  font-size: 13px; letter-spacing: .04em;
  text-decoration: none;
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { background: #2e333b; border-color: #454c58; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-wide { width: 100%; justify-content: center; }
.btn-mark { border-color: #6a5a2c; color: var(--mark); }
.btn-mark:hover { background: #322a14; border-color: var(--mark); }
.btn-danger { border-color: #6d3227; color: #f0836f; }
.btn-danger:hover { background: #3a1d17; border-color: var(--cut); }

/* ---- top bar ----------------------------------------------------- */

.bar {
  position: sticky; top: 0; z-index: 40;
  height: var(--bar-h);
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 0 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.bar-id { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.bar-id .mark { color: var(--mark); font-size: 13px; }
.bar-title {
  font-family: var(--display); font-weight: 700;
  text-transform: uppercase; letter-spacing: .16em; font-size: 15px;
}
.bar-sub { font-family: var(--mono); font-size: 12px; color: var(--dim); white-space: nowrap; }
.bar-actions { display: flex; gap: 8px; flex-shrink: 0; }

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

.shell {
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  height: calc(100vh - var(--bar-h));
}

/* ---- rail: the list of properties -------------------------------- */

.rail {
  display: flex; flex-direction: column;
  background: var(--panel);
  border-right: 1px solid var(--line);
  min-height: 0;
}
.rail-head { padding: 14px 14px 12px; border-bottom: 1px solid var(--line-soft); }
.rail-head h2 { margin: 0; font-size: 13px; font-weight: 600; color: var(--dim); }
.progress { margin: 8px 0 10px; font-family: var(--mono); font-size: 12px; color: var(--dim); }
.progress b { color: var(--text); font-weight: 600; }

.target-row { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--dimmer); }
.target-row input {
  width: 52px; padding: 3px 6px;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--r);
  font-family: var(--mono); text-align: center;
}

.rail-list { flex: 1; overflow-y: auto; padding: 8px 8px 16px; }
.rail-foot { padding: 10px 12px 14px; border-top: 1px solid var(--line-soft); }

/* one property in the rail */
.strip {
  position: relative;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 10px; align-items: center;
  width: 100%; padding: 7px 8px 7px 18px;
  margin-bottom: 3px;
  background: none; border: 1px solid transparent; border-radius: var(--r);
  text-align: left; cursor: pointer;
}
.strip:hover { background: var(--panel-2); }
.strip.is-open { background: var(--panel-2); border-color: var(--line); }
.strip.is-open::before {
  content: ''; position: absolute; left: 6px; top: 8px; bottom: 8px;
  width: 3px; background: var(--mark); border-radius: 2px;
}
.strip.drop-on { border-color: var(--mark); background: #2b2a1e; }
.strip.dragging { opacity: .45; }

.strip-pos {
  position: absolute; left: 3px; top: 50%; transform: translateY(-50%);
  font-family: var(--mono); font-size: 10px; color: var(--dimmer);
}
.strip.is-open .strip-pos { display: none; }

.strip-cover {
  width: 44px; height: 32px; border-radius: 2px; overflow: hidden;
  background: #101215; border: 1px solid var(--line-soft);
}
.strip-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }

.strip-text { min-width: 0; }
.strip-name {
  display: block; font-size: 13.5px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.strip-name.unset { color: var(--dimmer); font-style: italic; }
.strip-meta { display: block; font-family: var(--mono); font-size: 11px; color: var(--dim); }
.strip-empty .strip-meta { color: var(--cut); }

.strip-bin { margin-bottom: 10px; }
.strip-bin .strip-pos { display: none; }
.strip-bin .strip-cover { border-style: dashed; }

/* ---- sheet: the frames of the open property ---------------------- */

.sheet { min-width: 0; overflow-y: auto; }

.sheet-head {
  position: sticky; top: 0; z-index: 20;
  padding: 16px 20px 14px;
  background: linear-gradient(var(--bg) 78%, rgba(23,25,29,0));
  border-bottom: 1px solid var(--line-soft);
}
.sheet-head .eyebrow { font-size: 11px; color: var(--dim); margin: 0 0 8px; }
.head-top { display: flex; align-items: flex-start; gap: 14px; flex-wrap: wrap; }

.number-field { flex: 1 1 340px; min-width: 240px; }
.number-field label {
  display: block; font-family: var(--display); text-transform: uppercase;
  letter-spacing: .1em; font-size: 10.5px; color: var(--dimmer); margin-bottom: 4px;
}
.number-field input {
  width: 100%; padding: 8px 11px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  font-family: var(--display); font-size: 21px; font-weight: 600; letter-spacing: .01em;
}
.number-field input::placeholder { color: var(--dimmer); font-weight: 500; font-style: italic; }
.number-field input:focus { border-color: var(--mark); outline: none; }
.number-field input.is-blank { border-style: dashed; }
.bin-title { margin: 0; font-family: var(--display); font-size: 24px; letter-spacing: .01em; }
.field-note { margin: 5px 0 0; font-size: 11.5px; color: var(--dimmer); }
.field-note.saved { color: var(--mark); }

.head-side { display: flex; flex-direction: column; gap: 6px; padding-top: 18px; }
.head-side .btn-row { display: flex; gap: 6px; }

.meta-row { display: flex; gap: 12px; margin-top: 10px; flex-wrap: wrap; }
.meta-row .field { flex: 1 1 200px; }
.meta-row label {
  display: block; font-family: var(--display); text-transform: uppercase;
  letter-spacing: .1em; font-size: 10.5px; color: var(--dimmer); margin-bottom: 4px;
}
.meta-row input {
  width: 100%; padding: 6px 9px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  font-size: 13px;
}
.meta-row input:focus { border-color: var(--mark); outline: none; }

.sheet-stats { margin: 10px 0 0; font-family: var(--mono); font-size: 11.5px; color: var(--dim); }

/* selection toolbar */
.selbar {
  position: sticky; top: 0; z-index: 25;
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  flex-wrap: wrap;
  padding: 9px 20px;
  background: #2b2a1e;
  border-top: 1px solid #4a442c;
  border-bottom: 1px solid #4a442c;
}
.selcount { font-size: 12px; color: var(--mark); }
.selbar-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.selbar-controls label {
  font-family: var(--display); text-transform: uppercase; letter-spacing: .1em;
  font-size: 10.5px; color: #bfae7d;
}
.selbar select {
  padding: 5px 8px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r); font-size: 13px; max-width: 260px;
}

/* the frame grid */
.frames {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 22px 9px;
  padding: 18px 20px 120px;
  align-content: start;
}

.frame {
  position: relative;
  display: block; width: 100%; padding: 0;
  background: none; border: 0; cursor: pointer;
  text-align: left;
}
.frame-img {
  position: relative;
  aspect-ratio: 3 / 2;
  background: #0f1114;
  border: 1px solid var(--line-soft);
  border-radius: 2px;
  overflow: hidden;
}
.frame-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.frame:hover .frame-img { border-color: #4d545f; }

/* china-pencil mark on a selected frame */
.frame.sel .frame-img { border-color: var(--mark); box-shadow: 0 0 0 2px var(--mark); }
.frame.sel .frame-strip { color: var(--mark); }
.frame.dragging { opacity: .4; }

.frame-strip {
  display: flex; align-items: center; gap: 6px;
  margin-top: 5px;
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .06em;
  color: var(--dim); text-transform: none;
}
.frame-n { color: var(--dimmer); }
.frame-tag {
  margin-left: auto;
  padding: 0 4px; border: 1px solid var(--line);
  border-radius: 2px; font-size: 9px; color: var(--dimmer);
}
.frame-tag.cover { border-color: #6a5a2c; color: var(--mark); }

/* the perforation between two frames: click to cut the roll here */
.cut {
  position: absolute; left: -17px; top: 0; bottom: 21px; width: 26px; z-index: 5;
  display: flex; align-items: center; justify-content: center;
  background: none; border: 0; padding: 0; cursor: col-resize;
  opacity: 0; transition: opacity .12s;
}
.cut::before { content: ''; width: 0; border-left: 2px dashed var(--cut); height: 100%; }
.cut::after {
  content: 'CUT';
  position: absolute; top: -8px;
  font-family: var(--mono); font-size: 9px; font-weight: 600;
  letter-spacing: .1em; line-height: 1; color: var(--cut);
  background: var(--bg); padding: 2px 3px;
  border: 1px solid var(--cut); border-radius: 2px;
}
.frame:hover .cut { opacity: .55; }
.cut:hover, .cut:focus-visible { opacity: 1; }

/* where the dragged frames will land */
.frame.drop-before::before {
  content: ''; position: absolute; left: -6px; top: 0; bottom: 21px;
  width: 3px; background: var(--mark); border-radius: 2px; z-index: 6;
}

.sheet-empty {
  grid-column: 1 / -1;
  padding: 46px 20px; text-align: center; color: var(--dim);
  border: 1px dashed var(--line); border-radius: var(--r);
}
.sheet-empty b { display: block; color: var(--text); font-family: var(--display);
  text-transform: uppercase; letter-spacing: .1em; margin-bottom: 6px; }

/* ---- toast ------------------------------------------------------- */

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  z-index: 90;
  padding: 9px 16px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-left: 3px solid var(--mark);
  border-radius: var(--r);
  font-size: 13.5px;
  box-shadow: 0 8px 28px rgba(0,0,0,.5);
}
.toast.bad { border-left-color: var(--cut); }

/* ---- modal ------------------------------------------------------- */

.modal {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: rgba(10,11,13,.72);
  padding: 20px;
}
.modal-card {
  width: min(440px, 100%);
  padding: 20px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
}
.modal-card h3 {
  margin: 0 0 8px; font-family: var(--display);
  text-transform: uppercase; letter-spacing: .1em; font-size: 15px;
}
.modal-card p { margin: 0 0 14px; color: var(--dim); font-size: 14px; }
.modal-card select, .modal-card input {
  width: 100%; padding: 7px 10px; margin-bottom: 14px;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--r);
}
.modal-label { display: block; font-size: 12px; color: var(--dimmer); margin-bottom: 5px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }

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

.login-body { display: grid; place-items: center; min-height: 100vh; }
.login {
  width: min(320px, 90vw); padding: 26px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
}
.login .eyebrow { margin: 0; font-size: 11px; color: var(--dim); }
.login h1 { margin: 4px 0 18px; font-family: var(--display); font-size: 24px; letter-spacing: .02em; }
.login input {
  width: 100%; padding: 9px 11px; margin-bottom: 12px;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--r);
}
.login button {
  width: 100%; padding: 9px; cursor: pointer;
  background: var(--mark); border: 0; border-radius: var(--r);
  color: #1a1a1a; font-family: var(--display); font-weight: 700;
  text-transform: uppercase; letter-spacing: .1em;
}
.login-error { margin: -4px 0 12px; color: var(--cut); font-size: 13px; }

/* ---- narrow screens ---------------------------------------------- */

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; height: auto; }
  .rail { border-right: 0; border-bottom: 1px solid var(--line); }
  .rail-list { max-height: 42vh; }
  .frames { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); padding: 14px 12px 90px; }
  .sheet-head { padding: 14px 12px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---- server check ------------------------------------------------- */

.check-body { padding: 40px 20px; }
.check { width: min(760px, 100%); margin: 0 auto; }
.check .eyebrow { margin: 0; font-size: 11px; color: var(--dim); }
.check h1 { margin: 4px 0 16px; font-family: var(--display); font-size: 27px; letter-spacing: .01em; }

.check-verdict {
  margin: 0 0 22px; padding: 11px 14px;
  border: 1px solid var(--line); border-left-width: 3px; border-radius: var(--r);
  background: var(--panel); font-size: 14.5px;
}
.check-verdict.is-ok   { border-left-color: #6fbf8b; }
.check-verdict.is-warn { border-left-color: var(--mark); }
.check-verdict.is-bad  { border-left-color: var(--cut); }
.check-verdict a { color: var(--mark); }

.check-table { width: 100%; border-collapse: collapse; }
.check-table td { padding: 11px 8px; border-top: 1px solid var(--line-soft); vertical-align: top; }
.check-table tr:first-child td { border-top: 0; }

.check-dot { width: 20px; }
.check-dot span { display: block; width: 9px; height: 9px; margin-top: 6px; border-radius: 50%; }
.is-ok   .check-dot span { background: #6fbf8b; }
.is-warn .check-dot span { background: var(--mark); }
.is-bad  .check-dot span { background: var(--cut); }

.check-label {
  width: 42%;
  font-family: var(--display); font-size: 14px; letter-spacing: .02em;
}
.check-detail { color: var(--dim); font-size: 14px; }
.check-fix {
  display: block; margin-top: 5px;
  color: var(--dimmer); font-size: 12.5px; line-height: 1.5;
}
.check-foot { margin-top: 26px; font-size: 13px; color: var(--dimmer); }
.check-foot a { color: var(--dim); }

@media (max-width: 620px) {
  .check-label, .check-detail { display: block; width: auto; }
  .check-table td { padding: 8px; }
  .check-dot { display: none; }
}
.login-note { margin: 0 0 12px; font-size: 13px; line-height: 1.55; color: var(--dim); }
.login-code {
  margin: 0 0 14px; padding: 9px 10px; overflow-x: auto;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--r);
  font-family: var(--mono); font-size: 11.5px; color: var(--mark);
}
