@import url('https://fonts.googleapis.com/css2?family=Archivo:wght@500;600;700&family=IBM+Plex+Mono:wght@400;500&family=IBM+Plex+Sans:wght@400;500;600&display=swap');

/* ==========================================================================
   TileCat — catalogue editor
   Chrome stays graphite so page artwork reads true. Accents are ROEX lime
   and cyan, used only where an action or a live value needs to be found.
   ========================================================================== */

:root {
  --ink:        #16181a;
  --panel:      #1e2124;
  --panel-2:    #23272a;
  --pit:        #34393d;
  --line:       #2f3438;
  --line-soft:  #272b2e;
  --text:       #e6e9ea;
  --text-dim:   #9aa2a8;
  --text-faint: #6c757b;
  --lime:       #b1d339;
  --lime-dim:   #7f9a26;
  --cyan:       #10c7ca;
  --amber:      #e0a23c;
  --danger:     #e0625c;
  --paper:      #ffffff;

  --font-display: 'Archivo', system-ui, sans-serif;
  --font-ui:      'IBM Plex Sans', system-ui, sans-serif;
  --font-mono:    'IBM Plex Mono', ui-monospace, monospace;

  --rail-w: 168px;
  --insp-w: 300px;
  --bar-h: 52px;
  --r: 6px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--ink);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .display {
  font-family: var(--font-display);
  letter-spacing: -0.015em;
  margin: 0;
}

a { color: var(--cyan); }

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.eyebrow {
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
}

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

/* --- Buttons -------------------------------------------------------------- */

.btn {
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 8px 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: background .12s, border-color .12s, color .12s;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background: #2b3033; border-color: #3c4247; }
.btn:disabled { opacity: .4; cursor: not-allowed; }

.btn-primary {
  background: var(--lime);
  border-color: var(--lime);
  color: #14170a;
  font-weight: 600;
}
.btn-primary:hover:not(:disabled) { background: #c0e044; border-color: #c0e044; }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn-ghost:hover:not(:disabled) { background: var(--panel-2); color: var(--text); }

.btn-danger { color: var(--danger); border-color: transparent; background: transparent; }
.btn-danger:hover:not(:disabled) { background: rgba(224, 98, 92, .12); border-color: rgba(224, 98, 92, .3); }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }

/* --- Login gate ----------------------------------------------------------- */

.gate-body {
  display: grid;
  place-items: center;
  background:
    radial-gradient(900px 500px at 50% -10%, #1f2429 0%, var(--ink) 62%);
}

.gate { width: 320px; text-align: center; padding: 24px; }

.gate-mark {
  display: grid;
  grid-template-columns: repeat(2, 26px);
  grid-auto-rows: 26px;
  gap: 3px;
  justify-content: center;
  margin-bottom: 22px;
}
.gate-mark span { background: var(--line); border-radius: 2px; }
.gate-mark span:nth-child(1) { background: var(--lime); }
.gate-mark span:nth-child(4) { background: var(--cyan); }

.gate h1 { font-size: 26px; font-weight: 700; }
.gate-sub { color: var(--text-faint); margin: 4px 0 26px; font-size: 13px; }

.gate-form { text-align: left; display: grid; gap: 8px; }
.gate-form label { font-size: 12px; color: var(--text-dim); }
.gate-error { color: var(--danger); font-size: 12px; margin: 0; }

input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%;
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--text);
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 9px 11px;
}
input:focus, select:focus, textarea:focus { border-color: var(--cyan); outline: none; }

/* --- App shell ------------------------------------------------------------ */

.topbar {
  height: var(--bar-h);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 40;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
}
.brand-mark {
  width: 18px; height: 18px;
  display: grid;
  grid-template: repeat(2, 1fr) / repeat(2, 1fr);
  gap: 2px;
}
.brand-mark i { background: var(--line); border-radius: 1px; }
.brand-mark i:first-child { background: var(--lime); }
.brand-mark i:last-child { background: var(--cyan); }

.spacer { flex: 1; }

.doc-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 5px 8px;
  color: var(--text);
  min-width: 140px;
  max-width: 320px;
}
.doc-title:hover { border-color: var(--line); }

.savestate {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  display: flex;
  align-items: center;
  gap: 6px;
}
.savestate::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--lime-dim);
}
.savestate[data-state="dirty"]::before { background: var(--amber); }
.savestate[data-state="saving"]::before { background: var(--cyan); }
.savestate[data-state="error"]::before { background: var(--danger); }

/* --- Dashboard ------------------------------------------------------------ */

.wrap { max-width: 1180px; margin: 0 auto; padding: 34px 24px 80px; }

