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

:root {
  --bg: #111317;
  --panel: #1b2027;
  --panel-soft: #232a33;
  --line: rgba(214, 222, 232, 0.14);
  --text: #eef2f7;
  --muted: #9da9b8;
  --accent: #e6b450;
  --accent-2: #5fb7b2;
  --danger: #e86868;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
}

body {
  min-height: 100vh;
  font-family: "Segoe UI", system-ui, sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #101215 0%, #151a20 45%, #101215 100%);
}

.gallery-backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.gallery-backdrop-layer,
.gallery-backdrop-shade {
  position: absolute;
  inset: 0;
}

.gallery-backdrop-layer {
  inset: -24px;
  background-position: center 28%;
  background-repeat: no-repeat;
  background-size: cover;
  filter: blur(7px) brightness(1.1) saturate(0.9) contrast(0.96);
  opacity: 0;
  transform: scale(1.045);
  transition: opacity 1.1s ease;
}

.gallery-backdrop-layer.is-visible {
  opacity: 1;
}

.gallery-backdrop-shade {
  background:
    radial-gradient(circle at 50% 24%, rgba(14, 17, 21, 0.18), rgba(12, 15, 19, 0.56) 72%),
    linear-gradient(180deg, rgba(12, 14, 18, 0.34), rgba(12, 15, 19, 0.64));
}

body.lightbox-scroll-locked {
  position: fixed;
  left: 0;
  right: 0;
  width: 100%;
  overflow: hidden;
}

html {
  scrollbar-width: thin;
  scrollbar-color: rgba(230, 180, 80, 0.75) rgba(18, 22, 28, 0.86);
}

* {
  scrollbar-width: thin;
  scrollbar-color: rgba(230, 180, 80, 0.75) rgba(18, 22, 28, 0.86);
}

*::-webkit-scrollbar {
  width: 11px;
  height: 11px;
}

*::-webkit-scrollbar-track {
  background: rgba(18, 22, 28, 0.86);
  border-radius: 8px;
}

*::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(230, 180, 80, 0.92), rgba(95, 183, 178, 0.82));
  border: 2px solid rgba(18, 22, 28, 0.86);
  border-radius: 8px;
}

*::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #f0c669, #6fcac5);
}

*::-webkit-scrollbar-corner {
  background: rgba(18, 22, 28, 0.86);
}

button, input {
  font: inherit;
}

button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #252c36;
  color: var(--text);
  cursor: pointer;
}

a.link-btn {
  min-height: 36px;
  display: inline-grid;
  place-items: center;
  padding: 0 0.8rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #252c36;
  color: var(--text);
  text-decoration: none;
}

a.link-btn:hover {
  border-color: rgba(230, 180, 80, 0.58);
  background: #313946;
}

a.link-btn.is-active {
  border-color: rgba(230, 180, 80, 0.58);
  background: #313946;
}

.topbar-actions button,
.topbar-actions .link-btn,
.view-actions button,
.view-actions .link-btn {
  min-height: 32px;
  padding: 0 0.65rem;
  font-size: 0.88rem;
}

#model-seen-btn {
  width: 10rem;
  min-width: 10rem;
  box-sizing: border-box;
}

.selected-gallery-actions .gallery-seen-btn {
  width: 7.6rem;
  min-width: 7.6rem;
  box-sizing: border-box;
}

#model-seen-btn.is-seen-action,
.selected-gallery-actions .gallery-seen-btn.is-seen-action {
  border-color: rgba(95, 183, 178, 0.5);
  background: rgba(23, 78, 75, 0.9);
  color: #e7fffc;
}

#model-seen-btn.is-seen-action:hover:not(:disabled),
#model-seen-btn.is-seen-action.is-active,
.selected-gallery-actions .gallery-seen-btn.is-seen-action:hover:not(:disabled),
.selected-gallery-actions .gallery-seen-btn.is-seen-action.is-active {
  border-color: rgba(95, 183, 178, 0.72);
  background: rgba(31, 98, 94, 0.96);
}

