:root {
  --bg: #eef6ff;
  --panel: #ffffff;
  --panel-soft: #f5f9ff;
  --ink: #172432;
  --muted: #5e6d7d;
  --line: #bfd3e6;
  --accent: #1d6fb8;
  --accent-strong: #155893;
  --accent-soft: #e5f2ff;
  --blue-highlight: rgba(75, 143, 226, 0.45);
  --red-highlight: rgba(231, 79, 67, 0.48);
  --yellow-highlight: rgba(255, 219, 86, 0.62);
  --shadow: 0 16px 34px rgba(23, 64, 110, 0.13);
  --font: "Segoe UI", "Yu Gothic UI", "Meiryo", sans-serif;
  --rune-font: "GloranthaCoreRunes", var(--font);
}

@font-face {
  font-family: "GloranthaCoreRunes";
  src: url("../font/GloranthaCoreRunes1.5.woff2") format("woff2");
  font-display: swap;
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  background: linear-gradient(180deg, #eef6ff 0%, #dbeaff 100%);
  font-family: var(--font);
}

body { min-height: 100vh; }

.mobile-blocker {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
  text-align: center;
  color: #fff;
  background: #666;
  font-size: 24px;
  font-weight: 700;
}

.app-shell {
  height: 100vh;
  padding: 0;
  overflow: hidden;
}

.center-screen {
  min-height: calc(100vh - 48px);
  place-items: center;
}

.screen { display: none; }
.screen.active {
  display: block;
  height: 100%;
  overflow: auto;
}
.screen.active.center-screen { display: grid; }

.panel {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.start-panel {
  display: grid;
  gap: 18px;
  justify-items: center;
  text-align: center;
}

.start-title-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  flex-wrap: wrap;
}

.start-icon {
  width: 92px;
  height: 92px;
  object-fit: contain;
  filter: drop-shadow(0 14px 28px rgba(29, 111, 184, 0.18));
}

.title {
  margin: 0;
  font-size: 52px;
  line-height: 1.1;
}

.title::first-letter {
  font-family: var(--rune-font);
}

.subtitle {
  max-width: 720px;
  margin: 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.7;
}

.panel-header,
.toolbar,
.actions,
.input-row,
.pdf-load-grid {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.panel-header {
  justify-content: space-between;
}

.panel-header h2,
.panel-header h1 { margin: 0; }

.language-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

button,
.button-like,
select,
input {
  font: inherit;
}

button,
.button-like {
  min-height: 42px;
  padding: 9px 16px;
  border: 1px solid #9db3a6;
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.14s ease, box-shadow 0.14s ease, background 0.14s ease;
}

button:hover,
.button-like:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(30, 42, 34, 0.12);
}

.button-like.is-loaded,
button.is-loaded {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent-strong);
}

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

.danger {
  color: #fff;
  background: #a4463d;
  border-color: #84352f;
}

select,
input[type="text"] {
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

input[type="text"] { min-width: 220px; }

.hidden { display: none !important; }

.guide-list {
  display: grid;
  gap: 14px;
  margin-top: 18px;
  justify-items: center;
}

.guidance-top-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  width: min(920px, 100%);
}

.guide-block {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.guide-block p { margin: 0 0 12px; line-height: 1.65; }

.guidance-pdf-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  width: min(920px, 100%);
}

.pdf-load-card {
  display: grid;
  gap: 12px;
  align-content: start;
}

.pdf-load-card h3 {
  margin: 0;
}

