:root {
  --purple: #33206f;
  --green: #1fff7f;
  --green-mark: rgba(31, 255, 127, 0.3);
  --ink: #2f216b;
  --muted: #7c7690;
  --line: #d8d1eb;
  --soft: #f6f3fb;
  --panel: #ffffff;
  --control: #f0f0f2;
  --control-dark: #e2e2e5;
  --control-border: #b8b8bd;
  --danger: #d32f2f;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: transparent;
  color: var(--ink);
  font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.module-shell {
  width: 100%;
  min-height: 520px;
  padding: 0;
}

.ra-tool {
  position: relative;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 8px;
  width: 100%;
  height: 520px;
  padding: 10px;
  overflow: hidden;
  background: var(--panel);
}

.top-row,
.control-row,
.bottom-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.left-tools,
.right-tools,
.ra-controls,
.nav-controls,
.exam-record {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.search-box,
.jump-box,
.select-pill {
  display: inline-flex;
  align-items: center;
  height: 36px;
  overflow: hidden;
  border: 1px solid var(--control-border);
  border-radius: 4px;
  background: #fff;
}

.search-box input {
  width: 150px;
  height: 100%;
  padding: 0 10px;
  border: 0;
  outline: 0;
  color: var(--ink);
}

.jump-box input {
  width: 72px;
  height: 100%;
  padding: 0 8px;
  border: 0;
  outline: 0;
  color: var(--ink);
}

.icon-btn,
.mini-btn,
.label-btn,
.select-pill span,
.record-label {
  height: 36px;
  border: 0;
  border-left: 1px solid var(--control-border);
  background: linear-gradient(var(--control), var(--control-dark));
  color: var(--ink);
  font-weight: 700;
}

.icon-btn {
  width: 40px;
  color: #777;
  font-size: 24px;
  line-height: 1;
}

.mini-btn {
  min-width: 36px;
  padding: 0 8px;
  font-size: 14px;
}

.timer-box {
  color: var(--purple);
  font-size: 16px;
  font-weight: 800;
  white-space: nowrap;
}

.timer-box strong {
  padding: 0 4px;
  font-size: 24px;
}

.hidden {
  display: none;
}

.tag-menu {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: 36px;
}

.label-btn {
  min-width: 66px;
  border: 1px solid var(--control-border);
  border-radius: 4px 0 0 4px;
}

.tag-current {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  min-width: 92px;
  padding: 0 10px;
  border: 1px solid var(--control-border);
  border-left: 0;
  border-radius: 0 4px 4px 0;
  background: #fff;
  color: var(--purple);
  font-weight: 400;
  white-space: nowrap;
}

.tag-current span,
.tag-dropdown span {
  width: 11px;
  height: 11px;
  border: 1px solid transparent;
  border-radius: 999px;
  flex: 0 0 auto;
}

.tag-current span.empty {
  border-color: var(--control-border);
}

.tag-dropdown {
  position: absolute;
  z-index: 5;
  top: 38px;
  right: 0;
  width: 132px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 8px 20px rgba(41, 29, 86, 0.16);
}

.tag-dropdown button {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  height: 30px;
  padding: 0 8px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  font-size: 13px;
  font-weight: 400;
}

.tag-dropdown button:hover {
  background: var(--soft);
}

.clear-dot {
  border: 1px solid var(--control-border);
  background: transparent;
}

.question-badge {
  display: flex;
  align-items: center;
  width: 230px;
  min-width: 230px;
  max-width: 230px;
  height: 36px;
  padding: 0 10px;
  overflow: hidden;
  border: 1px solid var(--control-border);
  border-radius: 4px;
  background: linear-gradient(var(--control), var(--control-dark));
  color: var(--purple);
  font-size: 17px;
  font-weight: 400;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.select-pill span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  padding: 0 7px;
  border-left: 0;
}

.select-pill select {
  height: 100%;
  min-width: 96px;
  max-width: 96px;
  padding: 0 6px;
  border: 0;
  outline: 0;
  background: #fff;
  color: var(--purple);
  font-weight: 400;
}

.select-pill.compact select {
  min-width: 56px;
  max-width: 56px;
}

.main-btn {
  min-width: 74px;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--purple);
  border-radius: 4px;
  background: var(--purple);
  color: #fff;
  font-weight: 800;
}

.main-btn:hover,
.mini-btn:hover,
.icon-btn:hover,
.label-btn:hover,
.tag-current:hover {
  border-color: var(--green);
  background: var(--green);
  color: var(--purple);
}

.main-btn.active {
  border-color: var(--purple);
  background: var(--purple);
  color: #fff;
}

.main-btn:disabled {
  border-color: #cfcbd9;
  background: #e8e5ee;
  color: #8e879d;
  cursor: not-allowed;
}

.passage-panel {
  min-height: 0;
  padding: 14px 4px 6px;
  overflow: auto;
  border-top: 1px solid transparent;
}

.passage-text {
  width: 100%;
  max-width: none;
  margin: 0;
  color: var(--purple);
  font-size: 26px;
  line-height: 1.88;
  word-break: normal;
  overflow-wrap: normal;
  white-space: normal;
}

.chunk {
  display: inline;
  white-space: normal;
}

.char {
  display: inline;
  color: var(--purple);
  white-space: pre;
  transition: background-color 0.04s linear;
}

.char.colored {
  background: var(--green-mark);
}

.bottom-row {
  align-items: flex-end;
}

.record-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 80px;
  border: 1px solid var(--control-border);
  border-radius: 4px 0 0 4px;
}

.exam-record strong {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 58px;
  height: 36px;
  margin-left: -10px;
  border: 1px solid var(--control-border);
  border-left: 0;
  border-radius: 0 4px 4px 0;
  background: #fff;
  color: var(--purple);
  font-weight: 400;
}

.status {
  max-width: 360px;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.feedback-toast {
  position: absolute;
  right: 16px;
  bottom: 48px;
  z-index: 6;
  max-width: 260px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--purple);
  box-shadow: 0 8px 20px rgba(41, 29, 86, 0.16);
  font-size: 14px;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 520px;
  padding: 24px;
  background: #fff;
  color: var(--ink);
  text-align: center;
}

.empty-state h1 {
  margin: 0 0 8px;
  font-size: 22px;
}

.empty-state p {
  max-width: 520px;
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

@media (max-width: 900px) {
  .ra-tool {
    height: auto;
    min-height: 520px;
    overflow: visible;
  }

  .top-row,
  .control-row,
  .bottom-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .left-tools,
  .right-tools,
  .ra-controls,
  .nav-controls {
    flex-wrap: wrap;
    width: 100%;
  }

  .passage-panel {
    overflow: visible;
  }
}

@media (max-width: 620px) {
  .search-box input {
    width: 120px;
  }

  .question-badge {
    min-width: 100%;
    max-width: 100%;
  }

  .select-pill,
  .main-btn {
    flex: 1 1 auto;
  }

  .passage-text {
    font-size: 24px;
  }
}
