:root {
      color-scheme: dark;
      --bg: #0c1118;
      --panel: #121a24;
      --panel-strong: #182331;
      --panel-hover: #1c2939;
      --border: #29384b;
      --text: #edf3fa;
      --muted: #91a0b2;
      --accent: #56b4ff;
      --accent-soft: rgba(86, 180, 255, 0.14);
      --danger: #ff7d7d;
      --success: #65d49a;
      --shadow: 0 18px 50px rgba(0, 0, 0, 0.32);
      --radius: 14px;
    }


    html[data-theme="light"] {
      color-scheme: light;
      --bg: #edf2f7;
      --panel: #ffffff;
      --panel-strong: #eef4fa;
      --panel-hover: #e8f0f8;
      --border: #ccd7e3;
      --text: #182333;
      --muted: #68788d;
      --accent: #1479c9;
      --accent-soft: rgba(20, 121, 201, 0.12);
      --danger: #b83a45;
      --success: #188451;
      --shadow: 0 18px 50px rgba(34, 50, 70, 0.16);
    }

    html[data-theme="light"] .zoom-value {
      background: #f6f9fc;
    }

    html[data-theme="light"] .main {
      background:
        radial-gradient(circle at 70% 10%, rgba(20, 121, 201, 0.09), transparent 34%),
        var(--bg);
    }

    html[data-theme="light"] .main-header {
      background: rgba(237, 242, 247, 0.88);
    }

    html[data-theme="light"] .image-stage {
      background:
        linear-gradient(45deg, rgba(24,35,51,0.035) 25%, transparent 25%),
        linear-gradient(-45deg, rgba(24,35,51,0.035) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, rgba(24,35,51,0.035) 75%),
        linear-gradient(-45deg, transparent 75%, rgba(24,35,51,0.035) 75%),
        #dfe7ef;
      background-position: 0 0, 0 8px, 8px -8px, -8px 0;
      background-size: 16px 16px;
    }

    html[data-theme="light"] .thumbnail-button {
      background: #dfe7ef;
    }

    html[data-theme="light"] .loading-overlay {
      background: rgba(237, 242, 247, 0.68);
    }

    html[data-theme="light"] .gallery-error {
      background: rgba(255, 235, 237, 0.97);
      color: #8e2630;
    }

    * {
      box-sizing: border-box;
    }

    html,
    body {
      width: 100%;
      height: 100%;
      margin: 0;
      overflow: hidden;
      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;
    }

    button {
      color: inherit;
    }

    [ng-cloak] {
      display: none !important;
    }

    .auth-gate {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 14px;
      width: 100%;
      height: 100%;
      padding: 24px;
      color: var(--muted);
      text-align: center;
      background:
        radial-gradient(circle at 70% 10%, rgba(86, 180, 255, 0.08), transparent 34%),
        var(--bg);
    }

    .auth-gate-error strong {
      color: var(--text);
      font-size: 17px;
    }

    .auth-gate-error .download-button {
      margin-top: 4px;
    }

    .app-shell {
      display: grid;
      grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
      width: 100%;
      height: 100%;
      min-height: 0;
    }

    .main {
      display: flex;
      flex-direction: column;
      min-width: 0;
      min-height: 0;
      background:
        radial-gradient(circle at 70% 10%, rgba(86, 180, 255, 0.08), transparent 34%),
        var(--bg);
    }

    .main-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 16px;
      flex: 0 0 auto;
      min-height: 70px;
      padding: 14px 20px;
      border-bottom: 1px solid var(--border);
      background: rgba(12, 17, 24, 0.86);
      backdrop-filter: blur(14px);
    }

    .selection-title {
      min-width: 0;
    }

    .selection-title h2 {
      margin: 0;
      overflow: hidden;
      font-size: 18px;
      line-height: 1.25;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .selection-title p {
      margin: 5px 0 0;
      overflow: hidden;
      color: var(--muted);
      font-size: 12px;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .selection-title .session-context {
      color: var(--accent);
    }

    .header-actions {
      display: flex;
      align-items: center;
      justify-content: flex-end;
      gap: 8px;
      flex: 0 0 auto;
      flex-wrap: wrap;
    }

    .zoom-controls {
      display: flex;
      align-items: center;
      gap: 6px;
      padding-right: 8px;
      margin-right: 2px;
      border-right: 1px solid var(--border);
    }

    .zoom-value {
      min-width: 58px;
      height: 38px;
      padding: 0 8px;
      border: 1px solid var(--border);
      border-radius: 10px;
      background: #0d141d;
      color: var(--muted);
      font-size: 12px;
      font-variant-numeric: tabular-nums;
      text-align: center;
      cursor: pointer;
    }

    .zoom-value:hover:not(:disabled) {
      border-color: #415671;
      color: var(--text);
    }

    .zoom-value:disabled {
      cursor: default;
      opacity: 0.35;
    }

    .download-button {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 7px;
      min-height: 38px;
      padding: 0 13px;
      border: 1px solid rgba(86, 180, 255, 0.42);
      border-radius: 10px;
      background: var(--accent-soft);
      color: var(--accent);
      font-size: 12px;
      font-weight: 700;
      white-space: nowrap;
      cursor: pointer;
    }

    .download-button:hover:not(:disabled) {
      border-color: var(--accent);
      background: rgba(86, 180, 255, 0.2);
    }

    .download-button:disabled {
      cursor: default;
      opacity: 0.35;
    }

    .download-button-icon {
      font-size: 17px;
      line-height: 1;
    }

    .logout-button {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 7px;
      min-height: 38px;
      padding: 0 13px;
      border: 1px solid var(--border);
      border-radius: 10px;
      background: var(--panel);
      color: var(--muted);
      font-size: 12px;
      font-weight: 700;
      white-space: nowrap;
      cursor: pointer;
    }

    .logout-button:hover:not(:disabled) {
      border-color: #415671;
      background: var(--panel-hover);
      color: var(--text);
    }

    .logout-button:disabled {
      cursor: default;
      opacity: 0.5;
    }

    .logout-button-icon {
      font-size: 17px;
      line-height: 1;
    }

    .icon-button {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      min-width: 38px;
      height: 38px;
      padding: 0 12px;
      border: 1px solid var(--border);
      border-radius: 10px;
      background: var(--panel);
      cursor: pointer;
    }

    .icon-button:hover:not(:disabled) {
      border-color: #415671;
      background: var(--panel-hover);
    }

    .icon-button:disabled {
      cursor: default;
      opacity: 0.35;
    }

    .viewer-area {
      position: relative;
      display: flex;
      align-items: center;
      justify-content: center;
      flex: 1 1 auto;
      min-width: 0;
      min-height: 0;
      padding: 18px;
      overflow: hidden;
    }

    .image-stage {
      position: relative;
      display: flex;
      align-items: center;
      justify-content: center;
      width: 100%;
      height: 100%;
      min-width: 0;
      min-height: 0;
      border: 1px solid var(--border);
      border-radius: var(--radius);
      overflow: hidden;
      user-select: none;
      -webkit-user-select: none;
      touch-action: none;
      overscroll-behavior: contain;
      -webkit-tap-highlight-color: transparent;
      background:
        linear-gradient(45deg, rgba(255,255,255,0.022) 25%, transparent 25%),
        linear-gradient(-45deg, rgba(255,255,255,0.022) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, rgba(255,255,255,0.022) 75%),
        linear-gradient(-45deg, transparent 75%, rgba(255,255,255,0.022) 75%),
        #080c12;
      background-position: 0 0, 0 8px, 8px -8px, -8px 0;
      background-size: 16px 16px;
      box-shadow: var(--shadow);
    }

    .main-image {
      display: block;
      width: 100%;
      height: 100%;
      object-fit: contain;
      transform-origin: center center;
      transition: transform 120ms ease-out;
      will-change: transform;
      -webkit-user-drag: none;
    }

    .main-image.zoomed {
      cursor: grab;
    }

    .image-stage.interacting .main-image {
      cursor: grabbing;
      transition: none;
    }

    
    .empty-state {
      max-width: 520px;
      padding: 32px;
      color: var(--muted);
      line-height: 1.6;
      text-align: center;
    }

    .empty-state strong {
      display: block;
      margin-bottom: 7px;
      color: var(--text);
      font-size: 17px;
    }

    .loading-overlay {
      position: absolute;
      inset: 0;
      display: flex;
      align-items: center;
      justify-content: center;
      background: rgba(8, 12, 18, 0.62);
      backdrop-filter: blur(3px);
      z-index: 2;
    }

    .spinner {
      width: 34px;
      height: 34px;
      border: 3px solid rgba(255, 255, 255, 0.14);
      border-top-color: var(--accent);
      border-radius: 50%;
      animation: spin 750ms linear infinite;
    }

    @keyframes spin {
      to {
        transform: rotate(360deg);
      }
    }

    .gallery-error {
      position: absolute;
      left: 50%;
      bottom: 20px;
      z-index: 3;
      max-width: calc(100% - 40px);
      padding: 10px 14px;
      border: 1px solid rgba(255, 125, 125, 0.35);
      border-radius: 9px;
      background: rgba(67, 24, 29, 0.94);
      color: #ffd4d4;
      font-size: 13px;
      text-align: center;
      transform: translateX(-50%);
      box-shadow: var(--shadow);
    }

    .thumbnail-strip {
      flex: 0 0 auto;
      min-height: 122px;
      padding: 12px 18px 16px;
      border-top: 1px solid var(--border);
      background: var(--panel);
    }

    .thumbnail-list {
      display: flex;
      align-items: stretch;
      gap: 10px;
      margin: 0;
      padding: 0 2px 2px;
      overflow-x: auto;
      overflow-y: hidden;
      list-style: none;
      scrollbar-color: #3b4c60 transparent;
      scrollbar-width: thin;
    }

    .thumbnail-button {
      position: relative;
      display: block;
      width: 112px;
      height: 84px;
      padding: 0;
      overflow: hidden;
      border: 2px solid transparent;
      border-radius: 10px;
      background: #080c12;
      cursor: pointer;
      flex: 0 0 auto;
    }

    .thumbnail-button:hover {
      border-color: #415671;
    }

    .thumbnail-button.active {
      border-color: var(--accent);
      box-shadow: 0 0 0 3px var(--accent-soft);
    }

    .thumbnail-button img {
      display: block;
      width: 100%;
      height: 100%;
      object-fit: cover;
    }

    .thumbnail-index {
      position: absolute;
      right: 5px;
      bottom: 5px;
      min-width: 22px;
      padding: 3px 5px;
      border-radius: 6px;
      background: rgba(0, 0, 0, 0.7);
      color: white;
      font-size: 10px;
      font-variant-numeric: tabular-nums;
      text-align: center;
    }

    .thumbnail-empty {
      display: flex;
      align-items: center;
      min-height: 84px;
      color: var(--muted);
      font-size: 13px;
    }

    @media (max-width: 780px) {
      html,
      body {
        overflow: auto;
      }

      .app-shell {
        grid-template-columns: 1fr;
        grid-template-rows: minmax(430px, 54vh) minmax(520px, 70vh);
        height: auto;
        min-height: 100%;
      }

      .main {
        min-height: 520px;
      }

      .main-header {
        align-items: flex-start;
        padding-inline: 14px;
      }

      .header-actions {
        max-width: 210px;
      }

      .viewer-area {
        padding: 12px;
      }

      .thumbnail-strip {
        padding-inline: 12px;
      }
    }