.file-name,
.loaded-files {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.loaded-files {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.loaded-files span {
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.drop-zone {
  min-height: 96px;
  display: grid;
  place-items: center;
  padding: 18px;
  border: 2px dashed #7aa99a;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  text-align: center;
  font-weight: 700;
}

.drop-zone.dragover,
.pdf-load-card.dragover,
.pdf-view.dragover {
  outline: 3px solid rgba(29, 111, 184, 0.42);
  background: #dff0ff;
}

.screen.workspace.active {
  display: block;
  height: 100vh;
  min-height: 0;
  overflow: hidden;
}

.main-panel {
  position: relative;
  width: 100%;
  max-width: none;
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 4px;
  padding: 2px 10px 8px;
  border: 0;
  border-radius: 0;
  margin: 0;
  box-shadow: none;
  background: transparent;
  align-content: start;
}

.workspace-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  min-width: 0;
}

.workspace-brand-area {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
  flex: 0 1 auto;
}

.workspace-brand {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding-top: 2px;
  flex: 0 0 auto;
}

.workspace-brand-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: block;
  box-shadow: 0 8px 18px rgba(29, 111, 184, 0.22);
}

.workspace-brand-text {
  font-size: 12px;
  font-weight: 700;
  color: #55667a;
  white-space: nowrap;
}

.workspace-control-area {
  display: grid;
  gap: 2px;
  width: min(980px, 100%);
  flex: 1 1 980px;
  min-width: 0;
}

.workspace-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.workspace-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.workspace-topline,
.workspace-pdf-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.workspace-topline {
  justify-content: space-between;
  padding: 0 0 2px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.workspace-topline-left,
.workspace-topline-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.workspace-topline-left {
  justify-content: flex-start;
  min-width: 0;
}

.workspace-topline-right {
  justify-content: flex-end;
  margin-left: auto;
}

.workspace-topline-file {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.workspace-topline-file-name {
  min-width: 0;
  max-width: 180px;
  color: var(--muted);
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace-header-actions {
  margin-left: auto;
}

.workspace-row-spacer {
  flex: 1 1 auto;
}

.workspace-files-card,
.workspace-entry-card {
  display: grid;
  gap: 8px;
  padding: 6px 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.workspace-entry-card {
  flex: 1 1 520px;
  min-width: 0;
  padding: 0;
}

.workspace-section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.status-text {
  color: var(--muted);
  min-height: 0;
  line-height: 1.4;
  padding: 0;
  font-size: 13px;
}

.status-text.is-error {
  color: #9b2c2c;
  font-weight: 700;
}

.pdf-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-items: stretch;
}

.dictionary-entry-row {
  display: flex;
  align-items: end;
  justify-content: flex-start;
  gap: 10px;
  padding-top: 0;
  position: relative;
  z-index: 2;
  flex-wrap: wrap;
}

.entry-field {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-width: 0;
  margin: 0;
}

.entry-inline-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 0 1 auto;
}

.entry-inline-label {
  white-space: nowrap;
  font-weight: 700;
  font-size: 13px;
  color: var(--muted);
}

.entry-field input {
  width: 100%;
  min-width: 0;
}

.entry-inline-field input {
  width: 180px;
  min-width: 160px;
}

.entry-actions {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 0;
}

.pdf-pane {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 6px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  position: relative;
}

.pdf-pane h3 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
}

.pdf-pane-title-group {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
  flex-wrap: wrap;
}

.pdf-pane-file {
  font-size: 13px;
  line-height: 1.3;
  color: #7d8896;
  overflow-wrap: anywhere;
}

.pdf-pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.page-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.page-spinner {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.page-control input {
  width: 52px;
  min-height: 34px;
  border: 0;
  border-radius: 0;
  text-align: center;
  padding: 6px 4px;
  appearance: textfield;
  -moz-appearance: textfield;
}

.page-control input::-webkit-outer-spin-button,
.page-control input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.page-spinner-buttons {
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--line);
}

.page-step-button {
  min-height: 17px;
  width: 22px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: #f7fafc;
  color: #64748b;
  font-size: 10px;
  line-height: 1;
  box-shadow: none;
}

.page-step-button:hover {
  transform: none;
  box-shadow: none;
  background: #edf2f7;
}

.page-step-button + .page-step-button {
  border-top: 1px solid var(--line);
}

.pdf-view {
  position: relative;
  min-height: 0;
  height: 100%;
  min-height: calc(100vh - 96px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 4px;
}

.loaded-files {
  align-items: center;
  gap: 8px;
}

.pdf-render-host {
  width: 100%;
  min-height: 620px;
}

.pdf-page-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
  padding-bottom: 8px;
}

.pdf-page-stack.preparing {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  visibility: hidden;
  pointer-events: none;
}

.pdf-page-wrap {
  width: 100%;
  display: flex;
  justify-content: center;
  min-height: 48px;
}

.pdf-page-note {
  width: min(100%, 680px);
  min-height: 96px;
  display: grid;
  place-items: center;
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.88);
  color: var(--muted);
  text-align: center;
}

.pdf-page-note.is-error {
  color: #9b2c2c;
  border-color: rgba(155, 44, 44, 0.35);
  background: rgba(255, 244, 244, 0.92);
}

.pdf-canvas-wrap {
  position: relative;
  background: #fff;
  box-shadow: 0 10px 24px rgba(24, 30, 24, 0.15);
}

.pdf-page-canvas {
  display: block;
  position: relative;
  z-index: 0;
}

.pdf-text-layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  user-select: text;
  z-index: 2;
}

