/* ═══════════════════════════════════════════════════════════
   TOKENS
═══════════════════════════════════════════════════════════ */
:root {
  --bg:           #fdf7ee;
  --surface:      #ffffff;
  --surface-warm: #fef9f3;
  --border:       #ede5d8;
  --border-dark:  #d4c8b8;
  --text:         #2c2c3e;
  --muted:        #8b8ba7;
  --dim:          #b8b8cc;
  --coral:        #f06244;
  --coral-dark:   #d94e33;
  --coral-light:  #fff0ed;
  --coral-mid:    #ffd5cc;
  --yellow:       #ffc947;
  --yellow-light: #fff8e1;
  --yellow-dark:  #e8b030;
  --sage:         #5cb8a0;
  --sage-light:   #edfaf5;
  --sky:          #5ba4cf;
  --sky-light:    #e3f2fd;
  --lavender:     #9b8ec4;
  --toolbar-h:    58px;
  font-family: 'Nunito', system-ui, sans-serif;
  font-size: 13px;
  color-scheme: light;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { background: var(--bg); color: var(--text); min-height: 100vh; overflow-x: hidden; }

/* ═══════════════════════════════════════════════════════════
   TOOLBAR
═══════════════════════════════════════════════════════════ */
.toolbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--toolbar-h);
  background: var(--surface);
  box-shadow: 0 2px 16px rgba(44,44,62,0.07);
  display: flex; align-items: center; gap: 9px; padding: 0 16px;
}

/* tilted sticker brand badge */
.brand {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: 'Nunito', sans-serif; font-size: 13px; font-weight: 900;
  letter-spacing: 0.04em;
  color: #fff;
  background: var(--coral);
  border-radius: 8px;
  padding: 5px 10px;
  flex-shrink: 0;
  user-select: none;
  transform: rotate(-1.5deg);
  box-shadow: 2px 3px 0 var(--coral-dark);
  transition: transform 0.15s, box-shadow 0.15s;
}
.brand:hover { transform: rotate(0deg) scale(1.04); box-shadow: 1px 2px 0 var(--coral-dark); }
.brand-emoji { font-style: normal; font-size: 15px; }

/* search pill */
.search-wrap {
  position: relative; flex: 1; min-width: 160px; max-width: 420px;
}
.search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--muted); pointer-events: none; width: 16px; height: 16px;
}
.query {
  width: 100%;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 99px;
  color: var(--text);
  padding: 8px 14px 8px 35px;
  font-family: 'Nunito', sans-serif;
  font-weight: 600;
  font-size: 13px;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
  outline: none;
}
.query::placeholder { color: var(--dim); font-weight: 400; }
.query:focus {
  border-color: var(--coral);
  background: var(--surface);
  box-shadow: 0 0 0 4px var(--coral-light);
}

/* year range */
.year-range { display: flex; align-items: center; gap: 5px; flex-shrink: 0; }
.year-sep   { color: var(--dim); font-size: 13px; font-weight: 700; }
.year {
  background: var(--bg); border: 2px solid var(--border);
  border-radius: 10px; color: var(--text);
  padding: 6px 8px;
  font-family: 'Nunito', sans-serif; font-weight: 600; font-size: 12px;
  cursor: pointer; outline: none; transition: border-color 0.15s;
  appearance: auto;
}
.year:focus { border-color: var(--coral); }
.year option { background: var(--surface); }

/* toggle switch */
.matched-filter {
  display: flex; align-items: center; gap: 7px; cursor: pointer;
  white-space: nowrap; color: var(--muted);
  font-size: 12.5px; font-weight: 700;
  flex-shrink: 0; user-select: none;
}
.matched-filter input[type="checkbox"] {
  appearance: none; -webkit-appearance: none;
  width: 36px; height: 20px; background: var(--border-dark);
  border-radius: 10px; cursor: pointer; position: relative;
  transition: background 0.22s; border: none; padding: 0; outline: none; flex-shrink: 0;
}
.matched-filter input[type="checkbox"]::after {
  content: ''; position: absolute; width: 14px; height: 14px;
  background: #fff; border-radius: 50%; top: 3px; left: 3px;
  transition: transform 0.22s cubic-bezier(0.34,1.56,0.64,1);
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}
.matched-filter input[type="checkbox"]:checked { background: var(--coral); }
.matched-filter input[type="checkbox"]:checked::after { transform: translateX(16px); }
.matched-filter:has(input:checked) { color: var(--coral); }

