/* Photo Desk. Three-column gallery layout in the style of PhotoShelter: a dark icon rail,
 * the library column, the photo grid, and a collapsible photo info panel.
 * Light by default; dark mode is set with data-theme="dark" on <html>. Phones stack the columns. */

:root {
  --bg: #ffffff;
  --pane: #f6f7f9;
  --panel: #ffffff;
  --soft: #f1f3f6;
  --tile: #ededf0;
  --rail: #151a22;
  --rail-text: #aab3c2;
  --rail-active: #ffffff;
  --text: #171b22;
  --muted: #6b7280;
  --line: #e3e6eb;
  --accent: #1d5fd1;
  --accent-text: #ffffff;
  --focus: #1d5fd1;
  --danger: #c2362c;
  --purple: #6f4bd8;
  --ok: #1f8a57;
  --warn: #b26a00;
  --bad: #c2362c;
  --progress: #1f5f8b;
  --selected: #1f8a57;
  --review: #b26a00;
  --rejected: #c2362c;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0c0d10;
  --pane: #111317;
  --panel: #15171c;
  --soft: #1b1e24;
  --tile: #20242b;
  --rail: #000000;
  --rail-text: #9aa3b2;
  --rail-active: #ffffff;
  --text: #eceef2;
  --muted: #9aa3b2;
  --line: #262a32;
  --accent: #3b82f6;
  --accent-text: #ffffff;
  --focus: #3b82f6;
  --ok: #4fd18b;
  --warn: #f5b041;
  --bad: #ff6b61;
  --danger: #ff6b61;
  --progress: #6ec6ff;
  --selected: #4fd18b;
  --review: #f5b041;
  --rejected: #ff6b61;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0 0 0.5rem; line-height: 1.2; font-weight: 600; }
h1 { font-size: 20px; }
h2 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 0; }
h3 { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-top: 1.1rem; }

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

button {
  padding: 0.42rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  cursor: pointer;
  font-size: 13px;
}
button:hover { border-color: var(--text); }
button:disabled { opacity: 0.45; cursor: default; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, .card:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

button.primary, .button {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
  text-decoration: none;
  display: inline-block;
  padding: 0.55rem 1.1rem;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
}
button.primary:hover, .button:hover { opacity: 0.9; }

button.danger, .danger { color: var(--danger); border-color: var(--danger); }
button.danger:hover { background: var(--danger); color: #ffffff; }

input[type="search"], select, input[name], input[type="text"], input[type="password"] {
  padding: 0.42rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  font-size: 13px;
}

.muted { color: var(--muted); }
.small { font-size: 12px; }
.spacer { flex: 1; }
.empty { color: var(--muted); padding: 4rem 0; text-align: center; }
.check { display: inline-flex; gap: 0.4rem; align-items: center; color: var(--muted); font-size: 13px; }

kbd {
  font: 11px var(--mono);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 0.3rem;
  color: var(--muted);
}

/* Icon buttons */
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 8px;
}
.icon-button svg, .rail-btn svg, .search svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-sun { display: none; }
:root[data-theme="dark"] .icon-sun { display: block; }
:root[data-theme="dark"] .icon-moon { display: none; }
.icon-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  font-size: 18px;
  line-height: 1;
  border: none;
  background: transparent;
  color: var(--muted);
}
.icon-btn:hover { color: var(--text); border-color: transparent; }

/* Layout: rail | library | content | info */
.shell {
  display: grid;
  grid-template-columns: 64px 250px minmax(0, 1fr) 300px;
  height: 100vh;
  overflow: hidden;
}
.shell.no-info { grid-template-columns: 64px 250px minmax(0, 1fr) 0; }
.shell.no-info .info-pane { display: none; }

/* Icon rail */
.rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 0.9rem 0;
  background: var(--rail);
  min-height: 0;
}
.rail-mark {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--rail-active);
  margin-bottom: 0.9rem;
}
.rail-btn {
  width: 42px;
  height: 42px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--rail-text);
}
.rail-btn:hover { background: rgba(255, 255, 255, 0.08); color: var(--rail-active); border-color: transparent; }
.rail-btn.is-active { background: rgba(255, 255, 255, 0.12); color: var(--rail-active); }
.rail-user {
  font-size: 10px;
  color: var(--rail-text);
  max-width: 56px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
  margin-bottom: 0.25rem;
}

