:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "Meiryo", system-ui, sans-serif;
  font-size: 16px;
  color: #172033;
  background: #f4f7fb;
  --blue: #0b5cad;
  --blue-dark: #063d78;
  --blue-soft: #e8f2ff;
  --red: #b42318;
  --red-dark: #7a1510;
  --border: #aab7c7;
  --muted: #4c5b70;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  min-width: 320px;
  margin: 0;
}

body {
  overflow: hidden;
  background: #f4f7fb;
  color: #172033;
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button:focus-visible,
input:focus-visible {
  outline: 4px solid #ffbf47;
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.app-shell {
  width: 100%;
  height: 100dvh;
  min-height: 440px;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

.screen {
  width: 100%;
  height: 100%;
}

.home-screen {
  display: grid;
  place-items: center;
  overflow: auto;
}

.home-card,
.loading-card {
  width: min(680px, 100%);
  padding: clamp(28px, 6vw, 64px) clamp(20px, 6vw, 64px);
  border: 2px solid #d6e0ed;
  border-radius: 28px;
  background: #ffffff;
  box-shadow: 0 18px 48px rgb(24 51 87 / 12%);
  text-align: center;
}

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

.home-card h1 {
  margin-bottom: 18px;
  color: var(--blue-dark);
  font-size: clamp(3rem, 8vw, 5rem);
  line-height: 1;
  letter-spacing: 0.04em;
}

.home-lead {
  max-width: 30rem;
  margin: 0 auto 38px;
  color: #26364c;
  font-size: clamp(1.3rem, 3vw, 1.75rem);
  font-weight: 600;
  line-height: 1.55;
}

.home-actions {
  display: grid;
  gap: 18px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 76px;
  padding: 14px 22px;
  border: 3px solid transparent;
  border-radius: 18px;
  cursor: pointer;
  font-size: clamp(1.35rem, 3vw, 1.85rem);
  font-weight: 750;
  line-height: 1.2;
  text-align: center;
  transition: background-color 120ms ease, border-color 120ms ease, transform 120ms ease;
}

.button:active {
  transform: translateY(1px);
}

.button-primary {
  border-color: var(--blue);
  background: var(--blue);
  color: #ffffff;
}

.button-primary:hover {
  background: var(--blue-dark);
  border-color: var(--blue-dark);
}

.button-secondary {
  border-color: var(--blue);
  background: #ffffff;
  color: var(--blue-dark);
}

.button-secondary:hover {
  background: var(--blue-soft);
}

.button-danger {
  width: min(420px, 100%);
  border-color: var(--red);
  background: var(--red);
  color: #ffffff;
}

.button-danger:hover {
  border-color: var(--red-dark);
  background: var(--red-dark);
}

.button-small {
  min-width: 118px;
  min-height: 72px;
  padding-inline: 20px;
}

.message {
  min-height: 1.8em;
  margin: 24px 0 0;
  color: var(--muted);
  font-size: clamp(1.15rem, 2.5vw, 1.45rem);
  font-weight: 650;
  line-height: 1.45;
}

.message[data-tone="error"],
.result-status[data-tone="warning"],
.result-status[data-tone="not-found"] {
  color: #9d2016;
}

.result-status[data-tone="success"] {
  color: #0b6b3a;
}

.loading-screen {
  display: grid;
  place-items: center;
  overflow: auto;
}

.loading-card h1 {
  margin-bottom: 18px;
  color: var(--blue-dark);
  font-size: clamp(2rem, 6vw, 3.6rem);
  line-height: 1.2;
}

.loading-card p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: clamp(1.3rem, 3vw, 1.8rem);
  font-weight: 650;
}

.loading-mark {
  width: 58px;
  height: 58px;
  margin: 0 auto 26px;
  border: 7px solid #cfe0f4;
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: turn 900ms linear infinite;
}

@keyframes turn {
  to {
    transform: rotate(360deg);
  }
}

.search-screen {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
  overflow: hidden;
}

.search-header {
  width: min(100%, 980px);
  margin: 0 auto;
}

.search-header h1 {
  margin: 0 0 12px;
  color: var(--blue-dark);
  font-size: clamp(1.8rem, 4vw, 2.7rem);
  line-height: 1.15;
}

.search-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: stretch;
}

.search-form input {
  width: 100%;
  min-width: 0;
  min-height: 76px;
  padding: 12px 18px;
  border: 3px solid var(--blue);
  border-radius: 18px;
  background: #ffffff;
  color: #101828;
  font-size: clamp(1.45rem, 3.5vw, 2rem);
  font-weight: 650;
  line-height: 1.25;
}

.search-form input::placeholder {
  color: #65758a;
  opacity: 1;
  font-weight: 500;
}

.search-actions {
  display: flex;
  gap: 12px;
}

.result-status {
  min-height: 1.5em;
  margin: 10px 0 0;
  color: #26364c;
  font-size: clamp(1.35rem, 3vw, 1.9rem);
  font-weight: 800;
  line-height: 1.25;
}

.page-area {
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 2px 0;
}

.pdf-page {
  position: relative;
  flex: 0 1 auto;
  max-width: 100%;
  max-height: 100%;
  overflow: visible;
  border: 0;
  outline: 1px solid #aab7c7;
  background: #ffffff;
  box-shadow: 0 8px 26px rgb(24 51 87 / 18%);
}

.pdf-canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #ffffff;
}

.highlight-layer {
  position: absolute;
  inset: 0;
  overflow: visible;
  pointer-events: none;
}

.highlight-rect {
  position: absolute;
  min-width: 8px;
  min-height: 8px;
  border: 4px solid #d97706;
  border-radius: 7px;
  background: rgb(255 208 0 / 54%);
  box-shadow: 0 0 0 2px rgb(255 255 255 / 86%), 0 2px 9px rgb(109 69 0 / 42%);
}

.search-footer {
  display: flex;
  justify-content: center;
  padding-top: 2px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

@media (max-width: 640px) {
  .search-form {
    grid-template-columns: 1fr;
  }

  .search-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .button-small {
    width: 100%;
  }
}

@media (max-height: 680px) {
  .app-shell {
    padding-top: max(10px, env(safe-area-inset-top));
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }

  .home-card,
  .loading-card {
    padding-block: 24px;
  }

  .home-lead {
    margin-bottom: 22px;
  }

  .button,
  .button-small,
  .search-form input {
    min-height: 64px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    transition-duration: 1ms !important;
  }
}

@media (prefers-contrast: more) {
  .button,
  .search-form input,
  .pdf-page {
    border-width: 4px;
  }
}

noscript {
  display: block;
  padding: 24px;
  color: #9d2016;
  font-size: 1.4rem;
  font-weight: 700;
}