/* buttons */
input, select, button, textarea { font: inherit; }
#searchButton {
  background: var(--coral); color: #fff; border: none;
  border-radius: 99px; padding: 8px 20px;
  font-family: 'Nunito', sans-serif; font-weight: 800; font-size: 13px;
  cursor: pointer; flex-shrink: 0;
  box-shadow: 0 3px 0 var(--coral-dark);
  transition: transform 0.12s, box-shadow 0.12s, background 0.15s;
}
#searchButton:hover  { background: var(--coral-dark); }
#searchButton:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--coral-dark); }

#resetButton {
  background: transparent; color: var(--muted);
  border: 2px solid var(--border-dark); border-radius: 99px;
  padding: 7px 14px;
  font-family: 'Nunito', sans-serif; font-weight: 700; font-size: 13px;
  cursor: pointer; flex-shrink: 0;
  transition: color 0.15s, border-color 0.15s;
}
#resetButton:hover { color: var(--text); border-color: var(--muted); }

button.secondary {
  background: var(--surface); color: var(--muted);
  border: 2px solid var(--border-dark); border-radius: 99px;
  padding: 5px 14px; font-family: 'Nunito', sans-serif;
  font-weight: 700; font-size: 12px; cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
button.secondary:hover { color: var(--text); border-color: var(--muted); }

/* summary badge */
.summary { flex-shrink: 0; white-space: nowrap; }
.item-name-header {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.item-name-header > span:first-child { flex-shrink: 0; }
.item-name-header .summary { margin-left: 2px; }
.summary-inner {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--yellow-light);
  border: 1.5px solid var(--yellow);
  border-radius: 99px;
  padding: 3px 12px;
  font-family: 'Nunito', sans-serif; font-weight: 800; font-size: 12px;
  color: #7a5c00;
  letter-spacing: 0;
  text-transform: none;
}
.summary-inner.loading {
  background: var(--bg); border-color: var(--border-dark); color: var(--muted);
}

/* ═══════════════════════════════════════════════════════════
   RESULTS TABLE
═══════════════════════════════════════════════════════════ */
.results { overflow: auto; max-height: calc(100vh - var(--toolbar-h)); }
table { width: 100%; border-collapse: collapse; table-layout: fixed; }

/* column widths */
th:nth-child(1),  td:nth-child(1)  { width: 40px; }
th:nth-child(2),  td:nth-child(2)  { width: 40px; }
th:nth-child(3),  td:nth-child(3)  { width: 260px; }
th:nth-child(4),  td:nth-child(4)  { width: 100px; }
th:nth-child(5),  td:nth-child(5)  { width: 110px; }
th:nth-child(6),  td:nth-child(6)  { width: 110px; }
th:nth-child(7),  td:nth-child(7)  { width: 75px;  }
th:nth-child(8),  td:nth-child(8)  { width: 56px;  }

thead { position: sticky; top: 0; z-index: 5; }
th {
  background: var(--surface-warm);
  border-bottom: 2px solid var(--border);
  color: var(--muted);
  font-family: 'Nunito', sans-serif; font-weight: 800;
  font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase;
  padding: 9px 8px; text-align: left; cursor: pointer;
  user-select: none; white-space: nowrap;
  transition: color 0.15s;
}
th:hover { color: var(--coral); }
th[data-sort="is_matched"], th[data-sort="has_images"] { text-align: center; }
th.sort-asc  { color: var(--coral); }
th.sort-desc { color: var(--coral); }
th.sort-asc::after  { content: ' ↑'; }
th.sort-desc::after { content: ' ↓'; }
th.sort-bounce { animation: thBounce 0.2s ease; }
@keyframes thBounce {
  0%   { transform: scale(1); }
  40%  { transform: scale(0.92); }
  100% { transform: scale(1); }
}

td {
  padding: 8px 8px; border-bottom: 1px solid var(--border);
  vertical-align: middle; word-break: break-word;
  font-size: 12.5px; transition: background 0.1s;
}
td:nth-child(1), td:nth-child(2) { text-align: center; }

tbody tr.record-row { cursor: pointer; position: relative; }
tbody tr.record-row:nth-child(odd)  td { background: var(--surface); }
tbody tr.record-row:nth-child(even) td { background: var(--surface-warm); }
tbody tr.record-row:hover td { background: var(--coral-light) !important; }
tbody tr.record-row:hover td:first-child {
  box-shadow: inset 4px 0 0 var(--coral);
}

/* matched rows get subtle coral tint + left bar */
tbody tr.record-row:has(td:first-child input:checked) td {
  background: #fff7f5 !important;
}
tbody tr.record-row:has(td:first-child input:checked) td:first-child {
  box-shadow: inset 4px 0 0 var(--coral);
}
tbody tr.record-row:has(td:first-child input:checked):hover td {
  background: var(--coral-light) !important;
}

/* item name emphasis */
td:nth-child(3) { font-weight: 700; color: var(--text); font-size: 13px; }

/* year tag */
td:nth-child(8) {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11.5px; font-weight: 600;
  color: var(--lavender);
}

/* custom checkbox */
td input[type="checkbox"] {
  appearance: none; -webkit-appearance: none;
  width: 17px; height: 17px;
  border: 2.5px solid var(--border-dark); border-radius: 5px;
  background: transparent; cursor: pointer; position: relative;
  transition: border-color 0.15s, background 0.15s;
  vertical-align: middle;
}
td input[type="checkbox"]:checked {
  background: var(--coral); border-color: var(--coral);
}
td input[type="checkbox"]:checked::after {
  content: ''; position: absolute;
  left: 3px; top: 1px; width: 6px; height: 9px;
  border: 2.5px solid #fff; border-top: none; border-left: none;
  transform: rotate(45deg);
}

/* image star */
.star { color: var(--yellow-dark); font-size: 14px; line-height: 1; }

/* source-file tag chip */
.source-file {
  display: inline-block;
  background: var(--sky-light);
  border: 1.5px solid #b3d4f0;
  border-radius: 99px;
  padding: 2px 9px;
  color: #1a5fa8;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px; font-weight: 500;
  cursor: pointer; text-align: left; word-break: break-all;
  transition: background 0.15s, border-color 0.15s;
  max-width: 100%;
}
.source-file:hover { background: #d1e9fb; border-color: #82bde8; }
.source-file:disabled { cursor: default; opacity: 0.55; }
.source-file:disabled:hover { background: var(--sky-light); border-color: #b3d4f0; }

/* sticky-note textarea */
.note {
  background: var(--yellow-light);
  border: 1.5px solid #ffe082;
  border-radius: 6px;
  color: #5d4037;
  font-family: 'Nunito', sans-serif; font-size: 12px; font-weight: 600;
  min-width: 120px; min-height: 90px; resize: vertical;
  padding: 4px 7px; width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.note:focus {
  outline: none; border-color: var(--yellow-dark);
  box-shadow: 0 2px 10px rgba(255,193,7,0.25);
}
.note::placeholder { color: #c4a35a; }

/* empty state */
.empty-state {
  padding: 80px 20px; text-align: center;
  color: var(--muted);
}
.empty-state .big { font-size: 56px; display: block; margin-bottom: 12px; }
.empty-state .title { font-size: 18px; font-weight: 800; color: var(--text); margin-bottom: 6px; }
.empty-state .sub { font-size: 13px; font-weight: 600; }

/* ═══════════════════════════════════════════════════════════
   DETAIL PANEL
═══════════════════════════════════════════════════════════ */
.detail[hidden] { display: block !important; pointer-events: none; }
.detail {
  position: fixed; top: var(--toolbar-h); right: 0; bottom: 0;
  width: min(700px, 100vw);
  background: var(--surface);
  border-left: 2px solid var(--border);
  overflow-y: auto; padding: 24px 26px 40px; z-index: 40;
  transform: translateX(100%);
  transition: transform 0.4s cubic-bezier(0.34,1.4,0.64,1),
              box-shadow 0.4s ease;
  box-shadow: none;
}
.detail:not([hidden]) {
  transform: translateX(0);
  box-shadow: -16px 0 50px rgba(44,44,62,0.10);
  pointer-events: auto;
}
.detail > button.secondary { float: right; margin-left: 12px; }
.detail h2 {
  font-size: 19px; font-weight: 900; color: var(--text);
  line-height: 1.4; margin: 0 0 18px;
  padding-right: 80px;
}
.detail-note {
  display: grid;
  grid-template-columns: 80px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  clear: both;
  margin: 0 0 16px;
}
.detail-note label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  padding-top: 7px;
}
.detail-note .note {
  min-height: 72px;
}
.detail > table { table-layout: auto; width: 100%; margin-bottom: 4px; clear: both; }
.detail > table th {
  font-family: 'Nunito', sans-serif; font-size: 12px; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--muted); padding: 9px 10px;
  background: transparent; cursor: default; width: 130px;
  vertical-align: top; white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
.detail > table td {
  font-family: 'JetBrains Mono', monospace; font-size: 13px;
  color: var(--text); padding: 9px 10px; font-weight: 500;
  border-bottom: 1px solid var(--border);
}
.detail-source-file {
  display: inline;
  max-width: 100%;
  padding: 0;
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  word-break: break-all;
  cursor: pointer;
}
.detail-source-file:hover {
  color: var(--coral);
  text-decoration: underline;
}
.detail-images {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px; margin: 0 0 18px;
}
.detail-images figure { margin: 0; }
.detail img {
  width: 100%; height: auto; border-radius: 10px;
  border: 2px solid var(--border); display: block;
  transition: transform 0.2s, box-shadow 0.2s;
}
.detail img:hover { transform: scale(1.02); box-shadow: 0 8px 24px rgba(44,44,62,0.12); }

/* icon buttons and settings */
.icon-toggle {
  background: var(--surface-warm);
  border: 2px solid var(--border);
  border-radius: 99px;
  width: 36px; height: 36px;
  font-size: 16px; line-height: 1;
  cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: border-color 0.15s, background 0.15s;
  padding: 0;
}
.icon-toggle:hover { border-color: var(--coral); background: var(--coral-light); }
.settings { position: relative; flex-shrink: 0; }
.settings-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  z-index: 80;
  width: min(640px, calc(100vw - 24px));
  padding: 14px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 12px 38px rgba(44,44,62,0.14);
}
.settings-panel[hidden] { display: none; }
.settings-panel label {
  display: block;
  color: var(--text);
  font-size: 12px;
  font-weight: 900;
  margin-bottom: 8px;
}
.settings-row { display: flex; gap: 8px; }
.settings-row input {
  flex: 1;
  min-width: 0;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 7px 9px;
  outline: none;
}
.settings-row input:focus {
  border-color: var(--coral);
  box-shadow: 0 0 0 4px var(--coral-light);
}
.settings-row button {
  background: var(--coral);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 800;
  cursor: pointer;
}
.settings-panel p {
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.5;
  margin-top: 8px;
}
.settings-block + .settings-block {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.settings-heading {
  color: var(--text);
  font-size: 12px;
  font-weight: 900;
  margin-bottom: 10px;
}
.session-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.session-text {
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 700;
}
.user-create-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto auto;
  gap: 8px;
  margin-bottom: 10px;
}
.user-create-form input {
  min-width: 0;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 7px 9px;
  outline: none;
}
.user-create-form input:focus {
  border-color: var(--coral);
  box-shadow: 0 0 0 4px var(--coral-light);
}
.user-create-form button {
  background: var(--coral);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 800;
  cursor: pointer;
}
.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.panel-message {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-warm);
  color: var(--muted);
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 10px;
}
.panel-message.error {
  border-color: var(--coral-mid);
  background: var(--coral-light);
  color: var(--coral-dark);
}
.user-list,
.audit-log-list {
  display: grid;
  gap: 8px;
}
.user-row,
.audit-log-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-warm);
  padding: 10px;
}
.user-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  gap: 10px;
  align-items: center;
}
.user-main {
  min-width: 0;
}
.user-name {
  color: var(--text);
  font-size: 13px;
  font-weight: 900;
}
.user-meta {
  color: var(--muted);
  font-size: 11px;
  margin-top: 3px;
}
.panel-empty {
  border: 1px dashed var(--border-dark);
  border-radius: 8px;
  padding: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}
