*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary: #00e5a8;
  --primary-dark: #00a77d;
  --success: #42f59b;
  --warning: #ffb84d;
  --danger: #ff5f73;
  --bg: #06151f;
  --card: rgba(10, 35, 49, 0.92);
  --text: #ecfeff;
  --text-secondary: #9fc3c9;
  --border: rgba(118, 255, 214, 0.18);
  --radius: 12px;
  --shadow: 0 18px 46px rgba(0,0,0,0.34);

  /* Fast mode palette */
  --fast-accent: #00e5ff;
  --fast-accent-light: #6df6ff;
  --fast-accent-dark: #007f9a;
  --fast-bg: rgba(0, 229, 255, 0.12);

  /* Precise mode palette */
  --precise-accent: #00e5a8;
  --precise-accent-light: #63ffd2;
  --precise-accent-dark: #008f69;
  --precise-bg: rgba(0, 229, 168, 0.13);

  --analog-accent: #f59e0b;
  --analog-accent-light: #fde68a;
  --analog-accent-dark: #b45309;
  --analog-bg: rgba(245, 158, 11, 0.13);

  /* Active mode (defaults to normal, overridden by data-mode) */
  --mode-accent: var(--fast-accent);
  --mode-accent-light: var(--fast-accent-light);
  --mode-accent-dark: var(--fast-accent-dark);
  --mode-bg: var(--fast-bg);
}

[data-mode="normal"] {
  --mode-accent: var(--fast-accent);
  --mode-accent-light: var(--fast-accent-light);
  --mode-accent-dark: var(--fast-accent-dark);
  --mode-bg: var(--fast-bg);
}

[data-mode="confirm"] {
  --mode-accent: var(--precise-accent);
  --mode-accent-light: var(--precise-accent-light);
  --mode-accent-dark: var(--precise-accent-dark);
  --mode-bg: var(--precise-bg);
}

[data-mode="analog"] {
  --mode-accent: var(--analog-accent);
  --mode-accent-light: var(--analog-accent-light);
  --mode-accent-dark: var(--analog-accent-dark);
  --mode-bg: var(--analog-bg);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1a2e;
    --card: #16213e;
    --text: #e0e0e0;
    --text-secondary: #aaaaaa;
    --border: #2a2a4a;
    --shadow: 0 2px 8px rgba(0,0,0,0.3);
    --fast-accent: #5bc0de;
    --fast-accent-light: #7ed4ec;
    --fast-accent-dark: #2997c5;
    --fast-bg: rgba(91, 192, 222, 0.1);
    --precise-accent: #8fa4b8;
    --precise-accent-light: #a8c0d4;
    --precise-accent-dark: #5a6a7e;
    --precise-bg: rgba(143, 164, 184, 0.1);
    --analog-accent: #f2b84b;
    --analog-accent-light: #ffdb8a;
    --analog-accent-dark: #b87716;
    --analog-bg: rgba(242, 184, 75, 0.12);
  }
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background:
    radial-gradient(circle at 12% 8%, rgba(0, 229, 168, 0.24), transparent 28%),
    radial-gradient(circle at 92% 16%, rgba(255, 184, 77, 0.18), transparent 25%),
    linear-gradient(135deg, #031018 0%, #082335 46%, #07161f 100%);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  overflow-x: hidden;
}

#app {
  max-width: 480px;
  width: 100%;
  margin: 0 auto;
  padding: 16px;
  overflow-x: hidden;
}

/* Screen transitions */
#main-content {
  transition: opacity 0.22s ease, transform 0.22s ease;
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
}

#main-content.screen-exit {
  opacity: 0;
  transform: translateY(6px);
}

#main-content.screen-enter {
  opacity: 0;
  transform: translateY(-6px);
}

.frontend-lock-screen {
  min-height: calc(100vh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  display: grid;
  place-items: center;
  padding: 24px;
}

.frontend-lock-card {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}

.frontend-lock-card h1,
.frontend-lock-card p {
  margin: 0;
}

.frontend-lock-card p {
  color: var(--text-secondary);
}

.frontend-lock-card label {
  display: grid;
  gap: 8px;
  font-weight: 800;
}

.frontend-lock-card input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.frontend-lock-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--mode-bg);
  color: var(--mode-accent-light);
  font-size: 24px;
}

.frontend-lock-status {
  min-height: 20px;
  color: var(--danger);
  font-weight: 700;
}

.frontend-lock-status.ok {
  color: var(--success);
}

.auth-card h2 {
  font-size: 1.2rem;
  line-height: 1.25;
}

.auth-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
}

.auth-tab {
  min-height: 36px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text-secondary);
  font-weight: 900;
  cursor: pointer;
}

.auth-tab.active {
  background: var(--mode-bg);
  color: var(--mode-accent-light);
  box-shadow: inset 0 0 0 1px rgba(99, 255, 210, 0.18);
}

.auth-code-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
}

.auth-code-row .btn {
  min-height: 43px;
  white-space: nowrap;
}

.auth-links {
  display: flex;
  justify-content: flex-end;
}

.auth-links button {
  border: 0;
  background: transparent;
  color: var(--mode-accent-light);
  font-weight: 800;
  cursor: pointer;
}

@media (max-width: 380px) {
  .frontend-lock-screen {
    padding: 14px;
  }

  .frontend-lock-card {
    padding: 20px;
  }

  .auth-code-row {
    grid-template-columns: 1fr;
  }
}

.account-entry-btn {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 12000;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px 7px 12px;
  border-radius: 999px;
  border: 1px solid rgba(99, 255, 210, 0.28);
  background: rgba(5, 21, 31, 0.92);
  color: var(--mode-accent-light);
  font-weight: 900;
  cursor: pointer;
}

.account-entry-btn b {
  min-width: 26px;
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(99, 255, 210, 0.14);
  color: #fff;
  font-size: 0.78rem;
}

.account-info-panel {
  position: fixed;
  inset: 0;
  z-index: 18000;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(2, 8, 13, 0.68);
  backdrop-filter: blur(8px);
}

.account-info-card {
  width: min(430px, calc(100vw - 28px));
  max-height: min(680px, calc(100dvh - 32px));
  overflow: auto;
  border-radius: 20px;
  border: 1px solid rgba(99, 255, 210, 0.24);
  background:
    radial-gradient(circle at 14% 0%, rgba(99, 255, 210, 0.13), transparent 30%),
    linear-gradient(180deg, rgba(8, 28, 40, 0.98), rgba(3, 14, 22, 0.98));
  color: var(--text);
  box-shadow: 0 28px 80px rgba(0,0,0,0.52);
  padding: 18px;
}

.account-info-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.account-info-head span {
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 800;
}

.account-info-head h3 {
  margin: 3px 0 0;
  font-size: 1.05rem;
  word-break: break-all;
}

.account-info-head button {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.06);
  color: var(--text);
}

.account-credit-hero {
  margin: 16px 0;
  padding: 16px;
  border-radius: 16px;
  border: 1px solid rgba(99, 255, 210, 0.22);
  background: rgba(99, 255, 210, 0.09);
}

.account-credit-hero span {
  display: block;
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 800;
}

.account-credit-hero strong {
  display: block;
  margin-top: 4px;
  color: #fff;
  font-size: 2rem;
  line-height: 1.1;
}

.account-info-grid {
  display: grid;
  gap: 8px;
}

.account-info-grid p,
.account-events li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  color: var(--text-secondary);
}

.account-info-grid span,
.account-events span,
.account-events em {
  text-align: right;
  word-break: break-all;
}

.account-info-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.account-events {
  margin-top: 16px;
}

.account-events h4 {
  margin: 0 0 8px;
  font-size: 0.92rem;
}

.account-events ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.account-events li {
  display: grid;
  grid-template-columns: auto 1fr;
}

.account-events li em {
  grid-column: 1 / -1;
  color: var(--text-secondary);
  font-style: normal;
  font-size: 0.76rem;
}

.account-recharge-box {
  margin: 14px 0;
  padding: 14px;
  border: 1px solid rgba(99, 255, 210, 0.18);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
}

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

.account-recharge-head h4 {
  margin: 0;
}

.account-recharge-head button {
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 8px;
  background: rgba(255,255,255,0.06);
  color: inherit;
  padding: 6px 10px;
}

.account-recharge-plans {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.account-recharge-plan {
  min-height: 64px;
  border: 1px solid rgba(99,255,210,0.22);
  border-radius: 10px;
  background: rgba(99,255,210,0.08);
  color: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.account-recharge-plan:disabled {
  opacity: 0.45;
}

.account-payment-card {
  margin-top: 12px;
  display: grid;
  gap: 8px;
}

.account-payment-card p {
  margin: 0;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
}

.account-info-empty,
.account-info-error {
  padding: 12px;
  border-radius: 12px;
  background: rgba(255,255,255,0.06);
  color: var(--text-secondary);
}

.account-info-error {
  margin-top: 12px;
  color: var(--danger);
  border: 1px solid rgba(255, 105, 120, 0.22);
}

.hidden {
  display: none !important;
}

.debug-panel {
  margin-top: 16px;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid rgba(255, 184, 77, 0.22);
  background: linear-gradient(180deg, rgba(45, 24, 7, 0.85), rgba(12, 10, 6, 0.9));
}

.debug-overlay {
  position: fixed;
  inset: 0;
  z-index: 22000;
  display: grid;
  place-items: end center;
  padding: 18px;
  background: rgba(2, 8, 16, 0.18);
}

.debug-overlay-card {
  width: min(94vw, 560px);
  max-height: 72vh;
  overflow: hidden;
  border-radius: 20px;
  border: 1px solid rgba(255, 184, 77, 0.28);
  background: linear-gradient(180deg, rgba(18, 18, 18, 0.98), rgba(8, 10, 12, 0.98));
  box-shadow: 0 22px 70px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
}

.debug-overlay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.debug-overlay-header h3 {
  font-size: 1rem;
}

.debug-overlay-header button {
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04);
  color: #fff;
  padding: 6px 10px;
  border-radius: 10px;
}

.debug-overlay-body {
  padding: 12px 14px 16px;
  overflow: auto;
  display: grid;
  gap: 8px;
}

.debug-panel h3 {
  font-size: 1rem;
  margin-bottom: 6px;
}

.debug-panel p {
  color: var(--text-secondary);
  font-size: 0.86rem;
  margin-bottom: 10px;
}

.debug-log-list {
  display: grid;
  gap: 8px;
}

.debug-log-item {
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  color: #f7f0df;
  font-size: 0.82rem;
  word-break: break-word;
}

/* ====================== UPLOAD SECTION ====================== */
.upload-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px 0;
}

.upload-header {
  position: relative;
  overflow: hidden;
  padding: 18px 16px 20px;
  border: 1px solid rgba(99, 255, 210, 0.22);
  border-radius: 26px;
  background:
    radial-gradient(circle at 12% 12%, rgba(0, 229, 255, 0.2), transparent 28%),
    radial-gradient(circle at 86% 8%, rgba(255, 184, 77, 0.16), transparent 25%),
    linear-gradient(145deg, rgba(11, 49, 66, 0.98), rgba(5, 23, 34, 0.92));
  box-shadow: 0 22px 56px rgba(0,0,0,0.34), inset 0 1px 0 rgba(255,255,255,0.08);
}

.hero-grid {
  position: absolute;
  inset: 0;
  opacity: 0.18;
  background-image:
    linear-gradient(rgba(99,255,210,0.22) 1px, transparent 1px),
    linear-gradient(90deg, rgba(99,255,210,0.22) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: radial-gradient(circle at center, black, transparent 76%);
  pointer-events: none;
}

.hero-grid span {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--mode-accent);
  box-shadow: 0 0 18px var(--mode-accent);
}

.hero-grid span:nth-child(1) { left: 12%; top: 24%; }
.hero-grid span:nth-child(2) { left: 78%; top: 30%; }
.hero-grid span:nth-child(3) { left: 28%; top: 78%; }
.hero-grid span:nth-child(4) { left: 88%; top: 74%; }

.hero-chip {
  position: relative;
  width: max-content;
  margin: 0 auto 10px;
  padding: 5px 11px;
  border-radius: 999px;
  background: rgba(0, 229, 168, 0.13);
  border: 1px solid rgba(99,255,210,0.22);
  color: var(--mode-accent-light);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.upload-header h1 {
  position: relative;
  font-size: 1.55rem;
  text-align: center;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.upload-subtitle {
  position: relative;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.65;
  max-width: 360px;
  margin: 0 auto;
}

.mini-circuit-line {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin: 0 auto 12px;
  color: var(--mode-accent-dark);
}

.mini-circuit-line span {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--mode-accent);
  box-shadow: 0 0 0 5px var(--mode-bg), 0 0 18px var(--mode-accent);
}

.mini-circuit-line i {
  width: 42px;
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--mode-accent), #14b8a6);
}