/* Library column */
.library-pane {
  display: flex;
  flex-direction: column;
  background: var(--pane);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  min-height: 0;
}
.pane-logo { padding: 1rem 1rem 0.4rem; }
.pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.4rem 1rem 0.8rem;
}
.pane-head h1, .pane-head h2 { margin: 0; }
.pane-head h2 { text-transform: none; letter-spacing: 0; font-size: 15px; color: var(--text); }
.pane-section { padding: 0.8rem 1rem; border-top: 1px solid var(--line); }
.pane-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.5rem; }
.pane-foot { margin-top: auto; padding: 0.8rem 1rem; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; }

.live {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 11px;
  color: var(--muted);
}
.live .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.live[data-state="live"] .dot { background: var(--ok); }
.live[data-state="connecting"] .dot { background: var(--warn); }
.live[data-state="error"] { color: var(--bad); }
.live[data-state="error"] .dot { background: var(--bad); }

.brand-logo {
  display: block;
  position: relative;
  width: 170px;
  aspect-ratio: 1220 / 400;
  overflow: hidden;
  flex: 0 0 auto;
}
.brand-logo img {
  position: absolute;
  width: 122.95%;
  left: -11.475%;
  top: -95%;
  height: auto;
  max-width: none;
  mix-blend-mode: multiply;
}
:root[data-theme="dark"] .brand-logo img {
  filter: grayscale(1) invert(1);
  mix-blend-mode: screen;
}

.assignment-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.assignment-link {
  width: 100%;
  text-align: left;
  display: grid;
  gap: 0.1rem;
  border: none;
  background: transparent;
  padding: 0.45rem 0.6rem;
  border-radius: 8px;
  color: var(--text);
}
.assignment-link:hover { background: var(--soft); border-color: transparent; }
.assignment-link.is-active { background: var(--panel); box-shadow: 0 0 0 1px var(--line); font-weight: 600; }
.assignment-name { font-size: 13px; }
.assignment-link .small { font-weight: 400; color: var(--muted); }
.badges { display: flex; flex-wrap: wrap; gap: 0.25rem; }

.stack-form { display: grid; gap: 0.5rem; margin: 0 0 0.75rem; }
.stack-form[hidden] { display: none; }
.stack-form input { width: 100%; }
.form-row { display: flex; gap: 0.5rem; }

/* Top bar: search */
.content {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg);
}
.topbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1.1rem;
  border-bottom: 1px solid var(--line);
}
.search {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 0 1 420px;
  padding: 0 0.7rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--muted);
}
.search input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  padding: 0.5rem 0;
  outline: none;
}
.search:focus-within { border-color: var(--focus); }

.main {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.1rem 3rem;
  min-width: 0;
}

/* Gallery header: thumbnail, title, actions */
.gallery-head {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  flex-wrap: wrap;
  padding-bottom: 0.9rem;
}
.gallery-thumb {
  width: 64px;
  height: 64px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--tile);
  flex: 0 0 auto;
}
.gallery-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery-title h2 { font-size: 22px; font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--text); margin: 0; }
.gallery-title p { margin: 0.1rem 0 0; }

.filters-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.8rem;
  padding: 0.6rem 0;
  border-top: 1px solid var(--line);
}
.count { margin-left: auto; font-size: 12px; color: var(--muted); }

