:root {
  --ink: #182337;
  --muted: #6f7b8d;
  --line: #e5e9f0;
  --surface: #ffffff;
  --canvas: #f4f6fa;
  --accent: #3478f6;
  --accent-dark: #205dcc;
  --accent-soft: #eaf1ff;
  --success: #1a9b73;
  --success-soft: #e6f7f1;
  --shadow: 0 16px 48px rgba(22, 42, 77, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.hidden {
  display: none !important;
}

.eyebrow {
  margin: 0 0 6px;
  color: #8290a6;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.muted {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.brand-mark {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border-radius: 16px;
  color: #fff;
  background: linear-gradient(145deg, #4789ff, #285fd1);
  box-shadow: 0 12px 24px rgba(52, 120, 246, 0.22);
  font-size: 26px;
  font-weight: 800;
}

.brand-mark.small {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  font-size: 20px;
}

.auth-view {
  display: grid;
  min-height: 100vh;
  padding: 24px;
  place-items: center;
  background: radial-gradient(circle at top right, #e7efff 0, transparent 36%), var(--canvas);
}

.auth-card {
  width: min(100%, 440px);
  padding: 48px;
  border: 1px solid rgba(229, 233, 240, 0.88);
  border-radius: 26px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-card .brand-mark {
  margin-bottom: 32px;
}

.auth-card h1 {
  margin: 0;
  font-size: clamp(25px, 4vw, 34px);
  line-height: 1.2;
  letter-spacing: -0.04em;
}

.auth-intro {
  margin: 14px 0 28px;
  color: var(--muted);
  line-height: 1.7;
}

.auth-form,
.settings-block {
  display: grid;
  gap: 12px;
}

.auth-form label,
.answer-editor label {
  font-size: 13px;
  font-weight: 700;
}

.auth-form input,
.auth-form select,
.password-grid input,
.search-box,
.answer-editor textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: 0;
  background: #fbfcfe;
  color: var(--ink);
  transition: border 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.auth-form input,
.auth-form select,
.password-grid input {
  min-height: 48px;
  padding: 0 14px;
}

.auth-form input:focus,
.auth-form select:focus,
.password-grid input:focus,
.search-box:focus-within,
.answer-editor textarea:focus {
  border-color: rgba(52, 120, 246, 0.7);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(52, 120, 246, 0.1);
}

.auth-form small {
  margin-top: -4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.primary-button,
.secondary-button,
.danger-button,
.ghost-button,
.file-picker {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  padding: 0 16px;
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 700;
  transition: 150ms ease;
}

.primary-button {
  color: #fff;
  background: var(--accent);
  box-shadow: 0 8px 18px rgba(52, 120, 246, 0.2);
}

.primary-button:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
}

.secondary-button {
  color: #31588f;
  border-color: #dbe5f5;
  background: #f8faff;
}

.secondary-button:hover {
  border-color: #b9cdf1;
  background: var(--accent-soft);
}

.danger-button {
  color: #a84444;
  border-color: #f0d2d2;
  background: #fff8f8;
}

.danger-button:hover {
  border-color: #e6b6b6;
  background: #fff0f0;
}

.ghost-button {
  color: var(--muted);
  background: transparent;
}

.ghost-button:hover {
  color: var(--ink);
  background: #eef1f6;
}

.topbar {
  border-bottom: 1px solid rgba(229, 233, 240, 0.9);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(16px);
}

.topbar-inner,
.page-content {
  width: min(100% - 48px, 1240px);
  margin: 0 auto;
}

.topbar-inner {
  display: flex;
  min-height: 76px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.title-group,
.topbar-actions,
.file-row,
.editor-footer,
.pager,
.progress-copy,
.panel-heading {
  display: flex;
  align-items: center;
}

.title-group {
  gap: 12px;
}

.title-group h1 {
  margin: 0;
  font-size: 16px;
  letter-spacing: -0.02em;
}

.title-group .eyebrow {
  margin-bottom: 2px;
  font-size: 9px;
}

.topbar-actions {
  gap: 8px;
}

.page-content {
  display: grid;
  gap: 18px;
  padding: 28px 0 48px;
}

.mode-view {
  display: grid;
  gap: 18px;
}

.progress-card,
.sidebar,
.answer-panel,
.settings-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 8px 30px rgba(25, 48, 85, 0.04);
}

.progress-card {
  padding: 22px 24px;
}

.progress-copy {
  justify-content: space-between;
  gap: 16px;
}

.progress-copy h2 {
  margin: 0;
  font-size: 23px;
  letter-spacing: -0.04em;
}

.progress-copy strong {
  color: var(--accent-dark);
  font-size: 28px;
  letter-spacing: -0.04em;
}

.progress-track {
  height: 10px;
  margin-top: 18px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf1f6;
}

.progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #4b91ff, #3478f6);
  transition: width 300ms ease;
}

.progress-card .muted {
  margin: 10px 0 0;
}

.workspace-grid {
  display: grid;
  min-height: 560px;
  grid-template-columns: minmax(245px, 0.34fr) minmax(0, 1fr);
  gap: 18px;
}

.sidebar {
  display: flex;
  min-width: 0;
  flex-direction: column;
  padding: 20px 14px 14px;
}

.panel-heading {
  justify-content: space-between;
  gap: 10px;
  padding: 0 8px 14px;
}

.panel-heading h2 {
  margin: 0;
  font-size: 17px;
}

.count-pill,
.status-badge {
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

.count-pill {
  padding: 5px 9px;
  color: #55709e;
  background: var(--accent-soft);
}

.search-box {
  display: flex;
  min-height: 40px;
  align-items: center;
  gap: 7px;
  padding: 0 12px;
  color: #9ba7b9;
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
}

.question-list {
  display: grid;
  gap: 5px;
  margin-top: 12px;
  overflow: auto;
  padding-right: 3px;
}

.question-item {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 12px;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 52px;
  padding: 8px 9px;
  border: 1px solid transparent;
  border-radius: 11px;
  color: var(--ink);
  background: transparent;
  text-align: left;
}

.question-item:hover {
  background: #f5f8fd;
}

.question-item.active {
  border-color: #cfdef8;
  background: var(--accent-soft);
}

.question-item .item-index {
  color: #8391a6;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.question-item .item-text {
  overflow: hidden;
  font-size: 12px;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.question-item .item-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #d5dce7;
}

.question-item.completed .item-dot {
  background: var(--success);
  box-shadow: 0 0 0 3px var(--success-soft);
}

.answer-panel {
  display: flex;
  min-width: 0;
  flex-direction: column;
  padding: clamp(22px, 4vw, 44px);
}

.empty-state {
  display: grid;
  max-width: 520px;
  margin: auto;
  place-items: center;
  text-align: center;
}

.empty-icon {
  display: grid;
  width: 58px;
  height: 58px;
  margin-bottom: 16px;
  place-items: center;
  border-radius: 18px;
  color: var(--accent);
  background: var(--accent-soft);
  font-size: 30px;
}

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

.empty-state p {
  max-width: 410px;
  margin: 12px 0 22px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

.question-state {
  display: flex;
  min-height: 100%;
  flex-direction: column;
}

.question-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.question-number {
  color: #728096;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.status-badge {
  padding: 6px 10px;
  color: #8b6c27;
  background: #fff6dd;
}

.status-badge.done {
  color: #167957;
  background: var(--success-soft);
}

.question-text {
  max-width: 880px;
  margin: 28px 0 34px;
  font-size: clamp(23px, 3.2vw, 36px);
  line-height: 1.35;
  letter-spacing: -0.035em;
  white-space: pre-wrap;
  word-break: break-word;
}

.question-heading-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.question-heading-row .question-text {
  flex: 1;
}

.question-edit-state {
  display: grid;
  gap: 10px;
  margin: 22px 0 30px;
}

.question-edit-state label {
  font-size: 13px;
  font-weight: 700;
}

.question-edit-state textarea {
  width: 100%;
  min-height: 110px;
  resize: vertical;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: 0;
  color: var(--ink);
  background: #fbfcfe;
  line-height: 1.7;
}

.question-edit-state textarea:focus {
  border-color: rgba(52, 120, 246, 0.7);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(52, 120, 246, 0.1);
}

.question-edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.answer-editor {
  display: grid;
  gap: 10px;
  margin-top: auto;
}

.answer-editor textarea {
  min-height: 220px;
  resize: vertical;
  padding: 16px;
  line-height: 1.7;
}

.editor-footer {
  justify-content: space-between;
  gap: 12px;
}

.answer-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.editor-footer .muted {
  min-height: 20px;
}

.pager {
  justify-content: space-between;
  gap: 10px;
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.settings-card {
  overflow: hidden;
}

.settings-card summary {
  display: flex;
  min-height: 72px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 22px;
  cursor: pointer;
  list-style: none;
}

.settings-card summary::-webkit-details-marker {
  display: none;
}

.settings-card summary strong {
  display: block;
  font-size: 15px;
}

.summary-arrow {
  color: #92a0b4;
  font-size: 20px;
  transition: transform 150ms ease;
}

.settings-card[open] .summary-arrow {
  transform: rotate(180deg);
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  padding: 0 22px 22px;
}

.settings-block {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfcfe;
}

.settings-block h3 {
  margin: 0;
  font-size: 14px;
}

.settings-block p {
  margin: 6px 0 0;
}

.file-row {
  flex-wrap: wrap;
  gap: 8px;
}

.file-row input[type="file"] {
  display: none;
}

.file-picker {
  color: #31588f;
  border-color: #dbe5f5;
  background: #f8faff;
}

.file-picker:hover {
  border-color: #b9cdf1;
  background: var(--accent-soft);
}

.file-row .muted {
  flex: 1 1 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.password-grid {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
}

.password-grid-three {
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
}

.password-grid input {
  min-width: 0;
  min-height: 42px;
  font-size: 12px;
}

.toast {
  position: fixed;
  z-index: 10;
  top: 20px;
  left: 50%;
  max-width: min(90vw, 460px);
  padding: 11px 16px;
  border: 1px solid #d8e4f8;
  border-radius: 10px;
  color: #31588f;
  background: #f4f8ff;
  box-shadow: var(--shadow);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -10px);
  transition: 180ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.error {
  border-color: #f2c9c9;
  color: #a03d3d;
  background: #fff6f6;
}

.question-mode {
  min-height: 570px;
  place-items: center;
}

.question-mode-card {
  width: min(100%, 760px);
  padding: clamp(24px, 5vw, 52px);
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.question-mode-card h2 {
  margin: 0;
  font-size: clamp(24px, 4vw, 34px);
  letter-spacing: -0.04em;
}

.question-mode-card > .muted {
  max-width: 650px;
  margin: 12px 0 28px;
}

.ask-form {
  display: grid;
  gap: 10px;
}

.ask-form label {
  font-size: 13px;
  font-weight: 700;
}

.ask-form textarea {
  width: 100%;
  min-height: 230px;
  resize: vertical;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: 0;
  color: var(--ink);
  background: #fbfcfe;
  line-height: 1.7;
}

.ask-form textarea:focus {
  border-color: rgba(52, 120, 246, 0.7);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(52, 120, 246, 0.1);
}

.ask-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

@media (max-width: 840px) {
  .topbar-inner,
  .page-content {
    width: min(100% - 28px, 680px);
  }

  .workspace-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .workspace-grid {
    min-height: auto;
  }

  .sidebar {
    max-height: 270px;
  }

  .question-list {
    max-height: 175px;
  }

  .answer-panel {
    min-height: 570px;
  }
}

@media (max-width: 560px) {
  .auth-view {
    padding: 16px;
  }

  .auth-card {
    padding: 30px 22px;
    border-radius: 20px;
  }

  .topbar-inner,
  .page-content {
    width: min(100% - 20px, 680px);
  }

  .topbar-inner {
    min-height: 68px;
  }

  .topbar-actions .secondary-button {
    min-width: 0;
    padding: 0 10px;
    font-size: 12px;
  }

  .title-group h1 {
    font-size: 14px;
  }

  .title-group .brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    font-size: 17px;
  }

  .progress-card {
    padding: 18px;
  }

  .progress-copy h2 {
    font-size: 20px;
  }

  .progress-copy strong {
    font-size: 24px;
  }

  .answer-panel {
    padding: 22px 17px;
  }

  .question-text {
    margin: 20px 0 26px;
    font-size: 25px;
  }

  .question-heading-row {
    display: block;
  }

  .question-heading-row .secondary-button {
    width: 100%;
    margin-bottom: 22px;
  }

  .answer-editor textarea {
    min-height: 190px;
  }

  .editor-footer {
    align-items: flex-end;
    flex-direction: column;
  }

  .editor-footer .primary-button {
    width: 100%;
  }

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

  .password-grid-three {
    grid-template-columns: 1fr;
  }

  .answer-actions {
    width: 100%;
  }

  .answer-actions button {
    flex: 1 1 0;
  }

  .settings-card summary,
  .settings-grid {
    padding-right: 16px;
    padding-left: 16px;
  }
}
