:root {
  --bg: #0f1115;
  --bg-raised: #141821;
  --surface: #181d25;
  --surface-raised: #202633;
  --surface-soft: #131820;
  --surface-inset: #0f141b;
  --border: rgba(198, 210, 226, .13);
  --border-strong: rgba(206, 219, 238, .24);
  --text: #eff5fb;
  --muted: #9aa8ba;
  --muted-strong: #c2ccd9;
  --accent: #8fb8ff;
  --accent-dim: rgba(143, 184, 255, .13);
  --accent-border: rgba(143, 184, 255, .36);
  --violet: #b59cff;
  --violet-dim: rgba(181, 156, 255, .12);
  --violet-border: rgba(181, 156, 255, .31);
  --green: #56d47a;
  --green-dim: rgba(86, 212, 122, .12);
  --green-border: rgba(86, 212, 122, .32);
  --amber: #f3bc51;
  --amber-dim: rgba(243, 188, 81, .13);
  --amber-border: rgba(243, 188, 81, .33);
  --red: #ff746d;
  --red-dim: rgba(255, 116, 109, .12);
  --red-border: rgba(255, 116, 109, .33);
  --blue: #77c3ff;
  --blue-dim: rgba(119, 195, 255, .12);
  --blue-border: rgba(119, 195, 255, .33);
  --shadow-soft: 0 18px 48px rgba(0, 0, 0, .24);
  --shadow-panel: 0 1px 0 rgba(255, 255, 255, .04) inset, 0 12px 34px rgba(0, 0, 0, .18);
  --radius: 8px;
  --radius-lg: 10px;
}

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

html {
  color-scheme: dark;
  scroll-behavior: smooth;
}

body {
  min-height: 100dvh;
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(143, 184, 255, .055), rgba(15, 17, 21, 0) 260px),
    linear-gradient(90deg, rgba(86, 212, 122, .04), transparent 38%, rgba(181, 156, 255, .04)),
    var(--bg);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(206, 219, 238, .055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(206, 219, 238, .045) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(180deg, rgba(0,0,0,.62), transparent 68%);
  -webkit-mask-image: linear-gradient(180deg, rgba(0,0,0,.62), transparent 68%);
}

body > * {
  position: relative;
  z-index: 1;
}

a {
  color: inherit;
}

code {
  color: var(--muted-strong);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: .94em;
}

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

button {
  color: inherit;
}

button:disabled,
input:disabled,
select:disabled {
  opacity: .5;
  cursor: not-allowed;
}

*:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(143, 184, 255, .2);
}

* {
  scrollbar-color: rgba(154, 168, 186, .38) transparent;
}

.shell {
  width: min(1280px, calc(100vw - 48px));
  max-width: 1280px;
  margin: 0 auto;
  padding:
    max(18px, calc(env(safe-area-inset-top) + 12px))
    0
    calc(90px + env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  top: max(12px, env(safe-area-inset-top));
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 58px;
  margin-bottom: 28px;
  padding: 9px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: rgba(20, 24, 33, .9);
  box-shadow: var(--shadow-panel);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 4px 8px 4px 4px;
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
}

.brand:hover {
  background: rgba(255, 255, 255, .035);
}

.brand-icon,
.logo-circle {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border: 1px solid rgba(175, 199, 255, .32);
  border-radius: var(--radius);
  background: #12161c;
  box-shadow: 0 0 0 3px rgba(143, 184, 255, .06);
}

.brand-icon img {
  display: block;
  width: 24px;
  height: 24px;
}

.brand-name {
  color: #f8fbff;
  font-size: 16px;
  font-weight: 720;
  line-height: 1.1;
}

.brand-version {
  margin-top: 3px;
  color: rgba(154, 168, 186, .62);
  font-size: 10px;
  font-weight: 650;
  line-height: 1;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.settings-page .page-header,
.setup-page .page-header {
  display: block;
}

.page-title,
.page-header h1,
h1 {
  margin: 0 0 4px;
  color: #f7fbff;
  font-size: clamp(24px, 2vw, 32px);
  line-height: 1.08;
  font-weight: 760;
}

.page-sub,
.page-header p,
.sub {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.header-actions,
.btn-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.btn,
.btn-add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255,255,255,.055), rgba(255,255,255,.018));
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.035);
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, transform .15s;
}

.btn[hidden],
button[hidden] {
  display: none !important;
}

.btn:hover,
.btn-add:hover {
  border-color: var(--border-strong);
  background: rgba(255, 255, 255, .07);
}

.btn.primary,
.btn-primary,
.btn-add:not(.secondary) {
  color: #f8fbff;
  border-color: var(--accent-border);
  background: linear-gradient(180deg, rgba(143,184,255,.24), rgba(143,184,255,.12));
}