/* Selection bar */
.icon-btn-bar {
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn-bar:hover { background: var(--soft); border-color: transparent; }
.icon-btn-bar svg { width: 22px; height: 22px; fill: none; stroke: var(--text); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn-bar.danger svg { stroke: var(--danger); }
.selection-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.8rem;
  margin-bottom: 1rem;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 13px;
}
/* Keep the toolbar's space reserved so showing or hiding it never moves the photos */
.selection-bar { min-height: 48px; }
.selection-bar[hidden] { display: flex; visibility: hidden; }
#selection-count { font-weight: 600; margin-right: 0.4rem; }
#select-mode[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

/* Grid */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 28px 24px;
}
.card { display: flex; flex-direction: column; cursor: pointer; min-width: 0; user-select: none; }
/* Tile: light grey frame with the whole photo centred inside it, as in the reference */
.thumb {
  aspect-ratio: 8 / 9;
  background: var(--tile);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  padding: 14px 12px;
  border-radius: 14px;
}
/* contain: the whole photo is always visible inside the tile */
.thumb img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; display: block; }
.thumb-note { color: var(--muted); font-size: 12px; padding: 0.5rem; text-align: center; }
.card-actions { position: absolute; top: 10px; right: 10px; display: none; gap: 6px; }
.card.is-selected .card-actions,
.card:hover .card-actions,
.card:focus-within .card-actions { display: flex; }
.card-action {
  width: 30px;
  height: 30px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: rgba(17, 17, 17, 0.85);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
}
.card-action:hover { background: rgba(17, 17, 17, 1); border-color: transparent; }
.card-action svg { width: 16px; height: 16px; fill: none; stroke: #ffffff; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.card.is-selected .thumb { outline: 3px solid var(--accent); outline-offset: -3px; border-radius: 14px; }
.card.is-cursor .thumb { outline: 2px solid var(--text); outline-offset: 3px; }

.card-caption { display: flex; align-items: baseline; justify-content: space-between; gap: 0.6rem; padding-top: 0.7rem; min-width: 0; }
.card-title {
  font-size: 16px;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.card-dims { font-size: 14px; color: var(--muted); margin-top: 2px; }
.card-by { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: right; min-width: 0; }

/* Badges */
.badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.14rem 0.45rem;
  border-radius: 4px;
  background: var(--accent);
  color: var(--accent-text);
  white-space: nowrap;
}
.badge-warn { background: var(--warn); color: #ffffff; }
.badge-failed { background: var(--bad); color: #ffffff; }
.badge-uploading, .badge-progress { background: var(--progress); color: #ffffff; }
.badge-completed { background: var(--ok); color: #ffffff; }

/* Upload activity */
.uploads { border: 1px solid var(--line); padding: 0.75rem 1rem 1rem; margin-bottom: 1.1rem; background: var(--panel); border-radius: 10px; }
.uploads[hidden] { display: none; }
.uploads-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.uploads-head h2 { margin: 0.25rem 0; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 0.45rem 0.5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; }
tr.upload-failed td { background: rgba(194, 54, 44, 0.08); }

/* Photo info panel */
.info-pane {
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--line);
  background: var(--panel);
  overflow-y: auto;
  min-height: 0;
}
.info-pane .pane-head { padding-top: 1rem; }
.info-body { padding: 0 1rem 1.5rem; }
.info-body > p { padding: 0.5rem 0; }
.info-body summary { font-size: 16px; font-weight: 500; padding: 1rem 0; border-top: 1px solid var(--line); }
#gallery-info { padding-top: 0.8rem; }
#gallery-info details { border-top: none; padding: 0; }
.gi-field { display: grid; gap: 0.35rem; font-size: 13px; color: var(--muted); margin-bottom: 0.9rem; }
.gi-field input { width: 100%; font-size: 15px; color: var(--text); padding: 0.6rem 0.8rem; border-radius: 10px; }
.gi-files { color: var(--muted); font-size: 14px; margin: 0 0 1rem; }
.info-body details { border-top: 1px solid var(--line); padding: 0.7rem 0; }
.info-body summary { cursor: pointer; font-weight: 600; font-size: 13px; list-style: none; padding: 0.2rem 0; display: flex; align-items: center; gap: 0.5rem; }
.info-body summary::-webkit-details-marker { display: none; }
.info-body summary::before { content: ""; width: 0; height: 0; border-style: solid; border-width: 5px 0 5px 8px; border-color: transparent transparent transparent var(--text); transition: transform 0.15s ease; flex: 0 0 auto; }
.info-body details[open] > summary::before { transform: rotate(90deg); }
.info-body summary:hover { color: var(--accent); }
.info-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; padding-top: 0.8rem; border-top: 1px solid var(--line); }
.info-actions a.button { font-size: 13px; }

/* Shared meta lists */
.meta { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 0.35rem 0.9rem; margin: 0.5rem 0 0; font-size: 13px; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; overflow-wrap: anywhere; font-family: var(--mono); font-size: 12px; }
.nav-buttons, .actions { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.4rem 0 0.7rem; }

/* Photo dialog */
dialog {
  width: min(1120px, 96vw);
  max-height: 92vh;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.25);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.5); }
.detail-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.75rem 1.1rem; border-bottom: 1px solid var(--line); }
.detail-head h2 { margin: 0; text-transform: none; font-family: var(--mono); font-size: 13px; letter-spacing: 0.02em; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.detail-body { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(260px, 1fr); gap: 1.5rem; padding: 1.1rem; overflow: auto; max-height: calc(92vh - 58px); }
.detail-media { background: var(--tile); display: flex; align-items: center; justify-content: center; min-height: 240px; border-radius: 8px; }
.detail-media img { width: 100%; height: auto; max-height: 72vh; object-fit: contain; display: block; }
.detail-side h3:first-of-type { margin-top: 0.2rem; }

/* Admin dialog */
.admin-body { padding: 1rem 1.1rem 1.5rem; overflow: auto; max-height: calc(92vh - 58px); }
.admin-body h3 { margin-top: 1.25rem; }
.inline-form { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-bottom: 0.75rem; }
.secret-box {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin: 0.75rem 0;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--line);
  background: var(--soft);
  font-family: var(--mono);
  font-size: 13px;
  overflow-wrap: anywhere;
  border-radius: 8px;
}
.secret-box[hidden] { display: none; }
.admin-body td button { margin: 0.1rem 0; }
.error { color: var(--bad); min-height: 1.2em; margin: 0; font-size: 13px; }