.mini-circuit-line b {
  display: grid;
  place-items: center;
  width: 30px;
  height: 18px;
  border: 2px solid var(--mode-accent-dark);
  border-radius: 6px;
  background: rgba(3, 16, 24, 0.82);
  color: #ecfeff;
  font-size: 0.72rem;
}

.mini-circuit-line em {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  border: 1px solid var(--mode-accent);
  color: var(--mode-accent-light);
  background: rgba(3, 16, 24, 0.78);
  font-style: normal;
  font-size: 0.72rem;
  font-weight: 900;
}

.hero-tips {
  position: relative;
  display: flex;
  justify-content: center;
  gap: 7px;
  flex-wrap: wrap;
  margin-top: 13px;
}

.hero-tips span {
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  color: #cffaf0;
  font-size: 0.72rem;
  font-weight: 800;
}

.preview-area {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgba(99, 255, 210, 0.18);
  box-shadow: var(--shadow);
}

.preview-area img {
  width: 100%;
  display: block;
  max-height: 300px;
  object-fit: contain;
  background: #06151f;
}

.clear-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.6);
  color: white;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.upload-buttons {
  display: flex;
  gap: 12px;
}

.upload-advice-entry {
  position: fixed;
  left: calc(env(safe-area-inset-left) + 12px);
  bottom: calc(env(safe-area-inset-bottom) + 12px);
  z-index: 12000;
  min-height: 36px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(99, 255, 210, 0.28);
  background: rgba(5, 21, 31, 0.88);
  color: #eafff8;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.28);
  font-size: 0.82rem;
  font-weight: 850;
  cursor: pointer;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.upload-advice-modal {
  position: fixed;
  inset: 0;
  z-index: 21000;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(2, 8, 16, 0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.upload-advice-card {
  width: min(420px, calc(100vw - 28px));
  border-radius: 18px;
  border: 1px solid #d9e2ec;
  background: #ffffff;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.52);
  padding: 16px;
}

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

.upload-advice-head h2 {
  font-size: 1.05rem;
  color: #0f172a;
}

.upload-advice-head button {
  flex: 0 0 auto;
  min-height: 32px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.07);
  color: var(--text);
  font-weight: 850;
  cursor: pointer;
}

.upload-advice-card {
  color: #0f172a;
}

.upload-advice-head button {
  background: #0f766e;
  color: #ffffff;
}

.upload-advice-head button:disabled {
  cursor: not-allowed;
  opacity: 0.56;
  background: #e2e8f0;
  color: #64748b;
}

.upload-advice-list {
  display: grid;
  gap: 10px;
  margin-left: 20px;
}

.upload-advice-list li {
  color: #334155;
  font-size: 0.9rem;
  line-height: 1.65;
}

.upload-advice-list .upload-advice-important {
  margin-top: 2px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 203, 107, 0.34);
  background: #fffbeb;
  color: #92400e;
  font-weight: 900;
}

.upload-advice-countdown {
  min-height: 22px;
  margin-top: 12px;
  color: #0f766e;
  font-size: 0.82rem;
  font-weight: 850;
  text-align: right;
}

.split-mode-toggle {
  border: 1px solid rgba(99, 255, 210, 0.18);
  border-radius: 18px;
  background: rgba(10, 35, 49, 0.72);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.05);
}

.split-mode-toggle label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

.split-mode-toggle input[type="checkbox"] {
  position: relative;
  flex: 0 0 auto;
  width: 42px;
  height: 24px;
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid rgba(99, 255, 210, 0.20);
  border-radius: 999px;
  background: rgba(3, 16, 24, 0.78);
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.split-mode-toggle input[type="checkbox"]::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: rgba(236, 254, 255, 0.86);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.28);
  transition: transform 0.18s ease, background 0.18s ease;
}

.split-mode-toggle input[type="checkbox"]:checked {
  border-color: var(--mode-accent);
  background: linear-gradient(135deg, var(--mode-accent), var(--mode-accent-dark));
  box-shadow: 0 0 0 3px var(--mode-bg);
}

.split-mode-toggle input[type="checkbox"]:checked::before {
  transform: translateX(18px);
  background: #fff;
}

.split-mode-toggle input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--mode-accent-light);
  outline-offset: 3px;
}

.split-mode-toggle p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.88rem;
}

.split-input-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.split-input-card {
  border: 1px solid rgba(99, 255, 210, 0.16);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(10, 35, 49, 0.94), rgba(6, 21, 31, 0.82));
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.06);
}

.split-input-card.required-card {
  border-left: 4px solid var(--mode-accent);
}

.split-card-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
}

.split-card-head strong {
  font-size: 1rem;
}

.split-card-head span,
.upload-hint {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.upload-footer {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.78rem;
  opacity: 0.82;
  margin-top: -6px;
  padding-bottom: 4px;
}

.support-scope-btn {
  border: 1px solid rgba(99, 255, 210, 0.24);
  border-radius: 16px;
  background: rgba(10, 35, 49, 0.72);
  color: var(--mode-accent-light);
  padding: 12px 14px;
  font-weight: 850;
  cursor: pointer;
  transition: transform 0.16s, border-color 0.18s, background 0.18s;
}

.support-scope-btn:hover {
  transform: translateY(-1px);
  border-color: var(--mode-accent);
  background: var(--mode-bg);
}

.support-scope-modal {
  position: fixed;
  inset: 0;
  z-index: 18000;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(2, 8, 16, 0.72);
  backdrop-filter: blur(12px);
}

.support-scope-card {
  width: min(94vw, 640px);
  max-height: 82vh;
  overflow: hidden;
  border-radius: 24px;
  border: 1px solid rgba(99,255,210,0.24);
  background:
    radial-gradient(circle at top left, rgba(0,229,168,0.16), transparent 34%),
    linear-gradient(180deg, rgba(10,35,49,0.98), rgba(4,14,21,0.98));
  box-shadow: 0 28px 90px rgba(0,0,0,0.5);
}

.support-scope-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.support-scope-head h2 {
  font-size: 1.05rem;
}

.support-scope-head button {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  color: #fff;
  font-size: 1.3rem;
  cursor: pointer;
}

.support-scope-body {
  display: grid;
  gap: 12px;
  padding: 14px 16px 18px;
  overflow: auto;
  max-height: calc(82vh - 68px);
}

.support-scope-body section {
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  background: rgba(255,255,255,0.045);
  padding: 12px;
}

.support-scope-body h3 {
  font-size: 0.92rem;
  color: var(--mode-accent-light);
  margin-bottom: 8px;
}

.support-scope-body ul {
  padding-left: 18px;
  display: grid;
  gap: 5px;
}

.support-scope-body li {
  color: var(--text-secondary);
  font-size: 0.84rem;
  line-height: 1.5;
}

.image-crop-modal {
  position: fixed;
  inset: 0;
  z-index: 19000;
  display: grid;
  place-items: center;
  padding: 14px;
  overflow: hidden;
  background: rgba(2, 8, 16, 0.78);
  backdrop-filter: blur(12px);
}

.image-crop-card {
  width: min(96vw, 760px);
  max-width: 100%;
  max-height: min(92vh, 92dvh);
  overflow: hidden;
  border-radius: 20px;
  border: 1px solid rgba(99,255,210,0.24);
  background: linear-gradient(180deg, rgba(10,35,49,0.98), rgba(4,14,21,0.98));
  box-shadow: 0 28px 90px rgba(0,0,0,0.56);
  display: flex;
  flex-direction: column;
}

.image-crop-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 16px 12px;
  min-width: 0;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.image-crop-head h2 {
  font-size: 1.02rem;
  margin-bottom: 5px;
}

.image-crop-head p {
  color: var(--text-secondary);
  font-size: 0.84rem;
  line-height: 1.45;
}

.image-crop-head button {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  color: #fff;
  font-size: 1.3rem;
  cursor: pointer;
}

.image-crop-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 14px;
  min-width: 0;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.image-crop-tool-group {
  display: inline-flex;
  padding: 3px;
  border-radius: 12px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.10);
}

.image-crop-tool {
  min-height: 34px;
  padding: 7px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.05);
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
}

.image-crop-tool.active {
  background: var(--mode-accent);
  color: #021017;
  border-color: transparent;
}

.image-crop-tool:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

.image-crop-brush-size {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 0.84rem;
  font-weight: 800;
}

.image-crop-brush-size input {
  width: 120px;
  accent-color: var(--mode-accent);
}

.image-crop-body {
  flex: 1;
  min-height: 0;
  display: block;
  padding: 14px;
  overflow: auto;
  overscroll-behavior: contain;
}

.image-crop-stage-wrap {
  flex: 1;
  min-height: 220px;
  height: min(58vh, 58dvh, 680px);
  max-height: 100%;
  overflow: auto;
  max-width: 100%;
  overscroll-behavior: contain;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  padding: 0;
  background:
    linear-gradient(45deg, rgba(255,255,255,0.035) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255,255,255,0.035) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255,255,255,0.035) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255,255,255,0.035) 75%);
  background-size: 22px 22px;
  background-position: 0 0, 0 11px, 11px -11px, -11px 0;
}

.image-crop-stage {
  position: relative;
  display: inline-block;
  flex: 0 0 auto;
  margin: auto;
  line-height: 0;
  touch-action: none;
  user-select: none;
}

.image-crop-stage img {
  display: block;
  max-width: 100%;
  max-height: min(58vh, 58dvh, 680px);
  object-fit: contain;
  background: #fff;
}

.image-crop-stage.is-zoom-ready img {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
}

.image-paint-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.image-crop-stage.brush-mode {
  cursor: crosshair;
}

.image-crop-box {
  position: absolute;
  border: 2px solid var(--mode-accent-light);
  background:
    linear-gradient(rgba(255,255,255,0.16), rgba(255,255,255,0.16)),
    repeating-linear-gradient(0deg, transparent 0 31%, rgba(255,255,255,0.26) 31% 32%, transparent 32% 65%, rgba(255,255,255,0.26) 65% 66%, transparent 66% 100%),
    repeating-linear-gradient(90deg, transparent 0 31%, rgba(255,255,255,0.26) 31% 32%, transparent 32% 65%, rgba(255,255,255,0.26) 65% 66%, transparent 66% 100%);
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.54), 0 0 0 1px rgba(0,0,0,0.45) inset;
  cursor: move;
  touch-action: none;
}

.image-crop-box.inactive {
  pointer-events: none;
  cursor: crosshair;
}

.image-crop-handle {
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 2px solid #06151f;
  background: var(--mode-accent-light);
  box-shadow: 0 0 14px rgba(0,0,0,0.38);
}

.image-crop-handle-nw { left: -10px; top: -10px; cursor: nwse-resize; }
.image-crop-handle-n { left: 50%; top: -10px; transform: translateX(-50%); cursor: ns-resize; }
.image-crop-handle-ne { right: -10px; top: -10px; cursor: nesw-resize; }
.image-crop-handle-e { right: -10px; top: 50%; transform: translateY(-50%); cursor: ew-resize; }
.image-crop-handle-se { right: -10px; bottom: -10px; cursor: nwse-resize; }
.image-crop-handle-s { left: 50%; bottom: -10px; transform: translateX(-50%); cursor: ns-resize; }
.image-crop-handle-sw { left: -10px; bottom: -10px; cursor: nesw-resize; }
.image-crop-handle-w { left: -10px; top: 50%; transform: translateY(-50%); cursor: ew-resize; }

.image-crop-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1.2fr;
  gap: 10px;
  padding: 12px 14px 14px;
  padding-bottom: calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(255,255,255,0.08);
}

.image-crop-actions .btn {
  padding: 11px 12px;
  border-radius: 12px;
  min-height: 42px;
}

.image-crop-actions .btn-secondary {
  background: rgba(255,255,255,0.04);
  color: var(--text);
  border-color: rgba(255,255,255,0.12);
}

.split-textarea {
  min-height: 110px;
  resize: vertical;
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(3, 16, 24, 0.72);
  padding: 12px 14px;
  color: var(--text);
  font: inherit;
  line-height: 1.55;
}

