:root {
  --bg: #f6f4ee;
  --surface: #ffffff;
  --ink: #1e1e22;
  --muted: #6f6b63;
  --faint: #9c978d;
  --line: #e7e2d8;
  --red: #b8433a;
  --red-deep: #93352e;
  --red-soft: #fbeeeb;
  --blue: #2d62a8;
  --blue-deep: #244e84;
  --blue-soft: #ecf2fa;
  --serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, "Songti SC", "SimSun", serif;
  --sans: "Inter", "Segoe UI", "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", system-ui, sans-serif;
  --mono: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --gold: #b8860b;
  --gold-deep: #8a6508;
  --gold-soft: #fdf6e3;
  --gold-line: rgba(184, 134, 11, 0.55);
  --gold-wash: rgba(184, 134, 11, 0.07);
}

[data-color="red"] {
  --tone: #b8433a;
  --tone-deep: #93352e;
  --tone-soft: #fbeeeb;
  --tone-line: rgba(184, 67, 58, 0.55);
  --tone-wash: rgba(184, 67, 58, 0.05);
}

[data-color="blue"] {
  --tone: #2d62a8;
  --tone-deep: #244e84;
  --tone-soft: #ecf2fa;
  --tone-line: rgba(45, 98, 168, 0.55);
  --tone-wash: rgba(45, 98, 168, 0.05);
}

[data-color="green"] {
  --tone: #2f7d4f;
  --tone-deep: #256541;
  --tone-soft: #ecf7f0;
  --tone-line: rgba(47, 125, 79, 0.55);
  --tone-wash: rgba(47, 125, 79, 0.05);
}

[data-color="purple"] {
  --tone: #6f42ac;
  --tone-deep: #5a3590;
  --tone-soft: #f2ecfb;
  --tone-line: rgba(111, 66, 172, 0.55);
  --tone-wash: rgba(111, 66, 172, 0.05);
}

[data-color="orange"] {
  --tone: #a65a10;
  --tone-deep: #86480c;
  --tone-soft: #fdf2e5;
  --tone-line: rgba(166, 90, 16, 0.55);
  --tone-wash: rgba(166, 90, 16, 0.05);
}

[data-color="brown"] {
  --tone: #8a5a3b;
  --tone-deep: #6f4730;
  --tone-soft: #f8efe8;
  --tone-line: rgba(138, 90, 59, 0.55);
  --tone-wash: rgba(138, 90, 59, 0.05);
}

[data-color="teal"] {
  --tone: #0d7d7d;
  --tone-deep: #0a6363;
  --tone-soft: #e7f5f5;
  --tone-line: rgba(13, 125, 125, 0.55);
  --tone-wash: rgba(13, 125, 125, 0.07);
}

[data-color="slate"] {
  --tone: #5f6b7a;
  --tone-deep: #49545f;
  --tone-soft: #eef1f4;
  --tone-line: rgba(95, 107, 122, 0.55);
  --tone-wash: rgba(95, 107, 122, 0.07);
}

