:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #667085;
  --line: #d9e0ea;
  --accent: #f7814a;
  --accent-2: #0f766e;
  --field-bg: #e0e0e0;
  --field-border: #f7814a;
  --field-focus-bg: #ffffff;
  --field-focus-border: #7a7a7a;
  --nav-active-bg: #334155;
  --nav-active-text: #ffffff;
  --danger: #b42318;
  --shadow: 0 12px 30px rgba(23, 32, 51, .08);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111827;
  --panel: #1f2937;
  --text: #f9fafb;
  --muted: #cbd5e1;
  --line: #374151;
  --accent: #f7814a;
  --accent-2: #2dd4bf;
  --field-bg: #334155;
  --field-border: #f7814a;
  --field-focus-bg: #1f2937;
  --field-focus-border: #94a3b8;
  --nav-active-bg: #334155;
  --nav-active-text: #ffffff;
  --danger: #f87171;
  --shadow: 0 12px 30px rgba(0, 0, 0, .32);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.45;
}

a { color: var(--accent); text-decoration: none; }
.brand-nemo { color: #7a7a7a; }
.brand-openview { color: #f7814a; }
.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: .28em;
  max-width: 100%;
  line-height: 1;
  white-space: nowrap;
  vertical-align: middle;
}
.brand-logo {
  display: block;
  width: 1.22em;
  height: 1.22em;
  flex: 0 0 1.22em;
  object-fit: contain;
}
.brand-title { font-size: 20px; }
button, input, select, textarea {
  font: inherit;
}

input[type="checkbox"] {
  appearance: none;
  width: 18px;
  min-width: 18px;
  height: 18px;
  min-height: 18px;
  padding: 0;
  border: 2px solid var(--field-border);
  border-radius: 4px;
  background: #2b2a33;
  box-shadow: 0 0 0 1px rgba(0,0,0,.35);
  display: inline-grid;
  place-items: center;
}
input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}
input[type="checkbox"]:checked::after {
  content: "✓";
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
}

button {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  padding: 8px 14px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

button:hover {
  background: #334155;
  filter: none;
}
button.danger { background: var(--danger); }
.button-link {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  border-radius: 6px;
  padding: 8px 14px;
  background: var(--accent);
  color: #fff;
}
.button-link.secondary { background: var(--muted); }
.button-link:not(.secondary):hover,
.file-button:hover {
  background: #334155;
  filter: none;
}
.link-button {
  min-height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  text-decoration: underline;
}
.link-button:hover {
  background: transparent;
  filter: none;
}

input, select, textarea {
  min-height: 40px;
  width: 100%;
  border: 1px solid var(--field-border);
  border-radius: 6px;
  padding: 8px 10px;
  background: var(--field-bg);
  color: var(--text);
  transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease;
}
input[type="password"]::placeholder {
  color: #aab2c0;
  opacity: 1;
}
input[data-password-set]::placeholder {
  color: var(--text);
  opacity: 1;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: 1px;
}

input:focus,
select:focus,
textarea:focus {
  background: var(--field-focus-bg);
  border-color: var(--field-focus-border);
  outline: 2px solid rgba(122, 122, 122, .42);
  outline: 2px solid color-mix(in srgb, var(--field-focus-border) 42%, transparent);
  outline-offset: 1px;
}

input:-webkit-autofill,
input:-webkit-autofill:hover {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 1000px var(--field-bg) inset;
  border-color: var(--field-border);
  caret-color: var(--text);
}

input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 1000px var(--field-focus-bg) inset;
  border-color: var(--field-focus-border);
}

input:autofill {
  background: var(--field-bg);
  border-color: var(--field-border);
}

