/* ---------------------------------------------------------------------------
   Rayne portfolio — admin interface
   --------------------------------------------------------------------------- */

:root {
  --bg:        #f4f5f7;
  --panel:     #ffffff;
  --ink:       #1c2024;
  --ink-soft:  #5b636c;
  --ink-faint: #8b939c;
  --rule:      #e2e5ea;
  --accent:    #2f6f4f;
  --accent-dk: #255a40;
  --danger:    #b2372c;
  --danger-bg: #fdf1ef;
  --ok:        #1f6b45;
  --ok-bg:     #eef7f1;
  --warn-bg:   #fdf3e7;
  --radius:    10px;
  --shadow:    0 1px 2px rgba(20, 25, 30, .05), 0 4px 14px rgba(20, 25, 30, .06);
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

/* The hidden attribute must beat any display rule a class sets
   (a .btn is display:inline-flex, which otherwise wins over [hidden]). */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }
a { color: var(--accent); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

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

/* -- Top bar -------------------------------------------------------------- */

.topbar {
  background: var(--panel);
  border-bottom: 1px solid var(--rule);
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-inner {
  max-width: 1400px;
  margin-inline: auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  gap: 2rem;
  min-height: 60px;
  flex-wrap: wrap;
}

.logo { font-weight: 600; text-decoration: none; color: var(--ink); letter-spacing: -.01em; }
.logo span { color: var(--ink-faint); font-weight: 400; }

.topnav { display: flex; gap: .35rem; margin-right: auto; flex-wrap: wrap; }
.topnav a {
  text-decoration: none;
  color: var(--ink-soft);
  padding: .4rem .8rem;
  border-radius: 7px;
  font-size: .92rem;
}
.topnav a:hover { background: var(--bg); color: var(--ink); }
.topnav a.is-active { background: var(--ink); color: #fff; }

.topbar-right { display: flex; gap: 1.1rem; font-size: .88rem; align-items: center; }
.view-site { text-decoration: none; }
.logout { color: var(--ink-faint); text-decoration: none; }
.logout:hover { color: var(--danger); }

/* -- Page shell ----------------------------------------------------------- */

.page { max-width: 1400px; margin-inline: auto; padding: 1.75rem 1.5rem 5rem; }

.page-title {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -.02em;
  margin: 0 0 1.25rem;
}

.cols { display: grid; grid-template-columns: minmax(0, 22rem) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.cols-wide { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
@media (max-width: 900px) { .cols, .cols-wide { grid-template-columns: 1fr; } }

.card {
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1.4rem;
  box-shadow: var(--shadow);
}

.card h2 {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--ink-faint);
  margin: 0 0 1rem;
  display: flex;
  align-items: center;
  gap: .6rem;
}
.card h2.mt { margin-top: 2rem; }

.muted { color: var(--ink-faint); }
.muted.pad { padding: 2rem 0; }
.optional { color: var(--ink-faint); font-weight: 400; text-transform: none; letter-spacing: 0; font-size: .85em; }
.hint { color: var(--ink-faint); font-size: .84rem; margin: -.2rem 0 0; }

/* -- Flash messages ------------------------------------------------------- */

.flash {
  padding: .8rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: .92rem;
  border: 1px solid transparent;
}
.flash-success { background: var(--ok-bg);     color: var(--ok);     border-color: #cde6d8; }
.flash-error   { background: var(--danger-bg); color: var(--danger); border-color: #f3d3ce; }
.flash a { color: inherit; }
.flash code {
  background: rgba(0, 0, 0, .06);
  padding: .1em .35em;
  border-radius: 4px;
  font-size: .92em;
}

/* -- Forms ---------------------------------------------------------------- */

.stack { display: flex; flex-direction: column; gap: .45rem; }
.stack > label:not(:first-child),
.edit-grid > label:not(:first-child) { margin-top: .6rem; }

label { font-size: .86rem; font-weight: 500; color: var(--ink-soft); }

input[type="text"], input[type="email"], input[type="password"], textarea, select {
  font: inherit;
  width: 100%;
  padding: .55rem .7rem;
  border: 1px solid var(--rule);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px rgba(47, 111, 79, .13); }
textarea { resize: vertical; }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
@media (max-width: 560px) { .field-row { grid-template-columns: 1fr; } }

.color-input { padding: .2rem; height: 2.5rem; cursor: pointer; }

.checkbox { display: flex; align-items: center; gap: .5rem; font-weight: 400; color: var(--ink); }
.checkbox input { width: auto; }

.hidden-form { display: none; }

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

.btn {
  font: inherit;
  font-size: .9rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .55rem 1rem;
  border: 1px solid var(--rule);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  transition: background-color .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--bg); border-color: var(--ink-faint); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; align-self: flex-start; }
.btn-primary:hover { background: var(--accent-dk); border-color: var(--accent-dk); color: #fff; }

.btn-danger { color: var(--danger); border-color: #f0cec9; background: #fff; }
.btn-danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }

.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-soft); }
.btn-small { padding: .35rem .7rem; font-size: .84rem; }
.btn-block { width: 100%; align-self: stretch; }

.badge {
  display: inline-flex;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--rule);
  color: var(--ink-soft);
  border-radius: 999px;
  padding: .1rem .6rem;
  font-size: .76rem;
  white-space: nowrap;
  text-transform: none;
  letter-spacing: 0;
}
.badge-quiet { color: var(--ink-faint); background: transparent; }

/* -- Auth screens --------------------------------------------------------- */

.auth-body { display: grid; place-items: center; min-height: 100vh; padding: 1.5rem; }

.auth-card {
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 14px;
  padding: 2.25rem;
  width: min(100%, 27rem);
  box-shadow: 0 2px 6px rgba(20, 25, 30, .05), 0 20px 50px rgba(20, 25, 30, .1);
}
.auth-card h1 { margin: 0 0 .35rem; font-size: 1.4rem; letter-spacing: -.02em; }
.auth-card .lede { margin: 0 0 1.5rem; color: var(--ink-soft); font-size: .93rem; }
.auth-card form { display: flex; flex-direction: column; gap: .45rem; }
.auth-card label:not(:first-of-type) { margin-top: .6rem; }
.auth-card .btn { margin-top: 1.1rem; }
.auth-back { margin: 1.5rem 0 0; font-size: .86rem; text-align: center; }
.auth-back a { color: var(--ink-faint); text-decoration: none; }

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

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.stat {
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: .15rem;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
}
a.stat:hover { border-color: var(--accent); }
.stat-n { font-size: 1.85rem; font-weight: 600; letter-spacing: -.03em; line-height: 1.1; }
.stat-l { color: var(--ink-faint); font-size: .84rem; }

.recent-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(7rem, 1fr)); gap: .8rem; }
.recent-item { text-decoration: none; color: var(--ink-soft); font-size: .78rem; }
.recent-item img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 7px;
  border: 1px solid var(--rule);
  margin-bottom: .35rem;
}
.recent-item span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.todo { margin: 0; padding-left: 1.1rem; color: var(--ink-soft); font-size: .92rem; }
.todo li { margin-bottom: .4rem; }
.todo .done { list-style: none; margin-left: -1.1rem; color: var(--ok); }

