:root {
  --bg: #edf4fa;
  --surface: #ffffff;
  --ink: #102a43;
  --muted: #53687c;
  --line: #d2dfeb;
  --accent: #19608c;
  --accent-soft: #dcecf8;
  --highlight: rgba(255, 214, 101, 0.45);
  --word-highlight: rgba(126, 223, 180, 0.42);
  --free-highlight: rgba(74, 144, 226, 0.28);
  --free-highlight-selected: rgba(35, 111, 205, 0.64);
  --underline-select-highlight: rgba(245, 64, 64, 0.24);
  --underline-select-strong: rgba(229, 57, 53, 0.62);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  min-height: 100%;
  font-family: "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  color: var(--ink);
  background: radial-gradient(1200px 700px at -15% -20%, #dcecf8 0%, transparent 62%), var(--bg);
}

button,
input {
  font: inherit;
}

.screen[hidden] {
  display: none;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
}

.title-wrap h1 {
  margin: 0;
  font-size: 1rem;
}

.title-wrap p {
  margin: 2px 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.main-content {
  padding: 16px;
  display: grid;
  gap: 14px;
}

.hero-card,
.catalog-card,
.resume-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  padding: 14px;
}

.hero-card h2 {
  margin: 0;
  font-size: 1.02rem;
}

.hero-card p {
  margin: 6px 0 0;
  font-size: 0.88rem;
  color: var(--muted);
}

.main-actions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.resume-card {
  text-align: center;
}

.resume-card h3 {
  margin: 0;
  font-size: 0.98rem;
}

.resume-file {
  margin: 8px 0 0;
  font-size: 0.9rem;
  font-weight: 600;
}

.resume-meta {
  margin: 5px 0 12px;
  font-size: 0.82rem;
  color: var(--muted);
}

.catalog-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.catalog-head h3 {
  margin: 0;
  font-size: 0.96rem;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.pdf-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pdf-item-btn {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 10px;
  text-align: left;
  cursor: pointer;
  color: var(--ink);
  transition: background-color 0.16s ease;
}

.pdf-item-btn:hover {
  background: #f5f9fd;
}

button.small,
button.ghost,
button.fill,
button.tool-btn {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  cursor: pointer;
  padding: 8px 10px;
}

button.fill {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

button.ghost {
  color: var(--accent);
}

.reader-screen {
  height: 100dvh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.reader-toolbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
}

.back-btn {
  min-width: 38px;
  padding: 7px 10px;
}

.doc-meta-wrap {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 7px;
  overflow: hidden;
  white-space: nowrap;
}

#currentFile {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.88rem;
}

#pageInfo {
  color: var(--muted);
  font-size: 0.78rem;
  flex-shrink: 0;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  overflow-x: auto;
  white-space: nowrap;
  max-width: 56vw;
  scrollbar-width: none;
}

.toolbar-actions::-webkit-scrollbar {
  display: none;
}

.tool-btn {
  min-width: 34px;
  padding: 6px 8px;
  font-size: 0.88rem;
}

.tool-btn.active {
  border-color: #7fb3d1;
  background: var(--accent-soft);
}

.underline-color-input {
  width: 34px;
  min-width: 34px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 2px;
  cursor: pointer;
}

.underline-color-input[hidden] {
  display: none;
}

#zoomInfo {
  min-width: 44px;
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
}

.viewer-box {
  flex: 1;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 10px 8px 16px;
}

body.reader-active {
  overflow: hidden;
}