input:autofill:focus {
  background: var(--field-focus-bg);
  border-color: var(--field-focus-border);
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: .92rem;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  position: relative;
  width: min(460px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 26px;
}
.auth-close {
  position: absolute;
  top: 12px;
  right: 12px;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: var(--text);
  font-size: 1.5rem;
  text-decoration: none;
}
.auth-close:hover { background: rgba(100, 116, 139, .18); background: color-mix(in srgb, var(--muted) 18%, transparent); }
.full-button {
  justify-content: center;
  width: 100%;
  text-align: center;
}

.auth-card h1 { margin: 0 0 6px; font-size: 1.55rem; }
.auth-card h2 { margin: 0 0 18px; color: var(--muted); font-size: 1.05rem; }
.auth-card form { display: grid; gap: 14px; margin-top: 14px; }
.auth-card details { margin-top: 20px; }
.auth-brand {
  margin: 0 44px 20px 0;
  font-size: 1.18rem;
  font-weight: 800;
}
.clickable-summary { cursor: pointer; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 64px;
  padding: 12px max(18px, calc((100vw - 1899px) / 2 + 18px));
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.version {
  color: #64748b;
  margin-left: .35rem;
  font-size: 18px;
  font-weight: 400;
}
[data-theme="dark"] .version { color: #94a3b8; }

.topbar .brand-logo {
  width: 32px;
  height: 32px;
  flex-basis: 32px;
}
.topbar .brand-lockup { gap: .5rem; }

.topbar-brand {
  display: flex;
  align-items: center;
  min-width: 0;
  white-space: nowrap;
}
.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex: 0 0 auto;
}
.topbar-logout {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 40px;
  padding: 8px 4px;
  color: #ef4444;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 16px;
  font-weight: 500;
}
.topbar-logout:hover { color: #dc2626; }
.topbar-logout-icon {
  display: block;
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.settings-inline {
  display: flex;
  gap: 8px;
  align-items: center;
}
.settings-inline select { width: 124px; }
.settings-inline button {
  width: 42px;
  padding: 0;
  background: #f1f5f9;
  color: #475569;
}
.settings-inline button:hover { background: #e2e8f0; filter: none; }
[data-theme="dark"] .settings-inline button { background: #334155; color: #cbd5e1; }
[data-theme="dark"] .settings-inline button:hover { background: #475569; }
.language-create-title {
  margin: 24px 0 10px;
  font-size: 16px;
  font-weight: 700;
}
.language-create-form {
  display: block;
  margin-top: 0;
}
.language-create-search {
  display: grid;
  gap: 5px;
  width: min(760px, 100%);
}
.language-create-controls {
  display: flex;
  align-items: stretch;
  gap: 10px;
  width: fit-content;
  max-width: 100%;
}
.language-create-autocomplete {
  position: relative;
  flex: 0 1 260px;
  width: 260px;
  min-width: 0;
}
.language-create-controls input { width: 100%; }
.language-create-controls button { flex: 0 0 auto; }
.language-create-controls > button:disabled:hover {
  background: var(--accent);
  filter: none;
}
.language-create-search small { color: var(--muted); font-size: 14px; }
.language-create-suggestions {
  position: absolute;
  z-index: 100;
  top: calc(100% + 2px);
  left: 0;
  width: 100%;
  max-height: 22rem;
  overflow-y: auto;
  padding: 0.4rem 0;
  border: 1px solid #475569;
  border-radius: 8px;
  background: #27252f;
  color: #f8fafc;
  box-shadow: 0 12px 24px rgb(15 23 42 / 28%);
  scrollbar-width: auto;
  scrollbar-color: #9ca3af #17161c;
}
.language-create-suggestions::-webkit-scrollbar { width: 16px; }
.language-create-suggestions::-webkit-scrollbar-track { background: #17161c; }
.language-create-suggestions::-webkit-scrollbar-thumb {
  background: #9ca3af;
  border: 3px solid #17161c;
  border-radius: 10px;
}
.language-create-suggestion {
  display: block;
  width: 100%;
  padding: 0.65rem 1rem;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  box-shadow: none;
  cursor: pointer;
}
.language-create-suggestion[hidden] { display: none; }
.language-create-suggestion:hover,
.language-create-suggestion.is-active { background: #475569; filter: none; }
.topbar-theme .material-icons {
  display: block;
  font-size: 24px;
  line-height: 1;
}
.admin-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: .75rem;
  font-weight: 800;
}

.nav {
  position: sticky;
  top: 64px;
  z-index: 19;
  padding: 0 max(18px, calc((100vw - 1899px) / 2 + 18px));
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.nav-links {
  display: flex;
  gap: 4px;
  align-items: center;
  min-height: 48px;
}
.nav-links a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 12px 14px;
  border-radius: 6px;
  color: var(--text);
}
.nav-menu-icon { color: #f7814a; font-size: 20px; line-height: 1; }

.ov-title-with-icon {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ov-title-with-icon > .material-icons {
    flex: 0 0 auto;
    color: #f7814a;
    font-family: 'Material Icons' !important;
    font-style: normal;
    font-weight: normal;
    font-size: 1em;
    letter-spacing: normal;
    line-height: 1;
    text-transform: none;
    white-space: nowrap;
    direction: ltr;
    -webkit-font-feature-settings: 'liga';
    font-feature-settings: 'liga';
}
.nav-links a.active,
.nav-links a:hover {
  background: var(--nav-active-bg);
  color: var(--nav-active-text);
}

.page {
  width: min(1899px, 100%);
  margin: 0 auto;
  padding: 22px 18px 64px;
}
.footer {
  width: min(1899px, 100%);
  margin: 0 auto;
  padding: 14px 18px 28px;
  color: var(--muted);
  text-align: center;
  font-size: .9rem;
}
.footer-copyright {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: .28em;
}
.footer-copyright .brand-lockup { font-weight: 700; }
.footer-rights {
  display: block;
  flex-basis: 100%;
  color: var(--muted);
  text-align: center;
}
.auth-footer {
  position: fixed;
  bottom: 8px;
  left: 0;
  right: 0;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 18px;
}

.panel h1, .panel h2 { margin: 0 0 16px; }
.panel .backup-section-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 16px;
  font-size: 32px;
  line-height: 1.2;
  font-weight: 700;
}
.backup-section-title .material-icons {
  color: var(--accent);
  font-size: 32px;
}
.entity-heading {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 12px;
}
.entity-heading span {
  font: inherit;
  color: var(--muted);
}

.grid-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
  align-items: end;
}
.grid-form.compact {
  grid-template-columns: repeat(auto-fit, minmax(130px, max-content));
  justify-content: start;
}
.form-readonly {
  align-self: center;
  margin: 0;
  color: var(--muted);
}
.form-readonly strong {
  color: var(--text);
  font-weight: 600;
}
.protection-block {
  display: grid;
  gap: 12px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.protection-block h2 {
  margin: 0;
  font-size: 1.05rem;
}
.password-form {
  align-items: end;
}
.password-action {
  display: grid;
  grid-template-columns: minmax(210px, 1fr) auto;
  gap: 8px;
  align-items: end;
}
.password-action label {
  min-width: 0;
}
.password-action button {
  min-width: 58px;
}
.form-status {
  align-self: center;
  color: var(--accent-2);
  font-weight: 700;
  min-height: 1.35em;
}
.form-status.err {
  color: var(--danger);
}
.language-save-status {
  grid-column: 1 / -1;
}
.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
  margin: 10px 0;
}
.inline-form input, .inline-form select { width: min(260px, 100%); }
.entity-switch-form {
  margin-bottom: 4px;
}
.entity-manage-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 22px;
  align-items: end;
  margin: 6px 0 4px;
}
.entity-manage-row .entity-switch-form,
.entity-manage-row .entity-rename-form {
  margin: 0;
}
.entity-switch-form label {
  width: min(420px, 100%);
}
.entity-switch-form select {
  width: 100%;
}
.entity-rename-form {
  flex: 1 1 560px;
}
.entity-rename-form label {
  width: min(280px, 100%);
}
.entity-rename-form input[readonly] {
  background: var(--soft);
  color: var(--muted);
}
.entity-search-form {
  margin-top: 4px;
}
.entity-search-form input[name="q"] {
  width: min(420px, 100%);
}
.album-link-form {
  display: grid;
  gap: 8px;
  margin: 10px 0 0;
}
.album-link-form select { width: 100%; }
.link-album-label { color: var(--muted); }
.bulk-album-link {
  max-width: 420px;
  margin-block: 16px;
}
.check {
  align-items: center;
  grid-template-columns: auto 1fr;
  color: var(--text);
}
.check input { width: auto; min-height: auto; }
.file-picker {
  position: relative;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  min-width: 0;
}
.native-file {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  width: min(150px, 100%);
  border-radius: 6px;
  padding: 8px 14px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
.native-file:disabled + .file-button,
.file-button[aria-disabled="true"] {
  opacity: .55;
  cursor: not-allowed;
}
.file-names {
  display: block;
  max-width: 100%;
  color: var(--text);
  font-size: .85rem;
  overflow-wrap: anywhere;
}
.upload-wait {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  place-items: center;
  align-content: center;
  gap: 14px;
  background: rgba(0,0,0,.68);
  color: #fff;
  text-align: center;
}
.upload-wait.visible { display: grid; }
.upload-hourglass {
  display: block;
  font-size: 3.2rem;
  animation: hourglass-turn 1.2s ease-in-out infinite;
}
@keyframes hourglass-turn {
  0%, 45% { transform: rotate(0); }
  55%, 100% { transform: rotate(180deg); }
}

.flash {
  border: 1px solid var(--line);
  border-left: 5px solid var(--accent-2);
  border-radius: 6px;
  padding: 10px 12px;
  background: var(--panel);
}
.flash.err { border-left-color: var(--danger); }

.gallery-pagination {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto minmax(180px, 1fr);
  align-items: center;
  gap: 12px;
  width: min(1899px, calc(100% - 36px));
  margin: 14px auto;
}
.gallery-pagination label {
  grid-column: 1;
  justify-self: start;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  white-space: nowrap;
}
.gallery-pagination select {
  min-width: 96px;
}
.pager-buttons {
  grid-column: 2;
  justify-self: center;
  display: flex;
  align-items: center;
  gap: 8px;
}
.pager-buttons button {
  width: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: 50%;
  font-size: 1.35rem;
  line-height: 1;
  touch-action: manipulation;
}
.pager-buttons button:disabled {
  opacity: .45;
  cursor: default;
}
.pager-buttons span {
  min-width: 74px;
  text-align: center;
  color: var(--muted);
  font-weight: 700;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.image-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 10px;
}
.image-card[hidden] {
  display: none !important;
}
.image-card.dragging {
  opacity: .55;
  outline: 2px dashed var(--accent);
}
.image-card.selecting {
  outline: 2px solid var(--accent);
}
.image-card:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}
.image-card-header {
  position: relative;
}
.protected-badge {
  position: absolute;
  left: 8px;
  bottom: 8px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: calc(100% - 16px);
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(23, 32, 51, .88);
  color: #fff;
  font-size: .8rem;
  font-weight: 700;
  pointer-events: none;
}
.image-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  background: #000;
  border-radius: 6px;
}
.delete-btn-form {
  position: absolute;
  top: 4px;
  right: 4px;
  margin: 0;
}
.delete-btn {
  width: 32px;
  height: 32px;
  min-height: 32px;
  padding: 0;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  font-size: 1.2rem;
  font-weight: bold;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.delete-btn:hover {
  filter: brightness(.9);
}
.selection-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin: 12px 0;
}
.current-delete-target {
  flex-basis: 100%;
  margin: 0 0 2px;
  color: var(--muted);
}
.current-delete-target strong {
  color: var(--text);
  font-size: 1.05rem;
}
.selection-delete-form {
  margin: 0;
}
.help-text {
  color: var(--muted);
  font-size: .92rem;
}
.gallery-help {
  width: min(1899px, calc(100% - 36px));
  margin: -4px auto 14px;
}
.gallery-stats {
  width: min(1899px, calc(100% - 36px));
  margin: 14px auto 4px;
  font-weight: 700;
}
.select-marker {
  position: absolute;
  z-index: 3;
  top: 0;
  left: 0;
  display: none;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 0;
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
}
.select-marker::before {
  content: "";
  position: absolute;
  top: 10px;
  left: 10px;
  width: 28px;
  height: 28px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: rgba(0,0,0,.55);
  box-shadow: 0 2px 8px rgba(0,0,0,.35);
}
.selection-active .select-marker {
  display: block;
}
.image-card.selected .select-marker::before {
  background: var(--accent);
}
.image-card.selected .select-marker::after {
  content: "✓";
  display: grid;
  place-items: center;
  position: absolute;
  top: 10px;
  left: 10px;
  width: 28px;
  height: 28px;
  color: #fff;
  font-weight: 800;
}
.selection-active .image-card-header a {
  cursor: default;
}
.image-card h3 {
  margin: 0;
  font-size: .95rem;
  overflow-wrap: anywhere;
}
.image-card p { margin: 0; color: var(--muted); }

.last-upload-preview {
  max-width: 400px;
}
.last-upload-preview h3 {
  margin: 10px 0;
  font-size: .95rem;
  overflow-wrap: anywhere;
}

.diagnostics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}
.diagnostics span {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
}
.diagnostics b { display: block; margin-bottom: 4px; }

.lang-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 18px;
  align-items: center;
}
.lang-list a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  min-height: 48px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 10px 18px;
  color: var(--accent);
  background: var(--panel);
  font-weight: 700;
  text-decoration: none;
  transition: background 0.16s ease, color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}
.lang-list a:hover,
.lang-list a:focus-visible,
.lang-list a.active {
  background: var(--nav-active-bg);
  border-color: var(--nav-active-bg);
  color: var(--nav-active-text);
  box-shadow: 0 8px 18px rgba(51, 65, 85, 0.24);
  transform: translateY(-1px);
}
.lang-list form {
  margin-left: 0 !important;
}
.deepl-panel {
  display: grid;
  gap: 16px;
  scroll-margin-top: 120px;
}
.deepl-panel h2,
.deepl-panel p {
  margin: 0;
}
.deepl-feedback,
.deepl-test-status {
  padding: 12px;
  border-left: 4px solid var(--accent);
  background: var(--bg);
  font-weight: 700;
}
.deepl-feedback.is-success {
  border-left-color: #15866f;
}
.deepl-feedback.is-error {
  border-left-color: var(--danger);
  color: var(--danger);
}
.deepl-status {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  padding: 12px;
  border-left: 4px solid var(--danger);
  background: var(--bg);
}
.deepl-status.is-ready {
  border-left-color: #15866f;
}
.deepl-key-row,
.deepl-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
}
.deepl-key-row form {
  margin: 0;
}
.deepl-key-row label {
  min-width: min(420px, 100%);
}
.deepl-language-form {
  grid-template-columns: repeat(2, minmax(180px, 280px)) auto;
  align-items: end;
}
.deepl-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 28px;
}
.deepl-actions .secondary {
  background: var(--muted);
}
.lang-table {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}
.lang-row {
  display: grid;
  grid-template-columns: minmax(160px, 260px) 1fr;
  gap: 12px;
  margin: 0;
  border-bottom: 1px solid var(--line);
  padding: 8px 0;
}
.lang-row span { overflow-wrap: anywhere; }
.lang-table-edit {
  grid-column: 1 / -1;
  display: grid;
  gap: 10px;
  width: min(980px, 100%);
}
.lang-row-edit {
  display: grid;
  grid-template-columns: minmax(160px, 260px) minmax(260px, 1fr);
  gap: 10px;
  align-items: start;
}
.lang-row-edit textarea {
  min-height: 72px;
  resize: vertical;
}
.lang-scrollbox {
  position: relative;
  grid-column: 1 / -1;
  width: min(980px, 100%);
}
.lang-table-edit {
  display: grid;
  gap: 8px;
  max-height: 500px;
  overflow-y: scroll;
  padding-right: 22px;
  scrollbar-gutter: stable;
  scrollbar-color: #8a8f98 #eef2f7;
  scrollbar-width: auto;
}
.lang-table-edit::-webkit-scrollbar {
  width: 14px;
}
.lang-table-edit::-webkit-scrollbar-track {
  background: #eef2f7;
}
.lang-table-edit::-webkit-scrollbar-thumb {
  background: #8a8f98;
  border: 3px solid #eef2f7;
  border-radius: 999px;
}
.lang-scrollbar-rail {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 14px;
  border-radius: 999px;
  background: #eef2f7;
  pointer-events: auto;
  cursor: pointer;
  touch-action: none;
}
.lang-scrollbar-thumb {
  position: absolute;
  top: 0;
  left: 3px;
  right: 3px;
  min-height: 32px;
  border-radius: 999px;
  background: #8a8f98;
  cursor: grab;
  touch-action: none;
}
.lang-scrollbar-thumb:hover,
.lang-scrollbar-thumb.is-dragging {
  background: #64748b;
}
.lang-scrollbar-thumb.is-dragging {
  cursor: grabbing;
}
.lang-scrollbox.no-scroll .lang-scrollbar-rail {
  display: none;
}
.lang-row-edit {
  display: grid;
  grid-template-columns: minmax(160px, 260px) 1fr;
  gap: 12px;
}
.lang-key-display {
  display: block;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--muted);
  font: inherit;
  overflow-wrap: anywhere;
  user-select: text;
}