[data-color="pink"] {
  --tone: #b84a78;
  --tone-deep: #94385f;
  --tone-soft: #fbeef4;
  --tone-line: rgba(184, 74, 120, 0.55);
  --tone-wash: rgba(184, 74, 120, 0.05);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background-color: var(--bg);
  background-image:
    radial-gradient(1100px 520px at 50% -8%, rgba(184, 67, 58, 0.05), transparent 62%),
    radial-gradient(900px 480px at 82% 4%, rgba(45, 98, 168, 0.05), transparent 60%),
    radial-gradient(rgba(30, 30, 34, 0.035) 1px, transparent 1px);
  background-size: auto, auto, 26px 26px;
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.is-empty {
  min-height: 100vh;
  background-image:
    radial-gradient(1100px 520px at 50% -8%, rgba(184, 67, 58, 0.05), transparent 62%),
    radial-gradient(900px 480px at 82% 4%, rgba(45, 98, 168, 0.05), transparent 60%),
    radial-gradient(rgba(30, 30, 34, 0.035) 1px, transparent 1px),
    linear-gradient(180deg, #f7f5f2 0%, #f6f4ee 45%, #f2f2f2 100%);
  background-size: auto, auto, 26px 26px, 100% 100%;
  background-repeat: no-repeat, no-repeat, repeat, no-repeat;
}

button {
  font-family: inherit;
}

.page {
  width: min(1080px, 100%);
  margin: 0 auto;
  padding: 0 28px 48px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 2px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
}

.brand svg {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  box-shadow: 0 8px 20px -10px rgba(30, 30, 34, 0.5);
}

.brand-name {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.brand-en {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--faint);
  margin-top: 5px;
}

.topbar-keys {
  display: flex;
  gap: 14px;
  font-size: 11.5px;
  color: var(--muted);
}

.topbar-keys span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.key {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 4px;
}

.key.main {
  border: 1.5px solid rgba(184, 67, 58, 0.6);
  background: var(--red-soft);
}

.key.clause {
  border: 1.5px solid rgba(45, 98, 168, 0.6);
  background: var(--blue-soft);
}

.key.dashed {
  border: 1.5px dashed rgba(45, 98, 168, 0.65);
  background: #fff;
}

.key.gold {
  border: 1.5px solid var(--gold-line);
  background: var(--gold-soft);
}

.key.aux {
  border: 1.5px dotted rgba(184, 67, 58, 0.65);
  background: var(--red-soft);
}

.key.verb {
  border: 1.5px solid rgba(184, 67, 58, 0.65);
  background: var(--red-soft);
}

.hero {
  padding: 44px 0 34px;
  text-align: center;
}

.eyebrow {
  margin: 0 0 14px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--faint);
}

h1 {
  margin: 0;
  font-size: clamp(36px, 5.4vw, 58px);
  line-height: 1.1;
  letter-spacing: -0.03em;
  font-weight: 800;
}

h1 .accent {
  position: relative;
  color: var(--red);
  white-space: nowrap;
}

h1 .accent::after {
  content: "";
  position: absolute;
  left: 2px;
  right: 2px;
  bottom: 2px;
  height: 7px;
  border-radius: 99px;
  background: var(--red);
  opacity: 0.12;
}

.lede {
  max-width: 640px;
  margin: 22px auto 0;
  color: var(--muted);
  font-size: 15.5px;
  line-height: 1.75;
}

.composer {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 800px;
  margin: 30px auto 0;
  padding: 7px 7px 7px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 18px 44px -30px rgba(30, 30, 34, 0.42), 0 2px 5px rgba(30, 30, 34, 0.04);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.composer:focus-within {
  border-color: rgba(45, 98, 168, 0.5);
  box-shadow: 0 0 0 4px rgba(45, 98, 168, 0.09), 0 18px 44px -30px rgba(30, 30, 34, 0.42);
}

.composer input {
  flex: 1;
  min-width: 0;
  height: 46px;
  border: 0;
  outline: none;
  background: transparent;
  font-family: var(--sans);
  font-size: 16px;
  color: var(--ink);
}

.composer input::placeholder {
  color: #a9a399;
  font-size: 14.5px;
}

#ai-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 47px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

#ai-btn:hover {
  border-color: rgba(45, 98, 168, 0.5);
  background: var(--blue-soft);
  transform: translateY(-1px);
}

#ai-btn:disabled {
  opacity: 0.6;
  cursor: progress;
  transform: none;
}

#ai-btn:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.ai-status {
  max-width: 800px;
  margin: 10px auto 0;
  font-size: 12px;
  line-height: 1.6;
  text-align: center;
  color: var(--faint);
}

.ai-status:empty {
  display: none;
}

.ai-status[data-tone="loading"] {
  color: var(--blue);
}

.ai-status[data-tone="error"] {
  color: var(--red);
}

