/* 设计系统
     色彩：终端黑底、暖纸白字、琥珀强调、星金收藏
     字体：无衬线界面 / 宋体正文 / 等宽元信息
     布局：760px 单栏；输入是唯一焦点，结果像一张便笺，收藏库在下方 */
  :root {
    color-scheme: dark;
    --bg: #0a0a09;
    --panel: #111110;
    --panel-2: #171614;
    --line: #262523;
    --line-2: #3a3834;
    --ink: #ece9e3;
    --ink-2: #bdb7ad;
    --muted: #8d887f;
    --faint: #605c55;
    --accent: #d99a6c;
    --accent-2: #f2bd8c;
    --star: #e9b45f;
    --ok: #83b28d;
    --bad: #d97a6c;
    --serif: "Songti SC", "Noto Serif SC", "Source Han Serif SC", "STSong", SimSun, serif;
    --sans: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, -apple-system, sans-serif;
    --mono: "Cascadia Code", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  }
  * { box-sizing: border-box; }
  [hidden] { display: none !important; }
  html { background: var(--bg); }
  body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--sans);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
  }
  button { font-family: inherit; }
  ::selection { background: rgba(217, 154, 108, 0.28); color: #fff; }

  .topbar, main { position: relative; z-index: 1; }

  /* 底部极光：蓝紫为主，缓慢起伏与变色 */
  .aurora {
    position: fixed;
    left: 50%;
    bottom: -15vh;
    z-index: 0;
    width: 140vw;
    height: 62vh;
    transform: translateX(-50%);
    pointer-events: none;
    background: linear-gradient(to top, rgba(20, 26, 64, 0.65), rgba(20, 26, 64, 0) 78%);
    opacity: 0.95;
    mix-blend-mode: screen;
    -webkit-mask-image: linear-gradient(to top, #000 42%, transparent 100%);
    mask-image: linear-gradient(to top, #000 42%, transparent 100%);
  }
  .aurora span {
    position: absolute;
    display: block;
    border-radius: 50%;
    filter: blur(46px);
    will-change: transform, opacity;
  }
  .aurora .a1 {
    left: -6%;
    bottom: 6%;
    width: 78vw;
    height: 52vh;
    background: radial-gradient(circle at 50% 50%, rgba(20, 45, 110, 0.9), rgba(20, 45, 110, 0) 68%);
    animation: aurora-a 32s ease-in-out infinite alternate;
  }
  .aurora .a2 {
    right: -8%;
    bottom: -2%;
    width: 74vw;
    height: 58vh;
    background: radial-gradient(circle at 50% 50%, rgba(75, 30, 120, 0.8), rgba(75, 30, 120, 0) 70%);
    animation: aurora-b 40s ease-in-out infinite alternate;
  }
  .aurora .a3 {
    left: 26%;
    bottom: -6%;
    width: 72vw;
    height: 54vh;
    background: radial-gradient(circle at 50% 50%, rgba(45, 30, 95, 0.82), rgba(45, 30, 95, 0) 70%);
    animation: aurora-c 36s ease-in-out infinite alternate;
  }
  .aurora .a4 {
    left: 8%;
    bottom: 18%;
    width: 48vw;
    height: 38vh;
    background: radial-gradient(circle at 50% 50%, rgba(95, 25, 90, 0.6), rgba(95, 25, 90, 0) 72%);
    animation: aurora-d 48s ease-in-out infinite alternate;
  }
  @keyframes aurora-a {
    0% { transform: translate3d(-4%, 3%, 0) scale(1); opacity: 0.7; }
    50% { transform: translate3d(10%, -7%, 0) scale(1.22); opacity: 1; }
    100% { transform: translate3d(3%, -1%, 0) scale(1.08); opacity: 0.78; }
  }
  @keyframes aurora-b {
    0% { transform: translate3d(4%, 2%, 0) scale(1.05); opacity: 0.65; }
    50% { transform: translate3d(-9%, -5%, 0) scale(1.2); opacity: 0.95; }
    100% { transform: translate3d(-2%, 4%, 0) scale(0.98); opacity: 0.7; }
  }
  @keyframes aurora-c {
    0% { transform: translate3d(-4%, 2%, 0) scale(0.98); opacity: 0.6; }
    50% { transform: translate3d(6%, -5%, 0) scale(1.16); opacity: 0.9; }
    100% { transform: translate3d(-1%, 3%, 0) scale(1.05); opacity: 0.65; }
  }
  @keyframes aurora-d {
    0% { transform: translate3d(5%, -2%, 0) scale(1); opacity: 0.4; }
    50% { transform: translate3d(-6%, 5%, 0) scale(1.16); opacity: 0.7; }
    100% { transform: translate3d(2%, 1%, 0) scale(0.96); opacity: 0.45; }
  }

  .topbar {
    max-width: 760px;
    margin: 0 auto;
    padding: 24px 0 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
  }
  .wordmark {
    display: flex;
    align-items: center;
    gap: 9px;
    font: 11px/1 var(--mono);
    letter-spacing: 0.2em;
    color: var(--muted);
    white-space: nowrap;
  }
  .wordmark .mark {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 3px rgba(217, 154, 108, 0.1);
  }
  .top-actions { display: flex; align-items: center; gap: 8px; min-width: 0; }
  .status-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: transparent;
    border: 1px solid var(--line);
    color: var(--muted);
    font: 11px/1 var(--mono);
    letter-spacing: 0.04em;
    padding: 8px 11px;
    border-radius: 999px;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s;
  }
  .status-pill:hover { border-color: var(--line-2); color: var(--ink-2); }
  .status-pill .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--faint);
    flex: 0 0 auto;
    transition: background 0.2s, box-shadow 0.2s;
  }
  .status-pill.ok .dot { background: var(--ok); box-shadow: 0 0 0 3px rgba(131, 178, 141, 0.12); }
  .status-pill.bad .dot { background: var(--bad); box-shadow: 0 0 0 3px rgba(217, 122, 108, 0.1); }
  .icon-btn {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 50%;
    color: var(--muted);
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s, transform 0.2s;
  }
  .icon-btn:hover { border-color: var(--line-2); color: var(--ink); transform: rotate(12deg); }
  .icon-btn svg { width: 16px; height: 16px; }
  .icon-btn path, .icon-btn circle { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }

  main {
    max-width: 760px;
    margin: 0 auto;
    padding-bottom: 56px;
  }
  .hero {
    padding: clamp(44px, 9vh, 92px) 0 0;
    display: flex;
    flex-direction: column;
    gap: 24px;
  }
  h1 {
    margin: 0;
    font-size: clamp(30px, 5.4vw, 44px);
    font-weight: 300;
    line-height: 1.24;
    letter-spacing: 0.07em;
    color: var(--ink);
    text-wrap: balance;
  }
  .hero h1 { text-align: center; }
  .search {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 8px 8px 22px;
    background: linear-gradient(180deg, #151413, #101010);
    border: 1px solid var(--line);
    border-radius: 18px;
    transition: border-color 0.22s, box-shadow 0.22s, transform 0.12s;
  }
  .search:focus-within {
    border-color: var(--line-2);
    box-shadow: 0 0 0 4px rgba(217, 154, 108, 0.055), 0 24px 60px -40px rgba(0, 0, 0, 0.9);
  }
  .search.shake { animation: shake 0.32s ease; }
  #ideaInput {
    flex: 1;
    min-width: 0;
    padding: 15px 0;
    background: none;
    border: 0;
    outline: 0;
    color: var(--ink);
    font: 400 17px/1.5 var(--sans);
    letter-spacing: 0.02em;
    caret-color: var(--accent);
  }
  .go {
    flex: 0 0 auto;
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    background: var(--panel-2);
    border: 1px solid var(--line-2);
    border-radius: 50%;
    color: var(--ink);
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, color 0.2s, transform 0.15s;
  }
  .go:hover:not(:disabled) { background: var(--accent); border-color: var(--accent); color: #1b120a; transform: translateX(1px); }
  .go:disabled { cursor: default; opacity: 0.85; }
  .go:focus-visible, .fav-btn:focus-visible, .icon-btn:focus-visible,
  .status-pill:focus-visible, .ghost-btn:focus-visible, .btn:focus-visible, .star-mini:focus-visible,
  .fav-main:focus-visible {
    outline: 2px solid var(--accent-2);
    outline-offset: 2px;
  }
  .go svg.arrow { width: 20px; height: 20px; }
  .go svg.arrow path { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
  .spinner {
    display: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid rgba(236, 233, 227, 0.22);
    border-top-color: var(--ink);
    animation: spin 0.7s linear infinite;
  }
  .go.busy .arrow { display: none; }
  .go.busy .spinner { display: block; }

  .result-zone { margin-top: 38px; }
  .result-card {
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: clamp(20px, 4vw, 30px);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 20px;
    box-shadow: 0 40px 90px -60px #000;
    animation: rise 0.34s ease both;
  }
  .result-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
  .query-chip {
    max-width: 72%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 7px 10px;
    background: rgba(217, 154, 108, 0.07);
    border: 1px solid rgba(217, 154, 108, 0.16);
    border-radius: 8px;
    color: var(--accent);
    font: 11px/1.2 var(--mono);
    letter-spacing: 0.05em;
  }
  .fav-btn {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 11px;
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    font: 12px/1 var(--sans);
    cursor: pointer;
    transition: color 0.18s, border-color 0.18s, background 0.18s;
  }
  .fav-btn:hover { color: var(--star); border-color: rgba(233, 180, 95, 0.4); }
  .fav-btn.active { color: var(--star); border-color: rgba(233, 180, 95, 0.45); background: rgba(233, 180, 95, 0.07); }
  .fav-btn svg { width: 15px; height: 15px; }
  .fav-btn svg path { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; }
  .fav-btn.active svg path { fill: var(--star); stroke: var(--star); }
  .fav-btn.pop svg { animation: starpop 0.34s ease; }
  .result-text {
    margin: 0;
    color: var(--ink);
    font-family: var(--serif);
    font-size: clamp(16.5px, 2.4vw, 18.5px);
    line-height: 2.06;
    letter-spacing: 0.03em;
    text-align: justify;
    text-justify: inter-ideograph;
    overflow-wrap: break-word;
  }
  .result-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
  }
  .meta { font: 10.5px/1.5 var(--mono); color: var(--faint); letter-spacing: 0.04em; }
  .ghost-btn {
    padding: 6px 2px;
    background: none;
    border: 0;
    color: var(--muted);
    font: 12px/1 var(--sans);
    cursor: pointer;
    white-space: nowrap;
    transition: color 0.18s;
  }
  .ghost-btn:hover { color: var(--accent-2); }

  .thinking-row {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 0 14px;
    color: var(--muted);
    font: 13px/1 var(--sans);
    letter-spacing: 0.06em;
  }
  .dots { display: inline-flex; gap: 4px; }
  .dots i {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--accent);
    animation: bob 1.1s ease-in-out infinite;
  }
  .dots i:nth-child(2) { animation-delay: 0.14s; }
  .dots i:nth-child(3) { animation-delay: 0.28s; }

  .result-card.error { border-color: rgba(217, 122, 108, 0.34); }
  .error-title { margin: 0; color: var(--bad); font: 12px/1.5 var(--mono); letter-spacing: 0.06em; }
  .error-body { margin: 0; color: var(--ink-2); font-size: 13.5px; line-height: 1.85; }
  .error-actions { display: flex; gap: 14px; align-items: center; }

  .shelf { margin-top: 64px; }
  .shelf-head {
    display: flex;
    align-items: baseline;
    gap: 11px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--line);
  }
  .shelf-head h2 {
    margin: 0;
    color: var(--ink-2);
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.14em;
  }
  .count {
    padding: 4px 8px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--faint);
    font: 10.5px/1 var(--mono);
    letter-spacing: 0.03em;
    font-variant-numeric: tabular-nums;
  }
  .fav-list { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
  .fav-card {
    display: flex;
    align-items: flex-start;
    gap: 4px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    transition: border-color 0.18s, background 0.18s;
  }
  .fav-card:hover { border-color: var(--line-2); }
  .fav-card.expanded { border-color: rgba(217, 154, 108, 0.28); background: #121110; }
  .fav-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px 4px 16px 16px;
    background: none;
    border: 0;
    color: inherit;
    text-align: left;
    cursor: pointer;
  }
  .fav-query {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--accent);
    font: 10.5px/1.3 var(--mono);
    letter-spacing: 0.05em;
  }
  .fav-text {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin: 0;
    color: var(--ink-2);
    font-family: var(--serif);
    font-size: 14.5px;
    line-height: 1.9;
    letter-spacing: 0.02em;
    text-align: justify;
    text-justify: inter-ideograph;
    overflow-wrap: break-word;
  }
  .fav-card.expanded .fav-text { display: block; -webkit-line-clamp: unset; }
  .fav-side { flex: 0 0 auto; padding: 10px 10px 0 0; }
  .star-mini {
    display: grid;
    place-items: center;
    padding: 7px;
    background: none;
    border: 0;
    border-radius: 9px;
    color: var(--star);
    line-height: 0;
    cursor: pointer;
    transition: background 0.18s;
  }
  .star-mini:hover { background: rgba(233, 180, 95, 0.1); }
  .star-mini svg { width: 17px; height: 17px; }
  .star-mini svg path { fill: var(--star); stroke: var(--star); stroke-width: 1.4; stroke-linejoin: round; }

  .fav-empty {
    margin-top: 16px;
    padding: 36px 20px;
    border: 1px solid var(--line);
    border-radius: 14px;
    text-align: center;
    color: var(--faint);
    background: rgba(255, 255, 255, 0.012);
  }
  .fav-empty svg { width: 24px; height: 24px; margin-bottom: 12px; color: var(--faint); }
  .fav-empty svg path { fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linejoin: round; }
  .fav-empty p { margin: 0; font-size: 12.5px; line-height: 1.9; letter-spacing: 0.02em; }

  .modal {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.68);
    -webkit-backdrop-filter: blur(7px);
    backdrop-filter: blur(7px);
  }
  .sheet {
    width: min(460px, 100%);
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 17px;
    padding: 24px;
    background: var(--panel);
    border: 1px solid var(--line-2);
    border-radius: 18px;
    box-shadow: 0 50px 140px -50px #000;
    animation: rise 0.22s ease both;
  }
  .sheet h3 { margin: 0; font-size: 14.5px; font-weight: 500; letter-spacing: 0.08em; color: var(--ink); }
  .field { display: flex; flex-direction: column; gap: 7px; }
  .field label { color: var(--muted); font: 10px/1 var(--mono); letter-spacing: 0.08em; }
  .field input {
    padding: 10px 12px;
    background: #0d0d0c;
    border: 1px solid var(--line);
    border-radius: 10px;
    outline: none;
    color: var(--ink);
    font: 12.5px/1.45 var(--mono);
    transition: border-color 0.18s, box-shadow 0.18s;
  }
  .field input:focus { border-color: var(--line-2); box-shadow: 0 0 0 3px rgba(217, 154, 108, 0.06); }
  .sheet-actions { display: flex; align-items: center; justify-content: flex-end; gap: 9px; flex-wrap: wrap; }
  .btn {
    padding: 9px 14px;
    background: var(--panel-2);
    border: 1px solid var(--line-2);
    border-radius: 9px;
    color: var(--ink);
    font: 12.5px/1 var(--sans);
    cursor: pointer;
    transition: background 0.18s, border-color 0.18s, color 0.18s;
  }
  .btn:hover { border-color: var(--muted); }
  .btn.primary { background: var(--accent); border-color: var(--accent); color: #1b120a; font-weight: 600; }
  .btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
  .btn.quiet { margin-right: auto; background: none; border-color: transparent; color: var(--muted); padding-left: 2px; }
  .btn.quiet:hover { color: var(--ink-2); }

  .toast {
    position: fixed;
    left: 50%;
    bottom: max(26px, env(safe-area-inset-bottom, 26px));
    z-index: 60;
    transform: translateX(-50%);
    padding: 10px 16px;
    background: var(--panel-2);
    border: 1px solid var(--line-2);
    border-radius: 999px;
    color: var(--ink);
    font-size: 12.5px;
    line-height: 1.4;
    white-space: nowrap;
    max-width: calc(100vw - 32px);
    overflow: hidden;
    text-overflow: ellipsis;
    box-shadow: 0 20px 50px -20px #000;
    animation: toastin 0.22s ease both;
  }

  @keyframes spin { to { transform: rotate(360deg); } }
  @keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
  @keyframes bob { 0%, 100% { opacity: 0.35; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-3px); } }
  @keyframes starpop { 0% { transform: scale(1); } 40% { transform: scale(1.35); } 100% { transform: scale(1); } }
  @keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
  @keyframes toastin { from { opacity: 0; transform: translate(-50%, 6px); } to { opacity: 1; transform: translate(-50%, 0); } }

  @media (max-width: 540px) {
    .topbar { padding-top: 18px; }
    .wordmark { letter-spacing: 0.14em; }
    .hero { padding-top: 38px; gap: 21px; }
    .search { padding-left: 16px; border-radius: 16px; }
    .go { width: 42px; height: 42px; }
    .result-card { border-radius: 16px; }
    .query-chip { max-width: 64%; }
    .shelf { margin-top: 48px; }
    .fav-card { border-radius: 12px; }
  }
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  }

  /* 收藏页 */
  .fav-link { position: relative; text-decoration: none; }
  .fav-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--star);
    color: #1b120a;
    font: 10px/16px var(--mono);
    text-align: center;
    box-shadow: 0 0 0 2px var(--bg);
  }
  .subhead {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 24px 0 0;
  }
  .back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    font: 11px/1 var(--mono);
    letter-spacing: 0.06em;
    text-decoration: none;
    transition: color 0.18s;
  }
  .back-link:hover { color: var(--ink); }
  .back-link svg { width: 15px; height: 15px; }
  .back-link svg path { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
  .page-title {
    margin: clamp(34px, 7vh, 62px) 0 0;
    font-size: clamp(30px, 5.4vw, 44px);
    font-weight: 300;
    line-height: 1.24;
    letter-spacing: 0.07em;
    color: var(--ink);
  }
  .fav-empty a { color: var(--accent); text-decoration: none; }
  .fav-empty a:hover { color: var(--accent-2); }
  @media (max-width: 540px) {
    .subhead { padding-top: 18px; }
    .page-title { margin-top: 30px; }
  }