@media (max-width: 700px) {
  .language-create-controls {
    flex-direction: column;
    width: 100%;
  }
  .language-create-autocomplete { width: 100%; flex-basis: auto; }
  .language-create-controls button {
    width: 100%;
  }
  .deepl-language-form {
    grid-template-columns: 1fr;
  }
  .deepl-key-row form {
    width: 100%;
  }
  .deepl-key-row label {
    min-width: 0;
    width: 100%;
  }
}

.to-top {
  position: fixed;
  right: max(18px, calc((100vw - 1899px) / 2 + 18px));
  bottom: 18px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  line-height: 1;
  box-shadow: var(--shadow);
  transition: background-color .15s ease, color .15s ease;
}
.to-top .material-icons {
  color: inherit;
  font-size: 20px;
  line-height: 1;
}
.to-top:hover,
.to-top:focus-visible {
  background: #334155;
  color: #fff;
}

.viewer {
  width: 100vw;
  height: 100vh;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: #000;
  color: #fff;
}
.viewer-bar {
  position: relative;
  z-index: 3;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, auto) minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 10px 14px;
  pointer-events: none;
}
.viewer-controls {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 10px;
  justify-self: end;
  grid-column: 3;
  pointer-events: auto;
}
.viewer-bar a,
.viewer-bar button {
  width: 44px;
  min-width: 44px;
  min-height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255,255,255,.16);
  color: #fff;
}
.viewer-bar button.viewer-exif-button {
  width: auto;
  min-width: 58px;
  padding-inline: 14px;
  border-radius: 999px;
  font-size: .9rem;
}
.viewer-rotate-save {
  display: flex;
  gap: 8px;
}
.exif-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0,0,0,.64);
}
.exif-modal[hidden] {
  display: none;
}
.exif-panel {
  position: relative;
  width: min(720px, 100%);
  max-height: min(760px, calc(100vh - 40px));
  max-height: min(760px, calc(100dvh - 40px));
  overflow: auto;
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 8px;
  background: #111827;
  color: #fff;
  box-shadow: 0 22px 60px rgba(0,0,0,.45);
  padding: 22px;
}
.exif-panel h2 {
  margin: 0 52px 18px 0;
}
.exif-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 40px;
  min-width: 40px;
  min-height: 40px;
  padding: 0;
  border-radius: 50%;
  background: rgba(255,255,255,.16);
}
.exif-list {
  display: grid;
  grid-template-columns: minmax(130px, 220px) minmax(0, 1fr);
  gap: 8px 14px;
  margin: 0;
}
.exif-list dt {
  color: #cbd5e1;
  font-weight: 700;
  overflow-wrap: anywhere;
}
.exif-list dd {
  margin: 0;
  overflow-wrap: anywhere;
}
.viewer-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}
.viewer-image {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  min-width: 0;
  min-height: 0;
  margin: auto;
  display: block;
  object-fit: contain;
  object-position: center center;
  transform-origin: center center;
}
.viewer-locked-image {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  width: min(520px, 82vw);
  aspect-ratio: 4 / 3;
  border: 1px solid rgba(255,255,255,.24);
  border-radius: 8px;
  background: rgba(255,255,255,.08);
  color: #fff;
  text-align: center;
  text-decoration: none;
}
.viewer-locked-image .lock-icon {
  font-size: clamp(54px, 12vw, 104px);
  line-height: 1;
}
.viewer-locked-image strong {
  font-size: clamp(1.2rem, 3vw, 1.8rem);
}
.viewer-nav {
  position: absolute;
  z-index: 2;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 72px;
  min-height: 112px;
  border-radius: 999px;
  text-align: center;
  font-size: 4rem;
  color: #fff;
  line-height: 1;
  touch-action: manipulation;
  user-select: none;
}
.viewer-nav.prev { left: 0; }
.viewer-nav.next { right: 0; }
.viewer-stage > span { display: none; }
.viewer-thumbs {
  grid-column: 2;
  display: flex;
  min-width: 0;
  max-width: min(64vw, 940px);
  gap: 7px;
  overflow-x: auto;
  justify-content: center;
  padding: 4px;
  background: transparent;
  pointer-events: auto;
}
.viewer-thumbs a {
  position: relative;
  flex: 0 0 44px;
}
.viewer-thumbs a span {
  position: absolute;
  top: 2px;
  right: 2px;
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(0,0,0,.72);
  color: #fff;
  font-size: 10px;
  line-height: 1;
}
.viewer-thumbs img {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 5px;
  border: 1px solid rgba(255,255,255,.35);
}
.viewer-resume { display: none !important; }
.viewer-resume.visible { display: grid !important; }
.pause-badge {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: clamp(48px, 12vw, 110px);
  pointer-events: none;
  text-shadow: 0 8px 26px rgba(0,0,0,.65);
}
.backup-parts {
  margin-top: 18px;
}
.backup-parts-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.backup-part-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.backup-parts-list .button-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.backup-parts-list .backup-part-downloaded {
  background: #16856f;
  border-color: #16856f;
  color: #fff;
  cursor: pointer;
}
.backup-parts-list .backup-part-downloaded:hover,
.backup-parts-list .backup-part-downloaded:focus-visible {
  background: #116b5a;
  border-color: #116b5a;
}
.backup-part-check {
  min-width: 1em;
  font-weight: 800;
}
.backup-part-confirm {
  padding: 9px 12px;
  font-size: .9rem;
}
.restore-history {
  margin: 14px 0 18px;
}
.restore-parts-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}
.restore-part {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}
.restore-part.restored {
  border-color: #16856f;
  color: #16856f;
  font-weight: 700;
}
.restore-date {
  margin: 12px 0 0;
  font-weight: 700;
}

