﻿:root,
:root[data-theme='light'] {
  --bg: #f2efe8;
  --surface: #fffaf3;
  --surface-strong: #ffffff;
  --text: #212420;
  --muted: #646960;
  --line: #d5d0c4;
  --accent: #2f6d67;
  --accent-strong: #255751;
  --accent-soft: #bde8e2;
  --danger: #b64e36;
  --danger-soft: #f9cec0;
  --added-bg: rgba(46, 160, 67, 0.28);
  --added-inline: rgba(46, 160, 67, 0.58);
  --added-border: #2ea043;
  --removed-bg: rgba(207, 69, 57, 0.28);
  --removed-inline: rgba(207, 69, 57, 0.54);
  --removed-border: #cf4539;
  --focus-ring: #ffd85a;
  --select: #89bdb9;
  --shadow: 0 16px 42px rgba(28, 26, 21, 0.12);
  --ambient-a: #ffd8c4;
  --ambient-b: #c8e7eb;
  --chip-bg: rgba(255, 255, 255, 0.74);
  --radius: 18px;
  --editor-content-right-gap: 148px;
  --editor-content-bottom-gap: 28px;
  --editor-content-left-gap: 20px;
}

:root[data-theme='dark'] {
  --bg: #0f1416;
  --surface: #151d21;
  --surface-strong: #1b2429;
  --text: #e8efeb;
  --muted: #afbbb6;
  --line: #2a373d;
  --accent: #63b7ae;
  --accent-strong: #7ecdc5;
  --accent-soft: rgba(89, 220, 201, 0.42);
  --danger: #e48d74;
  --danger-soft: rgba(240, 133, 109, 0.44);
  --added-bg: rgba(46, 160, 67, 0.34);
  --added-inline: rgba(46, 160, 67, 0.62);
  --added-border: #2ea043;
  --removed-bg: rgba(207, 69, 57, 0.34);
  --removed-inline: rgba(248, 81, 73, 0.62);
  --removed-border: #f85149;
  --focus-ring: #ffe37a;
  --select: #4f8b84;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.32);
  --ambient-a: #663d2d;
  --ambient-b: #1f4f59;
  --chip-bg: rgba(20, 28, 31, 0.78);
}

@media (prefers-color-scheme: dark) {
  :root[data-theme='system'] {
    --bg: #0f1416;
    --surface: #151d21;
    --surface-strong: #1b2429;
    --text: #e8efeb;
    --muted: #afbbb6;
    --line: #2a373d;
    --accent: #63b7ae;
    --accent-strong: #7ecdc5;
    --accent-soft: rgba(89, 220, 201, 0.42);
    --danger: #e48d74;
    --danger-soft: rgba(240, 133, 109, 0.44);
    --added-bg: rgba(46, 160, 67, 0.34);
    --added-inline: rgba(46, 160, 67, 0.62);
    --added-border: #2ea043;
    --removed-bg: rgba(207, 69, 57, 0.34);
    --removed-inline: rgba(248, 81, 73, 0.62);
    --removed-border: #f85149;
    --focus-ring: #ffe37a;
    --select: #4f8b84;
    --shadow: 0 18px 44px rgba(0, 0, 0, 0.32);
    --ambient-a: #663d2d;
    --ambient-b: #1f4f59;
    --chip-bg: rgba(20, 28, 31, 0.78);
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

html {
  scrollbar-gutter: stable;
}

body {
  font-family: "Manrope", "Noto Sans SC", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 11% 6%, color-mix(in srgb, var(--ambient-a) 68%, transparent) 0%, transparent 34%),
    radial-gradient(circle at 84% 2%, color-mix(in srgb, var(--ambient-b) 68%, transparent) 0%, transparent 42%),
    var(--bg);
  line-height: 1.5;
}

.app-shell {
  width: min(100%, 98vw);
  margin: 24px auto 30px;
  position: relative;
  z-index: 1;
}

.hero {
  margin-bottom: 12px;
  animation: rise 380ms ease-out both;
}

.hero__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
}

