:root {
  color-scheme: dark;
  --ink: #f3f1e9;
  --muted: #aaa99f;
  --bg: #101614;
  --panel: #17201d;
  --panel-2: #202b27;
  --line: #34413c;
  --accent: #f0b44d;
  --accent-soft: #5b4523;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); }
button, select { font: inherit; }
button { color: inherit; }
.topbar {
  height: 64px; padding: 0 max(18px, env(safe-area-inset-left)); display: flex;
  align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line);
  background: rgba(16, 22, 20, .94); position: sticky; top: 0; z-index: 20;
  backdrop-filter: blur(16px);
}
.brand { display: flex; align-items: center; gap: 11px; font-weight: 750; letter-spacing: -.02em; }
.brand-mark {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px;
  background: var(--accent); color: #251b0c; font-size: 13px; letter-spacing: -.04em;
}
.counter { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 14px; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.topbar-actions form { margin: 0; }
.logout { border: 1px solid var(--line); background: var(--panel); border-radius: 9px; padding: 7px 10px; cursor: pointer; font-size: 12px; }
main { padding: 18px; }
.toolbar {
  display: flex; align-items: end; gap: 12px; margin-bottom: 18px; flex-wrap: wrap;
}
label { color: var(--muted); font-size: 12px; display: grid; gap: 6px; }
select, .filter {
  border: 1px solid var(--line); background: var(--panel); border-radius: 10px; min-height: 40px;
  padding: 8px 12px; color: var(--ink);
}
.filters { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.filter { cursor: pointer; min-height: 40px; }
.filter.active { background: var(--accent-soft); border-color: var(--accent); color: #ffe0a1; }
.workspace {
  display: grid; grid-template-columns: minmax(260px, 370px) minmax(0, 1fr); gap: 18px;
  height: calc(100vh - 164px); min-height: 480px;
}
.photo-list {
  overflow-y: auto; border: 1px solid var(--line); border-radius: 16px; background: var(--panel);
  padding: 8px; scrollbar-color: var(--line) transparent;
}
.photo-card {
  width: 100%; display: grid; grid-template-columns: 88px 1fr; gap: 12px; align-items: center;
  border: 1px solid transparent; background: transparent; border-radius: 11px; padding: 7px;
  text-align: left; cursor: pointer; margin: 0 0 3px;
}
.photo-card:hover { background: var(--panel-2); }
.photo-card.selected { background: var(--accent-soft); }
.photo-card.primary { border-color: var(--accent); }
.photo-card img, .thumb-placeholder {
  width: 88px; height: 66px; display: grid; place-items: center; object-fit: cover; border-radius: 7px;
  background: #0b0f0e; color: var(--muted);
}
.photo-meta { min-width: 0; }
.photo-name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.photo-stars { display: block; margin-top: 8px; color: var(--accent); letter-spacing: 1px; font-size: 16px; }
.photo-stars.unrated { color: var(--muted); font-size: 12px; letter-spacing: 0; }
.viewer {
  min-width: 0; border: 1px solid var(--line); border-radius: 16px; background: var(--panel);
  overflow: hidden; display: flex; flex-direction: column;
}
.stage {
  flex: 1; min-width: 0; min-height: 0; display: grid; place-items: center;
  background: #090c0b; position: relative; overflow: hidden;
}
.stage img {
  position: absolute; inset: 0; width: 100%; height: 100%; max-width: 100%; max-height: 100%;
  object-fit: contain; object-position: center; display: block;
}
.empty-state { color: var(--muted); text-align: center; }
.empty-state span { font-size: 54px; color: var(--line); }
.viewer-info {
  display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 14px 18px;
  border-top: 1px solid var(--line);
}
.viewer-info h1 { font-size: 16px; margin: 0; overflow-wrap: anywhere; }
.viewer-info p { color: var(--muted); margin: 5px 0 0; font-size: 12px; }
.rating { display: flex; gap: 2px; flex-shrink: 0; }
.rating button {
  border: 0; background: transparent; color: #6d716c; font-size: 29px; line-height: 1; padding: 6px 3px;
  cursor: pointer; touch-action: manipulation;
}
.rating button.on { color: var(--accent); }
.rating button.reset { font-size: 18px; width: 35px; height: 35px; margin-right: 5px; border: 1px solid var(--line); border-radius: 50%; }
.rating button:disabled { opacity: .35; cursor: wait; }
.shortcuts { color: var(--muted); border-top: 1px solid var(--line); font-size: 11px; padding: 8px 18px; }
kbd { border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 1px 4px; margin: 0 1px; }
.toast {
  position: fixed; left: 50%; bottom: max(22px, env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  padding: 10px 15px; border-radius: 10px; background: #f1eee5; color: #17201d; font-size: 13px;
  opacity: 0; pointer-events: none; transition: .2s; z-index: 50; box-shadow: 0 8px 30px #0008;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #e87373; color: #250707; }
.loading { color: var(--muted); padding: 30px 15px; text-align: center; }
.login-page { background: radial-gradient(circle at 50% 0%, #26342f 0, var(--bg) 48%); }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-panel {
  width: min(100%, 420px); display: grid; gap: 24px; padding: 30px; border: 1px solid var(--line);
  border-radius: 20px; background: rgba(23, 32, 29, .96); box-shadow: 0 28px 80px #0008;
}
.login-brand { padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.eyebrow { margin: 0 0 7px; color: var(--accent); font-size: 11px; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; }
.login-panel h1 { margin: 0; font-size: 32px; letter-spacing: -.04em; }
.login-intro, .session-note { color: var(--muted); line-height: 1.5; }
.login-intro { margin: 8px 0 0; }
.session-note { margin: 0; font-size: 12px; text-align: center; }
.login-form { display: grid; gap: 8px; }
.login-form label { margin-top: 7px; color: var(--ink); font-size: 13px; font-weight: 650; }
.login-form input {
  width: 100%; min-height: 48px; padding: 10px 13px; color: var(--ink); background: #0e1512;
  border: 1px solid var(--line); border-radius: 10px; font: inherit;
}
.login-form input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.login-form button { min-height: 48px; margin-top: 12px; border: 0; border-radius: 10px; background: var(--accent); color: #251b0c; font-weight: 800; cursor: pointer; }
.login-error { padding: 11px 13px; border: 1px solid #a74646; border-radius: 10px; background: #572727; color: #ffd7d7; font-size: 13px; }

@media (max-width: 760px) {
  .topbar { height: 56px; }
  .logout { padding: 6px 8px; }
  .counter { display: none; }
  main { padding: 10px; }
  .toolbar { gap: 8px; margin-bottom: 10px; }
  .toolbar label { flex: 1; }
  .toolbar select { width: 100%; }
  .filters { width: 100%; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 2px; }
  .filter { white-space: nowrap; }
  .workspace { display: flex; flex-direction: column-reverse; height: auto; min-height: 0; gap: 10px; }
  .viewer { height: min(62vh, 560px); position: sticky; top: 62px; z-index: 10; box-shadow: 0 10px 35px #0009; }
  .stage { min-height: 250px; }
  .viewer-info { align-items: flex-start; flex-direction: column; gap: 8px; padding: 10px 12px; }
  .rating { width: 100%; justify-content: space-between; }
  .rating button { font-size: 32px; padding: 5px; }
  .shortcuts { display: none; }
  .photo-list { overflow: visible; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; padding: 6px; }
  .photo-card { display: block; margin: 0; padding: 5px; }
  .photo-card img, .thumb-placeholder { width: 100%; height: auto; aspect-ratio: 4 / 3; }
  .photo-meta { padding: 6px 2px 2px; }
  .photo-name { font-size: 11px; }
  .photo-stars { margin-top: 3px; }
  .login-shell { padding: 16px; }
  .login-panel { padding: 24px 20px; }
}