.split-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(74, 144, 217, 0.15);
}

.split-preview {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  border: 2px solid var(--border);
}

.split-preview img {
  width: 100%;
  display: block;
  max-height: 240px;
  object-fit: contain;
  background: var(--bg);
}

.split-card-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.upload-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 18px 16px;
  border: 1px solid rgba(99, 255, 210, 0.20);
  border-radius: 18px;
  background:
    radial-gradient(circle at 20% 18%, var(--mode-bg), transparent 35%),
    linear-gradient(180deg, rgba(10, 35, 49, 0.96), rgba(4, 20, 30, 0.9));
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.15s, box-shadow 0.2s;
  color: var(--text);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
}

.upload-btn:hover {
  border-color: var(--mode-accent);
  background: var(--mode-bg);
  transform: translateY(-1px);
  box-shadow: 0 16px 34px rgba(15, 23, 42, 0.10);
}

.upload-btn svg {
  color: var(--primary);
}

.upload-btn span {
  font-size: 0.9rem;
  font-weight: 800;
}

@media (min-width: 900px) {
  .split-input-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 520px) {
  .image-crop-modal {
    padding: 6px;
    align-items: stretch;
    justify-items: stretch;
  }

  .image-crop-card {
    width: 100%;
    max-height: calc(100dvh - 12px);
    border-radius: 16px;
  }

  .image-crop-head {
    padding: 10px 12px 8px;
    gap: 8px;
  }

  .image-crop-head h2 {
    font-size: 0.96rem;
  }

  .image-crop-head p {
    font-size: 0.78rem;
  }

  .image-crop-stage-wrap {
    min-height: 220px;
    height: min(52dvh, 520px);
  }

  .image-crop-stage img {
    max-height: min(52dvh, 520px);
  }

  .image-crop-tools {
    padding: 9px 10px;
  }

  .image-crop-brush-size {
    flex: 1 1 100%;
  }

  .image-crop-brush-size input {
    flex: 1;
    min-width: 0;
    width: auto;
  }

  .image-crop-body {
    padding: 10px;
    overflow: auto;
  }

  .image-crop-actions {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
  }

  .image-crop-actions .btn {
    min-height: 40px;
    padding: 9px 10px;
  }
}

/* Mode segmented control */
.mode-toggle-section {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.mode-segment {
  display: flex;
  background: rgba(3, 16, 24, 0.72);
  border-radius: 18px;
  border: 1px solid rgba(99, 255, 210, 0.18);
  overflow: hidden;
  position: relative;
  padding: 5px;
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.06);
}

.mode-seg-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 13px 10px;
  cursor: pointer;
  transition: all 0.25s ease;
  border: none;
  border-radius: 13px;
  background: transparent;
  color: var(--text-secondary);
  position: relative;
  z-index: 1;
}

.mode-seg-icon {
  font-size: 1.4rem;
  line-height: 1;
}

.mode-seg-label {
  font-size: 0.9rem;
  font-weight: 600;
}

.mode-seg-sub {
  font-size: 0.72rem;
  opacity: 0.7;
}

.mode-seg-item.active {
  color: white;
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.14);
}

.mode-seg-normal.active {
  background: linear-gradient(135deg, var(--fast-accent), var(--fast-accent-dark));
}

.mode-seg-confirm.active {
  background: linear-gradient(135deg, var(--precise-accent), var(--precise-accent-dark));
}

.mode-seg-analog.active {
  background: linear-gradient(135deg, var(--analog-accent), var(--analog-accent-dark));
}

.mode-seg-item:not(.active):hover {
  background: var(--mode-bg);
}

.mode-features {
  display: flex;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}

.mode-feat-tag {
  font-size: 0.7rem;
  padding: 3px 8px;
  border-radius: 10px;
  background: var(--mode-bg);
  color: var(--mode-accent-light);
  font-weight: 500;
}

.mode-feat-tag.feat-off {
  opacity: 0.35;
  text-decoration: line-through;
}

/* Start button */
.start-btn {
  width: 100%;
  padding: 15px;
  border: none;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--mode-accent), var(--mode-accent-dark));
  color: white;
  font-size: 1rem;
  font-weight: 850;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.14);
  transition: background 0.2s, opacity 0.2s, transform 0.15s;
}

.start-btn:hover:not(:disabled) {
  background: var(--mode-accent-dark);
  transform: translateY(-1px);
}

.start-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ====================== LOADING ====================== */
.loading-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  gap: 20px;
}

/* Fast mode: bouncing dots */
.loading-dots {
  display: flex;
  gap: 8px;
}

.loading-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--fast-accent);
  animation: dot-bounce 1.2s ease-in-out infinite;
}

.loading-dot:nth-child(2) { animation-delay: 0.15s; }
.loading-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes dot-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Precise mode: spinner */
.spinner {
  width: 44px;
  height: 44px;
  border: 3px solid var(--border);
  border-top-color: var(--precise-accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 500;
}

.parse-loading {
  padding: 28px 12px;
}

.parse-loading-card {
  width: min(720px, 100%);
  padding: 26px;
  border-radius: 22px;
  border: 1px solid rgba(20, 184, 166, 0.2);
  background:
    radial-gradient(circle at 18% 18%, rgba(20, 184, 166, 0.16), transparent 30%),
    radial-gradient(circle at 84% 12%, rgba(245, 158, 11, 0.12), transparent 26%),
    linear-gradient(145deg, var(--card), var(--mode-bg));
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.12);
  display: grid;
  gap: 20px;
}

.parse-scan-visual {
  min-height: 170px;
  display: grid;
  place-items: center;
}

.scan-frame {
  position: relative;
  width: min(520px, 100%);
  height: 150px;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background:
    linear-gradient(90deg, rgba(15, 23, 42, 0.06) 1px, transparent 1px),
    linear-gradient(0deg, rgba(15, 23, 42, 0.06) 1px, transparent 1px),
    rgba(255, 255, 255, 0.62);
  background-size: 26px 26px;
}

.scan-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 72px;
  background: linear-gradient(90deg, transparent, rgba(20, 184, 166, 0.26), transparent);
  animation: scan-sweep 2.2s ease-in-out infinite;
}

.scan-node {
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: #14b8a6;
  box-shadow: 0 0 0 8px rgba(20, 184, 166, 0.12);
}

.scan-node.a { left: 15%; top: 28%; }
.scan-node.b { left: 44%; top: 28%; }
.scan-node.c { right: 16%; top: 58%; }
.scan-node.d { left: 28%; bottom: 20%; }

.scan-wire {
  position: absolute;
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, #14b8a6, #3b82f6);
}

.scan-wire.w1 { left: 16%; top: 33%; width: 29%; }
.scan-wire.w2 { left: 44%; top: 38%; width: 39%; transform: rotate(18deg); transform-origin: left center; }
.scan-wire.w3 { left: 29%; bottom: 25%; width: 54%; }

@keyframes scan-sweep {
  0% { left: -80px; opacity: 0; }
  12% { opacity: 1; }
  82% { opacity: 1; }
  100% { left: 100%; opacity: 0; }
}

.parse-loading-copy {
  text-align: center;
}

.parse-kicker {
  display: inline-flex;
  padding: 4px 10px;
  border-radius: 999px;
  color: #0f766e;
  background: rgba(20, 184, 166, 0.12);
  font-size: 0.78rem;
  font-weight: 800;
  margin-bottom: 10px;
}

.parse-loading-copy h2 {
  margin: 0;
  color: var(--text);
  font-size: 1.35rem;
}

.parse-loading-copy p,
.parse-wait-note {
  margin: 10px auto 0;
  color: var(--text-secondary);
  line-height: 1.7;
  max-width: 560px;
  font-size: 0.92rem;
}

.parse-progress-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.parse-progress-grid div {
  padding: 12px;
  border-radius: 14px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: rgba(255, 255, 255, 0.55);
}

.parse-progress-grid div.active {
  border-color: rgba(20, 184, 166, 0.4);
  background: rgba(20, 184, 166, 0.1);
}

.parse-progress-grid div.done {
  border-color: rgba(39, 174, 96, 0.28);
  background: rgba(39, 174, 96, 0.08);
}

.parse-progress-grid strong,
.parse-progress-grid span {
  display: block;
}

.parse-progress-grid strong {
  color: var(--text);
  font-size: 0.92rem;
}

.parse-progress-grid span {
  margin-top: 4px;
  color: var(--text-secondary);
  font-size: 0.78rem;
}

.parse-wait-note {
  text-align: center;
}

.loading-tip-card {
  padding: 13px 15px;
  border: 1px solid rgba(20, 184, 166, 0.18);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.62);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.loading-tip-card.switching {
  opacity: 0;
  transform: translateY(4px);
}

.loading-tip-card span,
.loading-tip-card p {
  display: block;
}

.loading-tip-card span {
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 900;
}

.loading-tip-card p {
  margin: 5px 0 0;
  color: var(--text);
  line-height: 1.65;
  font-size: 0.92rem;
}

.loading-timer {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-top: 4px;
}

.loading-timeout-reminder {
  position: fixed;
  inset: 0;
  z-index: 22000;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(2, 8, 16, 0.72);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.loading-timeout-card {
  width: min(420px, 100%);
  padding: 18px;
  border-radius: 18px;
  border: 1px solid rgba(255, 184, 77, 0.28);
  background:
    radial-gradient(circle at top left, rgba(255, 184, 77, 0.16), transparent 34%),
    linear-gradient(180deg, rgba(10, 35, 49, 0.98), rgba(4, 14, 21, 0.98));
  box-shadow: 0 24px 72px rgba(0, 0, 0, 0.52);
  display: grid;
  gap: 12px;
}

.loading-timeout-card h3 {
  margin: 0;
  color: #fff7ed;
  font-size: 1.08rem;
}

.loading-timeout-card p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.92rem;
  line-height: 1.65;
}

.slow-warning {
  color: var(--warning);
  font-size: 0.85rem;
  margin-top: 8px;
  padding: 8px 16px;
  background: rgba(255, 152, 0, 0.08);
  border-radius: 8px;
  text-align: center;
}

/* Precise mode: vertical stepper */
.loading-stepper {
  display: flex;
  flex-direction: column;
  gap: 0;
  width: 100%;
  max-width: 280px;
}

.loading-step-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  opacity: 0.3;
  transition: opacity 0.3s;
}

.loading-step-row.active {
  opacity: 1;
}

.loading-step-row.done {
  opacity: 0.55;
}

.loading-step-marker {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  flex-shrink: 0;
  margin-top: 1px;
}

.loading-step-row.active .loading-step-marker {
  border-color: var(--precise-accent);
  background: var(--precise-bg);
  animation: step-pulse 1.5s ease-in-out infinite;
}

.loading-step-row.done .loading-step-marker {
  border-color: var(--success);
  background: rgba(39, 174, 96, 0.1);
  color: var(--success);
}

@keyframes step-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

.loading-step-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.loading-step-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
}

.loading-step-row.active .loading-step-name {
  color: var(--precise-accent-dark);
}