.hero h1 {
  margin: 0 0 8px;
  font-family: "Fraunces", serif;
  font-size: clamp(2rem, 4vw, 3rem);
  letter-spacing: 0.02em;
}

.hero p {
  margin: 0;
  color: var(--muted);
  max-width: 860px;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin: 8px 0 10px;
}

.auto-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.diff-nav {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px;
  border: 1px solid color-mix(in srgb, var(--line) 82%, var(--text) 18%);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface-strong) 82%, transparent);
}

.diff-nav__status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 56px;
  padding: 0 10px;
  font: 700 0.9rem/1 "IBM Plex Mono", "Cascadia Mono", monospace;
  color: var(--text);
  white-space: nowrap;
}

.btn {
  appearance: none;
  border: 1px solid color-mix(in srgb, var(--line) 80%, var(--text) 20%);
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--text);
  padding: 9px 16px;
  font: 700 0.9rem/1 "Manrope", "Noto Sans SC", sans-serif;
  cursor: pointer;
  transition: transform 180ms ease, border-color 180ms ease, background-color 180ms ease;
}

.btn:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
}

.btn--accent {
  border-color: color-mix(in srgb, var(--accent) 64%, var(--line) 36%);
  background: color-mix(in srgb, var(--accent-soft) 78%, var(--surface-strong) 22%);
}

.btn--accent:hover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent-soft) 88%, var(--surface-strong) 12%);
}

.btn:active {
  transform: translateY(0);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.56;
  transform: none;
  border-color: color-mix(in srgb, var(--line) 90%, var(--text) 10%);
}

.theme-dropdown {
  position: relative;
  width: max-content;
}

.theme-trigger {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.theme-trigger__icon,
.theme-option svg {
  width: 14px;
  height: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.theme-trigger__icon svg,
.theme-option svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.theme-caret {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 180ms ease;
}

.theme-dropdown.is-open .theme-caret {
  transform: rotate(180deg);
}

.theme-menu {
  position: absolute;
  left: 0;
  top: calc(100% + 8px);
  width: 100%;
  z-index: 30;
  padding: 6px;
  box-sizing: border-box;
  border-radius: 14px;
  border: 1px solid color-mix(in srgb, var(--line) 82%, var(--text) 18%);
  background: var(--surface-strong);
  box-shadow: var(--shadow);
}

.theme-option {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  padding: 9px 10px;
  font: 700 0.88rem/1 "Manrope", "Noto Sans SC", sans-serif;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-align: left;
}

.theme-option:hover {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
}

.theme-option.is-active {
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  border-color: color-mix(in srgb, var(--accent) 42%, transparent);
}

.summary {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--chip-bg);
  padding: 10px 12px;
  margin-bottom: 12px;
}

.summary p {
  margin: 0;
}

#summaryText {
  font-size: 0.96rem;
  font-weight: 700;
  color: var(--text);
}

.editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 14px;
  align-items: stretch;
  gap: 12px;
  width: 100%;
}

.card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-strong) 100%);
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: rise 420ms ease-out both;
}

.editor-card {
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

.editor-card:focus-within {
  border-color: color-mix(in srgb, var(--select) 70%, var(--line) 30%);
  box-shadow: var(--shadow), 0 0 0 2px color-mix(in srgb, var(--select) 78%, transparent);
}

.editor-panels {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  min-height: 600px;
}

.editor-pane {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.editor-pane__header {
  padding: 12px 14px;
  font-size: 0.98rem;
  font-weight: 700;
  text-align: center;
  color: var(--text);
  min-width: 0;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface-strong) 78%, transparent);
}

.editor-pane--left {
  border-right: none;
}

.editor-pane--left .editor-surface {
  border-right: 1px solid var(--line);
}

.editor-surface {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr);
  min-height: 600px;
  flex: 1 1 auto;
}

.editor-gutter {
  position: relative;
  overflow: hidden;
  border-right: 1px solid color-mix(in srgb, var(--line) 88%, var(--text) 12%);
  background: color-mix(in srgb, var(--surface-strong) 74%, transparent);
}