.audit-log-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
  margin-bottom: 4px;
}
.audit-log-text {
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.5;
}

/* login */
.login-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 20px;
}
.login-shell {
  width: min(460px, 100%);
}
.login-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: 28px 24px;
  box-shadow: 0 18px 48px rgba(44,44,62,0.12);
}
.login-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0 12px;
  border-radius: 99px;
  background: var(--coral-light);
  color: var(--coral-dark);
  font-size: 12px;
  font-weight: 900;
  margin-bottom: 14px;
}
.login-card h1 {
  font-size: 28px;
  line-height: 1.2;
  margin-bottom: 8px;
}
.login-hint {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.6;
  margin-bottom: 18px;
}
.login-form {
  display: grid;
  gap: 10px;
}
.login-form label {
  color: var(--text);
  font-size: 12px;
  font-weight: 900;
}
.login-form input {
  width: 100%;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  outline: none;
}
.login-form input:focus {
  border-color: var(--coral);
  box-shadow: 0 0 0 4px var(--coral-light);
}
.login-form button {
  margin-top: 8px;
  background: var(--coral);
  color: #fff;
  border: none;
  border-radius: 8px;
  min-height: 42px;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
}

/* ═══════════════════════════════════════════════════════════
   DARK MODE
═══════════════════════════════════════════════════════════ */
body.dark {
  --bg:           #0b0e14;
  --surface:      #13171f;
  --surface-warm: #161c28;
  --border:       #272f40;
  --border-dark:  #37425a;
  --text:         #d4dae6;
  --muted:        #5c6980;
  --dim:          #37425a;
  --coral-light:  rgba(240,98,68,0.12);
  --coral-mid:    rgba(240,98,68,0.22);
  --yellow-light: rgba(255,201,71,0.09);
  --yellow-dark:  #e8b030;
  --sky-light:    rgba(91,164,207,0.12);
}