.loading-step-desc {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.loading-step-connector {
  width: 2px;
  height: 12px;
  background: var(--border);
  margin-left: 11px;
}

.loading-step-row.done + .loading-step-connector {
  background: var(--success);
}

.analysis-loading {
  padding: 28px 12px;
}

.analysis-loading-card {
  width: min(760px, 100%);
  background:
    radial-gradient(circle at 20% 18%, rgba(245, 158, 11, 0.12), transparent 30%),
    radial-gradient(circle at 84% 16%, rgba(52, 152, 219, 0.12), transparent 26%),
    linear-gradient(145deg, var(--card), #f8fafc);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.12);
  padding: 28px;
  display: grid;
  gap: 22px;
}

.analysis-hero {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  align-items: center;
  gap: 18px;
}

.analysis-board {
  position: relative;
  height: 126px;
  overflow: hidden;
  border-radius: 18px;
  border: 1px solid rgba(52, 152, 219, 0.22);
  background:
    linear-gradient(90deg, rgba(52, 152, 219, 0.08) 1px, transparent 1px),
    linear-gradient(0deg, rgba(52, 152, 219, 0.08) 1px, transparent 1px),
    rgba(255, 255, 255, 0.5);
  background-size: 24px 24px;
}

.analysis-board .node {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: var(--precise-accent);
  box-shadow: 0 0 0 7px rgba(52, 152, 219, 0.12);
}

.analysis-board .n1 { left: 14%; top: 24%; }
.analysis-board .n2 { left: 44%; top: 24%; }
.analysis-board .n3 { right: 15%; top: 56%; }
.analysis-board .n4 { left: 28%; bottom: 18%; }

.analysis-board .trace {
  position: absolute;
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(52, 152, 219, 0.15), rgba(52, 152, 219, 0.86), rgba(20, 184, 166, 0.22));
}

.analysis-board .trace-a {
  left: 14%;
  top: 30%;
  width: 31%;
}

.analysis-board .trace-b {
  left: 44%;
  top: 34%;
  width: 38%;
  transform: rotate(18deg);
  transform-origin: left center;
}

.analysis-board .trace-c {
  left: 28%;
  bottom: 24%;
  width: 55%;
}

.analysis-board .pulse {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #14b8a6;
  box-shadow: 0 0 16px rgba(20, 184, 166, 0.7);
  animation: board-pulse 2.4s ease-in-out infinite;
}

.analysis-board .pulse-a {
  left: 16%;
  top: 25%;
}

.analysis-board .pulse-b {
  left: 34%;
  bottom: 21%;
  animation-delay: 0.9s;
}

.answer-wait-visual {
  position: relative;
  height: 150px;
  border-radius: 22px;
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 22%, rgba(20, 184, 166, 0.18), transparent 28%),
    radial-gradient(circle at 82% 18%, rgba(245, 158, 11, 0.15), transparent 26%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(248, 250, 252, 0.92));
  border: 1px solid rgba(15, 23, 42, 0.1);
  display: grid;
  place-items: center;
}

.solve-orbit {
  position: absolute;
  inset: 18px;
  border-radius: 18px;
  border: 1px dashed rgba(59, 130, 246, 0.22);
  animation: solve-breathe 3.2s ease-in-out infinite;
}

.solve-orbit span {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #14b8a6;
  box-shadow: 0 0 14px rgba(20, 184, 166, 0.55);
}

.solve-orbit span:nth-child(1) { left: 18%; top: -4px; }
.solve-orbit span:nth-child(2) { right: 20%; top: 32%; background: #3b82f6; }
.solve-orbit span:nth-child(3) { left: 46%; bottom: -4px; background: #f59e0b; }

.answer-stack {
  position: relative;
  width: min(350px, 84%);
  height: 112px;
}

.answer-card {
  position: absolute;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 16px 34px rgba(15, 23, 42, 0.12);
}

.mini-card {
  width: 128px;
  height: 48px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  color: var(--text-secondary);
  font-size: 0.82rem;
  animation: card-float 3s ease-in-out infinite;
}

.mini-card span {
  width: 18px;
  height: 18px;
  border-radius: 6px;
  background: rgba(59, 130, 246, 0.16);
}

.mini-card.back {
  left: 10px;
  top: 10px;
  transform: rotate(-6deg);
}

.mini-card.mid {
  right: 8px;
  top: 20px;
  transform: rotate(5deg);
  animation-delay: 0.45s;
}

.main-card {
  left: 50%;
  bottom: 0;
  width: 230px;
  height: 76px;
  transform: translateX(-50%);
  padding: 14px 16px;
  display: grid;
  gap: 4px;
}

.main-card strong,
.main-card em {
  display: block;
}

.main-card strong {
  color: var(--text);
  font-size: 0.98rem;
}

.main-card em {
  color: var(--text-secondary);
  font-style: normal;
  font-size: 0.78rem;
}

.main-card i {
  display: block;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  margin-top: 4px;
  background: linear-gradient(90deg, #14b8a6, #3b82f6, #f59e0b);
  background-size: 220% 100%;
  animation: gradient-slide 2.4s ease-in-out infinite;
}

.soft-loader {
  display: inline-flex;
  gap: 5px;
  align-items: center;
}

.soft-loader span {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--precise-accent);
  animation: dot-wave 1.15s ease-in-out infinite;
}

.soft-loader span:nth-child(2) { animation-delay: 0.15s; }
.soft-loader span:nth-child(3) { animation-delay: 0.3s; }

@keyframes solve-breathe {
  0%, 100% { transform: scale(1); opacity: 0.65; }
  50% { transform: scale(0.97); opacity: 1; }
}

@keyframes card-float {
  0%, 100% { margin-top: 0; }
  50% { margin-top: -8px; }
}

@keyframes gradient-slide {
  0%, 100% { background-position: 0 0; }
  50% { background-position: 100% 0; }
}

@keyframes dot-wave {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.45; }
  40% { transform: translateY(-6px); opacity: 1; }
}

/* Legacy paper loader classes kept harmless for cached markup during rollout. */
.answer-paper {
  position: absolute;
  inset: auto;
}

@keyframes paper-write {
  0% { transform: scaleX(0.18); opacity: 0.45; }
  45% { transform: scaleX(1); opacity: 1; }
  100% { transform: scaleX(1); opacity: 0.72; }
}

@keyframes cursor-blink {
  0%, 45% { opacity: 1; }
  46%, 100% { opacity: 0; }
}

@keyframes board-pulse {
  0% { transform: translateX(0); opacity: 0.1; }
  25% { opacity: 1; }
  70% { transform: translateX(260px); opacity: 0.9; }
  100% { transform: translateX(300px); opacity: 0; }
}

.analysis-orbit {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--precise-accent-dark);
  font-weight: 800;
  white-space: nowrap;
}

.analysis-orbit .spinner {
  width: 38px;
  height: 38px;
}

.analysis-loading-copy h2 {
  margin: 0 0 8px;
  font-size: 1.35rem;
  color: var(--text);
}

.analysis-loading-copy p,
.analysis-wait-note {
  margin: 0;
  color: var(--text-secondary);
  line-height: 1.7;
  font-size: 0.92rem;
}

.analysis-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.analysis-metrics div {
  padding: 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid rgba(52, 152, 219, 0.14);
}

.analysis-metrics strong,
.analysis-metrics span {
  display: block;
}

.analysis-metrics strong {
  color: var(--text);
  font-size: 0.98rem;
}

.analysis-metrics span {
  margin-top: 4px;
  color: var(--text-secondary);
  font-size: 0.78rem;
}

.analysis-stage-list {
  display: grid;
  gap: 10px;
}

.analysis-stage {
  display: grid;
  grid-template-columns: 18px minmax(100px, 150px) 1fr;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.52);
  opacity: 0.68;
}

.analysis-stage span {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--border);
}

.analysis-stage strong {
  color: var(--text);
  font-size: 0.92rem;
}

.analysis-stage em {
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-style: normal;
  line-height: 1.5;
}

.analysis-stage.done {
  border-color: rgba(39, 174, 96, 0.32);
  background: rgba(39, 174, 96, 0.08);
  opacity: 0.92;
}

.analysis-stage.done span {
  background: var(--success);
}

.analysis-stage.active {
  border-color: rgba(52, 152, 219, 0.44);
  background: rgba(52, 152, 219, 0.08);
  opacity: 1;
}

.analysis-stage.active span {
  background: var(--precise-accent);
  box-shadow: 0 0 0 6px rgba(52, 152, 219, 0.14);
  animation: analysis-pulse 1.35s ease-in-out infinite;
}

@keyframes analysis-pulse {
  0%, 100% { transform: scale(1); opacity: 0.78; }
  50% { transform: scale(1.25); opacity: 1; }
}

/* ====================== ERROR ====================== */
.error-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  gap: 16px;
  text-align: center;
}

.error-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--danger);
  color: white;
  font-size: 2rem;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
}

.unrecognized-section {
  min-height: 72vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 0 96px;
}

.unrecognized-card {
  width: min(920px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
  gap: 18px;
  align-items: stretch;
  padding: 18px;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 28px;
  background:
    radial-gradient(circle at 18% 8%, rgba(20,184,166,0.18), transparent 34%),
    linear-gradient(135deg, rgba(10,31,48,0.94), rgba(9,15,25,0.96));
  box-shadow: 0 24px 70px rgba(0,0,0,0.36);
}

.unrecognized-image-wrap {
  min-height: 340px;
  border-radius: 22px;
  overflow: hidden;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  display: flex;
  align-items: center;
  justify-content: center;
}

.unrecognized-image-wrap img {
  width: 100%;
  height: 100%;
  max-height: 520px;
  object-fit: contain;
  display: block;
}

.unrecognized-image-empty {
  color: var(--text-secondary);
  font-size: 14px;
}

.unrecognized-message {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
  padding: 26px;
  border-radius: 22px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
}

.unrecognized-message h2 {
  font-size: 1.55rem;
  letter-spacing: -0.02em;
}

.unrecognized-message p {
  color: var(--text-secondary);
  line-height: 1.7;
}

.unrecognized-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
}

/* ====================== CONFIRMING ====================== */
.confirming-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-bottom: 100px;
}

.confirm-header {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 36px;
  align-items: center;
  position: sticky;
  top: 0;
  background: rgba(6, 21, 31, 0.86);
  backdrop-filter: blur(12px);
  padding: 10px 0;
  z-index: 10;
}

.confirm-header h2 {
  font-size: 1.1rem;
  text-align: center;
}

.confirm-back {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--card);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: var(--text-secondary);
  transition: background 0.2s;
}

.confirm-back:hover {
  background: var(--mode-bg);
}

.attempt-badge {
  background: var(--warning);
  color: white;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
}

/* Confirm image preview - collapsible */
.confirm-image-toggle {
  width: 100%;
  padding: 12px 14px;
  background: linear-gradient(180deg, var(--card), rgba(6, 21, 31, 0.74));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  color: var(--text);
  transition: background 0.2s;
}

.confirm-image-toggle:hover {
  background: var(--mode-bg);
}

.confirm-image-toggle .toggle-arrow {
  transition: transform 0.2s;
  color: var(--text-secondary);
}

.confirm-image-toggle.open .toggle-arrow {
  transform: rotate(180deg);
}

.confirm-image-body {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

.confirm-image-body img {
  width: 100%;
  display: block;
  max-height: 420px;
  object-fit: contain;
  background: var(--card);
}

.node-overlay-wrap {
  position: relative;
  display: inline-block;
  width: 100%;
  background: var(--card);
}

.node-overlay-wrap img {
  position: relative;
  z-index: 1;
}

.node-overlay-canvas {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.node-overlay-message {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 3;
  max-width: calc(100% - 24px);
  padding: 7px 10px;
  border-radius: 8px;
  color: #92400e;
  background: rgba(255, 251, 235, 0.94);
  border: 1px solid rgba(245, 158, 11, 0.35);
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.12);
}

/* Confirm info cards */
.circuit-info {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  border: 1px solid var(--border);
}

.circuit-info h3,
.branches-card h3,
.components-list h3,
.original-image-preview h3 {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.info-row {
  display: flex;
  gap: 8px;
  padding: 5px 0;
  font-size: 0.88rem;
}

.info-label {
  color: var(--text-secondary);
  white-space: nowrap;
  min-width: 72px;
}

.info-value {
  flex: 1;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.branches-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  border: 1px solid var(--border);
}

.branches-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.branch-item {
  font-size: 0.88rem;
  padding: 8px 10px;
  background: var(--mode-bg);
  border-radius: 8px;
  border-left: 3px solid var(--mode-accent);
  line-height: 1.5;
}

.components-list {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  border: 1px solid var(--border);
}

.component-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.component-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--mode-bg);
  border-radius: 10px;
  padding: 8px 12px;
  min-width: 80px;
}

.component-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--mode-accent);
}

.component-type {
  font-size: 0.76rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.info-block {
  background: linear-gradient(180deg, var(--card), rgba(6, 21, 31, 0.76));
  border-radius: var(--radius);
  padding: 12px 14px;
  border: 1px solid var(--border);
  font-size: 0.88rem;
  line-height: 1.6;
}

.target-edit-card {
  background:
    linear-gradient(135deg, rgba(10,35,49,0.96), rgba(6,21,31,0.78)),
    var(--mode-bg);
  border: 1px solid rgba(99, 255, 210, 0.18);
  border-left: 4px solid var(--mode-accent);
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.06);
}

.target-edit-card label {
  display: block;
  margin-bottom: 8px;
  color: var(--mode-accent-dark);
  font-size: 0.9rem;
  font-weight: 800;
}

.target-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(3, 16, 24, 0.72);
  color: var(--text);
  padding: 12px 13px;
  font: inherit;
  font-weight: 650;
  letter-spacing: 0.01em;
}