.btn-primary.saved {
  color: #eaffef;
  border-color: var(--green-border);
  background: var(--green-dim);
}

.btn-danger {
  color: #ffd2cf;
  border-color: var(--red-border);
  background: var(--red-dim);
}

.btn-danger:hover {
  background: rgba(255, 116, 109, .17);
}

.btn-sm {
  min-height: 34px;
  padding: 7px 11px;
  font-size: 12px;
}

.btn-icon,
.icon-btn,
.modal-close,
.search-clear,
.btn-remove,
.btn-add.icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-btn {
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .018);
  color: var(--muted-strong);
  text-decoration: none;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}

.icon-btn:hover,
.icon-btn:focus-visible {
  color: var(--text);
  border-color: var(--accent-border);
  background: var(--accent-dim);
}

.btn-icon {
  width: 38px;
  min-width: 38px;
  padding: 0;
  font-size: 20px;
}

input,
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-inset);
  color: var(--text);
  font-size: 14px;
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.025);
  transition: border-color .15s, box-shadow .15s, background .15s;
}

input::placeholder,
textarea::placeholder {
  color: rgba(154, 168, 186, .72);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent-border);
  box-shadow: 0 0 0 3px rgba(143,184,255,.12);
}

input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px var(--surface-inset) inset;
  -webkit-text-fill-color: var(--text);
  caret-color: var(--text);
  transition: background-color 5000s ease-in-out 0s;
}

select {
  cursor: pointer;
}

select option {
  background: var(--surface);
}

textarea {
  min-height: 116px;
  max-width: 100%;
  resize: vertical;
  line-height: 1.45;
}

.field {
  margin-bottom: 14px;
}

.field:last-child {
  margin-bottom: 0;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted-strong);
  font-size: 12px;
  font-weight: 650;
  text-transform: uppercase;
}

.field-note,
.status-meta,
.check-slug,
.config-key,
.refresh-status,
.password-state,
.user-id-cell,
.detail-label,
.item-year,
.item-link,
.result-meta,
.collection-item-meta {
  color: var(--muted);
}

.field-note {
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.55;
}

.input-row {
  display: flex;
  gap: 8px;
}

.input-row input {
  min-width: 0;
  flex: 1;
}

.section,
.stat,
.sync-bar,
.item,
.modal,
.detail-modal,
.detail-card,
.collection-item,
.status-row,
.check-item,
.callout,
.save-bar,
.user-table-wrap,
.empty,
.empty-table,
.search-empty {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(180deg, rgba(255,255,255,.035), rgba(255,255,255,.012)),
    var(--surface);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.03);
}

.section {
  scroll-margin-top: 96px;
  padding: 20px;
  margin-bottom: 14px;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 16px;
  color: var(--muted-strong);
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
}

.section-icon {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  vertical-align: middle;
}

.optional-tag {
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: rgba(255,255,255,.035);
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  text-transform: uppercase;
}

.config-state {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 7px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255,255,255,.035);
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
  line-height: 1.35;
  text-transform: uppercase;
}

.config-state[hidden] {
  display: none;
}

.config-state::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

.config-state.ok {
  color: #d9ffe2;
  border-color: var(--green-border);
  background: var(--green-dim);
}

.config-state.pending {
  color: #ffedc2;
  border-color: var(--amber-border);
  background: var(--amber-dim);
}

.config-state.err {
  color: #ffd2cf;
  border-color: var(--red-border);
  background: var(--red-dim);
}

.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.stat {
  position: relative;
  min-height: 92px;
  padding: 16px 18px 14px;
}

.stat.filterable {
  cursor: pointer;
  transition: transform .15s, border-color .15s, background .15s;
}

.stat.filterable::after {
  content: "";
  position: absolute;
  right: 16px;
  bottom: 16px;
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  color: rgba(194, 204, 217, .58);
  transform: rotate(-45deg);
  transition: color .15s, transform .15s;
}

.stat.active {
  border-color: rgba(143, 184, 255, .62);
  background:
    linear-gradient(180deg, rgba(143,184,255,.14), rgba(255,255,255,.024)),
    var(--surface-raised);
  transform: translateY(-1px);
}

.stat.active::after,
.stat.filterable:hover::after {
  color: var(--accent);
}

