﻿    :root {
      --bg: #f4f5f7;
      --panel: #ffffff;
      --line: #d8dde6;
      --text: #1f2937;
      --muted: #64748b;
      --accent: #1d4ed8;
      --green: rgba(125, 235, 155, 0.14);
      --yellow: rgba(255, 232, 92, 0.16);
      --red: rgba(255, 128, 128, 0.14);
      --green-solid: rgb(125, 235, 155);
      --yellow-solid: rgb(255, 232, 92);
      --red-solid: rgb(255, 128, 128);
    }

    * {
      box-sizing: border-box;
    }

    html {
      overflow-anchor: none;
    }

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

    header {
      position: sticky;
      top: 0;
      z-index: 50;
      display: flex;
      flex-wrap: wrap;
      gap: 0.7rem;
      align-items: center;
      padding: 0.75rem 1rem;
      background: var(--panel);
      border-bottom: 1px solid var(--line);
      box-shadow: 0 1px 10px rgba(15, 23, 42, 0.08);
    }

    h1 {
      margin: 0 0.5rem 0 0;
      font-size: 1.05rem;
      white-space: nowrap;
    }

    button,
    label.fileButton {
      border: 1px solid var(--line);
      border-radius: 0.55rem;
      background: #fff;
      color: var(--text);
      padding: 0.48rem 0.72rem;
      font: inherit;
      cursor: pointer;
      line-height: 1.2;
    }

    button:hover,
    label.fileButton:hover {
      border-color: #94a3b8;
      background: #f8fafc;
    }

    button:disabled {
      opacity: 0.45;
      cursor: not-allowed;
    }

    .primary {
      background: var(--accent);
      border-color: var(--accent);
      color: #fff;
      font-weight: 650;
    }

    .primary:hover {
      background: #1e40af;
      border-color: #1e40af;
    }

    input[type="file"] {
      display: none;
    }

    .spacer {
      flex: 1 1 auto;
    }

    .toggle {
      display: inline-flex;
      gap: 0.35rem;
      align-items: center;
      color: var(--muted);
      font-size: 0.9rem;
      user-select: none;
    }

    #status {
      color: var(--muted);
      font-size: 0.92rem;
      min-width: 12rem;
    }

    main {
      display: grid;
      place-items: center;
      flex: 1 1 auto;
      width: 100%;
      padding: 1rem;
      max-width: 1600px;
      margin: 0 auto;
    }

    body.pdfLoaded main {
      display: block;
    }

    #dropZone {
      min-height: 100px;
      max-width: 300px;
      width: 100%;
      margin: 0 auto;
      border: 1.5px dashed #cbd5e1;
      border-radius: 0.7rem;
      background: #eef2f7;
      padding: 0.55rem 0.75rem;
      overflow-x: auto;
      transition: border-color 0.15s, background 0.15s;
      cursor: pointer;
    }

    #dropZone.hasPdf {
      cursor: default;
    }

    #dropZone.dragover {
      border-color: var(--accent);
      background: #e0ecff;
    }

    #dropZone.hasPdf {
      min-height: auto;
      max-width: none;
      width: auto;
      margin: 0;
      border: 0;
      border-radius: 0;
      background: transparent;
      padding: 0;
      overflow-x: auto;
    }

    #dropZone.hasPdf.dragover {
      border: 0;
      background: transparent;
    }

    #emptyState {
      display: grid;
      place-items: center;
      min-height: 100px;
      color: var(--muted);
      text-align: center;
      padding: 0.35rem;
      font-size: 0.86rem;
      line-height: 1.35;
    }


    #emptyState[hidden],
    #dropZone.hasPdf #emptyState,
    body.pdfLoaded #emptyState {
      display: none !important;
      visibility: hidden !important;
      height: 0 !important;
      min-height: 0 !important;
      padding: 0 !important;
      margin: 0 !important;
      overflow: hidden !important;
    }

    #viewer {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 1rem;
      isolation: isolate;
    }

    #viewer.precisionMode .textLayer {
      pointer-events: none;
      user-select: none;
    }

    #viewer.precisionMode .page {
      cursor: crosshair;
    }

    .pageWrap {
      display: grid;
      grid-template-columns: auto 280px;
      gap: 12px;
      align-items: start;
      justify-content: center;
    }

    .pageComments {
      position: relative;
      min-height: 100%;
      width: 280px;
      pointer-events: none;
    }

    .page {
      position: relative;
      background: white;
      box-shadow: 0 5px 18px rgba(15, 23, 42, 0.18);
      overflow: hidden;
    }

    .page canvas {
      display: block;
      position: absolute;
      inset: 0;
      z-index: 1;
      background: #fff;
    }

    .textLayer {
      position: absolute;
      inset: 0;
      overflow: hidden;
      opacity: 1;
      line-height: 1;
      z-index: 2;
      transform-origin: 0 0;
      text-size-adjust: none;
      -webkit-text-size-adjust: none;
      forced-color-adjust: none;
      user-select: text;
    }

    .textLayer>span,
    .textLayer>br {
      color: transparent;
      position: absolute;
      white-space: pre;
      cursor: text;
      transform-origin: 0% 0%;
    }

    .textLayer ::selection {
      background: rgba(59, 130, 246, 0.30);
    }

    .annotationLayer {
      position: absolute;
      inset: 0;
      z-index: 3;
      pointer-events: none;
    }

    .mark,
    .selectionPreview {
      position: absolute;
      border-radius: 2px;
      mix-blend-mode: multiply;
    }

    .mark {
      pointer-events: auto;
      cursor: pointer;
    }

    .mark:hover,
    .mark.activeDeleteTarget {
      outline: 1px solid rgba(15, 23, 42, 0.38);
    }

    .selectionPreview {
      pointer-events: none;
    }

    .mark.green {
      background: var(--green);
    }

    .mark.yellow {
      background: var(--yellow);
    }

    .mark.red {
      background: var(--red);
    }

    .selectionPreview {
      z-index: 5;
      background: rgba(59, 130, 246, 0.22);
      outline: 1px solid rgba(37, 99, 235, 0.36);
    }

    .selectionBox {
      position: absolute;
      z-index: 5;
      border: 2px dashed #1d4ed8;
      background: rgba(29, 78, 216, 0.10);
      border-radius: 2px;
      pointer-events: none;
    }

    .commentBubble {
      position: absolute;
      z-index: 6;
      left: 0;
      width: 260px;
      min-height: 32px;
      max-height: 180px;
      overflow: auto;
      padding: 0.45rem 0.55rem;
      border: 1px solid rgba(15, 23, 42, 0.22);
      border-left-width: 5px;
      border-radius: 0.5rem;
      background: rgba(255, 255, 255, 0.96);
      box-shadow: 0 2px 8px rgba(15, 23, 42, 0.14);
      color: #111827;
      font-size: 12px;
      line-height: 1.3;
      pointer-events: auto;
      cursor: pointer;
      white-space: pre-wrap;
      overflow-wrap: anywhere;
    }

    .commentBubble:hover,
    .commentBubble.activeDeleteTarget {
      outline: 1px solid rgba(15, 23, 42, 0.38);
    }

    .commentBubble.green {
      border-left-color: var(--green-solid);
    }

    .commentBubble.yellow {
      border-left-color: var(--yellow-solid);
    }

    .commentBubble.red {
      border-left-color: var(--red-solid);
    }

    aside {
      display: none;
      position: sticky;
      top: 5rem;
      align-self: start;
      max-height: calc(100vh - 6rem);
      overflow: auto;
      background: var(--panel);
      border: 1px solid var(--line);
      border-radius: 0.8rem;
      padding: 1rem;
    }

    aside h2 {
      margin: 0 0 0.7rem;
      font-size: 1rem;
    }

    .hint {
      color: var(--muted);
      font-size: 0.9rem;
      line-height: 1.45;
    }

    #commentList {
      display: grid;
      gap: 0.6rem;
      margin-top: 0.75rem;
    }

    .commentCard {
      border: 1px solid var(--line);
      border-radius: 0.65rem;
      padding: 0.7rem;
      background: #fff;
    }

    .commentMeta {
      display: flex;
      gap: 0.45rem;
      align-items: center;
      color: var(--muted);
      font-size: 0.83rem;
      margin-bottom: 0.45rem;
    }

    .dot {
      width: 0.8rem;
      height: 0.8rem;
      border-radius: 50%;
      border: 1px solid rgba(15, 23, 42, 0.22);
      flex: 0 0 auto;
    }

    .dot.green {
      background: var(--green-solid);
    }

    .dot.yellow {
      background: var(--yellow-solid);
    }

    .dot.red {
      background: var(--red-solid);
    }

    .commentText {
      font-size: 0.88rem;
      line-height: 1.35;
      white-space: pre-wrap;
      overflow-wrap: anywhere;
    }

    .cardActions {
      display: flex;
      gap: 0.45rem;
      margin-top: 0.6rem;
    }

    .smallButton {
      padding: 0.35rem 0.5rem;
      font-size: 0.82rem;
      border-radius: 0.45rem;
    }

    #popup {
      position: fixed;
      z-index: 100;
      width: min(280px, calc(100vw - 2rem));
      background: #fff;
      border: 1px solid var(--line);
      border-radius: 0.8rem;
      box-shadow: 0 16px 40px rgba(15, 23, 42, 0.24);
      padding: 0.75rem;
    }

    #popup[hidden] {
      display: none;
    }

    #popup textarea {
      width: 100%;
      min-height: 72px;
      resize: vertical;
      border: 1px solid var(--line);
      border-radius: 0.55rem;
      padding: 0.55rem;
      font: inherit;
      margin-bottom: 0.65rem;
    }

    .colorGrid {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 0.5rem;
    }

    .colorButton {
      height: 38px;
      border: 1px solid rgba(15, 23, 42, 0.18);
      color: transparent;
      font-size: 0;
    }

    .colorButton.green {
      background: var(--green-solid);
    }

    .colorButton.yellow {
      background: var(--yellow-solid);
    }

    .colorButton.red {
      background: var(--red-solid);
    }

    .popupActions {
      display: flex;
      justify-content: flex-end;
      align-items: center;
      margin-top: 0.6rem;
    }


    .zoomControl {
      display: inline-flex;
      align-items: center;
      gap: 0.45rem;
      color: var(--muted);
      font-size: 0.9rem;
      white-space: nowrap;
    }

    #zoomSlider {
      width: 140px;
    }

    #zoomValue {
      min-width: 3.2rem;
      text-align: right;
      color: var(--text);
    }

    .versionBadge {
      display: inline-flex;
      align-items: center;
      padding: 0.15rem 0.45rem;
      border-radius: 999px;
      background: #e2e8f0;
      color: #475569;
      font-size: 0.75rem;
      font-weight: 700;
      margin-left: -0.3rem;
    }

    #deleteFloating {
      position: fixed;
      z-index: 140;
      display: inline-flex;
      gap: 0.35rem;
      align-items: center;
      padding: 0.25rem;
      border-radius: 999px;
      border: 1px solid rgba(15, 23, 42, 0.16);
      background: #fff;
      box-shadow: 0 10px 28px rgba(15, 23, 42, 0.22);
    }

    #deleteFloating[hidden] {
      display: none;
    }

    #deleteFloating button {
      width: 36px;
      height: 36px;
      display: grid;
      place-items: center;
      border-radius: 999px;
      padding: 0;
      background: #fff;
    }

    #trashFloating {
      border-color: #fecaca;
      color: #991b1b;
    }

    #trashFloating:hover {
      background: #fef2f2;
      border-color: #fca5a5;
    }

    #addCommentFloating:hover {
      filter: brightness(0.98);
    }

    .floatingColorButton {
      border: 1px solid rgba(15, 23, 42, 0.2);
      color: transparent;
      font-size: 0;
      box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.42);
    }

    .floatingColorButton:hover {
      transform: translateY(-1px);
      box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.5), 0 3px 10px rgba(15, 23, 42, 0.16);
    }

    .floatingColorButton.green {
      background: var(--green-solid);
    }

    .floatingColorButton.yellow {
      background: var(--yellow-solid);
    }

    .floatingColorButton.red {
      background: var(--red-solid);
    }

    #deleteFloating svg {
      width: 19px;
      height: 19px;
      pointer-events: none;
    }

    #popup.commentOnly .colorGrid {
      display: none;
    }

    #popup.commentOnly #saveCommentBtn {
      display: inline-block;
    }

    #toast {
      position: fixed;
      left: 50%;
      bottom: 1.25rem;
      transform: translateX(-50%);
      z-index: 120;
      background: #111827;
      color: white;
      padding: 0.65rem 0.9rem;
      border-radius: 999px;
      box-shadow: 0 10px 28px rgba(15, 23, 42, 0.25);
      font-size: 0.9rem;
      max-width: min(720px, calc(100vw - 2rem));
      text-align: center;
    }

    #toast[hidden] {
      display: none;
    }

    @media (max-width: 980px) {
      .pageWrap {
        grid-template-columns: auto;
      }

      .pageComments {
        width: min(280px, 100%);
        min-height: 0;
      }

      header {
        align-items: stretch;
      }

      #status {
        min-width: 0;
      }
    }