/* 新设锦锦专享解题大师 */
:root {
  --ink: #1b1730;
  --ink-2: #4b4566;
  --muted: #7b7594;
  --line: rgba(27, 23, 48, .10);
  --card: rgba(255, 255, 255, .78);
  --brand: #6b4dff;
  --brand-2: #ff77c8;
  --danger: #d63a55;
  --ok: #0f9d76;
  --radius: 22px;
  --shadow: 0 24px 60px -28px rgba(50, 30, 110, .45), 0 2px 8px rgba(50, 30, 110, .06);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  padding: calc(18px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans SC", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: #f7f5ff;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

/* ---- 背景装饰 ---- */
.bg-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(70px);
  opacity: .55;
  pointer-events: none;
  z-index: 0;
}
.orb-1 { width: 46vw; height: 46vw; min-width: 280px; min-height: 280px; top: -12vw; left: -10vw; background: radial-gradient(circle, #b9a6ff, transparent 68%); }
.orb-2 { width: 52vw; height: 52vw; min-width: 300px; min-height: 300px; bottom: -18vw; right: -14vw; background: radial-gradient(circle, #ffc0e2, transparent 68%); }
.bg-grid {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image: linear-gradient(rgba(107, 77, 255, .045) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(107, 77, 255, .045) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: radial-gradient(ellipse at 50% 0%, #000 35%, transparent 78%);
  -webkit-mask-image: radial-gradient(ellipse at 50% 0%, #000 35%, transparent 78%);
}

.shell {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel {
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, .7);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  backdrop-filter: blur(18px) saturate(1.1);
  -webkit-backdrop-filter: blur(18px) saturate(1.1);
}

/* ---- 登录 ---- */
.login-panel {
  margin: auto;
  width: 100%;
  max-width: 420px;
  padding: 34px 26px 24px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  animation: rise .5s cubic-bezier(.2, .7, .3, 1) both;
}
body:has(#loginView:not([hidden])) {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.brand { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.brand h1 { font-size: 22px; line-height: 1.35; margin: 2px 0 0; letter-spacing: .3px; }
.brand .sub { margin: 0; color: var(--muted); font-size: 14px; }

.mark { width: 64px; height: 64px; border-radius: 20px; display: grid; place-items: center;
  background: linear-gradient(145deg, rgba(124, 92, 255, .16), rgba(255, 122, 198, .16));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .7), 0 12px 26px -14px rgba(107, 77, 255, .7);
}
.mark svg { width: 40px; height: 40px; }
.mark.small { width: 44px; height: 44px; border-radius: 14px; flex: 0 0 auto; }
.mark.small svg { width: 28px; height: 28px; }

.field { display: flex; flex-direction: column; gap: 8px; }
.field-label { font-size: 13px; font-weight: 600; color: var(--ink-2); letter-spacing: .2px; }

.input-wrap { position: relative; display: block; }
input[type="password"], input[type="text"], textarea {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: rgba(255, 255, 255, .85);
  border: 1.5px solid rgba(107, 77, 255, .16);
  border-radius: 15px;
  padding: 14px 16px;
  outline: none;
  transition: border-color .18s, box-shadow .18s, background .18s;
  -webkit-appearance: none;
  appearance: none;
}
input[type="password"], input[type="text"] { padding-right: 52px; letter-spacing: .12em; }
textarea { resize: vertical; min-height: 132px; line-height: 1.7; letter-spacing: 0; }
input::placeholder, textarea::placeholder { color: #a8a3bd; letter-spacing: 0; }
input:focus, textarea:focus {
  border-color: rgba(107, 77, 255, .55);
  box-shadow: 0 0 0 4px rgba(107, 77, 255, .12);
  background: #fff;
}

.ghost-btn {
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; background: transparent; color: var(--muted);
  cursor: pointer; border-radius: 12px; padding: 8px;
  transition: color .16s, background .16s;
}
.ghost-btn:hover { color: var(--brand); background: rgba(107, 77, 255, .08); }
.ghost-btn:focus-visible { outline: 2px solid rgba(107, 77, 255, .55); outline-offset: 2px; }
.input-wrap .ghost-btn { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); }
.text-btn { font-size: 14px; font-weight: 600; padding: 8px 12px; }

.primary-btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 52px;
  font: inherit; font-weight: 700; font-size: 16px; letter-spacing: .5px;
  color: #fff; border: 0; border-radius: 16px; cursor: pointer;
  background: linear-gradient(120deg, #6b4dff 0%, #8a5cff 45%, #ff77c8 120%);
  box-shadow: 0 16px 34px -16px rgba(107, 77, 255, .85);
  transition: transform .16s, box-shadow .16s, filter .16s;
  overflow: hidden;
}
.primary-btn::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(120deg, transparent 20%, rgba(255, 255, 255, .35) 50%, transparent 80%);
  transform: translateX(-120%);
  transition: transform .6s;
}
.primary-btn:hover::after { transform: translateX(120%); }
.primary-btn:hover { transform: translateY(-1px); box-shadow: 0 20px 40px -16px rgba(107, 77, 255, .9); }
.primary-btn:active { transform: translateY(0) scale(.995); }
.primary-btn:disabled { filter: grayscale(.35) opacity(.65); cursor: not-allowed; transform: none; box-shadow: none; }
.primary-btn:focus-visible { outline: 3px solid rgba(107, 77, 255, .45); outline-offset: 3px; }
.btn-icon { transition: transform .18s; }
.primary-btn:hover .btn-icon { transform: translateX(3px); }

.msg { margin: 0; font-size: 13.5px; line-height: 1.5; padding: 10px 12px; border-radius: 12px; }
.msg.error { color: #a3132c; background: rgba(214, 58, 85, .09); border: 1px solid rgba(214, 58, 85, .18); }

.foot-note { margin: 0; text-align: center; font-size: 12px; color: var(--muted); }

/* ---- 顶栏 ---- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 4px 4px 0; }
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-title { font-size: 17px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-sub { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }

/* ---- 标签页 ---- */
.tabs {
  position: relative;
  display: grid; grid-template-columns: 1fr 1fr;
  background: rgba(255, 255, 255, .6);
  border: 1px solid rgba(255, 255, 255, .8);
  border-radius: 16px;
  padding: 5px;
  box-shadow: 0 10px 24px -20px rgba(50, 30, 110, .5);
}
.tab {
  position: relative; z-index: 1;
  font: inherit; font-size: 14.5px; font-weight: 600; color: var(--muted);
  background: transparent; border: 0; border-radius: 12px; padding: 11px 8px;
  cursor: pointer; transition: color .2s;
}
.tab.active { color: var(--brand); }
.tab-indicator {
  position: absolute; top: 5px; left: 5px; width: calc(50% - 5px); height: calc(100% - 10px);
  background: #fff; border-radius: 12px;
  box-shadow: 0 6px 16px -10px rgba(50, 30, 110, .6);
  transition: transform .28s cubic-bezier(.3, .7, .3, 1);
}
.tabs[data-active="image"] .tab-indicator { transform: translateX(100%); }

/* ---- 输入区 ---- */
.input-panel { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.pane { display: flex; flex-direction: column; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.hint { margin: 0; font-size: 12.5px; color: var(--muted); }
.counter { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

.dropzone {
  position: relative;
  border: 1.8px dashed rgba(107, 77, 255, .32);
  border-radius: 18px;
  background: rgba(255, 255, 255, .55);
  padding: 26px 18px;
  text-align: center;
  cursor: pointer;
  transition: border-color .18s, background .18s, transform .18s;
  min-height: 180px;
  display: grid; place-items: center;
}
.dropzone:hover, .dropzone:focus-visible { border-color: rgba(107, 77, 255, .65); background: rgba(255, 255, 255, .8); outline: none; }
.dropzone.dragover { border-color: var(--brand); background: rgba(107, 77, 255, .07); transform: scale(1.005); }
.dz-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--brand); }
.dz-title { margin: 6px 0 0; font-size: 15px; font-weight: 600; color: var(--ink); }
.dz-sub { margin: 0; font-size: 12.5px; color: var(--muted); }
.dz-preview { position: relative; width: 100%; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.dz-preview img { max-width: 100%; max-height: 320px; border-radius: 14px; box-shadow: 0 14px 30px -18px rgba(50, 30, 110, .7); }
.chip-btn {
  font: inherit; font-size: 13px; font-weight: 600; color: var(--brand);
  background: rgba(107, 77, 255, .1); border: 0; border-radius: 999px; padding: 7px 16px; cursor: pointer;
}
.chip-btn:hover { background: rgba(107, 77, 255, .18); }

/* ---- 结果 ---- */
.result-panel { padding: 18px; animation: rise .35s ease both; }
.result-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.result-head h2 { margin: 0; font-size: 16px; letter-spacing: .3px; }
.result-actions { display: flex; gap: 4px; }
.result-body { padding-top: 14px; font-size: 15px; line-height: 1.85; color: var(--ink-2); word-break: break-word; }
.result-body h3 { font-size: 15.5px; color: var(--ink); margin: 18px 0 6px; }
.result-body h3:first-child { margin-top: 0; }
.result-body p { margin: 0 0 10px; }
.result-body strong { color: var(--ink); }
.result-body ul, .result-body ol { margin: 0 0 12px; padding-left: 22px; }
.result-body li { margin: 4px 0; }
.result-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .92em; background: rgba(107, 77, 255, .1); padding: 1px 6px; border-radius: 6px;
}
.result-body .answer-box {
  margin-top: 16px; padding: 14px 16px; border-radius: 14px;
  background: linear-gradient(120deg, rgba(107, 77, 255, .09), rgba(255, 119, 200, .09));
  border: 1px solid rgba(107, 77, 255, .18);
}

/* ---- 思考中 ---- */
.thinking-panel { padding: 26px 18px; text-align: center; animation: rise .3s ease both; }
.thinking-dots { display: inline-flex; gap: 7px; margin-bottom: 12px; }
.thinking-dots span {
  width: 9px; height: 9px; border-radius: 50%;
  background: linear-gradient(135deg, #6b4dff, #ff77c8);
  animation: bounce 1.1s infinite ease-in-out;
}
.thinking-dots span:nth-child(2) { animation-delay: .15s; }
.thinking-dots span:nth-child(3) { animation-delay: .3s; }
.thinking-title { margin: 0; font-size: 15px; font-weight: 600; }
.thinking-sub { margin: 6px 0 0; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---- 加载 ---- */
.loading-panel { margin: auto; width: 100px; height: 100px; display: grid; place-items: center; border-radius: 26px; }
.spinner {
  width: 28px; height: 28px; border-radius: 50%;
  border: 3px solid rgba(107, 77, 255, .18); border-top-color: var(--brand);
  animation: spin .8s linear infinite;
}

.page-foot { text-align: center; font-size: 12px; color: var(--muted); padding: 6px 0 2px; }

/* ---- Toast ---- */
.toast {
  position: fixed; left: 50%; bottom: calc(26px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px);
  background: rgba(27, 23, 48, .92); color: #fff;
  font-size: 13.5px; padding: 11px 18px; border-radius: 999px;
  opacity: 0; pointer-events: none; transition: opacity .22s, transform .22s;
  z-index: 50; max-width: calc(100vw - 40px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes bounce {
  0%, 80%, 100% { transform: scale(.7); opacity: .5; }
  40% { transform: scale(1); opacity: 1; }
}

/* ---- 平板 ---- */
@media (min-width: 720px) {
  body { padding: 28px 24px 36px; }
  .shell { gap: 18px; }
  .login-panel { padding: 42px 36px 28px; }
  .brand h1 { font-size: 25px; }
  .input-panel, .result-panel { padding: 24px; }
  .topbar-title { font-size: 19px; }
  .result-body { font-size: 15.5px; }
}

/* ---- 手机 ---- */
@media (max-width: 420px) {
  body { padding-left: 12px; padding-right: 12px; }
  .brand h1 { font-size: 20px; }
  .topbar-sub { display: none; }
  .topbar-title { font-size: 15.5px; }
  .input-panel, .result-panel { padding: 14px; border-radius: 18px; }
  .primary-btn { min-height: 50px; font-size: 15.5px; }
  .dz-preview img { max-height: 240px; }
  .result-body { font-size: 14.5px; line-height: 1.8; }
  .tab { font-size: 14px; }
  .login-panel { padding: 28px 20px 20px; }
}

/* ---- 横屏手机（矮屏） ---- */
@media (max-height: 480px) and (orientation: landscape) {
  body { padding-top: 12px; padding-bottom: 12px; }
  .login-panel { max-height: none; }
  .brand .sub, .foot-note { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #f2eeff;
    --ink-2: #d5cfe9;
    --muted: #a29bba;
    --line: rgba(255, 255, 255, .12);
    --card: rgba(28, 24, 48, .72);
  }
  body { background: #14111f; }
  input[type="password"], input[type="text"], textarea { background: rgba(255, 255, 255, .06); color: var(--ink); }
  input:focus, textarea:focus { background: rgba(255, 255, 255, .1); }
  .tab-indicator { background: rgba(255, 255, 255, .1); }
  .dropzone { background: rgba(255, 255, 255, .04); }
  .dropzone:hover { background: rgba(255, 255, 255, .08); }
  .msg.error { color: #ffb3c0; }
  .toast { background: rgba(255, 255, 255, .14); backdrop-filter: blur(12px); }
}

/* ---- 拍照 / 相册 ---- */
.shot-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.shot-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-size: 14.5px; font-weight: 600;
  color: var(--ink-2); background: rgba(255, 255, 255, .8);
  border: 1.5px solid rgba(107, 77, 255, .18);
  border-radius: 14px; padding: 13px 12px; cursor: pointer;
  transition: border-color .18s, background .18s, color .18s, transform .14s;
  -webkit-tap-highlight-color: transparent;
}
.shot-btn:hover { border-color: rgba(107, 77, 255, .5); color: var(--brand); }
.shot-btn:active { transform: scale(.985); }
.shot-btn:focus-visible { outline: 3px solid rgba(107, 77, 255, .35); outline-offset: 2px; }
.primary-shot {
  color: #fff; border-color: transparent;
  background: linear-gradient(120deg, #6b4dff, #8a5cff 55%, #ff77c8 125%);
  box-shadow: 0 12px 26px -16px rgba(107, 77, 255, .9);
}
.primary-shot:hover { color: #fff; filter: brightness(1.04); }

/* ---- 相机浮层 ---- */
.camera-modal {
  position: fixed; inset: 0; z-index: 60;
  background: #08060f;
  display: flex; align-items: center; justify-content: center;
  animation: fade .18s ease both;
}
.camera-stage { position: relative; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
#cameraVideo {
  width: 100%; height: 100%; object-fit: contain; background: #000; display: block;
}
.camera-hint {
  position: absolute; top: calc(14px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  color: rgba(255, 255, 255, .8); font-size: 12.5px; background: rgba(0, 0, 0, .45);
  padding: 6px 14px; border-radius: 999px; white-space: nowrap; backdrop-filter: blur(8px);
}
.camera-bar {
  position: absolute; left: 0; right: 0; bottom: calc(20px + env(safe-area-inset-bottom));
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 26px; gap: 14px;
}
.camera-btn {
  font: inherit; font-size: 14px; font-weight: 600; color: #fff;
  background: rgba(255, 255, 255, .14); border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 999px; padding: 11px 20px; cursor: pointer; backdrop-filter: blur(10px);
  min-width: 78px;
}
.camera-btn:hover { background: rgba(255, 255, 255, .24); }
.shutter {
  width: 68px; height: 68px; border-radius: 50%; cursor: pointer;
  border: 4px solid rgba(255, 255, 255, .85); background: rgba(255, 255, 255, .25);
  box-shadow: 0 0 0 4px rgba(0, 0, 0, .35), inset 0 0 0 3px rgba(255, 255, 255, .5);
  transition: transform .12s, background .12s;
}
.shutter:active { transform: scale(.94); background: #fff; }
.shutter:focus-visible { outline: 3px solid #fff; outline-offset: 4px; }

@keyframes fade { from { opacity: 0 } to { opacity: 1 } }

@media (max-width: 420px) {
  .shot-btn { font-size: 13.5px; padding: 12px 8px; }
  .camera-hint { font-size: 11.5px; }
  .camera-bar { padding: 0 18px; }
  .camera-btn { padding: 10px 16px; min-width: 66px; }
  .shutter { width: 62px; height: 62px; }
}

@media (prefers-color-scheme: dark) {
  .shot-btn { background: rgba(255, 255, 255, .07); }
}
