:root {
  color-scheme: light dark;
  --bg: #f6f8fb;
  --shade-1: #ffffff;
  --shade-2: #eef3f8;
  --shade-3: #dbe4ee;
  --text: #1c2733;
  --muted: #617083;
  --accent: #006d80;
  --accent-dark: #004f5f;
  --alert: #b42318;
  --panel-bg: rgba(255, 255, 255, 0.94);
  --button-bg: #006d80;
  --button-text: #ffffff;
  --selected-bg: #12313b;
  --selected-text: #ffffff;
  --focus-ring: rgba(0, 109, 128, 0.35);
  --shadow: 0 16px 36px rgba(28, 39, 51, 0.14);
  --viewport-width: 1366px;
  --viewport-height: 768px;
  --page-height: 2800px;
  --left-shift-y: 0px;
  --right-shift-x: 0px;
  --right-shift-y: 0px;
  --right-opacity: 0.5;
  --swipe: 50%;
  --workspace-width: calc(100vw - 32px);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 12%, rgba(0, 109, 128, 0.1), transparent 28rem),
    linear-gradient(90deg, rgba(28, 39, 51, 0.05) 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(180deg, rgba(28, 39, 51, 0.05) 1px, transparent 1px) 0 0 / 24px 24px,
    var(--bg);
  color: var(--text);
  font-family: "Noto Sans JP", "Yu Gothic", "Hiragino Kaku Gothic ProN", Meiryo, system-ui, sans-serif;
  letter-spacing: 0;
}

a {
  color: var(--accent-dark);
}

.skip-link {
  position: fixed;
  left: 16px;
  top: 12px;
  z-index: 30;
  transform: translateY(-180%);
  padding: 8px 12px;
  background: var(--text);
  color: #fff;
}

.skip-link:focus {
  transform: translateY(0);
}

.mobile-warning {
  display: none;
}

.hero {
  max-width: 980px;
  margin: 0 auto;
  padding: 28px 20px 18px;
  text-align: center;
}

.top-links {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 12px 18px;
  margin-bottom: 18px;
  font-size: 0.82rem;
  font-weight: 700;
}

.language-switch {
  display: inline-grid;
  grid-template-columns: repeat(2, auto);
  overflow: hidden;
  border: 1px solid var(--shade-3);
  background: var(--shade-2);
}

.lang-button {
  min-height: 32px;
  padding: 0 10px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 0.76rem;
}

.lang-button[aria-pressed="true"] {
  background: var(--selected-bg);
  color: var(--selected-text);
}

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

h1 {
  margin-bottom: 18px;
  font-size: clamp(3.5rem, 12vw, 8rem);
  line-height: 1;
  font-weight: 900;
}

h1 span {
  color: var(--accent);
}

.intro {
  max-width: 760px;
  margin: 0 auto;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.8;
}

.url-inputs {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  width: min(1120px, calc(100% - 32px));
  margin: 18px auto 14px;
}

.url-panel,
.settings-panel,
.notes {
  background: var(--panel-bg);
  border: 1px solid var(--shade-3);
  box-shadow: var(--shadow);
}

.url-panel {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.versus {
  align-self: center;
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--button-bg);
  color: var(--button-text);
  font-size: 1.2rem;
  font-weight: 900;
  box-shadow: 0 10px 24px rgba(0, 109, 128, 0.22);
}

label,
legend {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

label {
  display: grid;
  gap: 6px;
}

input,
select,
button {
  min-height: 40px;
  border: 1px solid var(--shade-3);
  background: var(--shade-1);
  color: var(--text);
  font: inherit;
}

input,
select {
  width: 100%;
  padding: 0 10px;
}

input[type="file"] {
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  font-size: 0.82rem;
}

input:focus-visible,
select:focus-visible,
button:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

button {
  cursor: pointer;
  border-color: var(--button-bg);
  background: var(--button-bg);
  color: var(--button-text);
  font-weight: 900;
  transition: transform 160ms ease, filter 160ms ease;
}

button:hover {
  filter: brightness(0.94);
}

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

.secondary-button {
  border-color: var(--shade-3);
  background: var(--shade-1);
  color: var(--accent-dark);
}

.local-file-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.file-picker {
  min-width: 0;
}

.file-name {
  min-height: 1.2em;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.5;
  word-break: break-all;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.check-row input {
  width: 16px;
  min-height: 16px;
}

.auth-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.settings-panel {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  width: var(--workspace-width);
  max-width: calc(100% - 32px);
  margin: 0 auto 18px;
  padding: 14px;
  backdrop-filter: blur(16px);
}

.config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  align-items: end;
}

.config-grid button {
  min-width: 120px;
}

#overlay-group {
  min-width: min(230px, 100%);
}