/* Sign-in page */
.login-page { min-height: 100vh; display: grid; place-items: center; background: var(--pane); }
.login-card { width: min(360px, 92vw); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 2rem 1.75rem; }
.login-card .brand-logo { width: 220px; margin: 0 0 0.75rem; }
.login-card form { display: grid; gap: 0.9rem; margin-top: 1rem; }
.login-card label { display: grid; gap: 0.3rem; font-size: 12px; color: var(--muted); }
.login-card input { width: 100%; }
.login-card button.primary { width: 100%; padding: 0.6rem; }

/* Full-screen photo viewer: top bar, grey stage, info panel on the right */
dialog.viewer {
  width: 100vw;
  max-width: 100vw;
  height: 100vh;
  max-height: 100vh;
  margin: 0;
  border: none;
  border-radius: 0;
}
.viewer-top { padding: 0.6rem 1rem; }
.viewer-top h2 { font-family: inherit; font-size: 14px; letter-spacing: 0; text-transform: none; }
.viewer-top .nav-buttons { margin: 0; }
.viewer .detail-body { height: calc(100vh - 56px); max-height: none; grid-template-columns: minmax(0, 1fr) 340px; gap: 0; padding: 0; }
.viewer .detail-media { min-height: 0; border-radius: 0; background: var(--tile); padding: 1rem; }
.viewer .detail-media img { max-height: calc(100vh - 110px); }
.viewer .detail-side { overflow-y: auto; padding: 1.2rem 1.25rem; border-left: 1px solid var(--line); background: var(--panel); }
.viewer .detail-side h3 { font-size: 13px; text-transform: none; letter-spacing: 0; color: var(--text); font-weight: 600; margin-top: 1rem; }

/* Phones and small screens: columns stack; the rail becomes a top bar */
@media (max-width: 900px) {
  .shell, .shell.no-info { grid-template-columns: 1fr; height: auto; min-height: 100vh; overflow: visible; }
  .rail { flex-direction: row; justify-content: space-around; padding: 0.4rem 0.6rem; position: sticky; top: 0; z-index: 4; }
  .rail-mark { margin: 0; }
  .rail-user { display: none; }
  .library-pane { border-right: none; border-bottom: 1px solid var(--line); max-height: 40vh; }
  .content { min-height: 60vh; }
  .main { overflow: visible; }
  .info-pane, .shell.no-info .info-pane { display: none; }
  .search { flex: 1 1 auto; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 12px; }
  .detail-body, .viewer .detail-body { grid-template-columns: 1fr; height: auto; }
  .viewer .detail-side { border-left: none; }
  .gallery-title h2 { font-size: 17px; }
}

/* Selection checkbox: a black square with a check circle; a selected photo shows a blue dot with a check */
.check-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: #111111;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.check-badge svg { width: 20px; height: 20px; fill: none; stroke: #ffffff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.check-badge.is-on { top: 12px; left: 12px; width: 24px; height: 24px; border-radius: 50%; background: var(--accent); }
.check-badge.is-on svg { width: 14px; height: 14px; stroke-width: 2.6; }