.ai-status[data-tone="success"] {
  color: var(--green);
}

#analyze-btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  height: 47px;
  padding: 0 20px;
  border: 0;
  border-radius: 12px;
  background: var(--ink);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

#analyze-btn:hover {
  transform: translateY(-1px);
  background: #000;
  box-shadow: 0 10px 24px -12px rgba(0, 0, 0, 0.5);
}

#analyze-btn:active {
  transform: translateY(0) scale(0.99);
}

#analyze-btn:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.composer.shake {
  animation: shake 0.5s ease;
  border-color: var(--red);
}

.hero-translation {
  max-width: 800px;
  margin: 22px auto 0;
  text-align: left;
}

.hero-translation .insight.translation {
  padding: 16px 22px;
  border-radius: 18px;
  box-shadow: 0 16px 40px -38px rgba(30, 30, 34, 0.55);
}

.hero-translation .insight-head {
  margin-bottom: 10px;
}

.samples {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  max-width: 920px;
  margin: 20px auto 0;
}

.sample {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 7px 13px 7px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.sample em {
  flex: none;
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue-deep);
  font-style: normal;
  font-size: 10.5px;
  font-weight: 700;
  white-space: nowrap;
}

.sample span {
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 320px;
}

.sample:hover {
  transform: translateY(-1px);
  border-color: rgba(45, 98, 168, 0.4);
  background: #fff;
}

.sample:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.result {
  margin-top: 42px;
  scroll-margin-top: 24px;
}

.result-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.result-head .eyebrow {
  margin-bottom: 6px;
}

.result-head h2 {
  margin: 0;
  font-size: 24px;
  letter-spacing: -0.02em;
}

.result-meta {
  text-align: right;
}

.badge {
  display: inline-block;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.badge[data-kind="auto"] {
  background: var(--blue-soft);
  color: var(--blue-deep);
  border: 1px solid rgba(45, 98, 168, 0.25);
}

.badge[data-kind="ai"] {
  background: var(--blue-soft);
  color: var(--blue-deep);
  border: 1px solid rgba(45, 98, 168, 0.4);
}

.source-note {
  margin: 7px 0 0;
  font-size: 11.5px;
  color: var(--faint);
}

.paper {
  position: relative;
  padding: 34px 34px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 30px 70px -46px rgba(30, 30, 34, 0.5), 0 2px 6px rgba(30, 30, 34, 0.03);
  overflow: hidden;
}

.paper::before {
  content: "";
  position: absolute;
  top: 0;
  left: 34px;
  right: 34px;
  height: 3px;
  border-radius: 0 0 99px 99px;
  background: linear-gradient(90deg, var(--red) 0%, var(--red) 34%, var(--line) 34%, var(--line) 63%, var(--blue) 63%, var(--blue) 100%);
  opacity: 0.7;
}

.diagram {
  position: relative;
  padding: 10px 2px 4px;
}

.sentence {
  font-family: var(--serif);
  font-size: clamp(22px, 2.7vw, 30px);
  line-height: 1.4;
  color: var(--ink);
}

.s-row {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  margin-bottom: 20px;
}

.sentence-main {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 24px 10px;
}

.token {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  flex: none;
  max-width: 100%;
}

.token-line {
  display: inline-flex;
  align-items: baseline;
  white-space: nowrap;
}

.chunk-tag {
  position: relative;
  padding: 3px 8px 4px;
  border: 1px solid var(--tone-line, rgba(30, 30, 34, 0.25));
  border-radius: 999px;
  background: var(--tone-soft, #f2f2f2);
  color: var(--tone-deep, var(--ink));
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(30, 30, 34, 0.05);
}

.chunk-tag::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 100%;
  width: 1px;
  height: 9px;
  background: var(--tone-line, rgba(30, 30, 34, 0.25));
  transform: translateX(-50%);
  opacity: 0.7;
}

.chunk-tag.conductor,
.chunk-tag.virtual {
  border-style: dashed;
  background: #fff;
}

.chunk-tag[data-role="prepPhrase"] {
  border-color: var(--gold-line);
  background: var(--gold-soft);
  color: var(--gold-deep);
}

.clause-card {
  flex: 0 0 calc(100% - 10px);
  box-sizing: border-box;
  margin: 8px 0 0 10px;
  padding: 10px 11px 13px;
  border: 1.5px dashed var(--tone-line);
  border-left: 4px solid var(--tone);
  border-radius: 12px;
  background: var(--tone-wash);
  animation: cardIn 0.45s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.clause-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  margin-bottom: 11px;
}

.clause-badge {
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--tone);
  color: #fff;
  font-family: var(--sans);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1;
  white-space: nowrap;
  box-shadow: 0 4px 10px -4px rgba(30, 30, 34, 0.45);
}