.target-input:focus {
  outline: none;
  border-color: var(--mode-accent);
  box-shadow: 0 0 0 3px var(--mode-bg);
}

.target-edit-card p {
  margin-top: 8px;
  color: var(--text-secondary);
  font-size: 0.82rem;
  line-height: 1.55;
}

.confirm-validation-errors {
  border: 1px solid rgba(220, 38, 38, 0.24);
  border-left: 4px solid #dc2626;
  border-radius: 12px;
  padding: 12px 14px;
  background: rgba(220, 38, 38, 0.08);
  color: #fecaca;
  font-size: 0.86rem;
  line-height: 1.55;
}

.confirm-validation-errors strong {
  display: block;
  color: #fecaca;
  margin-bottom: 5px;
}

.confirm-validation-errors ul {
  margin: 0 0 0 18px;
}

.confirm-edit-grid {
  display: grid;
  gap: 10px;
}

.confirm-edit-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.confirm-edit-grid span {
  display: block;
  margin-bottom: 5px;
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 700;
}

.confirm-node-edit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

.confirm-node-edit {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 4px 8px;
  align-items: center;
  padding: 9px 10px;
  border: 1px solid rgba(99, 255, 210, 0.16);
  border-radius: 10px;
  background: rgba(3, 16, 24, 0.46);
}

.confirm-node-edit input {
  grid-row: span 2;
}

.confirm-node-edit span {
  font-weight: 800;
  color: var(--text);
}

.confirm-node-edit em {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-style: normal;
}

.regression-export-card {
  border: 1px dashed rgba(99, 255, 210, 0.24);
  border-radius: 14px;
  background: rgba(3, 16, 24, 0.50);
  overflow: hidden;
}

.regression-export-card summary {
  cursor: pointer;
  display: grid;
  gap: 4px;
  padding: 13px 14px;
  list-style: none;
}

.regression-export-card summary::-webkit-details-marker {
  display: none;
}

.regression-export-card summary span {
  color: var(--mode-accent);
  font-size: 0.9rem;
  font-weight: 850;
}

.regression-export-card summary em {
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-style: normal;
}

.regression-export-body {
  display: grid;
  gap: 12px;
  padding: 0 14px 14px;
}

.regression-export-grid {
  display: grid;
  gap: 10px;
}

.regression-export-grid label,
.regression-notes-label {
  display: grid;
  gap: 7px;
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 800;
}

.regression-export-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.regression-export-status {
  color: var(--mode-accent);
  font-size: 0.8rem;
  font-weight: 800;
}

.parse-note-line {
  margin: 3px 0;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* Confirm actions - sticky bottom */
.confirm-actions {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  padding: 12px 16px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  background: rgba(6, 21, 31, 0.92);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 20;
}

/* ====================== BUTTONS ====================== */
.btn {
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
  width: 100%;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.56;
  box-shadow: none;
  transform: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--mode-accent), var(--mode-accent-dark));
  color: white;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.14);
}

.btn-primary:hover {
  background: var(--mode-accent-dark);
}

.btn-secondary {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: rgba(0,0,0,0.03);
}

/* ====================== FEEDBACK MODAL ====================== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.modal-content {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 360px;
  width: 100%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.modal-content h3 {
  font-size: 1rem;
  margin-bottom: 16px;
}

.feedback-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.feedback-option {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  cursor: pointer;
}

.feedback-option input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ====================== RESULT SECTION ====================== */
.result-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-bottom: 20px;
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
}

/* Mode strip header */
.result-mode-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  min-width: 0;
  flex-wrap: wrap;
}

.result-mode-strip.strip-fast {
  background: var(--fast-bg);
  border: 1px solid rgba(41, 151, 197, 0.2);
}

.result-mode-strip.strip-precise {
  background: var(--precise-bg);
  border: 1px solid rgba(61, 79, 99, 0.2);
}

.strip-icon {
  font-size: 1.1rem;
}

.strip-name {
  font-weight: 700;
}

.strip-fast .strip-name { color: var(--fast-accent-dark); }
.strip-precise .strip-name,
.strip-confirm .strip-name { color: var(--precise-accent-dark); }

.strip-note {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-left: auto;
  overflow-wrap: anywhere;
}

.strip-verified {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.72rem;
  font-weight: 600;
  background: rgba(39, 174, 96, 0.12);
  color: #1e8449;
  padding: 2px 8px;
  border-radius: 10px;
}

/* Confidence badge */
.confidence-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 16px;
  font-size: 0.75rem;
  font-weight: 600;
}

.confidence-high { background: rgba(39,174,96,0.15); color: var(--success); }
.confidence-medium { background: rgba(243,156,18,0.15); color: var(--warning); }
.confidence-low { background: rgba(231,76,60,0.15); color: var(--danger); }

.low-confidence-warning {
  background: rgba(243,156,18,0.1);
  border: 1px solid var(--warning);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 0.85rem;
  color: var(--text);
  line-height: 1.6;
}

/* Fast result: answer hero */
.answer-hero {
  background: var(--card);
  border: 2px solid var(--mode-accent);
  border-radius: var(--radius);
  padding: 20px 16px;
  text-align: center;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.answer-hero-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.answer-hero-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--mode-accent-dark);
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  overflow-wrap: anywhere;
  -webkit-overflow-scrolling: touch;
}

.answer-hero-meta {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 8px;
  line-height: 1.5;
}

/* Fast result: compact steps */
.steps-compact {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.step-compact-item {
  padding: 10px 12px;
  border-left: 3px solid var(--mode-accent-light);
  background: var(--card);
  font-size: 0.88rem;
  line-height: 1.6;
  cursor: pointer;
  transition: background 0.2s;
}

.step-compact-item:first-child {
  border-radius: var(--radius) var(--radius) 0 0;
}

.step-compact-item:last-child {
  border-radius: 0 0 var(--radius) var(--radius);
}

.step-compact-item:only-child {
  border-radius: var(--radius);
}

.step-compact-item:not(:last-child) {
  border-bottom: 1px solid var(--border);
}

.step-compact-item:hover {
  background: var(--mode-bg);
}

.step-compact-num {
  display: inline-block;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--mode-bg);
  color: var(--mode-accent);
  font-size: 0.72rem;
  font-weight: 700;
  text-align: center;
  line-height: 20px;
  margin-right: 8px;
  flex-shrink: 0;
}

.step-compact-detail {
  display: inline;
}

.step-compact-math {
  display: block;
  margin-top: 6px;
  padding: 4px 8px;
  background: var(--mode-bg);
  border-radius: 6px;
  font-size: 0.9rem;
  overflow-x: auto;
  line-height: 1.8;
  max-width: 100%;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

/* Precise result: full steps */
.steps-section {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  border: 1px solid var(--border);
}

.steps-section h3,
.formulas-section h3,
.answer-section h3,
.verification-section h3,
.symbol-legend-section h3,
.var-defs-section h3,
.circuit-info h3,
.original-image-preview h3 {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.steps-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.step-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--card);
  border-left: 3px solid var(--mode-accent-light);
}

.step-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.step-detail {
  font-size: 0.88rem;
  line-height: 1.6;
  margin-bottom: 6px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.step-math-line {
  font-size: 0.92rem;
  padding: 5px 8px;
  margin: 4px 0;
  border-radius: 8px;
  background: var(--mode-bg);
  border: 1px solid var(--border);
  overflow-x: auto;
  line-height: 1.8;
}

.math-inline {
  display: inline;
  vertical-align: middle;
}

.step-plain-hint {
  font-size: 0.82rem;
  line-height: 1.6;
  padding: 7px 10px;
  border-radius: 8px;
  background: rgba(243, 156, 18, 0.1);
  color: #8a5a00;
}

/* Question / target sections */
.question-text-section,
.target-section {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  border: 1px solid var(--border);
}

.question-text-section p,
.target-section p {
  font-size: 0.88rem;
  line-height: 1.6;
}

/* Original image preview in result */
.original-image-preview {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  border: 1px solid var(--border);
}

.original-image-preview img {
  width: 100%;
  border-radius: 8px;
  max-height: 180px;
  object-fit: contain;
  background: var(--card);
  margin-top: 8px;
}

/* Symbol legend */
.symbol-legend-section {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  border: 1px solid var(--border);
}

.symbol-legend-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.symbol-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 5px 8px;
  background: var(--mode-bg);
  border-radius: 8px;
}

.symbol-latex {
  font-size: 0.95rem;
  min-width: 55px;
  color: var(--mode-accent);
  font-weight: 500;
}

.symbol-cn {
  font-size: 0.82rem;
  color: var(--text-secondary);
  flex: 1;
}

/* Variable definitions */
.var-defs-section {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--mode-accent);
}

.var-defs-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.var-def-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 7px 8px;
  background: var(--mode-bg);
  border-radius: 8px;
  line-height: 1.6;
}

.var-def-symbol {
  font-size: 0.95rem;
  min-width: 48px;
  color: var(--mode-accent);
  font-weight: 600;
  flex-shrink: 0;
  padding-top: 1px;
}

.var-def-body {
  font-size: 0.85rem;
  color: var(--text);
  flex: 1;
}

.var-def-name {
  font-weight: 600;
  color: var(--text);
}

.var-def-step {
  display: inline-block;
  font-size: 0.72rem;
  background: var(--mode-bg);
  color: var(--mode-accent);
  padding: 1px 6px;
  border-radius: 10px;
  margin-left: 4px;
  vertical-align: middle;
}

.var-defs-extra {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.var-defs-toggle {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 8px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--mode-accent);
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.2s;
}

.var-defs-toggle:hover {
  background: var(--mode-bg);
}

/* Formulas section */
.formulas-section {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  border: 1px solid var(--border);
  overflow-x: auto;
}

.formulas-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.formula-item {
  font-size: 0.92rem;
  padding: 6px 0;
  overflow-x: auto;
  border-bottom: 1px dashed var(--border);
}

.formula-line-no {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-bottom: 3px;
}

.formula-body {
  background: var(--mode-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
  overflow-x: auto;
}

.formula-body.formula-fallback {
  font-family: 'Courier New', monospace;
  color: var(--text-secondary);
  font-size: 0.88rem;
}

/* Answer section (precise mode) */
.answer-section {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  border: 2px solid var(--mode-accent);
}

.answer-box {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--mode-accent-dark);
}

/* Verification */
.verification-section {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  border: 1px solid var(--border);
}

.verification-banner {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 10px;
}

.verification-banner.vb-pass {
  background: rgba(39, 174, 96, 0.1);
  color: var(--success);
  border: 1px solid rgba(39, 174, 96, 0.2);
}

.verification-banner.vb-warn {
  background: rgba(243, 156, 18, 0.1);
  color: var(--warning);
  border: 1px solid rgba(243, 156, 18, 0.2);
}

.verification-banner.vb-fail {
  background: rgba(231, 76, 60, 0.1);
  color: var(--danger);
  border: 1px solid rgba(231, 76, 60, 0.2);
}