@media (hover: hover) and (pointer: fine) {
  .stat.filterable:hover {
    border-color: var(--border-strong);
    background:
      linear-gradient(180deg, rgba(255,255,255,.045), rgba(255,255,255,.016)),
      var(--surface-raised);
    transform: translateY(-1px);
  }

  .stat.filterable.active:hover {
    border-color: rgba(143, 184, 255, .62);
    background:
      linear-gradient(180deg, rgba(143,184,255,.14), rgba(255,255,255,.024)),
      var(--surface-raised);
  }
}

.stat-value {
  margin-bottom: 6px;
  font-size: 30px;
  line-height: 1;
  font-weight: 780;
}

.stat.movies .stat-value {
  color: var(--green);
}

.stat.shows .stat-value {
  color: var(--violet);
}

.stat.hidden .stat-value {
  color: var(--amber);
}

.stat-label {
  padding-right: 18px;
  color: var(--muted);
  font-size: 12px;
}

.sync-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
  padding: 12px 14px;
  border-color: rgba(119, 195, 255, .24);
  background:
    linear-gradient(180deg, rgba(119, 195, 255, .08), rgba(255,255,255,.018)),
    rgba(19, 24, 32, .92);
  color: var(--muted-strong);
  font-size: 12.5px;
}

.sync-bar-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  border: 1px solid rgba(119, 195, 255, .28);
  border-radius: var(--radius);
  background: rgba(119, 195, 255, .11);
  color: var(--blue);
}

.sync-bar span {
  white-space: nowrap;
}

.sync-bar strong {
  margin-left: 4px;
  color: var(--text);
  font-weight: 700;
}

.sync-msg,
.modal-toast {
  display: none;
  margin-bottom: 14px;
  padding: 10px 14px;
  border: 1px solid var(--green-border);
  border-radius: var(--radius);
  background: var(--green-dim);
  color: #d9ffe2;
  font-size: 13px;
}

.modal-toast {
  margin: 0 12px 12px;
}

.modal-toast.error {
  color: #ffd2cf;
  border-color: var(--red-border);
  background: var(--red-dim);
}

.controls {
  display: flex;
  align-items: stretch;
  gap: 8px;
  padding: 8px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: rgba(15, 20, 27, .5);
}

.search-field {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 160px;
}

.search-field input {
  min-width: 0;
  padding-right: 38px;
}

.controls select {
  width: auto;
  min-width: 178px;
  flex: 0 0 auto;
}

.add-title-btn {
  flex: 0 0 auto;
}

.search-clear {
  position: absolute;
  right: 6px;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.search-clear:hover {
  color: var(--text);
  background: rgba(255,255,255,.07);
}

.search-clear[hidden] {
  display: none;
}

.search-clear svg {
  width: 14px;
  height: 14px;
  pointer-events: none;
}

.items,
.log-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 74px;
  padding: 10px 12px;
  background: rgba(20, 24, 33, .78);
  border-color: rgba(198, 210, 226, .1);
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .15s;
}

.item:hover,
.search-result:hover,
.collection-item:hover {
  border-color: var(--border-strong);
  background: var(--surface-raised);
}

.item-poster,
.item-poster-placeholder,
.result-poster,
.result-poster-ph,
.detail-poster,
.detail-poster-ph,
.collection-item-poster,
.collection-item-ph {
  flex: 0 0 auto;
  border: 1px solid rgba(198, 210, 226, .18);
  border-radius: var(--radius);
  background: linear-gradient(145deg, #222b38, #10161f);
  object-fit: cover;
}

.item-poster,
.item-poster-placeholder,
.result-poster,
.result-poster-ph {
  width: 36px;
  height: 54px;
}

.item-poster-placeholder,
.result-poster-ph,
.detail-poster-ph,
.collection-item-ph {
  display: flex;
  align-items: center;
  justify-content: center;
}

.item-body {
  flex: 1;
  min-width: 0;
}

.item-title,
.result-title,
.collection-item-title,
.detail-title,
.username-cell {
  color: #f7fbff;
  font-weight: 700;
}

.item-title {
  margin-bottom: 4px;
  overflow: hidden;
  font-size: 14px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-meta,
.result-meta,
.collection-item-meta,
.detail-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.item-year,
.item-link {
  font-size: 12px;
}

.item-link {
  text-decoration: none;
}

.item-link:hover {
  color: var(--text);
}

.item-actions,
.result-actions,
.detail-actions,
.user-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  margin-left: auto;
}

.item-mode-toggle {
  display: inline-flex;
  gap: 4px;
}

.item-mode-btn,
.detail-tab,
.tab {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color .15s, background .15s, color .15s;
}

.item-mode-btn {
  padding: 6px 8px;
  white-space: nowrap;
}

.detail-mode-options {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(0, max-content));
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-inset);
}

.detail-mode-options .item-mode-btn {
  min-height: 34px;
  padding: 7px 10px;
}