.page-head { display: flex; align-items: flex-end; gap: 20px; margin-bottom: 26px; }
.page-head h1 { font-size: 28px; font-weight: 700; }
.page-head p { color: var(--text-dim); margin: 6px 0 0; font-size: 13px; max-width: 52ch; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
  gap: 16px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color .14s, transform .14s;
}
.card:hover { border-color: #414850; transform: translateY(-2px); }

.card-thumb {
  aspect-ratio: 1.414;
  background: var(--pit) center/cover no-repeat;
  border-bottom: 1px solid var(--line);
  display: grid;
  place-items: center;
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 11px;
}

.card-body { padding: 12px 13px 13px; display: grid; gap: 8px; }
.card-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.card-actions { display: flex; gap: 6px; margin-top: 2px; }

.tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 3px;
  border: 1px solid var(--line);
  color: var(--text-dim);
}
.tag-edited { color: var(--lime); border-color: var(--lime-dim); }

.dropzone {
  border: 1.5px dashed var(--line);
  border-radius: 10px;
  padding: 40px 24px;
  text-align: center;
  color: var(--text-dim);
  background: var(--panel);
  transition: border-color .14s, background .14s;
  cursor: pointer;
}
.dropzone:hover, .dropzone.over { border-color: var(--lime); background: #202520; color: var(--text); }
.dropzone h3 { font-size: 16px; margin-bottom: 6px; }
.dropzone p { margin: 0; font-size: 13px; }

.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-faint);
}

/* --- Import progress ------------------------------------------------------ */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(12, 14, 15, .82);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  z-index: 100;
}
.overlay[hidden] { display: none; }

.dialog {
  width: 420px;
  max-width: calc(100vw - 32px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 22px;
}
.dialog h2 { font-size: 17px; margin-bottom: 4px; }
.dialog .sub { color: var(--text-dim); font-size: 13px; margin: 0 0 18px; }

.bar {
  height: 4px;
  background: var(--line);
  border-radius: 3px;
  overflow: hidden;
}
.bar > i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--lime), var(--cyan));
  transition: width .2s;
}
.bar-label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
}

.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }

.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12px; color: var(--text-dim); }
.field .hint { font-size: 11px; color: var(--text-faint); font-family: var(--font-mono); }

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

.editor {
  display: grid;
  grid-template-columns: var(--rail-w) 1fr var(--insp-w);
  height: calc(100vh - var(--bar-h));
  overflow: hidden;
}

.rail {
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  padding: 10px;
  display: grid;
  gap: 8px;
  align-content: start;
}