.verification-items {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.verification-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.verification-label {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.verification-status {
  font-size: 1.1rem;
}

.status-icon.pass { color: var(--success); }
.status-icon.warn { color: var(--warning); }
.status-icon.fail { color: var(--danger); }

.consistency-notes {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 8px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.consistency-notes-list {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.consistency-note-item {
  font-size: 0.78rem;
  color: var(--text-secondary);
  padding: 4px 8px;
  background: rgba(0,0,0,0.02);
  border-radius: 6px;
  line-height: 1.5;
}

/* Switch mode hint card */
.switch-mode-card {
  background: var(--card);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
}

.switch-mode-card p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 10px;
  line-height: 1.5;
}

.switch-mode-btn {
  display: inline-block;
  padding: 8px 22px;
  border: 1px solid var(--mode-accent);
  border-radius: 20px;
  background: transparent;
  color: var(--mode-accent);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.switch-mode-btn:hover {
  background: var(--mode-bg);
}

/* Result actions */
.result-actions {
  padding-top: 4px;
}

/* Result V2 */
.result-v2 { display: flex; flex-direction: column; gap: 14px; min-width: 0; max-width: 100%; overflow-x: hidden; }
.result-v2-hero { background: var(--card); border: 2px solid var(--mode-accent); border-radius: var(--radius); padding: 16px; min-width: 0; max-width: 100%; overflow: hidden; }
.result-v2-hero h2 { font-size: 1rem; margin: 6px 0 10px; }
.result-v2-tag { display: inline-block; font-size: 0.75rem; padding: 3px 9px; border-radius: 14px; font-weight: 700; }
.tag-symbolic { background: rgba(243,156,18,0.15); color: #b06d00; }
.tag-numeric { background: rgba(39,174,96,0.15); color: #1e8449; }
.answer-box-v2 { font-size: 1.2rem; line-height: 1.8; overflow-x: auto; overflow-y: hidden; max-width: 100%; overflow-wrap: anywhere; -webkit-overflow-scrolling: touch; }
.confidence-line { margin-top: 8px; color: var(--text-secondary); font-size: 0.85rem; }

.result-grid-v2 { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; min-width: 0; max-width: 100%; }
.panel-v2 { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; min-width: 0; max-width: 100%; }
.panel-v2 h3 { font-size: 0.9rem; color: var(--text-secondary); margin-bottom: 8px; }
.panel-wide-v2 { grid-column: 1 / -1; }
.muted-v2 { font-size: 0.85rem; color: var(--text-secondary); }

.formula-list-v2 { display: flex; flex-direction: column; gap: 8px; }
.formula-chip { background: var(--mode-bg); border: 1px solid var(--border); border-radius: 10px; padding: 8px; min-width: 0; max-width: 100%; }
.formula-index { display: inline-block; font-size: 0.76rem; color: var(--text-secondary); margin-bottom: 4px; }
.formula-tex { overflow-x: auto; overflow-y: hidden; max-width: 100%; -webkit-overflow-scrolling: touch; }

.note-list-v2 { list-style: disc; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; }
.note-list-v2 li { font-size: 0.84rem; line-height: 1.55; }

.steps-list-v2 { display: flex; flex-direction: column; gap: 8px; }
.step-card-v2 { border-left: 3px solid var(--mode-accent-light); border-radius: 9px; border: 1px solid var(--border); padding: 10px; min-width: 0; max-width: 100%; }
.step-card-title { font-weight: 700; font-size: 0.88rem; margin-bottom: 4px; }
.step-card-detail { font-size: 0.84rem; line-height: 1.55; margin-bottom: 6px; overflow-wrap: anywhere; }
.step-card-formula { overflow-x: auto; overflow-y: hidden; max-width: 100%; -webkit-overflow-scrolling: touch; }

@media (min-width: 760px) {
  #app { max-width: 900px; }
  .result-grid-v2 { grid-template-columns: 1fr 1fr; }
}

/* Result Report Rewrite */
.result-report {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-bottom: 24px;
}

.report-summary,
.report-band,
.report-panel,
.report-details {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.report-summary {
  padding: 18px;
  border-left: 5px solid var(--mode-accent);
}

.report-summary.report-solid {
  border-left-color: var(--success);
}

.report-summary.report-caution {
  border-left-color: var(--warning);
}

.report-kicker {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--mode-bg);
  color: var(--mode-accent-dark);
  font-size: 0.76rem;
  font-weight: 700;
}

.report-summary h2 {
  margin-top: 10px;
  font-size: 1.15rem;
  line-height: 1.4;
}

.report-answer {
  margin-top: 12px;
  padding: 12px;
  background: rgba(0,0,0,0.03);
  border-radius: 8px;
  overflow-x: auto;
  font-size: 1.25rem;
  line-height: 1.8;
}

.report-reason {
  margin-top: 10px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.55;
}

.report-band {
  padding: 14px;
}

.report-band h3,
.report-panel h3 {
  margin-bottom: 8px;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.report-band p,
.report-muted,
.report-panel p {
  color: var(--text-secondary);
  font-size: 0.88rem;
  line-height: 1.65;
}

.report-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.report-panel {
  padding: 14px;
}

.report-formulas {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.report-formula-row {
  display: grid;
  grid-template-columns: 46px 1fr;
  gap: 10px;
  align-items: center;
  padding: 9px;
  background: rgba(0,0,0,0.03);
  border-radius: 8px;
}

.report-formula-row span {
  color: var(--text-secondary);
  font-size: 0.78rem;
}

.report-formula,
.report-step-formula {
  overflow-x: auto;
  color: var(--text);
}

.report-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-left: 18px;
}

.report-list li {
  font-size: 0.88rem;
  line-height: 1.55;
}

.report-details {
  padding: 0;
  overflow: hidden;
}

.report-details summary {
  cursor: pointer;
  padding: 14px;
  font-weight: 700;
}

.report-steps {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 14px 14px;
}

.report-step {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(0,0,0,0.02);
}

.report-step-head {
  color: var(--mode-accent);
  font-size: 0.78rem;
  font-weight: 700;
}

.report-step-title {
  margin-top: 3px;
  font-size: 0.92rem;
  font-weight: 700;
}

.report-step p {
  margin-top: 6px;
  color: var(--text-secondary);
  font-size: 0.86rem;
  line-height: 1.6;
}

.report-step-formula {
  margin-top: 8px;
  padding: 8px;
  background: var(--card);
  border-radius: 8px;
}

@media (min-width: 760px) {
  .report-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* Solution View (Answer + Process only) */
.solution-view {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-bottom: 20px;
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
}

.solution-view-answer-card,
.solution-view-process-card,
.node-position-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  min-width: 0;
  max-width: 100%;
}

.solution-view-answer-card {
  border-left: 4px solid var(--mode-accent);
}

.result-feedback-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  min-width: 0;
  max-width: 100%;
}

.result-feedback-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.result-feedback-copy strong {
  color: var(--text-primary);
  font-size: 0.95rem;
}

.result-feedback-copy span,
.result-feedback-status {
  color: var(--text-secondary);
  font-size: 0.82rem;
  line-height: 1.55;
}

.result-feedback-meta {
  color: var(--text-secondary);
  font-size: 0.82rem;
  white-space: nowrap;
}

.result-feedback-meta b {
  color: var(--text-primary);
}

.result-feedback-meta em {
  margin-left: 6px;
  color: var(--mode-accent);
  font-style: normal;
  font-weight: 700;
}

.result-feedback-actions {
  display: flex;
  gap: 10px;
  grid-column: 1 / -1;
}

.result-feedback-actions .btn {
  min-height: 38px;
}

.result-feedback-actions .btn.is-selected {
  border-color: var(--mode-accent);
  color: var(--mode-accent);
}

.result-feedback-status {
  grid-column: 1 / -1;
  min-height: 20px;
}

.result-warning-card {
  background: rgba(255, 184, 77, 0.10);
  border: 1px solid rgba(255, 184, 77, 0.30);
  border-left: 4px solid var(--warning);
  border-radius: 8px;
  padding: 12px 14px;
}

.result-warning-card h3 {
  font-size: 0.92rem;
  color: #ffe2ad;
  margin-bottom: 6px;
}

.result-warning-card p,
.result-warning-card li {
  color: rgba(255, 246, 225, 0.88);
  font-size: 0.84rem;
  line-height: 1.55;
}

.result-warning-card ul {
  display: grid;
  gap: 4px;
  margin: 8px 0 0 18px;
}

.solution-timing-card {
  background: rgba(15, 23, 42, 0.03);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}

.solution-timing-head {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}

.solution-timing-card h3 {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 0;
}

.solution-timing-verdict {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 0.82rem;
}

.solution-timing-list {
  display: grid;
  gap: 8px;
}

.solution-timing-row {
  display: grid;
  grid-template-columns: minmax(72px, 0.8fr) minmax(64px, 0.55fr) auto minmax(130px, 1.8fr);
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--card);
}

.solution-timing-row strong,
.solution-timing-row span,
.solution-timing-row em {
  font-size: 0.82rem;
  line-height: 1.35;
}

.solution-timing-row strong {
  color: var(--text);
}

.solution-timing-row span {
  font-weight: 800;
  color: var(--mode-accent);
}

.solution-timing-row em {
  color: var(--text-secondary);
  font-style: normal;
}

.solution-timing-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: max-content;
  min-width: 54px;
  padding: 3px 7px;
  border-radius: 999px;
  font-size: 0.72rem;
  line-height: 1.2;
  font-weight: 850;
  border: 1px solid transparent;
}

.solution-timing-pill.is-ok {
  color: #047857;
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.24);
}

.solution-timing-pill.is-warn {
  color: #a16207;
  background: rgba(245, 158, 11, 0.14);
  border-color: rgba(245, 158, 11, 0.28);
}

.solution-timing-pill.is-danger {
  color: #b91c1c;
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.26);
}

.solution-timing-pill.is-unknown {
  color: var(--text-secondary);
  background: rgba(100, 116, 139, 0.12);
  border-color: rgba(100, 116, 139, 0.24);
}
.solution-debug-card {
  background: rgba(15, 23, 42, 0.04);
  border: 1px dashed rgba(100, 116, 139, 0.45);
  border-radius: 8px;
  overflow: hidden;
}

.solution-debug-card summary {
  cursor: pointer;
  display: grid;
  gap: 5px;
  padding: 11px 12px;
  list-style: none;
}

.solution-debug-card summary::-webkit-details-marker {
  display: none;
}

.solution-debug-card summary span {
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 850;
}

.solution-debug-card summary em {
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-style: normal;
  overflow-wrap: anywhere;
}

.solution-debug-body {
  display: grid;
  gap: 10px;
  padding: 0 12px 12px;
}

.solution-debug-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 10px;
}

.solution-debug-section h4 {
  color: var(--text-secondary);
  font-size: 0.78rem;
  margin-bottom: 6px;
}

.solution-debug-section ul {
  display: grid;
  gap: 5px;
  margin-left: 18px;
}

.solution-debug-section li {
  color: var(--text);
  font-size: 0.78rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.solution-debug-body pre {
  max-height: 280px;
  overflow: auto;
  padding: 10px;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.88);
  color: #dbeafe;
  font-size: 0.74rem;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.solution-view-answer-card h3,
.solution-view-process-card h3,
.node-position-card h3 {
  font-size: 0.92rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.node-position-card {
  border-left: 4px solid #14b8a6;
}

.node-position-list {
  display: grid;
  gap: 8px;
}

.node-position-item {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 9px;
  background: rgba(20, 184, 166, 0.08);
  border: 1px solid rgba(20, 184, 166, 0.14);
}

.node-position-item strong {
  color: #0f766e;
  font-size: 0.9rem;
}

.node-position-item span {
  color: var(--text-secondary);
  font-size: 0.86rem;
  line-height: 1.55;
}

.solution-view-answer {
  font-size: 1.25rem;
  line-height: 1.8;
  overflow: visible;
  max-width: 100%;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
  box-sizing: border-box;
}

.solution-view-steps {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  max-width: 100%;
}

.solution-view-step {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.02);
  min-width: 0;
  max-width: 100%;
}

.solution-view-step-index {
  color: var(--mode-accent);
  font-size: 0.78rem;
  font-weight: 700;
}

.solution-view-step h4 {
  margin-top: 4px;
  font-size: 0.92rem;
}

.solution-view-step p {
  margin-top: 6px;
  font-size: 0.86rem;
  line-height: 1.6;
  color: var(--text-secondary);
  overflow-wrap: anywhere;
}

.inline-math {
  display: inline-block;
  vertical-align: middle;
  padding: 0 2px;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

.solution-view-step-formula {
  margin-top: 8px;
  background: var(--card);
  border-radius: 8px;
  padding: 8px;
  overflow-x: auto;
  max-width: 100%;
  min-width: 0;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

.solution-view-answer .katex-display,
.solution-view-answer .katex {
  max-width: 100%;
  overflow: visible;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  box-sizing: border-box;
}

.solution-view-step-formula .katex-display,
.solution-view-step-formula .katex {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
}

/* Readable description blocks */
.info-block .info-value {
  display: block;
  margin-top: 6px;
  line-height: 1.7;
  white-space: normal;
  word-break: break-word;
}

.parse-note-line {
  margin-top: 8px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.confirm-node-guide {
  margin: 14px 0;
  padding: 14px;
  border: 1px solid rgba(14, 116, 144, 0.22);
  border-radius: 12px;
  background:
    linear-gradient(135deg, rgba(236, 253, 245, 0.92), rgba(240, 249, 255, 0.9));
}

.confirm-node-guide-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.confirm-node-guide h3 {
  margin: 0;
  font-size: 15px;
  color: #0f766e;
}

.confirm-node-guide p {
  margin: 0;
  font-size: 12px;
  color: var(--text-secondary);
}

.confirm-node-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.confirm-node-item {
  padding: 11px 12px;
  border: 1px solid rgba(15, 118, 110, 0.16);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.04);
}

.confirm-node-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.confirm-node-title strong {
  color: #0f172a;
  font-size: 14px;
}

.node-ground-badge {
  padding: 2px 7px;
  border-radius: 999px;
  background: #0f766e;
  color: white;
  font-size: 11px;
}

.confirm-node-pos,
.confirm-node-links {
  font-size: 12px;
  line-height: 1.55;
}

.confirm-node-pos {
  color: #334155;
}

.confirm-node-links {
  margin-top: 4px;
  color: var(--text-secondary);
}

.element-list {
  overflow-x: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.element-list table {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
}

.element-list th,
.element-list td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
  font-size: 13px;
  line-height: 1.45;
}

.element-list th {
  color: var(--text-secondary);
  font-weight: 700;
  background: var(--mode-bg);
}

.element-list tr:last-child td {
  border-bottom: none;
}

.element-main strong,
.element-main span {
  display: block;
}

.element-main span {
  margin-top: 3px;
  color: var(--text-secondary);
}

.unknown-row td {
  background: rgba(220, 38, 38, 0.06);
}

.unknown-quantity {
  color: #dc2626 !important;
}

.element-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 7px;
}

.unknown-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.5;
}

.unknown-badge {
  color: #b91c1c;
  background: rgba(220, 38, 38, 0.13);
  border: 1px solid rgba(220, 38, 38, 0.24);
}

.directionality-cell {
  color: var(--text-secondary);
  min-width: 170px;
}

.confirm-edit-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 9px;
}

.confirm-edit-token {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  padding: 5px 7px;
  border: 1px solid rgba(99, 255, 210, 0.16);
  border-radius: 8px;
  background: rgba(3, 16, 24, 0.52);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 750;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
}

.confirm-edit-token span {
  white-space: nowrap;
}

.confirm-mini-input,
.confirm-mini-select {
  min-height: 28px;
  max-width: 150px;
  border: 1px solid rgba(99, 255, 210, 0.22);
  border-radius: 7px;
  background: rgba(6, 21, 31, 0.92);
  color: var(--text);
  padding: 4px 6px;
  font: inherit;
  font-size: 12px;
  font-weight: 750;
}

.confirm-mini-input {
  width: 74px;
}

.confirm-mini-select {
  width: auto;
}

.confirm-mini-input:focus,
.confirm-mini-select:focus {
  outline: none;
  border-color: var(--mode-accent);
  box-shadow: 0 0 0 2px rgba(99, 255, 210, 0.12);
}

.confirm-check-token input {
  margin: 0;
}

.same-value-row td {
  border-left: 4px solid transparent;
}

.same-value-orange td {
  background: rgba(245, 158, 11, 0.09);
}

.same-value-orange td:first-child {
  border-left-color: #f59e0b;
}

.same-value-orange .element-main strong {
  color: #9a5b00;
}

.same-value-yellow td {
  background: rgba(234, 179, 8, 0.11);
}

.same-value-yellow td:first-child {
  border-left-color: #eab308;
}

.same-value-yellow .element-main strong {
  color: #806000;
}

.same-value-green td {
  background: rgba(34, 197, 94, 0.09);
}

.same-value-green td:first-child {
  border-left-color: #22c55e;
}

.same-value-green .element-main strong {
  color: #15803d;
}

.same-value-cyan td {
  background: rgba(6, 182, 212, 0.09);
}

.same-value-cyan td:first-child {
  border-left-color: #06b6d4;
}

.same-value-cyan .element-main strong {
  color: #0e7490;
}

.same-value-blue td {
  background: rgba(59, 130, 246, 0.09);
}

.same-value-blue td:first-child {
  border-left-color: #3b82f6;
}

.same-value-blue .element-main strong {
  color: #1d4ed8;
}

.same-value-purple td {
  background: rgba(168, 85, 247, 0.09);
}

.same-value-purple td:first-child {
  border-left-color: #a855f7;
}

.same-value-purple .element-main strong {
  color: #7e22ce;
}

.same-value-silver td {
  background: rgba(148, 163, 184, 0.16);
}

.same-value-silver td:first-child {
  border-left-color: #94a3b8;
}

.same-value-silver .element-main strong {
  color: #475569;
}

@media (max-width: 640px) {
  .analysis-loading-card {
    padding: 20px;
  }

  .analysis-hero,
  .analysis-metrics,
  .parse-progress-grid {
    grid-template-columns: 1fr;
  }

  .analysis-orbit {
    justify-content: center;
  }

  .analysis-stage {
    grid-template-columns: 16px 1fr;
  }

  .analysis-stage em {
    grid-column: 2;
  }

  .confirm-edit-grid.two {
    grid-template-columns: 1fr;
  }

  .confirm-mini-input,
  .confirm-mini-select {
    max-width: 100%;
  }

  .unrecognized-card {
    grid-template-columns: 1fr;
    padding: 12px;
    border-radius: 22px;
  }

  .unrecognized-image-wrap {
    min-height: 240px;
  }

  .unrecognized-message {
    padding: 20px;
  }

  .unrecognized-actions {
    justify-content: stretch;
  }

  .unrecognized-actions .btn {
    width: 100%;
  }
}

.solution-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.solution-main { display: grid; gap: 12px; }
.knowledge-sidebar { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 12px; }
.knowledge-item { border-top: 1px dashed var(--border); padding-top: 8px; margin-top: 8px; }
.knowledge-item:first-child { border-top: none; margin-top: 0; padding-top: 0; }
.plain-hint { margin-top: 6px; color: var(--text-secondary); font-size: 13px; }
.parse-error-list { margin: 8px 0 0 18px; }
.parse-error-list li { margin: 4px 0; line-height: 1.4; }

.symbol-float {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 12px);
  left: calc(env(safe-area-inset-left) + 12px);
  z-index: 16000;
  width: max-content;
  max-width: calc(100vw - 24px);
  pointer-events: none;
}