.item-mode-btn:hover,
.detail-tab:hover,
.tab:hover {
  color: var(--text);
  background: rgba(255,255,255,.05);
}

.item-mode-btn.active,
.detail-tab.active {
  color: #f7fbff;
  border-color: rgba(143, 184, 255, .68);
  background: rgba(143, 184, 255, .22);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
}

.btn-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--red-border);
  border-radius: var(--radius);
  background: transparent;
  color: #ffd2cf;
  font-size: 0;
  cursor: pointer;
  transition: background .15s, transform .15s;
}

.btn-remove:hover {
  background: rgba(255, 116, 109, .17);
  transform: translateY(-1px);
}

.btn-remove svg {
  width: 18px;
  height: 18px;
}

.btn-spinner {
  animation: fetcherr-spin .75s linear infinite;
  transform-origin: center;
}

.btn-unhide {
  color: #d9ffe2;
  border-color: var(--green-border);
}

.btn-unhide:hover {
  background: rgba(86, 212, 122, .16);
}

.library-action-wrap {
  position: relative;
  display: inline-flex;
}

.item-menu-trigger {
  -webkit-appearance: none;
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted-strong);
  cursor: pointer;
  transition: border-color .15s, background .15s, color .15s, transform .15s;
}

.item-menu-trigger:hover,
.item-menu-trigger.open {
  color: var(--text);
  border-color: var(--border-strong);
  background: rgba(255,255,255,.06);
  transform: translateY(-1px);
}

.item-menu-trigger.open {
  color: #eef3ff;
  border-color: var(--accent-border);
  background: var(--accent-dim);
}

.item-menu-dots {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  pointer-events: none;
}

.item-menu-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: .95;
}

.library-action-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 80;
  display: none;
  min-width: 204px;
  padding: 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: rgba(21, 28, 38, .98);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.library-action-menu.drop-up {
  top: auto;
  bottom: calc(100% + 6px);
}

.library-action-menu[hidden] {
  display: none !important;
}

.library-action-menu.open {
  display: grid;
  gap: 4px;
}

.library-action-title {
  padding: 3px 8px 6px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
  line-height: 1.3;
  text-transform: uppercase;
}

.library-action-menu button {
  -webkit-appearance: none;
  appearance: none;
  display: grid;
  grid-template-columns: 13px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 34px;
  padding: 8px 9px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted-strong);
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}

.library-action-menu button::before {
  content: "";
  width: 7px;
  height: 7px;
  border: 1px solid rgba(194, 204, 217, .38);
  border-radius: 50%;
  background: transparent;
}

.library-action-menu button:hover {
  color: var(--text);
  background: rgba(255,255,255,.055);
}

.library-action-menu button.active {
  color: #eef3ff;
  border-color: var(--accent-border);
  background: var(--accent-dim);
}

.library-action-menu button.active::before {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(143, 184, 255, .13);
}

.empty,
.empty-table,
.search-empty {
  padding: 38px 20px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
  text-align: center;
}

.empty-title {
  margin-bottom: 4px;
  color: var(--text);
  font-size: 15px;
  font-weight: 740;
}

.empty-action {
  margin-top: 12px;
}

.loading-list {
  display: grid;
  gap: 8px;
}

.skeleton-row {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 120px;
  gap: 12px;
  align-items: center;
  min-height: 74px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: rgba(20, 24, 33, .62);
}

.skeleton-poster,
.skeleton-line,
.skeleton-chip {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  background: rgba(198, 210, 226, .09);
}

.skeleton-poster::after,
.skeleton-line::after,
.skeleton-chip::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.08), transparent);
  animation: shimmer 1.4s infinite;
}

.skeleton-poster {
  width: 36px;
  height: 54px;
}

.skeleton-lines {
  display: grid;
  gap: 8px;
}

.skeleton-line {
  width: min(360px, 86%);
  height: 12px;
}

.skeleton-line.short {
  width: min(220px, 52%);
}

.skeleton-chip {
  justify-self: end;
  width: 112px;
  height: 24px;
}

@keyframes shimmer {
  100% {
    transform: translateX(100%);
  }
}

@keyframes fetcherr-spin {
  to {
    transform: rotate(360deg);
  }
}

.pill,
.badge-in-lib,
.log-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255,255,255,.025);
  color: var(--muted-strong);
  font-size: 11px;
  font-weight: 650;
  white-space: nowrap;
}

.pill[hidden] {
  display: none;
}

.pill.green,
.pill.ok,
.badge-in-lib {
  color: #d9ffe2;
  border-color: var(--green-border);
  background: var(--green-dim);
}