.quick { display: flex; gap: .6rem; flex-wrap: wrap; }
.quick .btn-primary { align-self: auto; }

.empty-panel {
  background: var(--panel);
  border: 1px dashed var(--rule);
  border-radius: var(--radius);
  padding: 4rem 2rem;
  text-align: center;
}
.empty-panel h2 { margin: 0 0 .4rem; font-size: 1.15rem; }
.empty-panel p { color: var(--ink-faint); margin: 0 0 1.25rem; }
.empty-panel .btn-primary { align-self: center; }

/* -- Categories ----------------------------------------------------------- */

.cat-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }

.cat-item {
  border: 1px solid var(--rule);
  border-radius: 9px;
  background: #fff;
}
.cat-item.is-dragging { opacity: .45; }
.cat-item.drop-target { border-color: var(--accent); }

.cat-row { display: flex; align-items: center; gap: .8rem; padding: .7rem .85rem; }

.drag-handle {
  cursor: grab;
  color: var(--ink-faint);
  letter-spacing: -3px;
  font-size: 1rem;
  user-select: none;
}
.drag-handle:active { cursor: grabbing; }

.cat-main { display: flex; flex-direction: column; min-width: 0; margin-right: auto; }
.cat-main strong { font-weight: 600; }
.cat-slug { font-size: .76rem; color: var(--ink-faint); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.cat-desc { font-size: .84rem; color: var(--ink-soft); }

.cat-edit { border-top: 1px solid var(--rule); padding: .9rem .85rem; background: #fbfcfd; border-radius: 0 0 9px 9px; }
.edit-grid { display: flex; flex-direction: column; gap: .4rem; }

.edit-actions {
  display: flex;
  align-items: center;
  gap: .6rem;
  flex-wrap: wrap;
  margin-top: .9rem;
  padding-top: .8rem;
  border-top: 1px dashed var(--rule);
}
.edit-actions .btn-primary { align-self: auto; }
.edit-actions .btn-danger { margin-left: auto; }
.move-label { font-size: .8rem; color: var(--ink-faint); }
.edit-actions select { width: auto; font-size: .84rem; padding: .3rem .5rem; }

/* -- Upload --------------------------------------------------------------- */

.dropzone {
  position: relative;
  border: 2px dashed var(--rule);
  border-radius: var(--radius);
  padding: 2.5rem 1.5rem;
  text-align: center;
  background: #fbfcfd;
  transition: border-color .18s, background-color .18s;
}
.dropzone.is-over { border-color: var(--accent); background: var(--ok-bg); }
.dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}
.dropzone-hint { display: flex; flex-direction: column; gap: .3rem; pointer-events: none; }
.dropzone-hint strong { font-size: 1.02rem; }
.dropzone-hint span { color: var(--ink-faint); font-size: .86rem; }

.file-list { list-style: none; margin: .4rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .3rem; }
.file-list li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: .85rem;
  padding: .4rem .6rem;
  background: var(--bg);
  border-radius: 6px;
}
.file-list .file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-list .file-size { color: var(--ink-faint); white-space: nowrap; }
.file-list .too-big { color: var(--danger); }