.editor-gutter__inner {
  position: absolute;
  inset: 0;
  padding: 16px 8px 28px 0;
  will-change: transform;
}

.editor-gutter__line {
  height: 24px;
  line-height: 24px;
  text-align: right;
  font: 500 13px/24px "IBM Plex Mono", "Cascadia Mono", monospace;
  color: color-mix(in srgb, var(--muted) 84%, var(--text) 16%);
  user-select: none;
}

.editor-main {
  position: relative;
  min-width: 0;
  min-height: 600px;
  background: transparent;
  overflow: hidden;
}

.editor-highlight {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.editor-highlight__inner {
  position: absolute;
  top: 0;
  left: 0;
  min-width: 100%;
  width: max-content;
  padding: 16px var(--editor-content-right-gap) var(--editor-content-bottom-gap) var(--editor-content-left-gap);
  font: 400 14px/24px "IBM Plex Mono", "Cascadia Mono", monospace;
  letter-spacing: 0;
  white-space: pre;
  tab-size: 4;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  will-change: transform;
}

.editor-marker-rail {
  position: absolute;
  top: 16px;
  right: 12px;
  bottom: 28px;
  width: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface-strong) 76%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--line) 78%, transparent);
  pointer-events: none;
  display: none;
}

.editor-marker-rail__marker {
  position: absolute;
  left: 1px;
  right: 1px;
  min-height: 6px;
  border-radius: 999px;
  opacity: 0.96;
}

.editor-marker-rail__marker--removed {
  background: color-mix(in srgb, var(--removed-border) 82%, var(--removed-bg) 18%);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--removed-border) 44%, transparent);
}

.editor-marker-rail__marker--added {
  background: color-mix(in srgb, var(--added-border) 82%, var(--added-bg) 18%);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--added-border) 44%, transparent);
}


.page-overview {
  position: relative;
  min-width: 0;
}

.page-overview__inner {
  position: absolute;
  top: 56px;
  right: 2px;
  bottom: 28px;
  left: 2px;
  overflow: hidden;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface-strong) 76%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--line) 78%, transparent);
}

.page-overview__marker {
  position: absolute;
  left: 1px;
  right: 1px;
  min-height: 6px;
  border-radius: 999px;
  opacity: 0.96;
}

.page-overview__marker--removed {
  background: color-mix(in srgb, var(--removed-border) 82%, var(--removed-bg) 18%);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--removed-border) 44%, transparent);
}

.page-overview__marker--added {
  background: color-mix(in srgb, var(--added-border) 82%, var(--added-bg) 18%);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--added-border) 44%, transparent);
}

.editor-highlight__line {
  display: flex;
  align-items: stretch;
  width: max-content;
  min-width: calc(100% + var(--editor-content-right-gap));
  min-height: 24px;
  line-height: 24px;
  border-radius: 4px;
  color: transparent;
  pointer-events: none;
}

.editor-highlight__line.diff-line--removed {
  background: color-mix(in srgb, var(--removed-bg) 84%, transparent);
  border-radius: 0;
}

.editor-highlight__line.diff-line--added {
  background: color-mix(in srgb, var(--added-bg) 84%, transparent);
  border-radius: 0;
}

.editor-highlight__line.diff-line--block-start {
  border-top-left-radius: 4px;
  border-top-right-radius: 4px;
}

.editor-highlight__line.diff-line--block-end {
  border-bottom-left-radius: 4px;
  border-bottom-right-radius: 4px;
}

.editor-highlight__line--placeholder {
  position: relative;
  background: color-mix(in srgb, var(--surface-strong) 82%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--line) 64%, transparent);
}

.editor-highlight__line--placeholder::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    135deg,
    color-mix(in srgb, var(--line) 18%, transparent) 0 7px,
    transparent 7px 14px
  );
  opacity: 0.96;
}

.editor-highlight__line--placeholder-added {
  box-shadow: inset 3px 0 0 color-mix(in srgb, var(--added-border) 52%, transparent), inset 0 0 0 1px color-mix(in srgb, var(--line) 64%, transparent);
}