.pill.accent {
  color: #eee9ff;
  border-color: var(--violet-border);
  background: var(--violet-dim);
}

.pill.blue,
.callout.info,
.log-badge.info {
  color: #d8efff;
  border-color: var(--blue-border);
  background: var(--blue-dim);
}

.pill.amber,
.pill.pending,
.log-badge.warn {
  color: #ffedc2;
  border-color: var(--amber-border);
  background: var(--amber-dim);
}

.pill.err,
.callout.error,
.log-badge.error {
  color: #ffd2cf;
  border-color: var(--red-border);
  background: var(--red-dim);
}

.pill.sm {
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.pill-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: .82;
}

.hidden-count-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: 0 0 auto;
  height: 100%;
  min-height: 38px;
  padding: 8px 11px;
  border: 1px solid var(--amber-border);
  border-radius: var(--radius);
  background: var(--amber-dim);
  color: #ffedc2;
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}

.hidden-count-badge:hover {
  background: rgba(243, 188, 81, .22);
  border-color: rgba(243, 188, 81, .5);
}

.modal-overlay,
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 60px 20px 20px;
  background: rgba(6, 10, 16, .76);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.modal-backdrop {
  z-index: 1000;
  align-items: center;
}

.modal-overlay.open,
.modal-backdrop.open {
  display: flex;
}

.modal,
.detail-modal {
  width: 100%;
  max-height: calc(100dvh - 100px);
  overflow: hidden;
  border-color: var(--border-strong);
  background: #151c26;
  box-shadow: 0 28px 80px rgba(0,0,0,.5);
}

.modal {
  max-width: 560px;
  display: flex;
  flex-direction: column;
}

.settings-page .modal {
  width: min(520px, 100%);
  padding: 20px;
}

.detail-modal {
  position: relative;
  max-width: 820px;
  display: flex;
  flex-direction: column;
}

.modal-head {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  gap: 12px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  background: rgba(20, 27, 36, .96);
}

.settings-page .modal-head {
  flex-direction: row;
  align-items: flex-start;
  justify-content: space-between;
  padding: 0;
  margin-bottom: 16px;
  border-bottom: 0;
  background: transparent;
}

.modal-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-title {
  margin: 0;
  color: var(--text);
  font-size: 18px;
  font-weight: 760;
}

.modal-sub {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.modal-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.modal-close:hover {
  color: var(--text);
  background: rgba(255,255,255,.06);
}

.modal-search-row {
  display: flex;
  gap: 8px;
}

.modal-search-row .search-field {
  flex: 1;
}

.modal-body,
.detail-body {
  overflow: auto;
}

.modal-body {
  flex: 1;
  padding: 12px;
}

.search-modal .modal-body {
  flex: 0 1 auto;
  min-height: 0;
}

.search-modal .search-empty {
  padding-top: 30px;
  padding-bottom: 30px;
}

.detail-body {
  padding: 18px 20px 20px;
}

.detail-loading {
  padding: 28px 20px;
  color: var(--muted);
  font-size: 14px;
}

.search-result,
.collection-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  transition: background .15s, border-color .15s;
}

.result-body,
.collection-item-body {
  flex: 1;
  min-width: 0;
}

.result-title,
.collection-item-title {
  margin-bottom: 4px;
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-action-stack {
  position: relative;
  display: flex;
  justify-content: flex-end;
}

.btn-add.icon {
  width: 34px;
  min-width: 34px;
  height: 34px;
  padding: 0;
}

.tv-add-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 10;
  display: none;
  min-width: 158px;
  padding: 6px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: 0 16px 40px rgba(0,0,0,.35);
}

.tv-add-menu.drop-up {
  top: auto;
  bottom: calc(100% + 8px);
}

.tv-add-menu.open {
  display: grid;
  gap: 6px;
}

.detail-hero {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}

.detail-poster,
.detail-poster-ph {
  width: 110px;
  height: 165px;
}

.detail-poster-ph {
  font-size: 34px;
}

.detail-copy {
  min-width: 0;
  flex: 1;
}

.detail-title {
  margin: 0 0 8px;
  font-size: 24px;
  line-height: 1.16;
}

.detail-meta {
  gap: 8px;
  margin-bottom: 10px;
}

.detail-year {
  color: var(--muted);
  font-weight: 560;
}

.detail-overview {
  margin: 0;
  color: #dce5f0;
  font-size: 14px;
  line-height: 1.62;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.detail-card {
  padding: 14px;
  background: var(--surface-raised);
}

.detail-card h3 {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
}

.detail-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.detail-row + .detail-row {
  margin-top: 10px;
}

.detail-value {
  color: var(--text);
  font-size: 14px;
}

.detail-tabs,
.tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-inset);
}

