/* ============================================================
   Code2Image — "Studio Print" light aesthetic
   Warm paper + pure white panels, amber/ink editorial accents,
   serif display, mono code. Differentiated from dark/blue tools.
   ============================================================ */

:root {
  --paper: #f6f3ec;          /* warm paper background */
  --surface: #ffffff;        /* white panels */
  --ink: #22262e;            /* dark blue-ink text */
  --ink-soft: #5c6270;       /* secondary text */
  --line: #e6e0d4;           /* hairline borders */
  --line-strong: #d8d0c0;
  --gold: #c98f2a;           /* amber accent */
  --gold-soft: #f3e2ba;
  --coral: #d65a31;          /* secondary accent (silk print) */
  --serif: 'Instrument Serif', Georgia, serif;
  --body: 'IBM Plex Sans', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --sig: 'Dancing Script', cursive;
  --radius: 14px;
  --shadow: 0 14px 40px rgba(60, 50, 30, .10);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--body);
  color: var(--ink);
  background:
    radial-gradient(1000px 500px at 90% -10%, rgba(232,184,75,.16), transparent 60%),
    radial-gradient(800px 400px at -10% 10%, rgba(214,90,49,.10), transparent 55%),
    var(--paper);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
.inner { max-width: 1180px; margin: 0 auto; padding: 0 24px; }
a { color: inherit; text-decoration: none; }
img.logo { width: 38px; height: 38px; }

/* ---------- grain texture overlay ---------- */
body::after {
  content: "";
  position: fixed; inset: 0; pointer-events: none; z-index: 1; opacity: .5; mix-blend-mode: soft-light;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .12 0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: .5;
}
main, header, footer { position: relative; z-index: 2; }

