:root {
  --canvas: #f3f1eb;
  --paper: #fffdf8;
  --ink: #1d2423;
  --muted: #697573;
  --line: #deddd6;
  --sage: #2f8e87;
  --sage-deep: #236f69;
  --sage-soft: #e6f4f1;
  --warm: #f1e8d7;
  --warm-deep: #8d6330;
  --shadow: 0 18px 45px rgba(32, 51, 47, .08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% -5%, rgba(47, 142, 135, .09), transparent 28%),
    linear-gradient(180deg, #faf9f5 0%, var(--canvas) 100%);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", sans-serif;
}
button { font: inherit; }
button:focus-visible, a:focus-visible {
  outline: 3px solid rgba(47, 142, 135, .28);
  outline-offset: 2px;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  border-bottom: 1px solid rgba(47, 142, 135, .15);
  background: rgba(255, 253, 248, .94);
  backdrop-filter: blur(16px);
}
.topbar-inner {
  max-width: 1480px;
  min-height: 72px;
  margin: 0 auto;
  padding: 10px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.brand-kicker {
  margin-bottom: 3px;
  color: var(--sage-deep);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.brand-title { font-size: 20px; font-weight: 900; letter-spacing: -.02em; }
.mode-switch {
  display: inline-flex;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f4f4ef;
}
.mode {
  border: 0;
  border-radius: 8px;
  padding: 8px 15px;
  color: var(--muted);
  background: transparent;
  font-size: 13px;
  font-weight: 850;
  text-decoration: none;
  cursor: pointer;
}
.mode:hover { color: var(--sage-deep); }
.mode.active { color: #fff; background: var(--sage); box-shadow: 0 4px 12px rgba(47, 142, 135, .23); }
.toolbar {
  max-width: 1480px;
  margin: 0 auto;
  padding: 16px 22px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.passage-picker { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.passage-tab {
  min-width: max-content;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 13px;
  color: var(--muted);
  background: rgba(255, 255, 255, .72);
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}
.passage-tab.active {
  border-color: rgba(47, 142, 135, .34);
  color: var(--sage-deep);
  background: var(--sage-soft);
}
.toolbar-note { color: var(--muted); font-size: 12px; white-space: nowrap; }
.workspace {
  max-width: 1480px;
  height: calc(100vh - 160px);
  min-height: 620px;
  margin: 0 auto;
  padding: 14px 22px 24px;
  display: grid;
  grid-template-columns: minmax(390px, .9fr) minmax(520px, 1.1fr);
  gap: 16px;
}
.panel {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 253, 248, .96);
  box-shadow: var(--shadow);
}
.article-panel, .analysis-panel { height: 100%; overflow: auto; }
.article-head {
  position: sticky;
  top: 0;
  z-index: 4;
  padding: 22px 24px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 248, .96);
  backdrop-filter: blur(12px);
}
.eyebrow {
  margin-bottom: 5px;
  color: var(--sage-deep);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.article-title { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 27px; line-height: 1.2; }
.article-meta { margin-top: 8px; color: var(--muted); font-size: 12px; }
.article-body { padding: 18px 20px 42px; }
.paragraph-group { position: relative; margin-bottom: 22px; padding-left: 38px; }
.paragraph-label {
  position: absolute;
  left: 0;
  top: 7px;
  width: 27px;
  height: 27px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--warm-deep);
  background: var(--warm);
  font: 800 13px/1 Georgia, serif;
}
.sentence-block {
  width: 100%;
  margin: 0 0 4px;
  padding: 7px 9px;
  border: 1px solid transparent;
  border-radius: 9px;
  color: #27302e;
  background: transparent;
  cursor: pointer;
  text-align: left;
  font: 16px/1.72 Georgia, "Times New Roman", serif;
  transition: background .15s ease, border-color .15s ease, transform .15s ease;
}
.sentence-block:hover { border-color: rgba(47, 142, 135, .2); background: #f3f8f6; }
.sentence-block.active {
  border-color: rgba(47, 142, 135, .32);
  color: #173f3b;
  background: var(--sage-soft);
  box-shadow: inset 3px 0 0 var(--sage);
  transform: translateX(2px);
}
.analysis-head {
  position: sticky;
  top: 0;
  z-index: 4;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 248, .97);
  backdrop-filter: blur(12px);
}
.analysis-title { font-size: 18px; font-weight: 900; }
.analysis-subtitle { margin-top: 4px; color: var(--muted); font-size: 12px; }
.sentence-counter {
  align-self: center;
  padding: 6px 10px;
  border-radius: 999px;
  color: var(--sage-deep);
  background: var(--sage-soft);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}
.analysis-body { padding: 20px 22px 46px; }
.module {
  margin-bottom: 15px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: #fff;
}
.module-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 11px;
  color: var(--sage-deep);
  font-size: 11px;
  font-weight: 950;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.module-index {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  color: #fff;
  background: var(--sage);
  letter-spacing: 0;
}
.original { color: #202826; font: 18px/1.65 Georgia, "Times New Roman", serif; }
.translation { color: #2c3835; font-size: 16px; line-height: 1.75; }
.breakdown { display: grid; gap: 7px; }
.breakdown-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  min-height: 38px;
  padding: 9px 10px;
  border-radius: 9px;
  border-left: 3px solid rgba(47, 142, 135, .28);
  background: #f7f8f5;
}
.breakdown-row[data-level="2"] { margin-left: 18px; border-left-color: rgba(141, 99, 48, .35); }
.breakdown-row[data-level="3"], .breakdown-row[data-level="4"] { margin-left: 36px; border-left-color: rgba(105, 117, 115, .35); }
.breakdown-text { min-width: 0; color: #293330; font-family: Georgia, "Times New Roman", serif; line-height: 1.5; overflow-wrap: anywhere; }
.role {
  padding: 3px 7px;
  border: 1px dashed rgba(47, 142, 135, .45);
  border-radius: 999px;
  color: var(--sage-deep);
  background: var(--sage-soft);
  font-size: 11px;
  font-weight: 850;
  white-space: nowrap;
  cursor: pointer;
}
.role:hover { border-color: var(--sage); box-shadow: 0 2px 8px rgba(47, 142, 135, .18); }
.module-hint { margin-left: auto; color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: 0; text-transform: none; }
.g-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(29, 36, 35, .38);
  backdrop-filter: blur(3px);
}
.g-overlay[hidden] { display: none; }
.g-card {
  position: relative;
  width: min(500px, 100%);
  max-height: 82vh;
  overflow: auto;
  padding: 24px 26px 22px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--paper);
  box-shadow: 0 24px 60px rgba(32, 51, 47, .25);
}
.g-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  color: var(--muted);
  background: #f0efe9;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}
.g-camp {
  display: inline-block;
  margin-bottom: 10px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .04em;
}
.g-camp[data-camp="noun"] { color: #3b5da8; background: #eef3fb; }
.g-camp[data-camp="verb"] { color: #b4552a; background: #fdeee7; }
.g-camp[data-camp="adj"] { color: var(--sage-deep); background: var(--sage-soft); }
.g-camp[data-camp="adv"] { color: #7248a6; background: #f3ecfa; }
.g-camp[data-camp="structure"] { color: #697573; background: #f0f0ec; }
.g-title { margin: 0 0 10px; font-size: 20px; font-weight: 900; letter-spacing: -.01em; }
.g-desc { margin: 0 0 14px; color: #3d4946; font-size: 14.5px; line-height: 1.8; }
.g-ex {
  padding: 12px 14px;
  border-left: 3px solid rgba(47, 142, 135, .4);
  border-radius: 8px;
  color: #2c3835;
  background: #f5f7f4;
  font-size: 13.5px;
  line-height: 1.7;
}
.g-ex:empty { display: none; }
.identity-link {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  border: 0;
  border-radius: 9px;
  color: #fff;
  background: var(--sage);
  font-size: 14px;
  font-weight: 850;
  cursor: pointer;
  text-decoration: none;
}
.point-list { display: grid; gap: 9px; margin: 0; padding: 0; list-style: none; }
.point-list li { position: relative; padding-left: 18px; color: #3d4946; line-height: 1.65; }
.point-list li::before { content: ""; position: absolute; left: 1px; top: .7em; width: 6px; height: 6px; border-radius: 50%; background: var(--sage); }
.expression-list { display: grid; gap: 8px; }
.expression-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 11px;
  border: 1px solid #e7e5de;
  border-radius: 11px;
  background: #fbfaf7;
}
.expression-text { font-weight: 850; color: #253330; }
.expression-meaning { margin-top: 3px; color: var(--muted); font-size: 12px; }
.save-expression {
  border: 1px solid rgba(47, 142, 135, .34);
  border-radius: 8px;
  padding: 7px 9px;
  color: var(--sage-deep);
  background: #fff;
  cursor: pointer;
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}
.save-expression.saved { border-color: transparent; color: #fff; background: var(--sage); }
.save-expression:disabled { cursor: wait; opacity: .65; }
.empty-expression { color: var(--muted); font-size: 13px; }
.loading { padding: 60px 24px; color: var(--muted); text-align: center; }

@media (max-width: 980px) {
  .workspace { height: auto; min-height: 0; grid-template-columns: 1fr; }
  .article-panel { max-height: 66vh; }
  .analysis-panel { min-height: 70vh; }
}

@media (max-width: 640px) {
  .topbar-inner, .toolbar { padding-left: 14px; padding-right: 14px; }
  .topbar-inner { align-items: flex-start; flex-direction: column; gap: 10px; padding-top: 12px; padding-bottom: 12px; }
  .mode-switch { width: 100%; }
  .mode { flex: 1; text-align: center; }
  .toolbar { align-items: flex-start; flex-direction: column; }
  .toolbar-note { display: none; }
  .workspace { padding: 12px 10px 20px; }
  .panel { border-radius: 15px; }
  .article-head, .analysis-head, .analysis-body { padding-left: 16px; padding-right: 16px; }
  .article-body { padding-left: 12px; padding-right: 12px; }
  .paragraph-group { padding-left: 34px; }
  .breakdown-row { grid-template-columns: 1fr; }
  .role { justify-self: start; white-space: normal; text-align: left; }
  .expression-row { grid-template-columns: 1fr; }
  .save-expression { width: 100%; }
}