.detail-tabs {
  margin: 0 0 14px;
}

.detail-tab,
.tab {
  padding: 8px 12px;
}

.tab {
  border-color: transparent;
}

.tab.active {
  color: var(--text);
  background: var(--surface-raised);
}

.tab.info.active {
  color: var(--blue);
}

.tab.warn.active {
  color: var(--amber);
}

.tab.error.active {
  color: var(--red);
}

.toggle-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid var(--amber-border);
  border-radius: var(--radius-lg);
  background: var(--amber-dim);
}

.toggle-copy {
  min-width: 0;
}

.toggle-title {
  margin: 0 0 4px;
  color: #ffedc2;
  font-size: 13px;
  font-weight: 700;
}

.toggle-sub {
  margin: 0;
  color: #d9c696;
  font-size: 12.5px;
  line-height: 1.55;
}

.detail-actions {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) auto minmax(120px, 1fr);
  align-items: center;
  flex: initial;
  gap: 12px;
  margin-left: 0;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.detail-action-group {
  display: flex;
  align-items: center;
  min-width: 0;
}

.detail-action-link {
  justify-content: flex-start;
}

.detail-action-mode {
  justify-content: center;
}

.detail-action-danger {
  justify-content: flex-end;
}

.collection-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.collection-item-poster,
.collection-item-ph {
  width: 40px;
  height: 60px;
}

.collection-item-ph {
  font-size: 18px;
}

.settings-layout {
  display: grid;
  grid-template-columns: 176px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.settings-nav {
  position: sticky;
  top: 96px;
  display: grid;
  gap: 4px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: rgba(20, 24, 33, .74);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.03);
}

.settings-nav a {
  padding: 9px 10px;
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.settings-nav a:hover,
.settings-nav a.active {
  color: var(--text);
  background: var(--accent-dim);
}

.settings-content {
  min-width: 0;
}

.provider-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.provider-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.provider-remove-btn {
  justify-self: end;
}

.provider-actions {
  margin-top: 10px;
}

.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  margin-top: 10px;
  background: rgba(255,255,255,.025);
}

.status-meta {
  min-width: 0;
  font-size: 13px;
}

.status-meta strong {
  display: block;
  margin-bottom: 2px;
  color: var(--text);
  font-size: 14px;
}

.callout {
  margin-top: 14px;
  padding: 12px 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.callout.success {
  color: #d9ffe2;
  border-color: var(--green-border);
  background: var(--green-dim);
}

.callout a {
  color: var(--accent);
}

.addon-remove-summary {
  overflow: hidden;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-inset);
  color: var(--muted-strong);
  font-size: 12px;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.checklist {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}

.checklist.scrollable {
  max-height: 420px;
  overflow: auto;
  padding-right: 2px;
}

.check-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  color: inherit;
  background: rgba(15, 20, 27, .72);
}

.check-item:hover {
  border-color: var(--border-strong);
  background: rgba(32, 38, 51, .78);
}

.check-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  flex: 0 0 auto;
}

.check-meta {
  min-width: 0;
}

.check-title {
  color: var(--text);
  font-size: 14px;
  line-height: 1.3;
}

.check-slug {
  margin-top: 2px;
  font-size: 12px;
  line-height: 1.45;
}

.trakt-list-note {
  margin-top: 14px;
}

.trakt-list-note.compact {
  margin-top: 8px;
}

.trakt-list-actions {
  margin-top: 12px;
}

.user-table-wrap {
  margin-top: 14px;
  overflow: hidden;
  border-color: var(--border-strong);
  background:
    linear-gradient(180deg, rgba(143,184,255,.045), rgba(255,255,255,.012)),
    rgba(255,255,255,.02);
}

.user-table-scroll {
  max-height: 420px;
  overflow: auto;
}

.user-table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
}

.user-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-strong);
  background: rgba(20, 27, 36, .97);
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

.user-table tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.user-table tbody tr:last-child td {
  border-bottom: 0;
}

.user-table tbody tr:hover td {
  background: rgba(143,184,255,.035);
}

.user-table tbody tr.deleted {
  opacity: .45;
  background: rgba(255,116,109,.06);
}

.user-table input,
.user-table select {
  min-width: 0;
  margin: 0;
}

.username-cell {
  font-size: 14px;
}

.user-id-cell {
  margin-top: 3px;
  font-size: 11px;
}

.password-state {
  font-size: 12px;
  white-space: nowrap;
}

.password-state.pending {
  color: var(--blue);
}

.empty-table {
  padding: 18px 16px;
  text-align: left;
}