.sticky-x-scroll {
  min-height: 20px;
  overflow-x: auto;
  overflow-y: hidden;
  border: 1px solid var(--shade-3);
  background: var(--shade-2);
  scrollbar-color: var(--button-bg) var(--shade-2);
}

.sticky-x-scroll[hidden] {
  display: none;
}

.sticky-x-scroll::-webkit-scrollbar {
  height: 14px;
}

.sticky-x-scroll::-webkit-scrollbar-thumb {
  background: var(--button-bg);
}

.sticky-x-scroll::-webkit-scrollbar-track {
  background: var(--shade-2);
}

#sticky-x-scroll-inner {
  height: 1px;
  min-width: 100%;
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.toggle {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border: 1px solid var(--shade-3);
  background: var(--shade-2);
}

.toggle input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.toggle label {
  display: grid;
  place-items: center;
  min-height: 40px;
  padding: 0 10px;
  color: var(--text);
  text-align: center;
  cursor: pointer;
}

.toggle input:checked + label {
  background: var(--selected-bg);
  color: var(--selected-text);
}

.toggle input:disabled:not(:checked) + label {
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.72;
}

.comparison-layout {
  display: grid;
  grid-template-areas: "shift-left stage shift-right";
  grid-template-columns: 76px max-content 76px;
  justify-content: safe center;
  gap: 14px;
  align-items: start;
  width: var(--workspace-width);
  max-width: calc(100% - 32px);
  margin: 0 auto 28px;
  overflow-x: auto;
  padding-bottom: 10px;
}

.comparison-layout[data-mode="overlay"] {
  justify-content: center;
}

.shift-panel {
  position: relative;
  z-index: 18;
  display: grid;
  gap: 8px;
  align-items: center;
  justify-items: center;
  padding: 8px;
  background: var(--panel-bg);
  border: 1px solid var(--shade-3);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
}

body.shift-panels-stuck .shift-panel {
  position: fixed;
  top: var(--shift-panel-sticky-top, 154px);
}

.shift-panel-left {
  grid-area: shift-left;
}

.shift-panel-right {
  grid-area: shift-right;
}

body.shift-panels-stuck .shift-panel-left {
  left: var(--shift-panel-left-x, 16px);
}

body.shift-panels-stuck .shift-panel-right {
  left: var(--shift-panel-right-x, calc(100vw - 92px));
}

.shift-button {
  width: 42px;
  min-height: 42px;
  border-radius: 50%;
  font-size: 1.2rem;
  touch-action: none;
  user-select: none;
}

.shift-input {
  display: grid;
  gap: 4px;
  justify-items: center;
}

.shift-input input {
  width: 58px;
  padding: 0 6px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.shift-input label {
  color: var(--muted);
  font-size: 0.72rem;
}

.stage {
  grid-area: stage;
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, var(--viewport-width));
  gap: 18px;
  min-width: min-content;
}

.status-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(2, var(--viewport-width));
  gap: 18px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.status-row output {
  min-height: 28px;
  padding: 5px 10px;
  background: var(--shade-2);
  border: 1px solid var(--shade-3);
}

.frame-card {
  position: relative;
  width: var(--viewport-width);
  height: var(--page-height);
  background: #fff;
  box-shadow: var(--shadow);
  overflow: hidden;
}

iframe {
  position: relative;
  display: block;
  width: var(--viewport-width);
  height: var(--page-height);
  border: 0;
  background: #fff;
}

.left-card iframe {
  transform: translateY(var(--left-shift-y));
}

.right-card iframe {
  transform: translate(var(--right-shift-x), var(--right-shift-y));
}

.device-height-line {
  position: absolute;
  top: var(--viewport-height);
  left: -10px;
  width: calc(var(--viewport-width) + 20px);
  height: 1px;
  margin: 0;
  border: 0;
  background: var(--alert);
  pointer-events: none;
}