.symbol-float.node-float {
  top: calc(env(safe-area-inset-top) + 54px);
}

.symbol-float.netlist-float {
  top: calc(env(safe-area-inset-top) + 96px);
}

.current-probe-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 12px;
}

.current-probe-grid span {
  display: block;
  margin-bottom: 5px;
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 700;
}

.symbol-float-toggle,
.symbol-float-panel {
  pointer-events: auto;
}

.symbol-float-toggle {
  min-height: 34px;
  padding: 7px 11px;
  border-radius: 999px;
  border: 1px solid rgba(99, 255, 210, 0.28);
  background: rgba(8, 28, 40, 0.58);
  color: #eafff8;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.24), inset 0 1px 0 rgba(255,255,255,0.14);
  backdrop-filter: blur(14px) saturate(1.15);
  -webkit-backdrop-filter: blur(14px) saturate(1.15);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.02em;
  cursor: pointer;
  opacity: 0.86;
  transition: opacity 0.18s, transform 0.18s, background 0.18s, border-color 0.18s;
}

.symbol-float-toggle:hover,
.symbol-float.open .symbol-float-toggle {
  opacity: 1;
  transform: translateY(-1px);
  border-color: rgba(99, 255, 210, 0.48);
  background: rgba(8, 28, 40, 0.74);
}

.symbol-float-panel {
  width: min(360px, calc(100vw - 24px));
  max-height: min(62vh, 520px);
  margin-top: 8px;
  overflow: hidden;
  border-radius: 18px;
  border: 1px solid rgba(99, 255, 210, 0.24);
  background:
    radial-gradient(circle at top left, rgba(0, 229, 168, 0.14), transparent 38%),
    linear-gradient(180deg, rgba(8, 28, 40, 0.84), rgba(4, 16, 24, 0.78));
  box-shadow: 0 22px 64px rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(18px) saturate(1.25);
  -webkit-backdrop-filter: blur(18px) saturate(1.25);
}

.symbol-float-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.09);
}

.symbol-float-head strong {
  font-size: 13px;
  color: #eafff8;
}

.symbol-float-head button {
  width: 26px;
  height: 26px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  color: #eafff8;
  cursor: pointer;
  font-size: 17px;
  line-height: 1;
}

.symbol-float-body {
  max-height: calc(min(62vh, 520px) - 48px);
  overflow: auto;
  padding: 10px;
  display: grid;
  gap: 10px;
}

.symbol-float-body h4 {
  margin: 0 0 7px;
  font-size: 12px;
  color: rgba(207, 250, 240, 0.82);
}

.symbol-list-lite,
.symbol-node-list {
  display: grid;
  gap: 7px;
}

.symbol-row-lite,
.symbol-node-row {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 8px;
  padding: 8px 9px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.055);
}

.symbol-row-lite strong,
.symbol-node-row strong {
  color: #9fffe2;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.symbol-row-lite span,
.symbol-node-row span {
  color: rgba(236, 254, 255, 0.82);
  font-size: 12px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.symbol-row-lite.key-symbol,
.symbol-node-row.key-node {
  background: linear-gradient(135deg, rgba(0, 229, 168, 0.18), rgba(0, 229, 255, 0.10));
  border-color: rgba(99, 255, 210, 0.30);
}

.symbol-node-details {
  border-top: 1px solid rgba(255,255,255,0.08);
  padding-top: 8px;
}

.symbol-node-details summary {
  cursor: pointer;
  color: rgba(207, 250, 240, 0.88);
  font-size: 12px;
  font-weight: 850;
  margin-bottom: 8px;
  list-style-position: inside;
}

.symbol-netlist-box {
  margin: 0;
  max-height: calc(min(62vh, 520px) - 68px);
  overflow: auto;
  padding: 10px;
  border-radius: 12px;
  background: rgba(2, 8, 16, 0.72);
  border: 1px solid rgba(255,255,255,0.08);
  color: #dbeafe;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

@media (max-width: 520px) {
  .symbol-float {
    top: calc(env(safe-area-inset-top) + 8px);
    left: calc(env(safe-area-inset-left) + 8px);
    max-width: calc(100vw - 16px);
  }

  .symbol-float.node-float {
    top: calc(env(safe-area-inset-top) + 48px);
  }

  .symbol-float.netlist-float {
    top: calc(env(safe-area-inset-top) + 88px);
  }

  .symbol-float-panel {
    width: min(330px, calc(100vw - 16px));
    max-height: 56vh;
  }

  .symbol-row-lite,
  .symbol-node-row {
    grid-template-columns: 52px minmax(0, 1fr);
  }

  .solution-timing-row {
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
  }

  .solution-timing-row span,
  .solution-timing-row em {
    overflow-wrap: anywhere;
  }

  .result-feedback-panel {
    grid-template-columns: 1fr;
  }

  .result-feedback-meta {
    white-space: normal;
  }

  .result-feedback-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .account-recharge-plans {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 960px) {
  #app { max-width: 1100px; }
  .solution-layout { grid-template-columns: minmax(0, 2fr) 320px; align-items: start; }
}

.app-shell {
  min-height: 100vh;
  padding: 16px 14px calc(88px + env(safe-area-inset-bottom));
}

.app-shell-content {
  width: min(960px, 100%);
  margin: 0 auto;
}

.app-bottom-nav {
  position: fixed;
  left: 50%;
  bottom: calc(10px + env(safe-area-inset-bottom));
  z-index: 1000;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  width: min(420px, calc(100vw - 24px));
  padding: 8px;
  transform: translateX(-50%);
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 18px;
  background: rgba(10, 18, 32, 0.92);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.app-nav-item {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: rgba(226, 232, 240, 0.72);
  cursor: pointer;
}

.app-nav-item b {
  font-size: 15px;
  line-height: 1;
}

.app-nav-item.active {
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.18), rgba(45, 212, 191, 0.14));
  color: #ecfeff;
}

.app-home-head,
.app-page-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(96px, 168px);
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.app-page-head > div,
.app-home-head > div {
  min-width: 0;
}

.app-page-head .btn,
.app-home-head .btn {
  width: auto;
  min-width: 96px;
  padding: 11px 16px;
}

.app-home-head span,
.app-page-head span {
  display: block;
  margin-bottom: 4px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 800;
}

.app-home-head h2,
.app-page-head h2 {
  margin: 0;
  color: var(--text-primary);
  font-size: clamp(24px, 5vw, 34px);
  letter-spacing: 0;
  white-space: nowrap;
}

.app-mini-credit,
.app-mine-card,
.app-advice-card,
.app-history-cloud,
.app-empty-card,
.app-recharge-panel,
.app-doc-card,
.app-history-item {
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.72);
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.18);
}

.app-mini-credit {
  padding: 10px 12px;
  color: #ecfeff;
  cursor: pointer;
}

.app-advice-card {
  margin-bottom: 14px;
  padding: 14px;
}

.app-advice-card strong,
.app-section-title {
  color: #ecfeff;
  font-weight: 900;
}

.app-advice-card p,
.app-doc-card p,
.app-mine-card p,
.app-recharge-panel p {
  margin: 6px 0 0;
  color: var(--text-secondary);
  line-height: 1.65;
}

.app-page {
  display: grid;
  gap: 14px;
}

.app-history-list {
  display: grid;
  gap: 10px;
}

.app-history-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
}