body.dark .toolbar { box-shadow: 0 2px 20px rgba(0,0,0,0.4); }
body.dark thead th { background: oklch(11% 0.018 258); }

body.dark tbody tr.record-row:nth-child(odd)  td { background: var(--surface); }
body.dark tbody tr.record-row:nth-child(even) td { background: var(--surface-warm); }
body.dark tbody tr.record-row:hover td { background: var(--coral-light) !important; }
body.dark tbody tr.record-row:has(td:first-child input:checked) td { background: rgba(240,98,68,0.07) !important; }
body.dark tbody tr.record-row:has(td:first-child input:checked):hover td { background: var(--coral-light) !important; }

body.dark .note {
  background: rgba(255,201,71,0.07);
  border-color: rgba(255,201,71,0.18);
  color: #c4a068;
}
body.dark .note::placeholder { color: #8a6e3a; }
body.dark .source-file {
  background: rgba(91,164,207,0.1);
  border-color: rgba(91,164,207,0.22);
  color: #7bbfe0;
}
body.dark .source-file:hover { background: rgba(91,164,207,0.18); }
body.dark .source-file:disabled:hover { background: rgba(91,164,207,0.1); border-color: rgba(91,164,207,0.22); }
body.dark .settings-panel {
  box-shadow: 0 12px 38px rgba(0,0,0,0.38);
}
body.dark .login-card {
  box-shadow: 0 18px 48px rgba(0,0,0,0.45);
}
body.dark .summary-inner {
  background: rgba(255,201,71,0.08);
  border-color: rgba(255,201,71,0.2);
  color: #c4a068;
}
body.dark .summary-inner.loading { background: var(--surface); border-color: var(--border); color: var(--muted); }
body.dark .detail { border-left-color: var(--border); box-shadow: none; }
body.dark .detail:not([hidden]) { box-shadow: -16px 0 50px rgba(0,0,0,0.5); }
body.dark .empty-state .title { color: var(--text); }

/* ═══════════════════════════════════════════════════════════
   SCROLLBAR
═══════════════════════════════════════════════════════════ */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-dark); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ═══════════════════════════════════════════════════════════
   TABLET