.save-bar {
  position: sticky;
  bottom: max(20px, calc(env(safe-area-inset-bottom) + 12px));
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 20px;
  padding: 14px 16px;
  border-color: var(--accent-border);
  background: rgba(20, 24, 33, .9);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.save-bar p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.settings-output {
  margin-top: 14px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.refresh-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.refresh-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  opacity: 0;
  transition: opacity .3s;
}

.refresh-dot.flash {
  opacity: 1;
}

.log-entry {
  display: grid;
  grid-template-columns: 160px 58px minmax(0, 1fr);
  gap: 10px;
  align-items: baseline;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: rgba(20, 24, 33, .56);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  transition: background .12s, border-color .12s;
}

.log-entry:hover {
  border-color: var(--border);
  background: var(--surface);
}

.log-entry.error {
  border-color: var(--red-border);
  background: var(--red-dim);
}

.log-entry.warn {
  border-color: var(--amber-border);
  background: var(--amber-dim);
}

.log-time {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.log-badge {
  justify-content: center;
  padding: 2px 7px;
  font-size: 10px;
  text-transform: uppercase;
}

.log-msg {
  color: #e8eff8;
  word-break: break-word;
  line-height: 1.5;
}

.log-entry.error .log-msg {
  color: #ffd2cf;
}

.log-entry.warn .log-msg {
  color: #ffedc2;
}

.config-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.config-note {
  margin-bottom: 12px;
}

.config-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.config-val {
  max-width: 60%;
  overflow: hidden;
  color: var(--muted-strong);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  font-weight: 650;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.config-val.masked {
  opacity: .6;
}

body.auth-page {
  display: grid;
  min-height: 100dvh;
  overflow: hidden;
  place-items: center;
  padding: 28px;
}

body.auth-page::after {
  content: "";
  position: fixed;
  inset: auto 0 0 0;
  height: 40vh;
  pointer-events: none;
  background:
    linear-gradient(180deg, transparent, rgba(15, 17, 21, .76)),
    repeating-linear-gradient(90deg, rgba(143, 184, 255, .12) 0 1px, transparent 1px 96px);
  opacity: .5;
}

.bg-layer,
.bg-blob-tl,
.bg-blob-br,
.bg-orb {
  display: none;
}

.bg-grid {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: .16;
  background-image:
    linear-gradient(rgba(143, 184, 255, .5) 1px, transparent 1px),
    linear-gradient(90deg, rgba(86, 212, 122, .32) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(180deg, rgba(0,0,0,.85), transparent 78%);
  -webkit-mask-image: linear-gradient(180deg, rgba(0,0,0,.85), transparent 78%);
}

.card {
  width: min(100%, 430px);
  max-width: 430px;
  padding: 32px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.018)),
    rgba(20, 24, 33, .92);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.logo-wrap,
.logo {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
}

.logo-circle {
  width: 62px;
  height: 62px;
  border-radius: 14px;
}

.logo-circle img,
.logo img {
  display: block;
  width: 36px;
  height: 36px;
}

.card h1 {
  margin: 0 0 6px;
  color: var(--text);
  font-size: 24px;
  font-weight: 760;
  text-align: center;
}

.card .sub {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
}

.card .btn {
  width: 100%;
  margin-top: 8px;
}

.error {
  display: none;
  margin-top: 14px;
  padding: 10px 12px;
  border: 1px solid var(--red-border);
  border-radius: var(--radius);
  background: var(--red-dim);
  color: #ffd2cf;
  font-size: 13px;
}

@media (max-width: 900px) {
  .settings-layout {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .settings-nav {
    position: sticky;
    top: 78px;
    z-index: 70;
    display: flex;
    gap: 4px;
    overflow-x: auto;
    padding: 6px;
  }

  .settings-nav a {
    flex: 0 0 auto;
  }

  .field-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  body.auth-page {
    padding: 16px;
  }

  .brand-version {
    display: none;
  }

  .shell {
    width: min(100%, calc(100vw - 24px));
    padding:
      max(12px, calc(env(safe-area-inset-top) + 10px))
      0
      calc(106px + env(safe-area-inset-bottom));
  }

  .topbar {
    top: max(8px, env(safe-area-inset-top));
    margin-bottom: 20px;
  }

  .page-title,
  .page-header h1 {
    font-size: 25px;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .header-actions,
  .header-actions .btn {
    width: 100%;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stat {
    min-height: 84px;
  }

  .sync-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }

  .sync-bar span {
    white-space: normal;
  }

  .section {
    padding: 15px;
  }

  .controls {
    flex-direction: column;
    padding: 7px;
  }

  .controls select,
  .controls .search-field,
  .add-title-btn {
    display: inline-flex;
    width: 100%;
  }

  input,
  select,
  textarea,
  .controls input,
  .modal-search-row input {
    font-size: 16px;
  }

  .item {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) auto;
    gap: 8px 10px;
    align-items: center;
    padding: 10px;
  }

  .item-poster,
  .item-poster-placeholder {
    width: 42px;
    height: 63px;
    grid-column: 1;
    grid-row: 1;
    align-self: start;
  }

  .item-body {
    grid-column: 2;
    grid-row: 1;
  }

  .item-title {
    display: -webkit-box;
    margin-bottom: 4px;
    white-space: normal;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .item-actions {
    grid-column: 3;
    grid-row: 1;
    width: auto;
  }

  .item.has-mode-toggle .item-poster,
  .item.has-mode-toggle .item-poster-placeholder {
    grid-row: 1 / span 2;
  }

  .item.has-mode-toggle .item-body {
    grid-column: 2 / 4;
  }

  .item.has-mode-toggle .item-actions {
    grid-column: 2 / 4;
    grid-row: 2;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 38px;
    width: 100%;
    gap: 8px;
  }

  .item.has-mode-toggle .item-mode-toggle {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    width: 100%;
  }

  .item-mode-btn {
    width: 100%;
  }

  .btn-remove {
    width: 38px;
    height: 38px;
  }

  .detail-hero {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .detail-meta,
  .detail-actions {
    justify-content: center;
  }

  .detail-grid,
  .detail-actions {
    grid-template-columns: 1fr;
  }

  .detail-actions {
    justify-items: stretch;
  }

  .detail-action-link,
  .detail-action-mode,
  .detail-action-danger {
    justify-content: stretch;
  }

  .detail-action-group > .btn,
  .detail-action-group > .detail-mode-options {
    width: 100%;
  }

  .detail-mode-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .detail-modal::after {
    content: "";
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    height: 28px;
    pointer-events: none;
    background: linear-gradient(180deg, rgba(21, 28, 38, 0), #151c26);
  }

  .toggle-card {
    flex-direction: column;
    align-items: flex-start;
  }

  .modal-overlay,
  .modal-backdrop {
    align-items: flex-start;
    padding:
      max(14px, calc(env(safe-area-inset-top) + 10px))
      12px
      max(14px, calc(env(safe-area-inset-bottom) + 10px));
  }

  .modal,
  .detail-modal {
    max-height: calc(100dvh - 28px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  }

  .settings-page .modal {
    padding: 16px;
  }

  .modal-actions {
    flex-direction: column-reverse;
  }

  .modal-actions .btn {
    width: 100%;
  }

  .provider-row,
  .input-row {
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .provider-row {
    display: grid;
  }

  .status-row {
    align-items: flex-start;
    flex-wrap: wrap;
    padding: 12px;
  }

  .check-item {
    align-items: flex-start;
  }

  .check-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    flex-basis: 20px;
    margin-top: 1px;
  }

  .save-bar {
    position: static;
    flex-direction: column;
    align-items: stretch;
    margin-top: 16px;
  }

  .save-bar .btn {
    width: 100%;
  }

  .user-table {
    min-width: 0;
  }

  .user-table thead {
    display: none;
  }

  .user-table,
  .user-table tbody,
  .user-table tr,
  .user-table td {
    display: block;
    width: 100%;
  }

  .user-table tbody tr {
    padding: 12px;
    border-bottom: 1px solid var(--border);
  }

  .user-table tbody tr:last-child {
    border-bottom: 0;
  }

  .user-table tbody td {
    display: grid;
    grid-template-columns: 94px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    padding: 8px 0;
    border-bottom: 0;
  }

  .user-table tbody td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 11px;
    font-weight: 750;
    text-transform: uppercase;
  }

  .user-actions {
    flex-wrap: wrap;
  }

  .toolbar {
    align-items: flex-start;
  }

  .tabs {
    width: 100%;
    overflow-x: auto;
  }

  .tab {
    flex: 1;
  }

  .log-entry {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .log-time {
    display: none;
  }

  .skeleton-row {
    grid-template-columns: 42px minmax(0, 1fr);
  }

  .skeleton-chip {
    display: none;
  }

  .card {
    padding: 28px 22px;
  }
}

@media (max-width: 420px) {
  .brand-name {
    font-size: 15px;
  }

  .icon-btn {
    width: 36px;
    height: 36px;
  }

  .stats {
    gap: 8px;
  }

  .stat-value {
    font-size: 26px;
  }

  .config-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .config-val {
    max-width: 100%;
    text-align: left;
  }
}