.clause-meta {
  min-width: 0;
  font-family: var(--sans);
  font-size: 11.5px;
  color: var(--tone-deep);
  opacity: 0.85;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.clause-body {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 22px 10px;
  font-size: 0.92em;
}

.clause-body > .clause-card {
  flex: 0 0 calc(100% - 12px);
  margin-left: 12px;
  background: rgba(255, 255, 255, 0.55);
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.w {
  white-space: nowrap;
  color: var(--tone, var(--ink));
}

.w.punct {
  margin-left: 1px;
  color: #a9a399;
  font-size: 0.82em;
}

.w.punct.attach {
  margin-left: -1px;
}

.plain {
  display: inline-block;
}

.chunk {
  display: inline-block;
  padding: 2px 7px 3px;
  border: 1.5px solid var(--tone-line, rgba(30, 30, 34, 0.2));
  border-radius: 9px;
  background: var(--tone-wash, transparent);
  word-spacing: 0.12em;
  line-height: 1.25;
}

.chunk.conductor {
  border-style: dashed;
}

.chunk.virtual {
  border-style: dashed;
  border-color: var(--tone-line, rgba(45, 98, 168, 0.45));
  background: var(--tone-wash, rgba(45, 98, 168, 0.06));
}

.chunk.virtual .w {
  font-style: italic;
}

.chunk[data-role="conductor"] .w {
  font-weight: 700;
}

.chunk[data-role="predicate"] {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 6px;
}

.predicate-cell {
  display: inline-flex;
  align-items: center;
  padding: 1px 5px 2px;
  border: 1.5px solid var(--tone);
  border-radius: 6px;
  background: var(--tone-soft);
  line-height: 1.2;
}

.prep-cell {
  display: inline-flex;
  align-items: center;
  padding: 1px 5px 2px;
  border: 1.5px solid var(--tone);
  border-radius: 6px;
  background: var(--tone-soft);
  line-height: 1.2;
}

.chunk[data-role="prepPhrase"] {
  border-color: var(--gold-line);
  background: var(--gold-wash);
}

.ann[data-role="prepPhrase"] {
  color: var(--gold-deep);
}

.ann[data-role="prepPhrase"] .ann-tag {
  border-color: var(--gold-line);
  background: var(--gold-soft);
  color: var(--gold-deep);
}

.ann.virtual .ann-tag {
  border-style: dashed;
  background: #fff;
}

.diagram-measure {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  flex-wrap: nowrap;
  gap: 10px;
  width: max-content;
  visibility: hidden;
  pointer-events: none;
}

.annotations {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.ann {
  position: absolute;
  width: 0;
  height: 0;
  color: var(--tone, var(--red));
  opacity: 0;
}

.ann-stem {
  position: absolute;
  top: 0;
  left: -0.75px;
  width: 1.5px;
  background: currentColor;
  opacity: 0.6;
}

.ann-stem::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -1px;
  transform: translateX(-50%);
  border: 4.5px solid transparent;
  border-top: 6px solid currentColor;
  opacity: 0.9;
}

.ann-tag {
  position: absolute;
  top: calc(var(--stem, 24px) + 7px);
  left: 0;
  transform: translateX(-50%);
  padding: 5px 9px;
  border: 1px solid var(--tone-line, rgba(184, 67, 58, 0.28));
  border-radius: 999px;
  background: var(--tone-soft, var(--red-soft));
  color: var(--tone-deep, var(--red-deep));
  font-family: var(--sans);
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(30, 30, 34, 0.05);
}

.ann.conductor .ann-tag {
  border-style: dashed;
  border-color: var(--tone-line);
  background: #fff;
}

.ann.clause-type .ann-tag {
  padding: 5px 10px;
  border-color: var(--tone);
  background: var(--tone);
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.04em;
  box-shadow: 0 4px 10px -4px rgba(30, 30, 34, 0.45);
}

.annotations.is-ready .ann {
  animation: annIn 0.45s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.paper-foot {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
  padding-top: 13px;
  border-top: 1px dashed var(--line);
  font-size: 11.5px;
  color: var(--muted);
}

.paper-foot-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  width: 100%;
}

.paper-foot-row + .paper-foot-row {
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}

.color-row-label {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  color: var(--faint);
}

.paper-foot .legend-items {
  gap: 8px 16px;
}

.paper-foot .legend-chip {
  font-size: 11.5px;
}

.paper-foot .legend-swatch {
  width: 13px;
  height: 13px;
  border-radius: 4px;
}

.legend {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.rule-tip {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: var(--faint);
}

.insights {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 16px;
}

.insight {
  padding: 20px 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 16px 40px -38px rgba(30, 30, 34, 0.55);
}

.insight.translation {
  grid-column: 1 / -1;
}

.insight-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.insight-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.insight-en {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--faint);
}

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 99px;
}

.dot.red {
  background: var(--red);
}

.dot.blue {
  background: var(--blue);
}

.dot.ink {
  background: var(--ink);
}

.trunk-text {
  margin: 0 0 12px;
  font-family: var(--serif);
  font-size: 22px;
  line-height: 1.45;
  color: var(--red-deep);
}

.trunk-parts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.part {
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  padding: 6px 10px;
  background: #faf8f3;
  border: 1px solid #eee9df;
  border-radius: 9px;
}

.part em {
  flex: none;
  white-space: nowrap;
  font-style: normal;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.part b {
  font-family: var(--serif);
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}

.insight-note {
  margin: 0;
  font-size: 13px;
  line-height: 1.75;
  color: var(--muted);
}

.clause-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.clause-list li {
  padding: 12px 0;
  border-top: 1px dashed var(--line);
}

.clause-list li:first-child {
  padding-top: 0;
  border-top: 0;
}

.clause-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  margin-bottom: 7px;
}

.tag {
  padding: 3px 8px;
  border: 1px solid var(--tone-line, transparent);
  border-radius: 999px;
  background: var(--tone-soft, var(--blue-soft));
  color: var(--tone-deep, var(--blue-deep));
  font-size: 10.5px;
  font-weight: 700;
}

.clause-tags code {
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f4f1ea;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 11px;
}

.clause-target {
  font-size: 11.5px;
  color: var(--faint);
}

.clause-note {
  margin: 0;
  font-size: 13px;
  line-height: 1.75;
  color: var(--muted);
}

.clause-empty {
  padding: 6px 0;
  font-size: 13px;
  color: var(--faint);
}

.translation-text {
  margin: 0;
  font-size: 18px;
  line-height: 1.8;
  color: var(--ink);
}

.translation-text.is-pending {
  color: var(--faint);
  animation: pulse 1.2s ease-in-out infinite;
}

.translation-note {
  margin: 8px 0 0;
  font-size: 11px;
  color: var(--faint);
}

.ghost-btn {
  margin-top: 10px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
}

.ghost-btn:hover {
  border-color: rgba(45, 98, 168, 0.4);
  color: var(--blue-deep);
}


.legend-items {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 20px;
}

.legend-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--muted);
}

