:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --red: #e11d48;
  --red-soft: #fff1f2;
  --blue: #1d4ed8;
  --blue-soft: #eff6ff;
  --teal: #0d9488;
  --teal-soft: #f0fdfa;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --shadow: 0 4px 20px rgba(15, 23, 42, 0.06);
}

body.dark {
  --bg: #0b1120;
  --surface: #111827;
  --surface-2: #1e293b;
  --red-soft: rgba(225, 29, 72, 0.16);
  --blue-soft: rgba(59, 130, 246, 0.16);
  --teal-soft: rgba(20, 184, 166, 0.16);
  --text: #f1f5f9;
  --muted: #94a3b8;
  --border: #334155;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.navbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  max-width: 1200px; margin: 0 auto; padding: 12px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.brand-badge {
  width: 40px; height: 40px; border-radius: 11px;
  background: linear-gradient(135deg, var(--red), var(--blue));
  color: #fff; display: flex; align-items: center; justify-content: center;
}
.brand-badge svg { width: 22px; height: 22px; }
.brand-name { font-size: 18px; font-weight: 800; letter-spacing: -0.3px; }
.brand-tag { font-size: 11px; font-weight: 700; color: var(--muted); }

.nav-links { display: flex; gap: 8px; flex-wrap: wrap; }
.nav-pill {
  padding: 8px 15px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--muted); font-size: 13.5px; font-weight: 700; cursor: pointer;
}
.nav-pill.active { background: var(--red); color: #fff; border-color: var(--red); }

.hero {
  position: relative; overflow: hidden;
  background: linear-gradient(135deg, #fff1f2 0%, #eff6ff 50%, #f0fdfa 100%);
  border-bottom: 1px solid var(--border);
  padding: 42px 20px 34px; text-align: center;
}
body.dark .hero {
  background: linear-gradient(135deg, #1e1b4b 0%, #0f172a 55%, #042f2e 100%);
}
.hero-glow {
  position: absolute; width: 460px; height: 460px; border-radius: 50%;
  background: radial-gradient(circle, rgba(225, 29, 72, 0.14), rgba(29, 78, 216, 0.08), transparent 70%);
  top: -180px; left: 50%; transform: translateX(-50%); pointer-events: none;
}
.hero-inner { position: relative; max-width: 840px; margin: 0 auto; }
.grad-text {
  background: linear-gradient(135deg, #e11d48, #2563eb, #0d9488);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.hero-chip {
  display: inline-block; padding: 6px 15px; border-radius: 999px;
  background: var(--surface); color: var(--blue); font-size: 12px; font-weight: 800;
  margin-bottom: 14px; border: 1px solid var(--border); box-shadow: 0 2px 10px rgba(0,0,0,0.04);
}
.hero h1 { font-size: clamp(27px, 4.4vw, 42px); font-weight: 900; letter-spacing: -0.8px; line-height: 1.15; margin-bottom: 12px; }
.hero p { font-size: 15.5px; color: var(--muted); max-width: 670px; margin: 0 auto 22px; }

.quick-pills { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 16px; }
.q-pill {
  padding: 7px 13px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 12.5px; font-weight: 700;
  cursor: pointer; transition: all 0.15s ease; box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.q-pill:hover { border-color: var(--red); color: var(--red); transform: translateY(-2px); }

.search-wrap { position: relative; max-width: 640px; margin: 0 auto; }
.search-ico { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; color: var(--muted); }
.search-input {
  width: 100%; height: 52px; padding: 0 44px 0 46px; border-radius: 14px;
  border: 2px solid var(--border); background: #fff; font-size: 15px; outline: none;
  box-shadow: var(--shadow);
}
.search-input:focus { border-color: var(--blue); }
.clear-btn {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  width: 30px; height: 30px; border-radius: 8px; border: none; background: var(--surface-2); cursor: pointer;
}

.container { max-width: 1200px; margin: 0 auto; padding: 24px 20px; }
.grid-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.grid-header h2 { font-size: 20px; font-weight: 800; }
.count-pill { font-size: 13px; font-weight: 700; color: var(--muted); background: #fff; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--border); }

.tools-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(225px, 1fr)); gap: 14px;
}
.tool-card {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  padding: 18px; cursor: pointer; transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
  display: flex; flex-direction: column; justify-content: space-between; min-height: 148px;
}
.tool-card::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--red), var(--blue), var(--teal)); opacity: 0; transition: opacity 0.16s;
}
.tool-card:hover { transform: translateY(-4px); box-shadow: 0 14px 28px rgba(15, 23, 42, 0.1); border-color: #cbd5e1; }
.tool-card:hover::before { opacity: 1; }
.t-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.t-ico {
  width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 10px rgba(0,0,0,0.06);
}
.t-ico svg { width: 22px; height: 22px; }
.t-cat { font-size: 11px; font-weight: 800; padding: 3px 9px; border-radius: 999px; }
.t-title { font-size: 15.5px; font-weight: 800; margin-bottom: 4px; color: var(--text); }
.t-desc { font-size: 12.5px; color: var(--muted); line-height: 1.35; }

/* Workspace */
.workspace { max-width: 1120px; margin: 0 auto; }
.ws-topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.cat-badge { padding: 5px 12px; border-radius: 999px; font-size: 12px; font-weight: 800; background: var(--red-soft); color: var(--red); }
.ws-card { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 24px; box-shadow: var(--shadow); }
.ws-head { border-bottom: 1px solid var(--border); padding-bottom: 14px; margin-bottom: 18px; }
.ws-head h1 { font-size: 24px; font-weight: 900; margin-bottom: 4px; }
.ws-head p { color: var(--muted); font-size: 14.5px; }

.ws-split { display: grid; grid-template-columns: minmax(300px, 0.95fr) minmax(320px, 1.15fr); gap: 24px; align-items: start; }
@media (max-width: 820px) { .ws-split { grid-template-columns: 1fr; } }

.live-pane {
  position: sticky; top: 84px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 100%; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 16px; padding: 18px; min-height: 240px; text-align: center;
}
.live-pane img, .live-pane canvas { max-width: 100%; max-height: 440px; border-radius: 10px; box-shadow: 0 4px 14px rgba(0,0,0,0.1); }

.a4-paper {
  width: 100%; max-width: 520px; margin: 0 auto;
  background: #ffffff; color: #0f172a; border: 1px solid #cbd5e1;
  border-radius: 12px; padding: 22px; box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  text-align: left; font-size: 13.5px; line-height: 1.55;
}
.a4-hdr { border-bottom: 2px solid #1d4ed8; padding-bottom: 10px; margin-bottom: 14px; display: flex; justify-content: space-between; align-items: center; }
.a4-title { font-size: 17px; font-weight: 900; color: #1d4ed8; letter-spacing: 0.3px; }
.a4-row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid #f1f5f9; }
.a4-lbl { color: #64748b; font-weight: 700; min-width: 110px; }
.a4-val { color: #0f172a; font-weight: 600; text-align: right; word-break: break-word; }

.pdf-thumb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 12px 0; }
.pdf-thumb { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 8px; text-align: center; }
.pdf-thumb img { max-width: 100%; max-height: 180px; border-radius: 6px; }

@media print {
  body * { visibility: hidden; }
  .a4-paper, .a4-paper * { visibility: visible; }
  .a4-paper { position: absolute; left: 0; top: 0; width: 100%; box-shadow: none; border: none; }
}

.dropzone {
  border: 2px dashed #cbd5e1; border-radius: 16px; padding: 28px 16px; text-align: center;
  background: var(--surface-2); cursor: pointer; margin-bottom: 16px; transition: border-color 0.15s;
}
.dropzone:hover { border-color: var(--red); background: var(--red-soft); }

.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 13px; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.input, .select, .textarea {
  width: 100%; min-height: 44px; padding: 9px 13px; border-radius: 11px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font-size: 14.5px; outline: none;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--blue); background: #fff; }
.textarea { min-height: 100px; resize: vertical; font-family: inherit; }

.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
@media (max-width: 600px) { .row-2, .row-3 { grid-template-columns: 1fr; } }

.btn {
  padding: 11px 18px; border-radius: 12px; border: 1px solid var(--border);
  font-size: 14.5px; font-weight: 800; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-primary { background: var(--red); color: #fff; border-color: var(--red); width: 100%; }
.btn-blue { background: var(--blue); color: #fff; border-color: var(--blue); width: 100%; }
.btn-outline { background: var(--surface); color: var(--text); }
.btn-sm { padding: 7px 13px; font-size: 13px; width: auto; }

.preview-box {
  margin-top: 16px; padding: 16px; border-radius: 14px; border: 1px solid var(--border);
  background: var(--surface-2); text-align: center;
}
.preview-box img, .preview-box canvas { max-width: 100%; max-height: 380px; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.08); }
.result-pre {
  margin-top: 14px; padding: 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13.5px; white-space: pre-wrap; text-align: left;
}

.footer {
  margin-top: 40px; padding: 24px 20px; text-align: center; background: var(--surface); border-top: 1px solid var(--border);
}

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: #0f172a; color: #fff; padding: 10px 20px; border-radius: 999px;
  font-size: 13.5px; font-weight: 700; z-index: 120;
}
.announce-bar {
  background: linear-gradient(90deg, #e11d48, #1d4ed8); color: #fff;
  text-align: center; padding: 8px 14px; font-size: 13px; font-weight: 800;
}
.owner-pill {
  display: inline-block; padding: 7px 16px; border-radius: 999px;
  background: var(--blue-soft); color: var(--blue); border: 1px solid var(--border);
  font-size: 13.5px;
}
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(6px); display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal-box { width: 100%; max-width: 520px; max-height: 88vh; display: flex; flex-direction: column; }
.hidden { display: none !important; }