.pdf-text-item {
  position: absolute;
  z-index: 1;
  color: transparent;
  white-space: pre;
  transform-origin: left top;
  line-height: 1;
  border-radius: 2px;
}

.pdf-item-highlight {
  position: absolute;
  z-index: 0;
  border-radius: 2px;
  pointer-events: none;
}

.pdf-inline-highlight {
  border-radius: 2px;
}

.pdf-item-highlight.csv-hit,
.pdf-inline-highlight.csv-hit {
  background: var(--blue-highlight);
}

.pdf-item-highlight.browser-hit,
.pdf-inline-highlight.browser-hit {
  background: var(--yellow-highlight);
}

.pdf-item-highlight.incomplete-hit,
.pdf-inline-highlight.incomplete-hit {
  background: var(--red-highlight);
}

.dictionary-modal-backdrop {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  z-index: 40;
  background: rgba(20, 26, 22, 0.24);
}

.dictionary-modal-backdrop.visible { display: grid; }

.dictionary-modal {
  width: min(720px, calc(100vw - 48px));
  max-height: min(680px, calc(100vh - 48px));
  overflow: hidden;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.dictionary-modal-search {
  display: grid;
}

.dictionary-modal-search input {
  width: 100%;
}

.dictionary-list {
  overflow: auto;
  display: grid;
  gap: 10px;
  margin: 0;
  align-content: start;
}

.dictionary-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  cursor: pointer;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.dictionary-row:hover {
  border-color: rgba(29, 111, 184, 0.45);
  box-shadow: 0 8px 18px rgba(23, 64, 110, 0.08);
}

.dictionary-row.is-selected {
  border-color: rgba(29, 111, 184, 0.82);
  background: rgba(229, 242, 255, 0.95);
  box-shadow: 0 10px 20px rgba(23, 64, 110, 0.12);
}

.dictionary-modal-actions {
  justify-content: flex-end;
}

.hint-note {
  position: absolute;
  top: 88px;
  right: 12px;
  z-index: 20;
  width: min(430px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.hint-note.closed { display: none; }

.hint-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 6px 10px;
  background: var(--panel-soft);
  border-radius: 8px 8px 0 0;
  cursor: move;
}

.hint-note.dragging {
  user-select: none;
}

.hint-body {
  display: block;
  padding: 8px 10px;
  line-height: 1.55;
  font-size: 14px;
}

.hint-body p { margin: 0 0 4px; }

.translation-popover {
  position: fixed;
  z-index: 85;
  max-width: 360px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  box-shadow: var(--shadow);
  line-height: 1.5;
  overflow-wrap: anywhere;
  pointer-events: none;
}

.translation-popover.is-loading {
  color: var(--muted);
}

.translation-popover-stage {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-strong);
}

.translation-popover-source {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

.translation-popover-body {
  margin-top: 8px;
  white-space: pre-wrap;
}

.translation-popover-detail {
  margin-top: 8px;
  font-size: 11px;
  color: #6b7280;
  word-break: break-word;
}

.workspace-logo-link img {
  width: 56px;
  max-width: 12vw;
  display: block;
  filter: drop-shadow(0 8px 14px rgba(20, 26, 22, 0.25));
}

.workspace-logo-link {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 18;
  display: block;
}

.workspace-logo-link:hover img { animation: logo-hop 0.42s ease; }

@keyframes logo-hop {
  0% { transform: translateY(0); }
  42% { transform: translateY(-7px); }
  100% { transform: translateY(0); }
}

@media (max-width: 900px) {
  .workspace-header,
  .workspace-brand-area {
    flex-direction: column;
  }

  .workspace-control-area,
  .workspace-files-card {
    width: 100%;
    max-width: none;
  }

  .workspace-topline {
    justify-content: flex-start;
  }

  .workspace-topline-right {
    margin-left: 0;
    justify-content: flex-start;
  }

  .guidance-pdf-cards,
  .pdf-grid { grid-template-columns: 1fr; }
  .workspace { height: 100vh; }
  .main-panel { min-height: 0; }
  .entry-actions {
    padding-top: 0;
    margin-left: 0;
  }
}
