:root {
  /* warm, minimal light palette — cream + clay/terracotta */
  --bg: #fbf7f1;
  --surface: #ffffff;
  --surface-2: #fbf8f3;
  --line: #ece4d8;
  --line-strong: #ddd2c1;
  --text: #322e29;
  --muted: #8c8578;
  --accent: #dd6f4f;      /* warm terracotta */
  --accent-strong: #c65b3d;
  --accent-soft: #fbede6;
  --ok: #5b9e77;
  --err: #c1543d;
  --radius: 16px;
  --radius-sm: 11px;
  --shadow: 0 1px 2px rgba(80, 60, 40, .04), 0 14px 34px -20px rgba(150, 110, 70, .28);
  --shadow-sm: 0 1px 2px rgba(80, 60, 40, .05), 0 6px 16px -10px rgba(150, 110, 70, .22);

  --sans: "Plus Jakarta Sans", "IBM Plex Sans Thai", "Noto Sans SC",
    system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  line-height: 1.55;
}

/* subtle warm glow at the top, nothing loud */
body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto 0;
  height: 420px;
  background: radial-gradient(680px 300px at 50% -120px, rgba(221, 111, 79, .10), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

a { color: var(--accent-strong); text-underline-offset: 2px; }

/* ---- top bar ---- */
.topbar {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 22px;
  max-width: 860px;
  margin: 0 auto;
}
.brand { display: flex; align-items: center; }
.brand-name {
  font-family: "Fredoka", var(--sans);
  font-weight: 500;
  font-size: 28px;
  line-height: 1.0;
  letter-spacing: .2px;
  text-align: left;
  color: var(--text);
}

.langs {
  display: flex;
  gap: 2px;
  background: var(--surface);
  padding: 3px;
  border-radius: 999px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}
.langs button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 6px 13px;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  transition: color .15s, background .15s;
}
.langs button:hover { color: var(--text); }
.langs button.active { background: var(--accent-soft); color: var(--accent-strong); }

/* ---- layout ---- */
.wrap { position: relative; z-index: 1; max-width: 720px; margin: 0 auto; padding: 8px 22px 64px; }

.hero { text-align: center; margin: 40px 0 26px; }
.hero h1 {
  font-size: clamp(28px, 5vw, 42px);
  font-weight: 700;
  letter-spacing: -.5px;
  line-height: 1.15;
  margin: 0 0 12px;
  color: var(--text);
  text-wrap: balance;      /* even line lengths, no orphan words */
}
.sub {
  color: var(--muted);
  font-size: 16.5px;
  margin: 0 auto;
  max-width: 34em;
  text-wrap: balance;      /* balanced 1–2 lines in every language */
}

/* prominent, friendly privacy reassurance */
.trust {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
  padding: 9px 16px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 500;
  max-width: 42em;
  text-wrap: balance;
}
.trust-icon {
  display: inline-flex;
  color: var(--ok);
  flex: 0 0 auto;
}

