:root {
  --bg-app: #f7f7f8;
  --bg-main: #ffffff;
  --bg-soft: #f3f4f6;
  --line: #e5e7eb;
  --text-main: #111827;
  --text-muted: #6b7280;
  --sidebar-bg: #171717;
  --sidebar-line: #262626;
  --sidebar-text: #e5e5e5;
  --sidebar-muted: #a3a3a3;
  --sidebar-hover: #2a2a2a;
  --sidebar-active: #323232;
  --accent: #10a37f;
  --accent-hover: #0e8c6d;
  --bubble-user: #eaf4ee;
  --bubble-assistant: #ffffff;
  --shadow: 0 8px 28px rgba(17, 24, 39, 0.08);
  --font-main: "Source Han Sans SC", "PingFang SC", "Noto Sans CJK SC", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  width: 100%;
  margin: 0;
  font-family: var(--font-main);
  color: var(--text-main);
  background: radial-gradient(circle at 70% -20%, #eef2ff 0%, rgba(238, 242, 255, 0) 45%), var(--bg-app);
  overflow-x: hidden;
}

body.modal-open {
  overflow: hidden;
}

.hidden {
  display: none !important;
}

.app-shell-auth-loading {
  visibility: hidden;
}

.app-shell {
  height: 100%;
  width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: 198px minmax(0, 1fr);
  transition: grid-template-columns 0.22s ease;
}

.sidebar {
  background: linear-gradient(180deg, #1b1b1b 0%, #121212 100%);
  border-right: 1px solid var(--sidebar-line);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 11px 9px;
  min-height: 0;
  transition: padding 0.2s ease;
}

.sidebar-header {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 12px;
}

.sidebar-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.collapse-btn {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid #3a3a3a;
  background: #242424;
  color: #d4d4d8;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
}

.collapse-btn:hover {
  background: #2f2f2f;
}

.brand {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.sidebar-subtitle {
  font-size: 12px;
  color: var(--sidebar-muted);
  margin: 2px 4px 8px;
}

.conversation-list {
  overflow: auto;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 2px;
}

.sidebar-footer {
  border-top: 1px solid #2e2e2e;
  padding-top: 10px;
  margin-top: 10px;
  position: relative;
}

.profile-btn {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  color: #e5e5e5;
  border-radius: 10px;
  padding: 8px 9px;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.profile-btn:hover {
  background: #2a2a2a;
  border-color: #3a3a3a;
}

.profile-avatar {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #374151;
  color: #f9fafb;
  font-size: 12px;
}

.profile-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
}

.profile-name {
  font-size: 12px;
  color: #f4f4f5;
}

.profile-email {
  max-width: 100%;
  font-size: 11px;
  color: #a1a1aa;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-level {
  font-size: 11px;
  color: #a1a1aa;
}

.profile-chevron {
  color: #a1a1aa;
  font-size: 11px;
}

.profile-menu {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 6px);
  border: 1px solid #3a3a3a;
  background: #1f1f1f;
  border-radius: 10px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
  padding: 8px;
  max-height: min(62vh, 520px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

.profile-menu.hidden {
  display: none;
}

.profile-menu-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 8px;
}

.profile-menu-account {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 2px 8px;
}

.profile-menu-account-name {
  font-size: 13px;
  font-weight: 600;
  color: #f5f5f5;
}

.profile-menu-account-email {
  font-size: 12px;
  color: #a1a1aa;
  word-break: break-all;
}

.profile-menu-label {
  font-size: 11px;
  color: #a1a1aa;
  letter-spacing: 0.01em;
}

.profile-menu-select {
  width: 100%;
  border: 1px solid #3f3f46;
  border-radius: 8px;
  background: #27272a;
  color: #e5e7eb;
  padding: 6px 8px;
  font-size: 12px;
  outline: none;
}

.profile-menu-select:focus {
  border-color: #10a37f;
  box-shadow: 0 0 0 2px rgba(16, 163, 127, 0.2);
}

.profile-menu-divider {
  height: 1px;
  background: #3a3a3a;
  margin: 2px 0 8px;
}

.profile-menu-item {
  width: 100%;
  border: 0;
  border-radius: 8px;
  text-align: left;
  background: transparent;
  color: #e5e5e5;
  padding: 8px 10px;
  font-size: 13px;
  cursor: pointer;
}

.profile-menu-item:hover {
  background: #2f2f2f;
}

.profile-menu-item-danger {
  color: #fda4af;
}

.profile-menu-item-danger:hover {
  background: rgba(190, 24, 93, 0.16);
}

body.auth-page {
  min-height: 100%;
  background:
    radial-gradient(circle at 20% 20%, rgba(16, 163, 127, 0.14), transparent 35%),
    radial-gradient(circle at 85% 10%, rgba(59, 130, 246, 0.16), transparent 32%),
    linear-gradient(180deg, #f3f4f6 0%, #eef2ff 100%);
}

.auth-shell {
  min-height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 460px);
  gap: 32px;
  align-items: center;
  padding: 48px min(6vw, 72px);
}

.auth-hero {
  max-width: 620px;
}

.auth-shell-wide {
  grid-template-columns: minmax(0, 1fr) minmax(360px, 620px);
}

.auth-hero-badge {
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #0f766e;
  background: rgba(255, 255, 255, 0.72);
}

.auth-hero h1 {
  margin: 18px 0 14px;
  font-size: clamp(40px, 5vw, 64px);
  line-height: 0.95;
  letter-spacing: -0.04em;
  color: #0f172a;
}

.auth-hero p {
  margin: 0;
  max-width: 560px;
  font-size: 17px;
  line-height: 1.7;
  color: #334155;
}

.auth-hero-points {
  margin: 24px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 12px;
}

.auth-hero-points li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: #1e293b;
}

.auth-hero-points li::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(135deg, #10a37f, #2563eb);
  box-shadow: 0 0 0 4px rgba(16, 163, 127, 0.12);
}

.auth-card {
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 28px;
  padding: 28px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.12);
  backdrop-filter: blur(16px);
}

.auth-card-extended {
  padding: 26px 24px 24px;
}

.auth-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.auth-card-head-stack {
  align-items: flex-start;
  flex-direction: column;
}

.auth-brand {
  font-size: 18px;
  font-weight: 700;
  color: #0f172a;
}

.auth-tabs {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 5px;
  border-radius: 999px;
  background: #f1f5f9;
}

.auth-tabs-wrap {
  width: 100%;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.auth-tab {
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #475569;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.auth-tab.active {
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
}

.auth-intro {
  margin: 18px 0 0;
  font-size: 14px;
  line-height: 1.6;
  color: #475569;
}

.auth-notice {
  margin-top: 18px;
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.6;
}

.auth-notice.is-error {
  color: #991b1b;
  background: #fee2e2;
  border: 1px solid #fecaca;
}

.auth-notice.is-success {
  color: #166534;
  background: #dcfce7;
  border: 1px solid #bbf7d0;
}

.auth-form {
  display: grid;
  gap: 14px;
  margin-top: 20px;
}

.auth-inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.auth-link-btn {
  border: 0;
  background: transparent;
  color: #0f766e;
  padding: 0;
  font-size: 13px;
  cursor: pointer;
}

.auth-link-btn:hover {
  text-decoration: underline;
}

.auth-field {
  display: grid;
  gap: 7px;
}

.auth-field span {
  font-size: 12px;
  color: #334155;
}

.auth-field input {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 14px;
  background: #ffffff;
  color: #0f172a;
  padding: 13px 14px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.auth-field input:focus {
  border-color: #10a37f;
  box-shadow: 0 0 0 4px rgba(16, 163, 127, 0.12);
}

.auth-submit {
  border: 0;
  border-radius: 16px;
  background: linear-gradient(135deg, #111827 0%, #10a37f 100%);
  color: #ffffff;
  padding: 14px 16px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, opacity 0.16s ease;
}

.auth-submit:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 36px rgba(16, 163, 127, 0.2);
}

.auth-submit:disabled {
  cursor: wait;
  opacity: 0.72;
  transform: none;
  box-shadow: none;
}

.auth-footnote {
  margin: 18px 0 0;
  font-size: 12px;
  line-height: 1.6;
  color: #64748b;
}

body.admin-page {
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(16, 163, 127, 0.12), transparent 30%),
    linear-gradient(180deg, #f8fafc 0%, #eef2ff 100%);
}

.admin-shell {
  min-height: 100%;
  padding: 32px min(5vw, 56px) 48px;
}

.admin-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.admin-header h1 {
  margin: 8px 0 8px;
  font-size: clamp(30px, 4vw, 46px);
  line-height: 1;
  color: #0f172a;
}

.admin-header p {
  margin: 0;
  color: #475569;
  line-height: 1.7;
}

.admin-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: rgba(255, 255, 255, 0.82);
  color: #0f766e;
  padding: 7px 12px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.admin-header-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.admin-primary-btn,
.admin-secondary-btn,
.admin-danger-btn,
.admin-link-btn {
  border: 0;
  border-radius: 14px;
  padding: 11px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

.admin-primary-btn {
  background: #0f172a;
  color: #ffffff;
}

.admin-secondary-btn {
  background: #e2e8f0;
  color: #0f172a;
}

.admin-danger-btn {
  background: #fee2e2;
  color: #b91c1c;
}

.admin-link-btn {
  background: #ffffff;
  color: #0f172a;
  border: 1px solid #cbd5e1;
}

.admin-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.admin-summary-card,
.admin-block {
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: rgba(255, 255, 255, 0.92);
  border-radius: 22px;
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.08);
}

.admin-summary-card {
  padding: 18px;
}

.admin-summary-label {
  font-size: 12px;
  color: #64748b;
}

.admin-summary-value {
  margin-top: 8px;
  font-size: 32px;
  font-weight: 700;
  color: #0f172a;
}

.admin-block {
  margin-top: 16px;
  padding: 18px;
}

.admin-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.admin-block-head h2 {
  margin: 0;
  font-size: 18px;
  color: #0f172a;
}

.admin-current-text {
  font-size: 13px;
  color: #475569;
}

.admin-card-list {
  display: grid;
  gap: 14px;
}

.admin-user-card {
  border: 1px solid #e2e8f0;
  border-radius: 18px;
  padding: 16px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

.admin-user-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.admin-user-name {
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
}

.admin-user-email,
.admin-user-meta {
  color: #64748b;
  font-size: 13px;
  line-height: 1.6;
}

.admin-status-tag {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: #e0f2fe;
  color: #075985;
  padding: 6px 10px;
  font-size: 12px;
  white-space: nowrap;
}

.admin-user-actions,
.admin-table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.admin-table-wrap {
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
}

.admin-table th,
.admin-table td {
  padding: 12px 10px;
  border-bottom: 1px solid #e2e8f0;
  text-align: left;
  font-size: 13px;
  color: #0f172a;
}

.admin-table th {
  color: #64748b;
  font-weight: 600;
}

.admin-table-empty {
  text-align: center;
  color: #64748b;
}

.admin-audit-list {
  display: grid;
  gap: 12px;
}

.admin-audit-item {
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 14px;
  background: #ffffff;
}

.admin-audit-title {
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
}

.admin-audit-meta {
  margin-top: 4px;
  font-size: 12px;
  color: #64748b;
}

.admin-audit-details {
  margin: 10px 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12px;
  color: #334155;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.admin-empty {
  border: 1px dashed #cbd5e1;
  border-radius: 16px;
  padding: 18px;
  color: #64748b;
  text-align: center;
}

.conversation-item {
  border: 1px solid transparent;
  background: transparent;
  border-radius: 12px;
  padding: 7px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.conversation-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.conversation-item:hover {
  background: var(--sidebar-hover);
}

.conversation-item.active {
  border-color: #3f3f46;
  background: var(--sidebar-active);
}

.conversation-actions-wrap {
  position: relative;
  flex: 0 0 auto;
}

.conversation-manage-btn {
  width: 22px;
  height: 22px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: #a1a1aa;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.conversation-item:hover .conversation-manage-btn,
.conversation-item.active .conversation-manage-btn,
.conversation-manage-btn.active {
  opacity: 1;
}

.conversation-manage-btn:hover,
.conversation-manage-btn.active {
  background: #2f2f2f;
  border-color: #454545;
  color: #f4f4f5;
}

.conversation-action-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 124px;
  border: 1px solid #3a3a3a;
  border-radius: 10px;
  background: #1f1f1f;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.35);
  padding: 6px;
  z-index: 8;
}

.conversation-action-menu.hidden {
  display: none;
}

.conversation-action-item {
  width: 100%;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #e5e5e5;
  text-align: left;
  font-size: 12px;
  padding: 7px 9px;
  cursor: pointer;
}

.conversation-action-item:hover {
  background: #2f2f2f;
}

.conversation-action-item.conversation-action-danger {
  color: #fecaca;
}

.conversation-action-item.conversation-action-danger:hover {
  background: #3f1d1d;
  color: #fee2e2;
}

@media (hover: none) {
  .conversation-manage-btn {
    opacity: 1;
  }
}

.conversation-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--sidebar-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-meta {
  margin-top: 4px;
  font-size: 11px;
  color: var(--sidebar-muted);
}

.app-shell.sidebar-collapsed {
  grid-template-columns: 66px minmax(0, 1fr);
}

.app-shell.sidebar-collapsed .sidebar {
  padding: 12px 8px;
}

.app-shell.sidebar-collapsed .brand,
.app-shell.sidebar-collapsed .sidebar-subtitle,
.app-shell.sidebar-collapsed .conversation-list,
.app-shell.sidebar-collapsed .profile-main,
.app-shell.sidebar-collapsed .profile-chevron {
  display: none;
}

.app-shell.sidebar-collapsed .sidebar-topline {
  justify-content: center;
}

.app-shell.sidebar-collapsed .btn-primary {
  width: 42px;
  height: 42px;
  padding: 0;
  margin: 0 auto;
  border-radius: 12px;
  font-size: 0;
}

.app-shell.sidebar-collapsed .btn-primary::before {
  content: '+';
  font-size: 24px;
  line-height: 1;
}

.app-shell.sidebar-collapsed .profile-btn {
  grid-template-columns: 1fr;
  justify-items: center;
  padding: 8px;
}

.app-shell.sidebar-collapsed .profile-menu {
  left: calc(100% + 8px);
  right: auto;
  bottom: 0;
  width: 248px;
}

.main-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: 0;
  min-width: 0;
}

.main-header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: rgba(247, 247, 248, 0.9);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.header-center h2 {
  margin: 0;
  font-size: 16px;
  line-height: 1.3;
}

.config-hint {
  margin: 3px 0 0;
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg-main);
  color: var(--text-main);
  cursor: pointer;
  font-size: 16px;
  display: none;
}

.icon-btn-show {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.message-list {
  overflow: auto;
  padding: 24px 0 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.message-list.focus-scroll-active::after {
  content: '';
  display: block;
  flex: 0 0 auto;
  height: var(--focus-anchor-space, 52vh);
  pointer-events: none;
}

.message-row {
  width: 100%;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  padding: 0 clamp(10px, 1.6vw, 20px);
}

.message-row.user {
  justify-content: flex-end;
}

.message-row.enter .message-inner {
  animation: bubble-in-left 0.26s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.message-row.enter.user .message-inner {
  animation: bubble-in-right 0.26s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.message-inner {
  width: 100%;
  max-width: none;
  min-width: 0;
  display: flex;
  gap: 0;
  align-items: flex-start;
}

.message-row.assistant .message-inner {
  width: 100%;
  max-width: none;
}

.message-row.user .message-inner {
  width: 100%;
  max-width: none;
  justify-content: flex-end;
}

.avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  flex: 0 0 auto;
}

.avatar.assistant {
  color: #0f172a;
  background: linear-gradient(145deg, #e2e8f0 0%, #cbd5e1 100%);
}

.avatar.user {
  color: #fff;
  background: linear-gradient(145deg, #374151 0%, #111827 100%);
}

.message {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bubble-assistant);
  box-shadow: var(--shadow);
  padding: 12px 14px;
  line-height: 1.65;
  font-size: 14px;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.message.user {
  background: var(--bubble-user);
  color: #1f2937;
  border-color: #cfe3d6;
  margin-left: auto;
  width: fit-content;
  max-width: min(86%, 980px);
  box-shadow: 0 12px 26px rgba(92, 142, 112, 0.14);
}

.message.assistant {
  color: var(--text-main);
  border: none;
  background: transparent;
  box-shadow: none;
  border-radius: 0;
  padding: 0;
  width: 100%;
  max-width: 100%;
}

.message.user .message-meta {
  color: rgba(31, 41, 55, 0.58);
}

.summary {
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.summary strong {
  color: #374151;
}

.summary-soft {
  color: #9ca3af;
}

.stage1-head {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: nowrap;
  gap: 8px;
}

.stage1-head strong {
  min-width: 0;
  white-space: nowrap;
}

.stage1-head-compact {
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
}

.stage1-head-difficulty {
  display: inline-flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 4px;
  margin-left: auto;
  text-align: right;
  line-height: 1;
}

.stage1-head-difficulty-label {
  color: #94a3b8;
  font-size: 10px;
  line-height: 1.2;
  white-space: nowrap;
  font-weight: 500;
}

.stage1-head-difficulty-value {
  font-size: 16px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.01em;
}

.stage1-head-difficulty.difficulty-easy {
  color: #166534;
}

.stage1-head-difficulty.difficulty-medium {
  color: #1d4ed8;
}

.stage1-head-difficulty.difficulty-hard {
  color: #c2410c;
}

.stage1-head-difficulty.difficulty-very-hard {
  color: #b91c1c;
}

.stage1-head-difficulty.difficulty-unknown {
  color: #4b5563;
}

.message-meta {
  margin-top: 8px;
  font-size: 11px;
  color: #9ca3af;
  line-height: 1.35;
}

.message-meta-soft {
  color: #9ca3af;
}

.stage1-summary-grid {
  display: grid;
  gap: 8px;
}

.stage1-overview-inline {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: nowrap;
}

.stage1-followup-note {
  font-size: 12px;
  line-height: 1.45;
  color: #374151;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.62);
  padding: 7px 10px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-end;
  text-align: right;
  flex: 0 0 auto;
  width: max-content;
  max-width: 100%;
  min-width: 0;
  margin-left: auto;
}

.stage1-followup-summary-line {
  font-size: 12px;
  line-height: 1.45;
  width: 100%;
}

.stage1-followup-summary-line + .stage1-followup-summary-line {
  margin-top: 2px;
}

.stage1-followup-summary-line-primary {
  font-weight: 600;
}

.stage1-followup-note.difficulty-easy {
  border-color: rgba(34, 197, 94, 0.22);
  color: #166534;
  background: rgba(240, 253, 244, 0.72);
}

.stage1-followup-note.difficulty-medium {
  border-color: rgba(59, 130, 246, 0.22);
  color: #1d4ed8;
  background: rgba(239, 246, 255, 0.74);
}

.stage1-followup-note.difficulty-hard {
  border-color: rgba(249, 115, 22, 0.24);
  color: #c2410c;
  background: rgba(255, 247, 237, 0.74);
}

.stage1-followup-note.difficulty-very-hard {
  border-color: rgba(239, 68, 68, 0.24);
  color: #b91c1c;
  background: rgba(254, 242, 242, 0.76);
}

.stage1-followup-note.difficulty-unknown {
  border-color: rgba(148, 163, 184, 0.22);
  color: #4b5563;
  background: rgba(249, 250, 251, 0.78);
}

.level-overview {
  margin-top: 12px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #fafafa;
  padding: 10px;
}

.level-overview-compact {
  margin-top: 0;
  padding: 7px 9px;
  width: auto;
  min-width: 280px;
  max-width: none;
  flex: 1 1 460px;
}

.ratio-bar {
  height: 11px;
  width: 100%;
  border-radius: 999px;
  overflow: hidden;
  background: #e2e8f0;
  display: flex;
  gap: 1px;
  padding: 1px;
}

.level-overview-compact .ratio-bar {
  width: 100%;
}

.ratio-segment {
  height: 100%;
  border-radius: 999px;
}

.ratio-empty {
  display: inline-flex;
  align-items: center;
  padding-left: 8px;
  color: #9ca3af;
  font-size: 11px;
}

.ratio-note {
  margin-top: 8px;
  color: #9ca3af;
  font-size: 11px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.ratio-note-compact {
  margin-top: 6px;
  gap: 8px;
}

.ratio-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.ratio-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  display: inline-block;
}

.dual-row-wrap {
  margin-top: 12px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #ffffff;
  padding: 8px;
}

.stage1-token-panel {
  border-top: 1px solid rgba(148, 163, 184, 0.22);
  padding-top: 8px;
  display: grid;
  gap: 6px;
}

.stage1-token-head {
  display: flex;
  align-items: center;
  margin-bottom: 0;
  width: 100%;
}

.stage1-token-title {
  min-width: 0;
}

.stage1-token-head-note-inline {
  color: #94a3b8;
  font-size: 11px;
  line-height: 1.35;
  white-space: nowrap;
}

.stage1-token-panel .dual-row-grid {
  margin-top: 0;
}

.llm-block {
  margin-top: 12px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #fbfcfe;
  padding: 10px;
}

.llm-loading-block {
  background: linear-gradient(180deg, #f8fbff 0%, #f3f7ff 100%);
}

.stage2-block {
  display: grid;
  gap: 8px;
}

.stage2-segment {
  min-width: 0;
}

@media (max-width: 720px) {
  .stage1-overview-inline {
    gap: 8px;
    flex-wrap: wrap;
  }

  .stage1-head-difficulty {
    width: 100%;
    justify-content: flex-end;
  }

  .level-overview-compact {
    width: 100%;
    min-width: 0;
  }

  .level-overview-compact .ratio-bar {
    width: 100%;
  }

  .stage1-followup-note {
    flex-basis: 100%;
    width: 100%;
  }

  .stage1-token-head-note-inline {
    font-size: 10px;
  }
}

.llm-title {
  font-size: 13px;
  font-weight: 700;
  color: #1f2937;
  margin-bottom: 6px;
}

.stage2-loading-text {
  margin-top: 1px;
  font-size: 13px;
  color: #9ca3af;
}

.stage2-error-wrap {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.stage2-error-main {
  min-width: 0;
  flex: 1 1 auto;
}

.stage2-error-actions {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stage2-copy-prompt-btn {
  white-space: nowrap;
}

.llm-loading-skeleton,
.llm-inline-skeleton {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.llm-inline-skeleton {
  margin-top: 4px;
}

.llm-skeleton-line {
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, #f1f5f9 0%, #e2e8f0 50%, #f1f5f9 100%);
  background-size: 200% 100%;
  animation: word-skeleton-flow 1.2s ease-in-out infinite;
}

.llm-skeleton-line-wide {
  width: 90%;
}

.llm-skeleton-line-mid {
  width: 72%;
}

.llm-skeleton-line-narrow {
  width: 58%;
}

.llm-subtitle {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 600;
  color: #4b5563;
}

.explain-list {
  margin: 6px 0 0;
  padding-left: 18px;
  color: #374151;
  font-size: 13px;
}

.explain-list li {
  margin-bottom: 5px;
}

.simplified-text {
  margin-top: 0;
  border: 0;
  background: transparent;
  border-radius: 0;
  padding: 0;
  font-size: 14px;
  color: #0f172a;
  line-height: 1.7;
  white-space: pre-wrap;
}

.simplified-card {
  margin-top: 6px;
  border: 1px solid #dbeafe;
  background: linear-gradient(180deg, #f8fbff 0%, #f2f8ff 100%);
  border-radius: 11px;
  padding: 9px 10px;
}

.sentence-actions-row {
  margin-top: 8px;
  display: flex;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 6px;
}

.sentence-actions-row-rewrite {
  justify-content: flex-start;
  align-items: center;
  gap: 10px;
}

.sentence-actions-left,
.sentence-actions-right {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.sentence-actions-row-rewrite .sentence-actions-right {
  margin-left: auto;
}

.sentence-action-btn {
  border: 1px solid #d1d5db;
  background: #ffffff;
  color: #1f2937;
  border-radius: 9px;
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.sentence-action-btn:hover {
  border-color: #93c5fd;
  color: #1d4ed8;
}

.sentence-action-btn-translate {
  background: #f8fafc;
}

.sentence-action-btn-tokenize {
  background: #eef2ff;
  border-color: #c7d2fe;
  color: #3730a3;
}

.sentence-action-btn-tokenize:hover {
  border-color: #a5b4fc;
  color: #312e81;
}

.sentence-action-btn-toggle {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: #334155;
  gap: 6px;
}

.toggle-arrow {
  font-size: 10px;
  line-height: 1;
  color: inherit;
  opacity: 0.75;
}

.analyze-sentence-btn {
  border-color: #22c55e;
  background: linear-gradient(135deg, #dcfce7 0%, #d1fae5 100%);
  color: #14532d;
  box-shadow: 0 4px 12px rgba(34, 197, 94, 0.16);
}

.translation-panel {
  margin-top: 8px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #ffffff;
  padding: 7px 8px;
}

.translation-title {
  font-size: 11px;
  color: #6b7280;
  margin-bottom: 4px;
}

.translation-text {
  font-size: 13px;
  color: #111827;
  line-height: 1.58;
}

.translation-loading {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.translation-actions-row {
  margin-top: 8px;
  display: flex;
  justify-content: flex-end;
}

.plain-message-text {
  white-space: pre-wrap;
  word-break: break-word;
}

.dual-row-toolbar {
  margin-top: 6px;
  display: flex;
  justify-content: flex-end;
}

.dual-row-translation .translation-panel {
  margin-top: 6px;
}

.simplified-card .translation-panel {
  margin-top: 6px;
  padding: 6px 8px;
}

.variant-token-panel {
  margin-top: 8px;
  border: 1px solid #dbeafe;
  border-radius: 10px;
  background: #ffffff;
  padding: 7px 8px;
}

.variant-token-head {
  margin-top: 6px;
  margin-bottom: 4px;
}

.variant-token-legend {
  justify-content: flex-start;
}

.variant-token-grid {
  margin-top: 2px;
}

.variant-token-explain-title {
  margin-top: 8px;
}

.explain-list-compact {
  margin-top: 4px;
}

.message.user .translation-panel {
  background: rgba(255, 255, 255, 0.76);
  border-color: #cfe3d6;
}

.message.user .translation-title {
  color: #2f6b4f;
}

.message.user .translation-text {
  color: #1f2937;
}

.message.user .sentence-action-btn {
  border-color: #cfe3d6;
  background: rgba(255, 255, 255, 0.76);
  color: #2f6b4f;
}

.message.user .sentence-action-btn:hover {
  border-color: #7fb699;
  color: #1f5a40;
}

.message.user .llm-skeleton-line {
  background: linear-gradient(90deg, rgba(163, 212, 183, 0.24) 0%, rgba(255, 255, 255, 0.82) 50%, rgba(163, 212, 183, 0.24) 100%);
  background-size: 200% 100%;
  animation: word-skeleton-flow 1.2s ease-in-out infinite;
  border-radius: 8px;
}

.rewrite-panel {
  margin-top: 10px;
  border-top: 1px dashed #d1d5db;
  padding-top: 8px;
}

.rewrite-panel.rewrite-panel-compact {
  margin-top: 0;
  border-top: none;
  padding-top: 0;
}

.level-switch {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.level-chip {
  border: 1px solid #d1d5db;
  background: #ffffff;
  color: #374151;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1;
  padding: 7px 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.level-chip:hover {
  border-color: #93c5fd;
  color: #1d4ed8;
}

.level-chip.active {
  border-color: #3b82f6;
  background: #eff6ff;
  color: #1d4ed8;
}

.chip-badge {
  font-size: 10px;
  color: #6b7280;
}

.chip-badge-ok {
  color: #16a34a;
}

.chip-badge-error {
  color: #dc2626;
}

.variant-result {
  margin-top: 8px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #ffffff;
  padding: 8px 10px;
}

.debug-rewrite-wrap {
  margin-top: 10px;
  border-top: 1px dashed #d1d5db;
  padding-top: 8px;
}

.debug-rewrite-grid {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.debug-rewrite-card {
  border: 1px solid #dbeafe;
  border-radius: 10px;
  background: #ffffff;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.debug-rewrite-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.debug-rewrite-model-wrap {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.debug-rewrite-model {
  font-size: 12px;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.debug-rewrite-time {
  font-size: 12px;
  font-weight: 800;
  color: #1d4ed8;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.debug-status {
  border-radius: 999px;
  font-size: 10px;
  padding: 2px 7px;
  border: 1px solid transparent;
  line-height: 1.2;
  white-space: nowrap;
}

.debug-status-ok {
  color: #166534;
  border-color: #86efac;
  background: #f0fdf4;
}

.debug-status-fail {
  color: #991b1b;
  border-color: #fecaca;
  background: #fef2f2;
}

.debug-rewrite-text {
  font-size: 13px;
  line-height: 1.58;
  color: #111827;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.prompt-preview-card {
  border: 1px solid #fcd34d;
  background: #fffbeb;
}

.prompt-preview-text {
  margin-top: 6px;
  margin-bottom: 0;
  border: 1px solid #fde68a;
  border-radius: 8px;
  background: #ffffff;
  padding: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
  font-size: 12px;
  line-height: 1.5;
  color: #0f172a;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 280px;
  overflow: auto;
}

.prompt-preview-actions {
  margin-top: 8px;
}

.over-level-word {
  color: #b91c1c;
  font-weight: 800;
}

.dual-row-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.dual-row-title {
  font-size: 12px;
  color: #6b7280;
}

.dual-row-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px 8px;
  font-size: 11px;
  color: #9ca3af;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.legend-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  display: inline-block;
}

.dual-row-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 5px;
}

.token-grid-scrollable {
  max-height: min(46vh, 420px);
  overflow-y: auto;
  padding-right: 2px;
  align-content: flex-start;
  scrollbar-gutter: stable;
  -webkit-overflow-scrolling: touch;
}

.token-grid-scrollable::-webkit-scrollbar {
  width: 8px;
}

.token-grid-scrollable::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.55);
  border-radius: 999px;
}

.token-grid-scrollable::-webkit-scrollbar-track {
  background: transparent;
}

.token-col {
  border: 1px solid #e5e7eb;
  border-radius: 7px;
  overflow: hidden;
  width: max-content;
  max-width: 100%;
}

.token-clickable {
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.token-clickable:hover {
  border-color: #93c5fd;
  box-shadow: 0 6px 16px rgba(59, 130, 246, 0.16);
  transform: translateY(-1px);
}

.token-word {
  padding: 4px 7px;
  background: #ffffff;
  border-bottom: 1px solid #e5e7eb;
  text-align: center;
  font-size: 12px;
  color: #111827;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

.token-color {
  height: 8px;
  width: 100%;
}

.token-col-text .token-word {
  border-bottom: 0;
}

.token-word-level {
  font-weight: 700;
}

.level-l1 {
  background: #22c55e;
  color: #14532d;
}

.level-l2 {
  background: #14b8a6;
  color: #134e4a;
}

.level-l3 {
  background: #06b6d4;
  color: #164e63;
}

.level-l4 {
  background: #3b82f6;
  color: #1e3a8a;
}

.level-l5 {
  background: #6366f1;
  color: #312e81;
}

.level-l6 {
  background: #8b5cf6;
  color: #4c1d95;
}

.level-l10 {
  background: #b91c1c;
  color: #7f1d1d;
}

.level-l0,
.level-lp {
  background: #9ca3af;
  color: #374151;
}

.level-text-l1 {
  color: #22c55e;
}

.level-text-l2 {
  color: #14b8a6;
}

.level-text-l3 {
  color: #06b6d4;
}

.level-text-l4 {
  color: #3b82f6;
}

.level-text-l5 {
  color: #6366f1;
}

.level-text-l6 {
  color: #8b5cf6;
}

.level-text-l10 {
  color: #b91c1c;
}

.level-text-l0,
.level-text-lp {
  color: #6b7280;
}

.scheme-under {
  background: #10b981;
  color: #065f46;
}

.scheme-over {
  background: #ef4444;
  color: #7f1d1d;
}

.scheme-neutral {
  background: #9ca3af;
  color: #374151;
}

.text-under {
  color: #0f766e;
}

.text-over {
  color: #dc2626;
}

.text-neutral {
  color: #6b7280;
}

@keyframes bubble-in-left {
  0% {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes bubble-in-right {
  0% {
    opacity: 0;
    transform: translateY(12px) translateX(8px) scale(0.98);
  }
  100% {
    opacity: 1;
    transform: translateY(0) translateX(0) scale(1);
  }
}

@keyframes llm-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes llm-track-move {
  0% {
    transform: translateX(-110%);
  }
  50% {
    transform: translateX(80%);
  }
  100% {
    transform: translateX(280%);
  }
}

@keyframes llm-dot-flash {
  0% {
    opacity: 0.25;
    transform: translateY(0);
  }
  50% {
    opacity: 1;
    transform: translateY(-1px);
  }
  100% {
    opacity: 0.25;
    transform: translateY(0);
  }
}

@keyframes stage-reveal-in {
  0% {
    opacity: 0;
    transform: translateY(10px) scale(0.982);
  }
  55% {
    opacity: 0.72;
  }
  100% {
    opacity: 1;
    transform: none;
  }
}

@keyframes token-pop-in {
  0% {
    opacity: 0;
    transform: translateY(9px) scale(0.93);
  }
  45% {
    opacity: 0.56;
  }
  100% {
    opacity: 1;
    transform: none;
  }
}

@keyframes stage-detail-in {
  0% {
    opacity: 0;
    transform: translateY(7px);
  }
  60% {
    opacity: 0.8;
  }
  100% {
    opacity: 1;
    transform: none;
  }
}

@keyframes char-reveal-in {
  0% {
    opacity: 0;
  }
  60% {
    opacity: 0.78;
  }
  100% {
    opacity: 1;
  }
}

.stage1-layout {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stage1-layout .stage-block {
  display: flex;
  flex-direction: column;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  background: #ffffff;
  padding: 12px;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.04);
  position: relative;
  overflow: hidden;
}

.stage1-layout .stage-block::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  opacity: 0.88;
}

.stage1-layout .stage-block-primary {
  border-color: #d7ede1;
  background: linear-gradient(180deg, #fcfffd 0%, #f6fbf8 100%);
  box-shadow: 0 10px 24px rgba(52, 211, 153, 0.08);
}

.stage1-layout .stage-block-primary-merged {
  padding: 11px 12px;
}

.stage1-layout .stage-block-primary::before {
  background: linear-gradient(180deg, #34d399 0%, #10b981 100%);
}

.stage1-layout .stage-block-primary.difficulty-easy {
  border-color: #86efac;
  background: linear-gradient(180deg, #fbfffc 0%, #ecfdf3 100%);
  box-shadow: 0 12px 26px rgba(34, 197, 94, 0.1);
}

.stage1-layout .stage-block-primary.difficulty-easy::before {
  background: linear-gradient(180deg, #22c55e 0%, #16a34a 100%);
}

.stage1-layout .stage-block-primary.difficulty-medium {
  border-color: #93c5fd;
  background: linear-gradient(180deg, #fbfdff 0%, #eff6ff 100%);
  box-shadow: 0 12px 26px rgba(59, 130, 246, 0.1);
}

.stage1-layout .stage-block-primary.difficulty-medium::before {
  background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
}

.stage1-layout .stage-block-primary.difficulty-hard {
  border-color: #fdba74;
  background: linear-gradient(180deg, #fffdfa 0%, #fff7ed 100%);
  box-shadow: 0 12px 26px rgba(249, 115, 22, 0.1);
}

.stage1-layout .stage-block-primary.difficulty-hard::before {
  background: linear-gradient(180deg, #fb923c 0%, #ea580c 100%);
}

.stage1-layout .stage-block-primary.difficulty-very-hard {
  border-color: #fca5a5;
  background: linear-gradient(180deg, #fffdfd 0%, #fef2f2 100%);
  box-shadow: 0 12px 26px rgba(239, 68, 68, 0.12);
}

.stage1-layout .stage-block-primary.difficulty-very-hard::before {
  background: linear-gradient(180deg, #ef4444 0%, #dc2626 100%);
}

.stage1-layout .stage-block-primary.difficulty-unknown {
  border-color: #d1d5db;
  background: linear-gradient(180deg, #ffffff 0%, #f9fafb 100%);
  box-shadow: 0 10px 22px rgba(148, 163, 184, 0.08);
}

.stage1-layout .stage-block-primary.difficulty-unknown::before {
  background: linear-gradient(180deg, #9ca3af 0%, #6b7280 100%);
}

.stage1-layout .stage-block-secondary {
  border-color: #dce8ef;
  background: linear-gradient(180deg, #ffffff 0%, #f9fcff 100%);
}

.stage1-layout .stage-block-secondary::before {
  background: linear-gradient(180deg, #22d3ee 0%, #06b6d4 100%);
}

.stage1-layout .stage-block-main {
  border-color: #dde5f5;
  background: linear-gradient(180deg, #fbfdff 0%, #f7f9ff 100%);
}

.stage1-layout .stage-block-main::before {
  background: linear-gradient(180deg, #818cf8 0%, #6366f1 100%);
}

.stage1-layout .stage-block-primary .stage1-head {
  margin-bottom: 10px;
}

.stage1-layout .stage-block-primary .summary + .summary {
  margin-top: 8px;
}

.stage1-layout .stage-block-secondary .dual-row-wrap {
  margin-top: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0;
}

.stage1-layout .stage-block-secondary .dual-row-head {
  margin-bottom: 8px;
}

.stage1-layout .stage-block-main .llm-block {
  margin-top: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0;
}

.stage1-layout.progressive-enter .stage-reveal {
  opacity: 0;
  transform: translateY(10px) scale(0.982);
  animation: stage-reveal-in calc(var(--stage-duration, 420ms) + 260ms) cubic-bezier(0.18, 0.82, 0.22, 1) forwards;
  animation-delay: var(--reveal-delay, 0ms);
  will-change: opacity, transform;
}

.stage1-layout.progressive-enter .stage-sequence-item {
  opacity: 0;
  transform: translateY(7px);
  animation: stage-detail-in var(--stage-detail-duration, 520ms) cubic-bezier(0.18, 0.82, 0.22, 1) forwards;
  animation-delay: var(--item-delay, 0ms);
  will-change: opacity, transform;
}

.stage1-layout.progressive-enter .token-col.token-col-animated {
  opacity: 0;
  transform: translateY(7px) scale(0.98);
  animation: token-pop-in var(--token-duration, 260ms) cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
  animation-delay: calc(var(--token-start-delay, 80ms) + var(--token-delay, 0ms));
}

.stage1-layout.progressive-enter .progressive-text .char-reveal {
  opacity: 0;
  animation: char-reveal-in var(--char-duration, 320ms) ease-out forwards;
  animation-delay: calc(var(--token-start-delay, 80ms) + var(--char-delay, 0ms));
}

.empty {
  font-size: 13px;
  color: var(--text-muted);
}

.empty-screen {
  width: calc(100% - 30px);
  margin: 80px auto 10px;
  text-align: center;
  color: var(--text-muted);
}

.empty-screen .title {
  font-size: 28px;
  font-weight: 700;
  color: #111827;
  margin-bottom: 12px;
}

.empty-screen .desc {
  font-size: 14px;
}

.composer-wrap {
  padding: 12px 18px 18px;
  background: linear-gradient(180deg, rgba(247, 247, 248, 0) 0%, rgba(247, 247, 248, 0.96) 25%, rgba(247, 247, 248, 1) 100%);
  border-top: 1px solid var(--line);
}

.composer-card {
  width: 100%;
  margin: 0 auto;
  border: 1px solid #d1d5db;
  border-radius: 22px;
  background: var(--bg-main);
  box-shadow: 0 20px 30px rgba(17, 24, 39, 0.06);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  padding: 10px;
  min-width: 0;
}

.composer-card textarea {
  border: none;
  outline: none;
  resize: none;
  min-height: 26px;
  max-height: 220px;
  height: 26px;
  padding: 6px 8px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.45;
  background: transparent;
  min-width: 0;
  overflow-y: hidden;
}

.btn {
  border: none;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-primary {
  width: 100%;
  background: #2a2a2a;
  color: #f4f4f5;
}

.btn-primary:hover {
  background: #3a3a3a;
}

.btn-send {
  align-self: auto;
  justify-self: end;
  min-width: 84px;
  position: relative;
  z-index: 1;
  background: var(--accent);
  color: #ffffff;
}

.btn-send:hover {
  background: var(--accent-hover);
}

.btn-send:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.composer-tip {
  width: 100%;
  margin: 8px auto 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
}

@media (max-width: 1280px) {
  .message.user {
    max-width: min(90%, 820px);
  }
}

@media (min-width: 1600px) {
  .composer-card {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
  }

  .btn-send {
    align-self: end;
    justify-self: end;
    min-width: 74px;
  }
}

.btn-light {
  background: #f3f4f6;
  color: #374151;
}

.btn-light:hover {
  background: #e5e7eb;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-backdrop.hidden {
  display: none;
}

.settings-panel {
  width: min(760px, 100%);
  border-radius: 16px;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  box-shadow: 0 30px 60px rgba(15, 23, 42, 0.24);
  padding: 16px 16px 12px;
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.settings-head h3 {
  margin: 0;
  font-size: 17px;
}

.settings-scroll {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
  touch-action: pan-y;
  padding-right: 4px;
  margin-right: -4px;
}

.settings-block {
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #fafafa;
  padding: 12px;
  margin-bottom: 0;
}

.settings-block.settings-block-wide {
  grid-column: 1 / -1;
}

.settings-title {
  font-size: 13px;
  color: #4b5563;
  margin-bottom: 8px;
}

.settings-help {
  margin-top: 6px;
  font-size: 11px;
  color: #9ca3af;
  line-height: 1.4;
}

.settings-option {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 14px;
  color: #374151;
}

.settings-option:last-child {
  margin-bottom: 0;
}

.settings-select {
  width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  background: #ffffff;
  padding: 8px 10px;
  font-size: 14px;
}

.settings-foot {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #e5e7eb;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  background: #ffffff;
}

.confirm-panel {
  width: min(420px, 100%);
  border-radius: 14px;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  box-shadow: 0 30px 60px rgba(15, 23, 42, 0.24);
  padding: 16px;
}

.confirm-title {
  font-size: 17px;
  font-weight: 700;
  color: #111827;
}

.confirm-message {
  margin-top: 10px;
  font-size: 14px;
  color: #1f2937;
  line-height: 1.5;
}

.confirm-warning {
  margin-top: 6px;
  font-size: 12px;
  color: #6b7280;
}

.confirm-actions {
  margin-top: 14px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.btn-danger {
  background: #dc2626;
  color: #ffffff;
}

.btn-danger:hover {
  background: #b91c1c;
}

.floating-word-layer {
  position: fixed;
  inset: 0;
  z-index: 58;
  pointer-events: none;
}

.floating-word-card {
  position: absolute;
  width: min(330px, calc(100vw - 18px));
  border-radius: 14px;
  border: 1px solid #d1d5db;
  background: #ffffff;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.2);
  overflow: hidden;
  pointer-events: auto;
}

.floating-word-card.active {
  border-color: #93c5fd;
  box-shadow: 0 20px 46px rgba(29, 78, 216, 0.18);
}

.floating-card-head {
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 7px 6px 9px;
  cursor: grab;
  user-select: none;
}

.floating-card-head:active {
  cursor: grabbing;
}

.floating-card-heading {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.floating-card-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.floating-card-title {
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.floating-card-level {
  border-radius: 999px;
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 10px;
  line-height: 1;
  padding: 3px 6px;
  white-space: nowrap;
}

.floating-card-subtitle {
  font-size: 11px;
  color: #6b7280;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.floating-card-tools {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 1px;
  flex: 0 0 auto;
}

.floating-card-close {
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #6b7280;
  cursor: pointer;
  margin-top: 1px;
  flex: 0 0 auto;
}

.floating-card-close:hover {
  background: #e5e7eb;
  color: #111827;
}

.floating-card-body {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  max-height: min(66vh, 480px);
  overflow: auto;
}

.word-actions-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.word-audio-btn {
  font-size: 11px;
  padding: 5px 8px;
  border-radius: 9px;
}

.word-audio-btn-head {
  padding: 4px 7px;
  font-size: 10px;
}

.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #6b7280;
  font-size: 10px;
}

.inline-check-head {
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 3px 5px;
}

.word-section {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #ffffff;
  padding: 7px 8px;
}

.word-section.compact {
  padding: 7px 8px 6px;
}

.word-section-title {
  font-size: 12px;
  font-weight: 700;
  color: #374151;
}

.word-supplement-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: #6b7280;
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 999px;
  padding: 4px 8px;
  width: fit-content;
}

.word-supplement-indicator-error {
  color: #b91c1c;
  background: #fef2f2;
  border-color: #fecaca;
}

.word-supplement-spinner {
  width: 12px;
  height: 12px;
  border: 2px solid #bfdbfe;
  border-top-color: #3b82f6;
  border-radius: 999px;
  animation: llm-spin 0.9s linear infinite;
}

.word-list {
  margin: 5px 0 0;
  padding-left: 15px;
  color: #1f2937;
  font-size: 11.5px;
  line-height: 1.52;
}

.word-list li {
  margin-bottom: 4px;
}

.word-list.word-list-skeleton {
  list-style: none;
  padding-left: 0;
  margin-top: 6px;
}

.word-skeleton-item {
  height: 10px;
  border-radius: 999px;
  margin-bottom: 6px;
  background: linear-gradient(90deg, #f1f5f9 0%, #e2e8f0 50%, #f1f5f9 100%);
  background-size: 200% 100%;
  animation: word-skeleton-flow 1.2s ease-in-out infinite;
}

.word-skeleton-item:nth-child(1) {
  width: 86%;
}

.word-skeleton-item:nth-child(2) {
  width: 64%;
}

@keyframes word-skeleton-flow {
  0% {
    background-position: 180% 0;
  }
  100% {
    background-position: -20% 0;
  }
}

.word-more-btn {
  margin-top: 2px;
  font-size: 10px;
  padding: 5px 7px;
  border-radius: 8px;
}

.source-note {
  margin-top: 2px;
  text-align: right;
  color: #9ca3af;
  font-size: 9.5px;
}

@media (max-width: 1360px) {
  .auth-shell {
    grid-template-columns: 1fr;
    gap: 24px;
    padding: 28px 18px 36px;
  }

  .auth-hero {
    max-width: none;
  }

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

  .auth-card-head {
    flex-direction: column;
    align-items: stretch;
  }

  .auth-tabs {
    width: 100%;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 224px;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 20;
  }

  .app-shell.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .app-shell.sidebar-open::after {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 10;
  }

  .icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .config-hint {
    max-width: calc(100vw - 92px);
  }

  .message-row {
    padding: 0 9px;
  }

  .message-inner {
    width: 100%;
    max-width: 100%;
  }

  .message.user {
    max-width: 100%;
  }

  .stage1-head {
    flex-direction: row;
    align-items: center;
    flex-wrap: nowrap;
    justify-content: flex-start;
  }

  .dual-row-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
  }

  .stage2-error-wrap {
    flex-direction: column;
    align-items: stretch;
  }

  .stage2-error-actions {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
  }

  .dual-row-legend {
    justify-content: flex-start;
  }

  .composer-wrap {
    padding: 10px 10px 12px;
  }

  .settings-panel {
    width: min(760px, 100%);
    max-height: calc(100vh - 40px);
  }

  .settings-scroll {
    grid-template-columns: minmax(0, 1fr);
    padding-right: 2px;
    margin-right: -2px;
  }

  .floating-word-card {
    width: min(312px, calc(100vw - 12px));
  }
}