.thumb {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  background: var(--pit);
  aspect-ratio: 1.414;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.active { border-color: var(--lime); box-shadow: 0 0 0 1px var(--lime); }
.thumb-no {
  position: absolute;
  left: 4px; bottom: 4px;
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 1px 4px;
  border-radius: 2px;
  background: rgba(0,0,0,.62);
  color: #fff;
}
.thumb-dot {
  position: absolute;
  right: 4px; top: 4px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 0 2px rgba(0,0,0,.4);
}

/* --- Canvas pit ----------------------------------------------------------- */

.pit {
  background:
    repeating-linear-gradient(45deg, #31363a 0 8px, #34393d 8px 16px);
  overflow: auto;
  position: relative;
  display: grid;
  place-items: center;
  padding: 28px;
}

.stage {
  position: relative;
  background: var(--paper);
  box-shadow: 0 12px 40px rgba(0,0,0,.5);
  transform-origin: center center;
}
.stage img.page-bg {
  display: block;
  width: 100%;
  height: 100%;
  user-select: none;
  -webkit-user-drag: none;
}

/* Slots: corner registration marks, the way a prepress proof is marked up. */
.slot {
  position: absolute;
  cursor: pointer;
  overflow: hidden;
}
.slot .slot-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.slot::before,
.slot::after,
.slot > .reg-b,
.slot > .reg-c {
  content: '';
  position: absolute;
  width: 11px;
  height: 11px;
  border: 1.5px solid var(--cyan);
  opacity: 0;
  transition: opacity .12s;
  pointer-events: none;
}
.slot::before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; }
.slot::after  { top: -1px; right: -1px; border-left: 0; border-bottom: 0; }
.slot > .reg-b { bottom: -1px; left: -1px; border-right: 0; border-top: 0; }
.slot > .reg-c { bottom: -1px; right: -1px; border-left: 0; border-top: 0; }

.pit.show-slots .slot::before,
.pit.show-slots .slot::after,
.pit.show-slots .slot > .reg-b,
.pit.show-slots .slot > .reg-c { opacity: .5; }

.slot:hover::before, .slot:hover::after,
.slot:hover > .reg-b, .slot:hover > .reg-c { opacity: 1; }

.slot.selected::before, .slot.selected::after,
.slot.selected > .reg-b, .slot.selected > .reg-c {
  opacity: 1;
  border-color: var(--lime);
  width: 15px;
  height: 15px;
}

.slot.over {
  box-shadow: inset 0 0 0 2px var(--lime), 0 0 0 2px var(--lime);
  background: rgba(177, 211, 57, .16);
}

.slot-badge {
  position: absolute;
  top: 3px; left: 3px;
  font-family: var(--font-mono);
  font-size: 9px;
  line-height: 1;
  padding: 3px 5px;
  border-radius: 2px;
  background: rgba(0,0,0,.72);
  color: var(--lime);
  opacity: 0;
  transition: opacity .12s;
  pointer-events: none;
  white-space: nowrap;
}
.slot:hover .slot-badge, .slot.selected .slot-badge { opacity: 1; }

.slot.locked { cursor: default; }
.slot.locked .slot-badge { color: var(--text-faint); }

/* Text overlays */
.tbox {
  position: absolute;
  cursor: text;
  display: flex;
  align-items: center;
  line-height: 1.05;
  white-space: pre;
  overflow: visible;
}
.tbox.edited { outline: 1px dashed rgba(16, 199, 202, .45); }
.pit.show-slots .tbox { outline: 1px dashed rgba(16, 199, 202, .3); }
.tbox:hover { outline: 1px solid var(--cyan); }
.tbox.selected { outline: 1.5px solid var(--lime); }

/* --- Inspector ------------------------------------------------------------ */

.inspector {
  background: var(--panel);
  border-left: 1px solid var(--line);
  overflow-y: auto;
  padding: 14px;
  display: grid;
  gap: 16px;
  align-content: start;
}

.insp-section { display: grid; gap: 9px; }
.insp-section > .eyebrow { padding-bottom: 4px; border-bottom: 1px solid var(--line-soft); }

.kv {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  font-family: var(--font-mono);
  font-size: 11px;
}
.kv dt { color: var(--text-faint); }
.kv dd { margin: 0; color: var(--text-dim); text-align: right; }

.row { display: flex; gap: 8px; align-items: center; }
.row > * { min-width: 0; }

.range { -webkit-appearance: none; appearance: none; width: 100%; height: 3px; background: var(--line); border-radius: 2px; }
.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px; height: 13px;
  border-radius: 50%;
  background: var(--lime);
  cursor: pointer;
}
.range::-moz-range-thumb {
  width: 13px; height: 13px; border: 0; border-radius: 50%;
  background: var(--lime); cursor: pointer;
}

.slot-list { display: grid; gap: 5px; }
.slot-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid var(--line-soft);
  border-radius: 5px;
  cursor: pointer;
  font-size: 12px;
}
.slot-row:hover { background: var(--panel-2); }
.slot-row.active { border-color: var(--lime); background: #212617; }
.slot-row .sw {
  width: 22px; height: 22px;
  border-radius: 3px;
  background: var(--pit) center/cover no-repeat;
  border: 1px solid var(--line);
  flex: none;
}
.slot-row .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot-row .st { font-family: var(--font-mono); font-size: 10px; color: var(--text-faint); }
.slot-row.filled .st { color: var(--lime); }

.hint-box {
  font-size: 12px;
  color: var(--text-faint);
  line-height: 1.5;
  padding: 10px;
  border: 1px dashed var(--line);
  border-radius: 6px;
}

.toast-stack {
  position: fixed;
  right: 16px; bottom: 16px;
  display: grid;
  gap: 8px;
  z-index: 200;
}
.toast {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--lime);
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 13px;
  max-width: 340px;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
  animation: slidein .18s ease-out;
}
.toast.err { border-left-color: var(--danger); }
@keyframes slidein { from { opacity: 0; transform: translateY(6px); } }

/* --- Responsive ----------------------------------------------------------- */

@media (max-width: 1080px) {
  .editor { grid-template-columns: 120px 1fr 264px; }
  :root { --insp-w: 264px; }
}

@media (max-width: 820px) {
  .editor { grid-template-columns: 1fr; grid-template-rows: auto 1fr auto; height: auto; }
  .rail {
    grid-auto-flow: column;
    grid-auto-columns: 96px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    overflow-x: auto;
  }
  .inspector { border-left: 0; border-top: 1px solid var(--line); }
  .pit { min-height: 60vh; }
  .doc-title { max-width: 150px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