.webpage-public {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}
.webpage-brand {
  position: fixed;
  top: 16px;
  left: 18px;
  z-index: 5;
  color: var(--muted);
  font-size: 1.1rem;
  font-weight: 800;
}
.webpage-shell {
  width: min(1600px, calc(100% - 32px));
  margin: 0 auto;
  padding: 64px 0 44px;
}
.webpage-shell h1 {
  margin: 0 0 24px;
  text-align: center;
}
.webpage-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  margin: 18px 0;
}
.webpage-image {
  display: block;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #000;
}
.webpage-image[hidden] {
  display: none !important;
}
.webpage-image img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  background: #000;
}
.webpage-image.protected {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 4 / 3;
  text-decoration: none;
}
.webpage-lock {
  color: #fff;
  font-size: 44px;
  line-height: 1;
}
.webpage-pagination {
  width: 100%;
}

@media (max-width: 786px) {
  .topbar { align-items: center; gap: 6px; padding-inline: 10px; }
  .topbar-brand { flex: 1 1 auto; overflow: hidden; }
  .brand-title { overflow: hidden; }
  .topbar-actions { gap: 6px; }
  .topbar-logout { width: 34px; min-height: 38px; padding: 0; }
  .topbar-logout-text { display: none; }
  .topbar-logout-icon { display: block; }
  .settings-inline { gap: 6px; }
  .settings-inline select { width: 102px; min-height: 38px; padding: 6px 8px; }
  .settings-inline button { width: 38px; min-height: 38px; }
  .admin-avatar { width: 32px; height: 32px; flex-basis: 32px; }
  .nav { padding-inline: 10px; }
  .nav-links {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 6px;
    min-height: 0;
    padding: 10px 0;
  }
  .nav-links a {
    width: auto;
    max-width: 100%;
    padding: 10px 12px;
    text-align: center;
    white-space: nowrap;
  }
  .inline-form input, .inline-form select { width: 100%; }
  .lang-row { grid-template-columns: 1fr; }
  .protection-block .grid-form.compact {
    grid-template-columns: minmax(0, 1fr);
    justify-content: stretch;
  }
  .protection-block .password-form {
    width: 100%;
  }
  .protection-block .password-action {
    grid-template-columns: minmax(0, 1fr) auto;
    width: 100%;
  }
  .protection-block .check {
    justify-self: start;
    max-width: 100%;
  }
  .viewer-stage { padding-inline: 2px; }
  .viewer-nav { width: 64px; min-height: 120px; font-size: 3rem; }
  .viewer-nav.prev { left: 0; }
  .viewer-nav.next { right: 0; }
  .viewer-bar { gap: 6px; grid-template-columns: minmax(0, 1fr) auto; padding-inline: 6px; }
  .viewer-thumbs { grid-column: 1; justify-self: center; max-width: 100%; }
  .viewer-controls { grid-column: 2; }
  .viewer-controls { gap: 6px; }
  .viewer-bar a, .viewer-bar button { width: 40px; min-width: 40px; min-height: 40px; }
  .viewer-bar button.viewer-exif-button { width: auto; min-width: 54px; }
  .viewer-thumbs a { flex-basis: 40px; }
  .viewer-thumbs img { width: 40px; height: 40px; }
  .exif-list { grid-template-columns: 1fr; }
  .lang-row-edit { grid-template-columns: 1fr; }
  .desktop-only { display: none !important; }
  .gallery-help { display: none !important; }
  .gallery-pagination {
    width: calc(100% - 20px);
    grid-template-columns: 1fr;
    justify-items: center;
  }
  .gallery-pagination label {
    grid-column: 1;
    width: 100%;
    justify-content: center;
  }
  .pager-buttons {
    grid-column: 1;
  }
  .pager-buttons button {
    width: 52px;
    min-width: 52px;
    min-height: 52px;
  }
  .webpage-shell {
    width: calc(100% - 20px);
    padding: 68px 0 32px;
  }
  .webpage-gallery {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 10px;
  }
}

@media (max-width: 407px) {
  .page { padding-inline: 10px; }
  .panel { padding: 14px; }
  .topbar { padding-inline: 10px; }
  .settings-inline select { width: 92px; }
}