.result-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .6rem; }
.result { display: flex; gap: .8rem; align-items: center; padding: .6rem; border-radius: 8px; border: 1px solid var(--rule); }
.result-ok  { background: var(--ok-bg);     border-color: #cde6d8; }
.result-bad { background: var(--danger-bg); border-color: #f3d3ce; }
.result-thumb { width: 52px; height: 52px; object-fit: cover; border-radius: 5px; flex: none; }
.result-icon {
  width: 52px; height: 52px; flex: none; display: grid; place-items: center;
  border-radius: 5px; background: #fff; color: var(--danger); font-weight: 700; font-size: 1.3rem;
}
.result-text { display: flex; flex-direction: column; min-width: 0; }
.result-text strong { font-size: .9rem; overflow: hidden; text-overflow: ellipsis; }
.result-text span { font-size: .82rem; color: var(--ink-soft); }
.result-list + .btn { margin-top: 1rem; }

/* -- Artwork grid --------------------------------------------------------- */

.toolbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.1rem;
}
.chips { display: flex; gap: .4rem; flex-wrap: wrap; margin-right: auto; }
.chip {
  text-decoration: none;
  color: var(--ink-soft);
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: .3rem .85rem;
  font-size: .86rem;
  display: inline-flex;
  gap: .4rem;
  align-items: center;
}
.chip span { color: var(--ink-faint); font-size: .76rem; font-variant-numeric: tabular-nums; }
.chip:hover { border-color: var(--ink-faint); color: var(--ink); }
.chip.is-active { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip.is-active span { color: rgba(255, 255, 255, .65); }

.bulk-bar {
  position: sticky;
  top: 60px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: .7rem;
  flex-wrap: wrap;
  background: var(--ink);
  color: #fff;
  padding: .6rem .9rem;
  border-radius: 9px;
  margin-bottom: 1rem;
}
.bulk-bar[hidden] { display: none; }
.bulk-count { font-size: .88rem; margin-right: auto; }
.bulk-bar select { width: auto; font-size: .86rem; padding: .3rem .5rem; }
.bulk-bar .btn-ghost { color: rgba(255, 255, 255, .75); }
.bulk-bar .btn-ghost:hover { background: rgba(255, 255, 255, .12); color: #fff; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
  gap: 1rem;
  align-items: start;
}

.art-card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.art-card.is-selected { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(47, 111, 79, .22); }

.art-select { position: absolute; top: .6rem; left: .6rem; z-index: 2; }
.art-select input {
  width: 1.15rem;
  height: 1.15rem;
  cursor: pointer;
  accent-color: var(--accent);
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .35));
}