/* ---------- header ---------- */
.site-header {
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.7);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20;
}
.site-header .inner { display: flex; align-items: center; justify-content: space-between; height: 70px; gap: 24px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-name { font-family: var(--serif); font-size: 1.5rem; letter-spacing: -.2px; }
.brand-sub { font-family: var(--mono); font-size: .72rem; color: var(--ink-soft); letter-spacing: 1px; text-transform: uppercase; }
.nav { display: flex; gap: 8px; }
.nav a { padding: 8px 12px; font-family: var(--mono); font-size: .8rem; color: var(--ink-soft); border-radius: 999px; transition: all .18s; }
.nav a:hover { color: var(--gold); background: var(--gold-soft); }

/* ---------- hero ---------- */
.hero { padding: 34px 0 22px; text-align: center; }
.eyebrow { font-family: var(--mono); font-size: .74rem; letter-spacing: 3px; text-transform: uppercase; color: var(--coral); margin-bottom: 10px; }
.hero h1 {
  font-family: var(--serif); font-weight: 400; font-size: clamp(2rem, 4.2vw, 3.1rem);
  line-height: 1.08; letter-spacing: -.5px; max-width: 800px; margin: 0 auto;
}
.hero h1 em { font-style: italic; color: var(--gold); }
.lede { max-width: 620px; margin: 12px auto 0; color: var(--ink-soft); font-size: 1rem; }

/* ---------- star divider ---------- */
.hero::after {
  content: "✦ ✦ ✦"; display: block; margin-top: 14px;
  font-size: .8rem; color: var(--line-strong); letter-spacing: 8px;
}

/* ---------- tool section ---------- */
.tool { padding: 14px 0 56px; }
.tool-grid { display: grid; grid-template-columns: 320px 1fr; gap: 28px; align-items: start; }

/* controls panel */
.controls {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px; box-shadow: var(--shadow); position: sticky; top: 90px;
}
.controls h2 { font-family: var(--serif); font-size: 1.4rem; font-weight: 400; margin-bottom: 20px; }
.control-block { margin-bottom: 20px; }
.control-label { display: block; font-family: var(--mono); font-size: .72rem; letter-spacing: 1.5px; text-transform: uppercase; color: var(--ink-soft); margin-bottom: 10px; }
.theme-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.swatch {
  aspect-ratio: 1; border-radius: 9px; border: 2px solid var(--line); cursor: pointer;
  background: var(--c, #ccc); transition: all .16s; position: relative;
}
.swatch:hover { transform: translateY(-2px); }
.swatch.active { border-color: var(--ink); box-shadow: 0 0 0 3px var(--gold-soft); }

select, input[type="text"] {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 9px;
  font-family: var(--mono); font-size: .85rem; color: var(--ink); background: var(--paper);
}
select:focus, input[type="text"]:focus { outline: 2px solid var(--gold); border-color: transparent; }
input[type="range"] { width: 100%; accent-color: var(--gold); }
.toggle { display: flex; align-items: center; gap: 10px; font-size: .9rem; margin-bottom: 9px; cursor: pointer; color: var(--ink-soft); }
.toggle input { accent-color: var(--gold); width: 16px; height: 16px; }

.btn-download {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px; border: none; border-radius: 11px; cursor: pointer; font-weight: 700; font-size: 1rem;
  background: linear-gradient(135deg, var(--gold), var(--coral)); color: #fff;
  box-shadow: 0 10px 24px rgba(214,90,49,.28); transition: all .18s;
}
.btn-download:hover { transform: translateY(-2px); box-shadow: 0 14px 30px rgba(214,90,49,.36); }
.btn-download span { font-size: 1.2rem; }
.hint { font-size: .74rem; color: var(--ink-soft); text-align: center; margin-top: 14px; }

/* stage */
.stage { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.editor-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.panel-head { display: flex; align-items: center; gap: 7px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: #fbf9f4; }
.dot { width: 11px; height: 11px; border-radius: 50%; }
.d1 { background: #e2703a; } .d2 { background: #e8b84b; } .d3 { background: #7bb28a; }
.panel-title { margin-left: 8px; font-family: var(--mono); font-size: .72rem; color: var(--ink-soft); }
#editor {
  width: 100%; min-height: 260px; resize: vertical; border: none; outline: none; padding: 18px 20px;
  font-family: var(--mono); font-size: 14px; line-height: 1.65; color: var(--ink); background: transparent;
}
#editor::placeholder { color: #b9b2a4; }

/* 预览区固定高度：画布尺寸随参数变化时容器高度不变，页面不抖动 */
.preview-scroll {
  height: clamp(300px, calc(100vh - 320px), 600px);
  overflow: hidden; border-radius: var(--radius); box-shadow: var(--shadow);
  background: var(--paper);
}
#preview { display: flex; align-items: center; justify-content: center; height: 100%; }

/* ---------- canvas preview ---------- */
#preview canvas { display: block; max-width: 100%; max-height: 100%; width: auto; height: auto; border-radius: 4px; }

/* ---------- content sections ---------- */
.content-section { padding: 64px 0; }
.content-section h2 { font-family: var(--serif); font-weight: 400; font-size: 2rem; margin-bottom: 30px; }
.content-section h2::after { content: " ✦"; color: var(--gold); font-size: 1.2rem; }
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 26px; transition: all .2s;
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow); border-color: var(--gold); }
.card h3 { font-family: var(--serif); font-size: 1.25rem; font-weight: 400; color: var(--coral); margin-bottom: 10px; }
.card p { color: var(--ink-soft); font-size: .95rem; }

/* ---------- FAQ ---------- */
.faq-section { max-width: 760px; }
.faq details { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; background: var(--surface); overflow: hidden; }
.faq details[open] { border-color: var(--gold); box-shadow: 0 4px 18px rgba(201,143,42,.12); }
.faq summary {
  display: flex; align-items: center; gap: 12px; padding: 16px 20px; cursor: pointer; list-style: none;
  font-weight: 600; font-size: .98rem;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::before { content: '+'; flex: 0 0 auto; width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--gold-soft); color: var(--gold); border-radius: 6px; font-weight: 700; }
.faq details[open] summary::before { content: '−'; background: var(--gold); color: #fff; }
.faq details p { padding: 0 22px 18px 54px; color: var(--ink-soft); font-size: .93rem; }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--line); background: rgba(255,255,255,.5); padding: 40px 0; margin-top: 40px; }
.site-footer .inner { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 18px; }
.footer-brand { display: flex; align-items: center; gap: 10px; font-family: var(--serif); font-size: 1.1rem; }
.footer-nav { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.footer-nav a { font-family: var(--mono); font-size: .76rem; color: var(--ink-soft); }
.footer-nav a:hover { color: var(--gold); }
.copyright { font-size: .76rem; color: var(--ink-soft); font-family: var(--mono); }

/* ---------- static content pages ---------- */
.content-page { padding: 56px 0 72px; }
.content-page article { max-width: 760px; margin: 0 auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 44px 48px; box-shadow: var(--shadow); }
.content-page h1 { font-family: var(--serif); font-weight: 400; font-size: 2.3rem; margin-bottom: 8px; }
.content-page .page-meta { font-family: var(--mono); font-size: .76rem; color: var(--ink-soft); margin-bottom: 30px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.content-page h2 { font-family: var(--serif); font-weight: 400; font-size: 1.4rem; margin: 26px 0 10px; color: var(--coral); }
.content-page p, .content-page li { color: var(--ink-soft); line-height: 1.7; font-size: .96rem; }
.content-page ul, .content-page ol { padding-left: 22px; margin: 10px 0; }
.content-page a { color: var(--gold); font-weight: 600; border-bottom: 1px solid var(--gold-soft); }
.content-page strong { color: var(--ink); }

/* ---------- CMS-generated pages compatibility ----------
   (arXiv/home 的 Latest Articles 注入 + articles.html 归档页 + 文章页)
   CMS 模板用 .logo(文本)、.nav-links、.article-list、.article-content 等类，
   这里统一成 Studio Print 风格，保证生成页与首页视觉一致。 */
.article-list { display: grid; gap: 14px; }
.article-list a {
  display: block; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px 24px; transition: all .2s;
}
.article-list a:hover { transform: translateY(-2px); border-color: var(--gold); box-shadow: var(--shadow); }
.article-list .article-title { font-weight: 700; font-size: 1.02rem; line-height: 1.45; margin-bottom: 8px; }
.article-list a:hover .article-title { color: var(--gold); }
.article-list .article-desc { font-size: .9rem; color: var(--ink-soft); line-height: 1.6; }

.logo { display: flex; align-items: center; gap: 11px; font-weight: 700; font-size: 1.15rem; }
.logo-img { width: 38px; height: 38px; display: block; }
.nav-links { display: flex; gap: 4px; list-style: none; align-items: center; }
.nav-links a { padding: 8px 13px; font-family: var(--mono); font-size: .8rem; color: var(--ink-soft); border-radius: 999px; transition: all .18s; }
.nav-links a:hover { color: var(--gold); background: var(--gold-soft); }
.site-header .inner { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.site-header nav { display: flex; }

.article-content { padding: 48px 0 72px; }
.article-content article { max-width: 760px; margin: 0 auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 44px 48px; box-shadow: var(--shadow); }
.article-content h1 { font-family: var(--serif); font-weight: 400; font-size: 2.1rem; line-height: 1.15; margin-bottom: 10px; }
.article-content .article-meta { font-family: var(--mono); font-size: .74rem; color: var(--ink-soft); margin-bottom: 28px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.article-back { display: inline-block; margin-bottom: 22px; font-family: var(--mono); font-size: .78rem; color: var(--gold); }
.article-back:hover { text-decoration: underline; }
.article-content h2, .article-content h3 { font-family: var(--serif); font-weight: 400; color: var(--coral); margin: 26px 0 12px; }
.article-content h2 { font-size: 1.5rem; }
.article-content h3 { font-size: 1.2rem; }
.article-content p, .article-content li { color: var(--ink-soft); line-height: 1.75; font-size: .99rem; }
.article-content ul, .article-content ol { padding-left: 22px; margin: 12px 0; }
.article-content a { color: var(--gold); font-weight: 600; border-bottom: 1px solid var(--gold-soft); }
.article-content strong { color: var(--ink); }
.article-content pre {
  background: var(--paper); border: 1px solid var(--line); border-radius: 10px;
  padding: 16px 18px; overflow: auto; font-family: var(--mono); font-size: .85rem; line-height: 1.6;
}
.article-content code { font-family: var(--mono); font-size: .85em; background: var(--gold-soft); color: var(--gold); padding: 1px 5px; border-radius: 4px; }
.article-content pre code { background: none; color: var(--ink); padding: 0; }

.faq-section h2 { font-family: var(--serif); font-weight: 400; font-size: 1.5rem; margin-bottom: 18px; }
.faq-section h2::after { content: ""; }

.footer-links { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.footer-links a { font-family: var(--mono); font-size: .76rem; color: var(--ink-soft); }
.footer-links a:hover { color: var(--gold); }
.copyright { font-size: .76rem; color: var(--ink-soft); font-family: var(--mono); }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .tool-grid { grid-template-columns: 1fr; }
  .controls { position: static; }
  .cards { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .nav { display: none; }
  .site-header .inner { justify-content: center; }
  .hero { padding: 28px 0 18px; }
  .content-section { padding: 44px 0; }
  #editor { min-height: 200px; }
}