/* ---- card ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.tabs { display: flex; gap: 6px; margin-bottom: 16px; }
.tab {
  flex: 0 0 auto;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 8px 15px;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  font-size: 14px;
  transition: all .15s;
}
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab.active { color: var(--accent-strong); background: var(--accent-soft); }

.tabpanel.hidden, .hidden { display: none !important; }

/* ---- dropzone ---- */
.dropzone {
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 46px 20px;
  text-align: center;
  cursor: pointer;
  background: var(--surface-2);
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone:focus {
  border-color: var(--accent);
  background: var(--accent-soft);
  outline: none;
}
.dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.dz-icon {
  width: 46px; height: 46px; margin: 0 auto 12px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 20px;
}
.dz-main { font-size: 16px; font-weight: 600; margin: 0 0 5px; color: var(--text); }
.dz-hint { color: var(--muted); font-size: 13px; margin: 0; }

/* ---- url row ---- */
.url-row { display: flex; gap: 8px; }
.url-row input {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  color: var(--text);
  padding: 13px 15px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 15px;
  transition: border-color .15s, box-shadow .15s;
}
.url-row input::placeholder { color: #b3aa9b; }
.url-row input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
#panel-url .dz-hint { margin-top: 10px; }

/* ---- buttons ---- */
.btn {
  border: 0;
  border-radius: var(--radius-sm);
  padding: 13px 18px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
  transition: background .15s, filter .15s, transform .04s;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-strong); }
.btn.ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--line-strong); }
.btn.ghost:hover { background: #f4eee4; }
.btn:disabled { opacity: .5; cursor: default; }

.formats { color: var(--muted); font-size: 12.5px; text-align: center; margin: 18px 2px 2px; line-height: 1.7; }
.formats span { color: var(--text); font-weight: 600; }

/* ---- status ---- */
.status {
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.status.load { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong); }
.status.err { border-color: #eab5a8; background: #fbeae5; color: var(--err); }
.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  margin-right: 9px; vertical-align: -2px;
  border: 2px solid rgba(198, 91, 61, .28);
  border-top-color: var(--accent-strong);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- result ---- */
.result { margin-top: 22px; }
.result-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.result-head h2 { font-size: 16px; font-weight: 700; margin: 0; }
.result-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.pill {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  color: var(--muted);
  padding: 8px 13px;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  transition: all .15s;
}
.pill:hover { color: var(--text); }
.pill.active { color: var(--accent-strong); border-color: transparent; background: var(--accent-soft); }

.raw, .preview {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 18px 20px;
  max-height: 60vh;
  overflow: auto;
  box-shadow: var(--shadow-sm);
}
.raw {
  font-family: var(--mono);
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  color: #4a453e;
}
.preview { line-height: 1.7; }
.preview > :first-child { margin-top: 0; }
.preview h1, .preview h2, .preview h3 { line-height: 1.3; letter-spacing: -.2px; }
.preview table { border-collapse: collapse; margin: 8px 0; }
.preview td, .preview th { border: 1px solid var(--line-strong); padding: 7px 11px; }
.preview th { background: var(--surface-2); }
.preview code { background: var(--surface-2); padding: 2px 6px; border-radius: 6px; font-family: var(--mono); font-size: 90%; }
.preview pre { background: var(--surface-2); border: 1px solid var(--line); padding: 13px 15px; border-radius: 10px; overflow: auto; }
.preview pre code { background: none; padding: 0; }
.preview blockquote { margin: 10px 0; padding: 4px 16px; border-left: 3px solid var(--accent); color: var(--muted); }
.preview img { max-width: 100%; border-radius: 8px; }
.preview a { color: var(--accent-strong); }

/* ---- footer ---- */
.foot { position: relative; z-index: 1; text-align: center; color: var(--muted); font-size: 13px; padding: 10px 22px 44px; }
.foot a { color: var(--muted); text-decoration: underline; }
.foot a:hover { color: var(--text); }

/* ---- FAQ ---- */
.faq { margin-top: 40px; }
.faq h2 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -.2px;
  text-align: center;
  margin: 0 0 16px;
}
.faq details {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 2px 18px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
}
.faq summary {
  list-style: none;
  cursor: pointer;
  padding: 15px 28px 15px 0;
  font-weight: 600;
  font-size: 15px;
  position: relative;
  color: var(--text);
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: "";
  position: absolute;
  right: 2px;
  top: 50%;
  width: 9px;
  height: 9px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: translateY(-65%) rotate(45deg);
  transition: transform .2s;
}
.faq details[open] summary::after { transform: translateY(-35%) rotate(-135deg); }
.faq summary:hover { color: var(--accent-strong); }
.faq-a {
  padding: 0 0 16px;
  color: var(--muted);
  font-size: 14.5px;
  line-height: 1.65;
}

/* ---- toast ---- */
.toast {
  position: fixed;
  left: 50%; bottom: 28px;
  transform: translateX(-50%) translateY(16px);
  background: var(--text);
  color: #fff;
  padding: 11px 20px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: all .25s;
  box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 560px) {
  .url-row { flex-direction: column; }
  .result-actions { width: 100%; }
  .hero { margin: 28px 0 24px; }
}