.ribbon {
  position: absolute;
  top: .6rem;
  right: .6rem;
  z-index: 2;
  background: var(--ink);
  color: #fff;
  font-size: .68rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: .18rem .5rem;
  border-radius: 4px;
}

.art-thumb { display: block; background: var(--bg); }
.art-thumb img { width: 100%; height: 190px; object-fit: contain; }

.art-body { padding: .8rem .9rem 1rem; display: flex; flex-direction: column; gap: .3rem; align-items: flex-start; }
.art-body h3 {
  margin: 0;
  font-size: .96rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.art-meta { margin: 0 0 .35rem; font-size: .79rem; color: var(--ink-faint); }

.art-edit { border-top: 1px solid var(--rule); padding: .9rem; background: #fbfcfd; }
.art-edit .btn-primary { align-self: auto; }

/* -- Server info list ----------------------------------------------------- */

.server-info { display: grid; grid-template-columns: auto 1fr; gap: .3rem 1rem; margin: 0; font-size: .87rem; }
.server-info dt { color: var(--ink-faint); }
.server-info dd { margin: 0; }

/* -- Artist portrait ------------------------------------------------------ */

.portrait-manager { display: flex; gap: 1.1rem; align-items: flex-start; }

.portrait-preview {
  width: 8.5rem;
  flex: none;
  border-radius: 9px;
  border: 1px solid var(--rule);
  background: var(--bg);
}

.portrait-empty {
  aspect-ratio: 4 / 5;
  display: grid;
  place-items: center;
  border-style: dashed;
  color: var(--ink-faint);
  font-size: .8rem;
}

.portrait-controls { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .8rem; }
.portrait-remove { margin-top: .2rem; }
.mt-hint { margin-top: 1.1rem; }

input[type="file"] {
  font: inherit;
  font-size: .86rem;
  width: 100%;
  padding: .45rem;
  border: 1px solid var(--rule);
  border-radius: 7px;
  background: #fff;
  cursor: pointer;
}
input[type="file"]::file-selector-button {
  font: inherit;
  font-size: .84rem;
  margin-right: .7rem;
  padding: .3rem .7rem;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--bg);
  color: var(--ink);
  cursor: pointer;
}
input[type="file"]::file-selector-button:hover { border-color: var(--ink-faint); }

@media (max-width: 560px) {
  .portrait-manager { flex-direction: column; }
  .portrait-preview { width: 10rem; }
}

/* Sub-heading inside a card's form, for grouping related fields. */
.subhead {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--ink-faint);
  margin: 1.6rem 0 .2rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--rule);
}