#model-seen-btn.is-seen-action:disabled,
.selected-gallery-actions .gallery-seen-btn.is-seen-action:disabled {
  border-color: rgba(95, 183, 178, 0.18);
  background: rgba(23, 78, 75, 0.34);
  color: rgba(231, 255, 252, 0.48);
}

button:hover,
button.is-active {
  border-color: rgba(230, 180, 80, 0.58);
  background: #313946;
}

button.has-errors,
button.has-errors:hover {
  border-color: rgba(232, 104, 104, 0.62);
  background: rgba(120, 34, 34, 0.86);
  color: #ffd4d4;
}

button:disabled {
  border-color: rgba(214, 222, 232, 0.08);
  background: rgba(37, 44, 54, 0.42);
  color: rgba(157, 169, 184, 0.48);
  cursor: not-allowed;
  opacity: 0.72;
}

button:disabled:hover {
  border-color: rgba(214, 222, 232, 0.08);
  background: rgba(37, 44, 54, 0.42);
}

input {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #12161c;
  color: var(--text);
  padding: 0 0.75rem;
  outline: none;
}

input:focus {
  border-color: rgba(95, 183, 178, 0.65);
}

input:disabled {
  border-color: rgba(214, 222, 232, 0.08);
  background: rgba(18, 22, 28, 0.55);
  color: rgba(157, 169, 184, 0.55);
  cursor: not-allowed;
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1680px, calc(100vw - 28px));
  margin: 14px auto;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  min-height: 86px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(27, 32, 39, 0.92);
  box-shadow: var(--shadow);
}

.topbar > div:first-child {
  padding: 0.7rem 0 0.7rem 0.9rem;
  display: flex;
  align-items: center;
}

.topbar > .topbar-actions {
  padding: 0 0.9rem 0 0;
}

.topbar h1 {
  margin-top: 0.15rem;
  font-size: clamp(1.2rem, 2vw, 2rem);
  line-height: 1;
  font-weight: 750;
}

.app-title-link {
  color: inherit;
  text-decoration: none;
}

.app-version-stack {
  display: inline-grid;
  gap: 0.08rem;
  margin-left: 0.35rem;
  vertical-align: middle;
}

.app-tagline {
  color: var(--accent-2);
  font-size: 0.38em;
  font-weight: 500;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
}

.app-version-label {
  color: var(--accent);
  font-size: 0.36em;
  font-weight: 400;
  white-space: nowrap;
  line-height: 1;
}

.eyebrow {
  color: var(--accent);
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.topbar-actions {
  display: grid;
  grid-template-columns: auto auto auto;
  column-gap: 0.75rem;
  align-items: center;
  justify-content: end;
  min-width: 0;
}

.stats-stack {
  display: grid;
  grid-column: 3;
  grid-template-rows: repeat(2, 28px);
  gap: 0.12rem;
  flex: 0 0 auto;
}

.stats-row {
  display: grid;
  grid-template-columns: 3.2rem auto;
  align-items: center;
  gap: 0.4rem;
  width: auto;
}

.stats-card {
  min-height: 28px;
  display: grid;
  align-items: center;
  padding: 0 0.6rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(18, 22, 28, 0.82);
  white-space: nowrap;
}

.stats-label,
.user-stats,
#stats {
  font-size: 0.86rem;
  line-height: 1.15;
}

.stats-breakdown {
  display: grid;
  grid-template-columns: 11ch 14ch 14ch;
  column-gap: 0.42rem;
  align-items: baseline;
  font-variant-numeric: tabular-nums;
}

.stats-breakdown .stat-part {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  column-gap: 0.28rem;
  align-items: baseline;
}

.stats-breakdown .stat-num {
  text-align: right;
}

.stats-breakdown .stat-word {
  text-align: left;
}

.stats-label {
  color: var(--text);
  text-align: right;
}

#stats {
  color: var(--muted);
}

.user-stats {
  color: var(--accent-2);
}

.auth-box {
  display: contents;
  min-width: 0;
}

