:root {
  color-scheme: dark;
  --bg: #090b0f;
  --panel: #11151c;
  --panel-2: #161b23;
  --line: #28303a;
  --text: #edf2f7;
  --muted: #99a6b5;
  --accent: #2dd4bf;
  --accent-2: #f59e0b;
  --danger: #fb7185;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(90deg, rgba(255,255,255,0.035) 1px, transparent 1px),
    linear-gradient(rgba(255,255,255,0.035) 1px, transparent 1px),
    var(--bg);
  background-size: 42px 42px;
}

.login-panel {
  width: min(520px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 28px;
}

.login-panel h1 {
  font-size: 28px;
  margin: 0 0 22px;
}

.login-panel label {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

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

.password-row input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #0c1016;
  color: var(--text);
  min-height: 44px;
  padding: 0 12px;
}

.password-row button {
  border: 1px solid rgba(45, 212, 191, 0.7);
  border-radius: 7px;
  background: rgba(45, 212, 191, 0.14);
  color: var(--text);
  min-height: 44px;
  padding: 0 16px;
  cursor: pointer;
  font-weight: 800;
}

.login-error {
  color: var(--danger);
  margin: 12px 0 0;
  font-weight: 700;
}

.app-shell {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  min-height: 100vh;
}

.series-panel {
  border-right: 1px solid var(--line);
  background: var(--panel);
  display: flex;
  min-height: 100vh;
  max-height: 100vh;
  flex-direction: column;
  overflow: hidden;
}

.brand-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px 12px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 22px;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
  line-height: 1.2;
}

.count-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  padding: 6px 10px;
  white-space: nowrap;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 0 18px 12px;
}

.language-switcher {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 0 18px 12px;
}

.login-language-switcher {
  padding: 0;
  margin: 0 0 20px;
}

.language-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  min-height: 34px;
  background: #0c1016;
  color: var(--muted);
  cursor: pointer;
  font-weight: 700;
  font-size: 13px;
  padding: 0 6px;
}

.language-button.is-active {
  border-color: rgba(45, 212, 191, 0.7);
  background: rgba(45, 212, 191, 0.12);
  color: var(--text);
}

.tab,
.viewer-actions button {
  border: 1px solid var(--line);
  background: #0c1016;
  color: var(--muted);
  cursor: pointer;
  border-radius: 7px;
  min-height: 34px;
}

.tab.is-active {
  border-color: rgba(45, 212, 191, 0.6);
  background: rgba(45, 212, 191, 0.12);
  color: var(--text);
}

.series-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 12px 18px;
  scrollbar-color: var(--accent) #0c1016;
  scrollbar-width: thin;
}

.series-list::-webkit-scrollbar {
  width: 10px;
}

.series-list::-webkit-scrollbar-track {
  background: #0c1016;
}

.series-list::-webkit-scrollbar-thumb {
  background: #35414d;
  border: 2px solid #0c1016;
  border-radius: 999px;
}

.series-list::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

.series-button {
  width: 100%;
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  padding: 8px;
  text-align: left;
}

.series-button:hover,
.series-button.is-active {
  background: var(--panel-2);
  border-color: var(--line);
}

.series-button.is-active {
  border-color: rgba(45, 212, 191, 0.45);
}

.series-button img {
  width: 58px;
  height: 58px;
  object-fit: contain;
  background: #020304;
  border-radius: 6px;
}

.series-name {
  display: block;
  color: var(--text);
  font-weight: 700;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.series-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.workspace {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 100vh;
  background: #050608;
}

.viewer-header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 14px 20px;
  min-height: 62px;
}

.viewer-actions {
  display: flex;
  gap: 8px;
}

.viewer-actions button {
  min-width: 42px;
  padding: 0 12px;
  color: var(--text);
}

.viewer-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(255,255,255,0.035) 1px, transparent 1px),
    linear-gradient(rgba(255,255,255,0.035) 1px, transparent 1px),
    #050608;
  background-size: 36px 36px;
}

#slice-image {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  image-rendering: auto;
  transform-origin: center;
  transition: transform 120ms ease, opacity 120ms ease;
  user-select: none;
}

#slice-image.is-small-source {
  height: 100%;
  width: auto;
  object-fit: contain;
}

.empty-state {
  position: absolute;
  color: var(--muted);
}

.scrubber {
  border-top: 1px solid var(--line);
  padding: 10px 20px 14px;
  background: #080b10;
}

.scrubber-meta {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.scrubber-hint {
  margin: -2px 0 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

#slice-range {
  width: 100%;
  accent-color: var(--accent);
}

.report-workspace {
  grid-template-rows: auto minmax(0, 1fr);
}

.report-content {
  overflow: auto;
  padding: 42px;
  color: #111827;
  background: #f8fafc;
  font-size: 26px;
  line-height: 1.62;
}

.report-content,
.report-content * {
  font-size: 26px !important;
  line-height: 1.62 !important;
}

.report-content b,
.report-content strong {
  font-weight: 800 !important;
}

.report-content > * {
  max-width: 1080px;
}

.report-content p {
  margin-bottom: 1.1em;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
    min-height: 100svh;
  }

  .series-panel {
    min-height: auto;
    max-height: 34vh;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    overflow: hidden;
  }

  .brand-row {
    align-items: center;
    padding: 10px 12px 8px;
  }

  .brand-row .eyebrow {
    margin: 0;
    font-size: 11px;
  }

  .count-pill {
    padding: 4px 8px;
    font-size: 12px;
  }

  .language-switcher {
    padding: 0 12px 8px;
  }

  .tabs {
    padding: 0 12px 8px;
  }

  .series-list {
    display: block;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 0 12px 10px;
  }

  .workspace {
    min-height: calc(100svh - 186px);
    grid-template-rows: auto minmax(48svh, 1fr) auto;
  }

  .viewer-header {
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    min-height: 54px;
  }

  .viewer-header h2 {
    font-size: 16px;
  }

  .viewer-actions {
    gap: 6px;
    flex-shrink: 0;
  }

  .viewer-actions button {
    min-width: 36px;
    min-height: 32px;
    padding: 0 9px;
  }

  .viewer-stage {
    min-height: 48svh;
    background-size: 28px 28px;
  }

  .scrubber {
    padding: 8px 12px 12px;
  }

  .scrubber-hint {
    font-size: 12px;
    margin-bottom: 6px;
  }

  #slice-range {
    min-height: 32px;
  }

  .report-content {
    padding: 22px 16px 32px;
  }

  .report-content,
  .report-content * {
    font-size: 20px !important;
    line-height: 1.5 !important;
  }
}

@media (max-width: 520px) {
  .login-screen {
    align-items: start;
    padding: 18px 12px;
  }

  .login-panel {
    margin-top: 8svh;
    padding: 20px;
  }

  .login-panel h1 {
    font-size: 26px;
    margin-bottom: 18px;
  }

  .login-language-switcher {
    grid-template-columns: 1fr;
  }

  .password-row {
    grid-template-columns: 1fr;
  }

  .password-row button {
    width: 100%;
  }

  .language-button {
    min-height: 38px;
  }

  .app-shell {
    min-height: 100svh;
  }

  .language-switcher:not(.login-language-switcher) {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .language-button {
    font-size: 12px;
  }

  .workspace {
    min-height: calc(100svh - 182px);
    grid-template-rows: auto minmax(52svh, 1fr) auto;
  }

  .viewer-stage {
    min-height: 52svh;
  }

  #slice-image.is-small-source {
    width: 100%;
    height: auto;
  }
}