.editor-highlight__line--placeholder-removed {
  box-shadow: inset 3px 0 0 color-mix(in srgb, var(--removed-border) 52%, transparent), inset 0 0 0 1px color-mix(in srgb, var(--line) 64%, transparent);
}

.editor-highlight__segment {
  color: transparent;
  pointer-events: none;
}

.editor-highlight__segment--removed {
  background: color-mix(in srgb, var(--removed-inline) 90%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--removed-border) 86%, transparent);
}

.editor-highlight__segment--added {
  background: color-mix(in srgb, var(--added-inline) 90%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--added-border) 86%, transparent);
}



.editor-highlight__segment--placeholder {
  display: inline-block;
  width: 0;
}

.editor-highlight__content {
  display: block;
  flex: 0 0 auto;
  min-width: 0;
  pointer-events: none;
}

.editor-highlight__end-gap {
  display: block;
  flex: 1 1 auto;
  width: auto;
  min-width: 8ch;
  pointer-events: none;
}

.editor-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  resize: none;
  margin: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  caret-color: var(--text);
  padding: 16px var(--editor-content-right-gap) var(--editor-content-bottom-gap) var(--editor-content-left-gap);
  font: 400 14px/24px "IBM Plex Mono", "Cascadia Mono", monospace;
  letter-spacing: 0;
  white-space: pre;
  overflow: auto;
  scrollbar-gutter: stable;
  tab-size: 4;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  cursor: text;
}

.editor-input::selection {
  background: color-mix(in srgb, var(--select) 72%, transparent);
}


.editor-input::-webkit-scrollbar {
  width: 12px;
  height: 12px;
  cursor: default;
}

.editor-input::-webkit-scrollbar-thumb {
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
  background: color-mix(in srgb, var(--line) 28%, var(--text) 72%);
  cursor: default;
}

.editor-input::-webkit-scrollbar-track {
  background: color-mix(in srgb, var(--surface) 76%, transparent);
  cursor: default;
}

.editor-input::-webkit-scrollbar-corner {
  background: color-mix(in srgb, var(--surface) 76%, transparent);
  cursor: default;
}

.legend {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  color: var(--muted);
  font-size: 0.88rem;
}

.legend__tag {
  display: inline-block;
  width: 13px;
  height: 13px;
  border-radius: 3px;
  margin-right: 6px;
  vertical-align: middle;
}

.legend__tag--added {
  background: color-mix(in srgb, var(--added-bg) 90%, transparent);
  border: 1px solid color-mix(in srgb, var(--added-border) 48%, transparent);
}

.legend__tag--removed {
  background: color-mix(in srgb, var(--removed-bg) 90%, transparent);
  border: 1px solid color-mix(in srgb, var(--removed-border) 48%, transparent);
}

.ambient {
  position: fixed;
  z-index: 0;
  pointer-events: none;
  filter: blur(56px);
  opacity: 0.34;
}

.ambient--a {
  width: 300px;
  height: 300px;
  top: 24px;
  left: 5vw;
  background: var(--ambient-a);
}

.ambient--b {
  width: 360px;
  height: 360px;
  top: 4px;
  right: 3vw;
  background: var(--ambient-b);
}

@keyframes rise {
  from {
    transform: translateY(10px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@media (max-width: 980px) {
  .editor-grid {
    grid-template-columns: 1fr;
  }

  .page-overview {
    display: none;
  }

  .editor-marker-rail {
    display: block;
    right: 2px;
    z-index: 3;
  }

  .editor-highlight {
    right: 14px;
  }

  .editor-input {
    right: 14px;
    width: auto;
  }

  .editor-panels {
    grid-template-columns: 1fr;
  }

  .editor-pane--left {
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .editor-pane--left .editor-surface {
    border-right: none;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(1500px, 96vw);
    margin-top: 16px;
  }

  .actions {
    gap: 8px;
  }

  .diff-nav {
    gap: 6px;
  }

  .diff-nav__status {
    min-width: 50px;
    padding: 0 8px;
    font-size: 0.84rem;
  }

  .btn {
    padding: 9px 13px;
  }

  .editor-main,
  .editor-surface {
    min-height: 420px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