.stage[data-mode="overlay"] {
  display: block;
  justify-self: center;
  width: var(--viewport-width);
  min-height: calc(var(--page-height) + 28px);
}

.stage[data-mode="overlay"] .status-row {
  display: none;
}

.stage[data-mode="overlay"] .frame-card {
  position: absolute;
  inset: 28px auto auto 0;
}

.stage[data-mode="overlay"] .right-card {
  pointer-events: none;
}

.stage[data-mode="overlay"][data-overlay="difference"] .right-card {
  mix-blend-mode: difference;
  opacity: var(--right-opacity);
}

.stage[data-mode="overlay"][data-overlay="swipe"] .right-card {
  clip-path: inset(0 calc(100% - var(--swipe)) 0 0);
}

.swipe-handle {
  display: none;
  position: absolute;
  top: 28px;
  left: calc(var(--swipe) - 15px);
  z-index: 4;
  width: 30px;
  height: var(--page-height);
  cursor: ew-resize;
}

.swipe-handle::before {
  content: "";
  position: absolute;
  left: 14px;
  top: 0;
  width: 2px;
  height: 100%;
  background: var(--alert);
}

.stage[data-mode="overlay"][data-overlay="swipe"] .swipe-handle {
  display: block;
}

.notes {
  width: min(980px, calc(100% - 32px));
  margin: 0 auto 18px;
  padding: 16px;
  color: var(--muted);
  line-height: 1.8;
}

.notes h2 {
  color: var(--text);
  font-size: 1rem;
}

.notes code {
  color: var(--alert);
  font-weight: 800;
}

.footer {
  padding: 0 16px 26px;
  color: var(--muted);
  text-align: center;
  font-size: 0.78rem;
}

@media (max-width: 980px) {
  body {
    padding-top: 74px;
  }

  .mobile-warning {
    position: fixed;
    inset: 0 0 auto;
    z-index: 60;
    display: block;
    padding: 14px 18px;
    border-bottom: 2px solid var(--alert);
    background: var(--selected-bg);
    color: var(--selected-text);
    font-size: 0.88rem;
    font-weight: 800;
    line-height: 1.55;
  }

  .hero {
    text-align: left;
  }

  .top-links {
    justify-content: flex-start;
  }

  .url-inputs,
  .settings-panel,
  .config-grid,
  .auth-grid {
    grid-template-columns: 1fr;
  }

  .versus {
    justify-self: center;
  }

  .comparison-layout {
    grid-template-areas:
      "shift-left shift-right"
      "stage stage";
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    justify-content: stretch;
    width: auto;
    margin-inline: 16px;
  }

  .shift-panel {
    top: auto;
    bottom: 14px;
    z-index: 16;
    grid-template-columns: auto auto auto;
    width: 100%;
    max-width: 160px;
    margin-block: 8px;
  }

  body.shift-panels-stuck .shift-panel {
    top: auto;
    bottom: 14px;
    width: min(160px, calc((100vw - 48px) / 2));
  }

  .shift-button {
    width: 38px;
    min-height: 38px;
  }

  .shift-input input {
    width: 50px;
  }

  .shift-panel-left {
    justify-self: start;
  }

  .shift-panel-right {
    justify-self: end;
  }

  body.shift-panels-stuck .shift-panel-left {
    left: 12px;
  }

  body.shift-panels-stuck .shift-panel-right {
    right: 12px;
    left: auto;
  }

  .stage {
    grid-template-columns: 1fr;
  }

  .status-row {
    grid-template-columns: 1fr;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151b22;
    --shade-1: #1d2630;
    --shade-2: #24313d;
    --shade-3: #3a4a58;
    --text: #f4f7fb;
    --muted: #b9c5d0;
    --accent: #7dd3e8;
    --accent-dark: #a8efff;
    --alert: #ff7f6f;
    --panel-bg: rgba(29, 38, 48, 0.94);
    --button-bg: #8bdff0;
    --button-text: #061016;
    --selected-bg: #8bdff0;
    --selected-text: #061016;
    --focus-ring: rgba(139, 223, 240, 0.45);
    --shadow: 0 16px 36px rgba(0, 0, 0, 0.32);
  }
}