.pdf-pages {
  margin: 0 auto;
  width: min(100%, 1040px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.page-shell {
  position: relative;
  width: 100%;
  max-width: 980px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 8px;
}

.page-shell.loading-page .page-stage {
  background: linear-gradient(120deg, #f4f8fc 20%, #eef4fa 40%, #f4f8fc 60%);
  background-size: 240% 100%;
  animation: pagePulse 1.4s ease-in-out infinite;
}

.page-shell.loading-page .page-canvas {
  opacity: 0;
}

.page-shell.loading-error .page-stage {
  background: #fff0f0;
}

.page-badge {
  margin: 0 0 6px;
  font-size: 0.74rem;
  color: var(--muted);
}

.page-stage {
  position: relative;
}

.page-canvas {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  border-radius: 2px;
  box-shadow: 0 10px 30px rgba(16, 42, 67, 0.12);
}

@keyframes pagePulse {
  0% {
    background-position: 0% 50%;
  }
  100% {
    background-position: 100% 50%;
  }
}

.segment-layer,
.annotation-layer,
.bubble-layer {
  position: absolute;
  inset: 0;
}

.annotation-layer {
  z-index: 1;
  pointer-events: none;
}

.segment-layer {
  z-index: 2;
  pointer-events: none;
}

.segment-hit {
  position: absolute;
  border: 0;
  border-radius: 7px;
  background: var(--highlight);
  opacity: 0;
  pointer-events: none;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.page-shell.translate-active .segment-hit {
  opacity: 0.48;
  pointer-events: auto;
}

.page-shell.translate-active .segment-hit:hover {
  opacity: 0.7;
}

.page-shell.word-active .segment-hit {
  opacity: 0.46;
  pointer-events: auto;
}

.page-shell.word-active .segment-hit.word-hit {
  background: var(--word-highlight);
}

.page-shell.word-active .segment-hit:hover {
  opacity: 0.68;
}

.page-shell.freestyle-active .segment-hit {
  opacity: 0.46;
  pointer-events: auto;
}

.page-shell.freestyle-active .segment-hit.freestyle-hit {
  background: var(--free-highlight);
  touch-action: none;
}

.page-shell.freestyle-active .segment-hit:hover {
  opacity: 0.72;
}

.page-shell.freestyle-active .segment-hit.freestyle-hit.selected {
  background: var(--free-highlight-selected);
  opacity: 0.96;
}

.page-shell.underline-active .segment-hit {
  opacity: 0.44;
  pointer-events: auto;
}

.page-shell.underline-active .segment-hit.word-hit {
  background: var(--underline-select-highlight);
  touch-action: none;
}

.page-shell.underline-active .segment-hit:hover {
  opacity: 0.72;
}

.page-shell.underline-active .segment-hit.word-hit.selected {
  background: var(--underline-select-strong);
  opacity: 0.96;
}

.page-shell.erase-active .annotation-hit {
  opacity: 0.82;
  pointer-events: auto;
}

.annotation-hit {
  position: absolute;
  border: 1px dashed rgba(208, 67, 67, 0.72);
  border-radius: 8px;
  background: rgba(245, 64, 64, 0.18);
  opacity: 0;
  pointer-events: none;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.underline-mark {
  position: absolute;
  border-radius: 999px;
  pointer-events: none;
}

.segment-hit.selected {
  opacity: 0.92;
  outline: none;
}

.bubble-layer {
  z-index: 3;
  pointer-events: none;
}

.translation-bubble {
  position: absolute;
  max-width: min(90%, 420px);
  border: 1px solid #95bdd8;
  border-radius: 12px;
  background: #f6fbff;
  padding: 9px 10px;
  box-shadow: 0 10px 24px rgba(16, 42, 67, 0.17);
}

.translation-bubble::before {
  content: "";
  position: absolute;
  left: 14px;
  top: -8px;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-bottom: 8px solid #95bdd8;
}

.translation-bubble::after {
  content: "";
  position: absolute;
  left: 14px;
  top: -7px;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-bottom: 8px solid #f6fbff;
}

.bubble-source {
  margin: 0;
  font-size: 0.74rem;
  color: var(--muted);
  line-height: 1.35;
  white-space: pre-wrap;
}

.bubble-text {
  margin: 4px 0 0;
  font-size: 0.86rem;
  color: var(--ink);
  line-height: 1.4;
}

.empty-state {
  margin: 20px auto;
  width: min(100%, 620px);
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
  padding: 16px;
  color: var(--muted);
}

.empty-state p {
  margin: 4px 0;
}

@media (min-width: 900px) {
  .main-content {
    grid-template-columns: minmax(330px, 430px) 1fr;
    align-items: start;
  }

  .resume-card {
    grid-column: 1 / -1;
    width: min(100%, 700px);
    justify-self: center;
  }

  .reader-toolbar {
    padding-left: 14px;
    padding-right: 14px;
  }

  .viewer-box {
    padding-left: 14px;
    padding-right: 14px;
  }

  .toolbar-actions {
    max-width: none;
  }
}