═══════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
  th:nth-child(5),  td:nth-child(5),
  th:nth-child(7),  td:nth-child(7) { display: none; }
}

/* ═══════════════════════════════════════════════════════════
   MOBILE
═══════════════════════════════════════════════════════════ */
@media (max-width: 600px) {
  :root { --toolbar-h: auto; }
  .toolbar {
    flex-wrap: wrap; height: auto;
    padding: 10px 12px; gap: 8px; row-gap: 8px;
  }
  #resetButton    { order: 1; }
  .search-wrap    { order: 1; flex: 1 1 0; min-width: 0; max-width: none; }
  .year-range     { order: 3; flex: 1 0 100%; }
  .matched-filter { order: 4; }
  .settings       { order: 5; }
  .theme-toggle   { order: 6; }
  .settings-panel { width: min(100vw - 24px, 640px); }
  .session-row,
  .user-row,
  .user-create-form { grid-template-columns: 1fr; }
  .session-row { align-items: stretch; }

  th:nth-child(4),  td:nth-child(4),
  th:nth-child(5),  td:nth-child(5),
  th:nth-child(6),  td:nth-child(6),
  th:nth-child(7),  td:nth-child(7) { display: none; }

  th:nth-child(3), td:nth-child(3) { width: auto; }
  th:nth-child(8), td:nth-child(8) { width: 52px; }
  .item-name-header { gap: 6px; }
  .summary-inner { padding: 2px 7px; font-size: 11px; }

  td { padding: 13px 8px; font-size: 14px; }
  td input[type="checkbox"] { width: 22px; height: 22px; }
  td input[type="checkbox"]:checked::after { left: 4px; top: 2px; width: 8px; height: 11px; }
  .star { font-size: 17px; }
  .results { max-height: none; overflow-x: auto; }

  .detail[hidden] { display: block !important; pointer-events: none; }
  .detail {
    top: 0 !important; right: 0; left: 0; bottom: 0;
    width: 100vw !important; border-left: none;
    border-top: 2px solid var(--border);
    border-radius: 18px 18px 0 0;
    padding: 8px 16px 40px;
    transform: translateY(100%) !important;
    transition: transform 0.4s cubic-bezier(0.34,1.2,0.64,1),
                box-shadow 0.4s ease !important;
  }
  .detail:not([hidden]) {
    transform: translateY(0) !important;
    box-shadow: 0 -12px 50px rgba(44,44,62,0.12) !important;
  }
  .detail::before {
    content: ''; display: block; width: 40px; height: 4px;
    background: var(--border-dark); border-radius: 2px; margin: 0 auto 16px;
  }
  .detail h2 { font-size: 16px; padding-right: 0; }
  .detail-note { grid-template-columns: 1fr; }
  .detail > table th { width: 90px; }
  .detail-images { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}