.legend-swatch {
  display: inline-block;
  width: 15px;
  height: 15px;
  border: 1px solid var(--tone-line);
  border-radius: 5px;
  background: var(--tone);
}

.foot {
  padding-top: 34px;
}

.foot p {
  max-width: 760px;
  margin: 0;
  font-size: 11.5px;
  line-height: 1.7;
  color: var(--faint);
}

.hero > * {
  animation: rise 0.65s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.hero > :nth-child(2) {
  animation-delay: 0.06s;
}

.hero > :nth-child(3) {
  animation-delay: 0.12s;
}

.hero > :nth-child(4) {
  animation-delay: 0.18s;
}

.hero > :nth-child(5) {
  animation-delay: 0.24s;
}

.result.is-visible .paper {
  animation: rise 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.result.is-visible .insight {
  animation: rise 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.result.is-visible .insights .insight:nth-child(2) {
  animation-delay: 0.06s;
}

.result.is-visible .insights .insight:nth-child(3) {
  animation-delay: 0.12s;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes annIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes pulse {
  0%, 100% {
    opacity: 0.5;
  }
  50% {
    opacity: 1;
  }
}

@keyframes shake {
  10%, 90% {
    transform: translateX(-1px);
  }
  20%, 80% {
    transform: translateX(2px);
  }
  30%, 50%, 70% {
    transform: translateX(-3px);
  }
  40%, 60% {
    transform: translateX(3px);
  }
}

@media (min-width: 768px) {
  .sentence-main {
    gap: 28px 12px;
  }


  .clause-card {
    flex-basis: calc(100% - 22px);
    margin-left: 22px;
    padding: 12px 16px 16px;
    border-radius: 14px;
  }

  .clause-body {
    gap: 26px 12px;
  }

  .clause-body > .clause-card {
    flex-basis: calc(100% - 24px);
    margin-left: 24px;
  }

  .chunk-tag {
    font-size: 11.5px;
  }
}

@media (max-width: 900px) {
  .insights {
    grid-template-columns: 1fr;
  }

  .paper {
    padding: 28px 20px 14px;
  }

  .paper::before {
    left: 20px;
    right: 20px;
  }
}

@media (max-width: 620px) {
  .page {
    padding: 0 16px 32px;
  }

  .topbar {
    padding: 16px 0;
  }

  .topbar-keys {
    display: none;
  }

  .hero {
    padding-top: 26px;
  }

  .lede {
    font-size: 14.5px;
  }

  .composer {
    padding: 6px 6px 6px 14px;
    border-radius: 16px;
    gap: 6px;
  }

  .composer input {
    font-size: 15px;
    height: 44px;
  }

  .composer input::placeholder {
    font-size: 13px;
  }

  #ai-btn {
    height: 44px;
    padding: 0 10px;
    font-size: 12px;
  }

  #analyze-btn {
    height: 44px;
    padding: 0 14px;
    gap: 6px;
    font-size: 13px;
  }

  .sample span {
    max-width: 190px;
  }

  .result {
    margin-top: 30px;
  }

  .result-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .result-meta {
    text-align: left;
  }

  .paper {
    padding: 24px 14px 12px;
    border-radius: 18px;
  }

  .paper::before {
    left: 14px;
    right: 14px;
  }

  .sentence {
    font-size: 21px;
  }

  .sentence-main {
    gap: 20px 9px;
  }

  .clause-card {
    padding: 9px 10px 12px;
  }

  .clause-body {
    gap: 20px 9px;
  }

  .clause-badge {
    font-size: 11px;
  }

  .rule-tip {
    margin-left: 0;
  }

  .insight {
    padding: 16px 16px;
  }

  .trunk-text {
    font-size: 19px;
  }

  .translation-text {
    font-size: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}