.app-history-item strong,
.app-history-item p {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  -webkit-box-orient: vertical;
}

.app-history-item strong { -webkit-line-clamp: 1; color: var(--text-primary); }
.app-history-item p { -webkit-line-clamp: 2; color: var(--text-secondary); font-size: 13px; }
.app-history-item span { color: #bae6fd; font-size: 12px; }
.app-history-item em { color: var(--text-secondary); font-size: 12px; font-style: normal; }

.app-history-cloud,
.app-empty-card,
.app-recharge-panel,
.app-doc-card,
.app-mine-card {
  padding: 14px;
}

.app-cloud-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.app-cloud-grid ul {
  display: grid;
  gap: 8px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.app-cloud-grid li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 12px;
}

.app-mine-balance {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.app-mine-card strong {
  color: #ecfeff;
  font-size: 34px;
}

.app-mine-meta {
  display: grid;
  gap: 10px;
  margin: 16px 0 0;
}

.app-mine-meta div {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.app-mine-meta dt {
  color: var(--app-muted);
  font-size: 13px;
  font-weight: 850;
}

.app-mine-meta dd {
  min-width: 0;
  margin: 0;
  color: var(--app-ink);
  font-size: 14px;
  word-break: break-all;
}

.app-plan-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.app-plan-btn,
.app-link-row {
  border: 1px solid var(--app-line);
  border-radius: 14px;
  background: var(--app-surface);
  color: var(--app-ink);
  cursor: pointer;
}

.app-plan-btn {
  display: grid;
  gap: 4px;
  min-height: 74px;
  padding: 12px 10px;
  text-align: center;
}

.app-recharge-note {
  color: var(--app-muted) !important;
  font-size: 14px;
  line-height: 1.55 !important;
}

.app-plan-btn:hover,
.app-link-row:hover {
  border-color: rgba(15, 118, 110, 0.35);
  background: #f8fafc;
}

.app-plan-btn span {
  color: var(--text-secondary);
  font-size: 12px;
}

.app-link-list {
  display: grid;
  gap: 8px;
}

.app-link-row {
  min-height: 50px;
  padding: 0 16px;
  text-align: left;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.04);
}

.app-link-row.danger {
  color: #fecaca;
}

.app-doc-card textarea {
  width: 100%;
  margin: 8px 0;
  resize: vertical;
}

.app-update-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(2, 6, 23, 0.68);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.app-update-card {
  width: min(420px, 100%);
  padding: 18px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 18px;
  background: rgba(15, 23, 42, 0.96);
  box-shadow: 0 24px 72px rgba(0, 0, 0, 0.38);
  color: var(--text-primary);
}

.app-update-card h3 {
  margin: 0 0 10px;
  font-size: 20px;
}

.app-update-card p {
  margin: 8px 0;
  color: var(--text-secondary);
  line-height: 1.6;
}

.app-update-changelog {
  margin: 12px 0;
  padding: 12px;
  border-radius: 12px;
  background: rgba(30, 41, 59, 0.72);
  color: var(--text-secondary);
  line-height: 1.65;
  white-space: pre-wrap;
}

.app-update-card .btn {
  width: 100%;
  margin-top: 8px;
}

.app-update-force {
  color: #fecaca !important;
  font-weight: 800;
}

@media (max-width: 640px) {
  .app-shell {
    padding: 12px 10px calc(84px + env(safe-area-inset-bottom));
  }

  .app-history-item {
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
  }

  .app-cloud-grid,
  .app-plan-grid {
    grid-template-columns: 1fr;
  }
}

/* Native App shell polish. This repo is the APK/App build only; the C-drive website keeps its own styling. */
:root {
  --app-bg: #f5f7fb;
  --app-surface: #ffffff;
  --app-surface-muted: #eef2f7;
  --app-ink: #101827;
  --app-muted: #64748b;
  --app-line: #d9e2ec;
  --app-primary: #0f766e;
  --app-primary-strong: #0b5f59;
  --app-danger: #dc2626;
}

body {
  background: var(--app-bg);
  color: var(--app-ink);
}

#app {
  max-width: 520px;
  padding: 0;
}

.app-shell {
  min-height: 100dvh;
  padding: calc(14px + env(safe-area-inset-top)) 14px calc(88px + env(safe-area-inset-bottom));
  background: var(--app-bg);
}

.app-shell-content {
  width: 100%;
  margin: 0 auto;
}

.app-native-home {
  display: grid;
  gap: 14px;
}

.app-auth-screen {
  min-height: 100dvh;
  display: grid;
  align-content: center;
  gap: 18px;
  padding: calc(24px + env(safe-area-inset-top)) 18px calc(24px + env(safe-area-inset-bottom));
  background: var(--app-bg);
}

.app-auth-brand span {
  color: var(--app-primary);
  font-size: 13px;
  font-weight: 900;
}

.app-auth-brand h1 {
  margin: 8px 0;
  color: var(--app-ink);
  font-size: 32px;
  line-height: 1.08;
  letter-spacing: 0;
}

.app-auth-brand p {
  margin: 0;
  color: var(--app-muted);
  line-height: 1.65;
}

.app-auth-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--app-line);
  border-radius: 22px;
  background: var(--app-surface);
  box-shadow: 0 16px 42px rgba(15, 23, 42, 0.1);
}

.app-auth-tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  padding: 4px;
  border-radius: 14px;
  background: var(--app-surface-muted);
}

.app-auth-tab {
  min-height: 38px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--app-muted);
  font-weight: 900;
}

.app-auth-tab.active {
  background: #fff;
  color: var(--app-primary);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}

.app-auth-card label {
  display: grid;
  gap: 7px;
  color: var(--app-ink);
  font-size: 13px;
  font-weight: 850;
}

.app-auth-card input {
  min-height: 46px;
  width: 100%;
  border: 1px solid var(--app-line);
  border-radius: 13px;
  background: #fff;
  color: var(--app-ink);
  padding: 0 12px;
  font: inherit;
}

.app-auth-card input:focus {
  outline: none;
  border-color: var(--app-primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.app-auth-code-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.app-auth-code-row .btn {
  min-height: 46px;
  white-space: nowrap;
}

.app-auth-status {
  min-height: 20px;
  color: var(--app-muted);
  font-size: 13px;
  font-weight: 800;
}

.app-auth-status.error {
  color: var(--app-danger);
}

.app-auth-status.ok {
  color: var(--app-primary);
}

.app-auth-note {
  margin: 0;
  color: var(--app-muted);
  font-size: 12px;
  line-height: 1.6;
}

.app-native-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.app-native-topbar span,
.app-native-section-head span,
.app-native-hero span {
  display: block;
  color: var(--app-muted);
  font-size: 12px;
  font-weight: 800;
}

.app-native-topbar strong {
  display: block;
  margin-top: 3px;
  color: var(--app-ink);
  font-size: 26px;
  line-height: 1.15;
}

.app-native-credit {
  min-width: 94px;
  min-height: 48px;
  padding: 8px 12px;
  border: 1px solid var(--app-line);
  border-radius: 14px;
  background: var(--app-surface);
  color: var(--app-ink);
  text-align: left;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.07);
}

.app-native-credit span {
  margin: 0 0 2px;
  font-size: 11px;
}

.app-native-credit b {
  color: var(--app-primary);
  font-size: 18px;
}

.app-native-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: end;
  padding: 18px;
  border-radius: 22px;
  background: linear-gradient(135deg, #0f766e, #155e75);
  color: #fff;
  box-shadow: 0 14px 34px rgba(15, 118, 110, 0.24);
}

.app-native-hero span,
.app-native-hero p {
  color: rgba(255, 255, 255, 0.78);
}

.app-native-hero h1 {
  margin: 6px 0;
  color: #fff;
  font-size: 30px;
  line-height: 1.08;
  letter-spacing: 0;
}

.app-native-hero p {
  max-width: 280px;
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
}

.app-native-primary-action {
  min-width: 78px;
  min-height: 42px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: #fff;
  color: var(--app-primary-strong);
  font-weight: 900;
}

.app-native-quick-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.app-native-quick-card {
  min-height: 76px;
  display: grid;
  align-content: center;
  gap: 5px;
  padding: 12px 10px;
  border: 1px solid var(--app-line);
  border-radius: 18px;
  background: var(--app-surface);
  color: var(--app-ink);
  text-align: left;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.05);
}

.app-native-quick-card b {
  font-size: 16px;
}

.app-native-quick-card span {
  color: var(--app-muted);
  font-size: 12px;
  line-height: 1.35;
}

.mode-seg-item.locked,
.mode-seg-item:disabled {
  opacity: 0.48;
  cursor: not-allowed;
  filter: grayscale(0.5);
}

.mode-seg-item.locked .mode-seg-label::after {
  content: "  ";
}

.app-native-section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin: 4px 0 10px;
}

.app-native-section-head h2 {
  margin: 3px 0 0;
  color: var(--app-ink);
  font-size: 22px;
  line-height: 1.2;
}

.app-native-section-head em {
  color: var(--app-muted);
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
}

.app-native-upload-card .upload-header,
.app-native-upload-card .hero-grid,
.app-native-upload-card .mini-circuit-line,
.app-native-upload-card .hero-chip,
.app-native-upload-card .hero-tips {
  display: none;
}

.app-native-upload-card .upload-section {
  gap: 12px;
  padding: 0;
}

.app-native-upload-card .mode-toggle-section,
.app-native-upload-card .split-mode-toggle,
.app-native-upload-card .split-input-card,
.app-native-upload-card .preview-area,
.app-native-upload-card .upload-advice-card,
.app-native-upload-card .image-crop-card {
  border-color: var(--app-line);
  background: var(--app-surface);
  color: var(--app-ink);
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.05);
}

.app-native-upload-card .split-mode-toggle p,
.app-native-upload-card .upload-hint,
.app-native-upload-card .split-card-head span,
.app-native-upload-card .upload-subtitle {
  color: var(--app-muted);
}

.app-native-upload-card .upload-btn,
.app-native-upload-card .start-btn,
.app-native-upload-card .btn-primary {
  border-radius: 14px;
  box-shadow: none;
}

.app-native-upload-card .start-btn:not(:disabled),
.app-native-upload-card .btn-primary {
  background: var(--app-primary);
  color: #fff;
}

.account-entry-btn,
#debug-toggle-btn,
#app-version-badge {
  display: none !important;
}

.app-native-upload-card .upload-advice-entry {
  display: inline-flex;
  align-items: center;
  left: calc(env(safe-area-inset-left) + 16px);
  bottom: calc(82px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.96);
  color: var(--app-primary);
  border-color: var(--app-line);
  box-shadow: 0 12px 26px rgba(15, 23, 42, 0.12);
}

.app-bottom-nav {
  bottom: env(safe-area-inset-bottom);
  width: 100%;
  max-width: 520px;
  padding: 8px 18px calc(8px + env(safe-area-inset-bottom));
  border-width: 1px 0 0;
  border-color: var(--app-line);
  border-radius: 0;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 -8px 24px rgba(15, 23, 42, 0.08);
}

.app-nav-item {
  color: var(--app-muted);
}

.app-nav-item b {
  font-size: 16px;
}

.app-nav-item.active {
  background: var(--app-surface-muted);
  color: var(--app-primary);
}

.app-page-head h2,
.app-mine-card strong,
.app-history-item strong,
.app-section-title {
  color: var(--app-ink);
}

.app-mine-card,
.app-advice-card,
.app-history-cloud,
.app-empty-card,
.app-recharge-panel,
.app-doc-card,
.app-history-item {
  border-color: var(--app-line);
  background: var(--app-surface);
  color: var(--app-ink);
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.05);
}

@media (max-width: 380px) {
  .app-native-hero {
    grid-template-columns: 1fr;
  }

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