.auth-box input {
  width: 118px;
  height: 28px;
  min-height: 0;
  padding: 0 0.55rem;
  font-size: 0.82rem;
  box-sizing: border-box;
}

.auth-box button {
  height: 28px;
  min-height: 0;
  padding: 0 0.5rem;
  font-size: 0.82rem;
  line-height: 1;
  box-sizing: border-box;
}

.auth-box span {
  color: var(--muted);
  font-size: 0.9rem;
}

.auth-profile {
  display: contents;
  min-width: 0;
}

.auth-profile-head {
  display: grid;
  grid-column: 2;
  grid-template-rows: repeat(2, 28px);
  align-items: center;
  gap: 0.12rem;
  flex-wrap: nowrap;
  justify-content: end;
}

.auth-profile-head > *,
.auth-profile-settings > * {
  height: 28px;
}

.auth-identity,
.auth-profile-actions {
  display: grid;
  min-width: 0;
}

.auth-identity {
  grid-template-columns: 22px minmax(0, 1fr);
  align-items: center;
  gap: 0.35rem;
  width: 118px;
}

.auth-profile-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.35rem;
  width: 118px;
}

.header-avatar,
.profile-avatar {
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--accent);
  background: #252c36;
  font-weight: 700;
}

.header-avatar {
  width: 22px;
  height: 22px;
  font-size: 0.72rem;
}

.header-avatar img,
.profile-avatar img,
.profile-avatar-content img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.auth-credential-row,
.auth-button-row {
  display: grid;
  grid-template-columns: 118px 118px;
  align-items: center;
  gap: 0.35rem;
  justify-content: end;
}

.auth-credential-row > *,
.auth-button-row > * {
  width: 100%;
}

.auth-validation-message {
  grid-column: 1 / -1;
  color: #ff927d;
  font-size: 0.76rem;
  line-height: 1.15;
  max-width: 240px;
  text-align: right;
}

.registration-dialog,
.profile-dialog {
  position: fixed;
  inset: 0;
  width: min(24rem, calc(100vw - 2rem));
  max-height: calc(100dvh - 2rem);
  margin: auto;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #171c23;
  box-shadow: 0 1.25rem 4rem rgba(0, 0, 0, 0.55);
  overflow: auto;
}

.registration-dialog::backdrop,
.profile-dialog::backdrop {
  background: rgba(7, 9, 12, 0.72);
}

.registration-dialog form,
.profile-dialog form {
  display: grid;
  gap: 0.6rem;
  padding: 1rem;
}

.registration-dialog h2,
.profile-dialog h2 {
  margin: 0 0 0.15rem;
  font-size: 1.08rem;
}

.registration-dialog input,
.profile-dialog input {
  width: 100%;
  min-height: 34px;
  padding: 0 0.6rem;
  box-sizing: border-box;
}

.registration-dialog-error,
.profile-dialog-error {
  margin: 0;
  color: #ff927d;
  font-size: 0.82rem;
}

.registration-dialog-actions,
.profile-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.45rem;
  margin-top: 0.2rem;
}

.profile-avatar-editor {
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr);
  align-items: center;
  gap: 0.8rem;
  padding: 0.2rem 0;
}

.profile-avatar-large {
  width: 68px;
  height: 68px;
  font-size: 1.35rem;
}

.profile-avatar-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.auth-username {
  display: grid;
  align-items: center;
  justify-items: center;
  min-width: 118px;
  min-height: 0;
  line-height: 1;
}

.auth-profile-settings {
  display: grid;
  grid-column: 1;
  grid-template-rows: repeat(2, 28px);
  align-items: center;
  gap: 0.12rem;
  flex-wrap: nowrap;
  justify-content: end;
}

.auth-setting {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1;
  white-space: nowrap;
}

.auth-setting input {
  width: 14px;
  height: 14px;
  min-height: 0;
  flex: 0 0 auto;
  margin: 0;
  accent-color: var(--accent);
}

[hidden] {
  display: none !important;
}

.layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 14px;
  margin-top: 14px;
  align-items: start;
}
