/* Metric-matched fallback for Inter — prevents layout shift (CLS) when the web
   font swaps in: the fallback (Arial, adjusted) occupies the same space as Inter. */
@font-face {
  font-family: "Inter Fallback";
  src: local("Arial");
  ascent-override: 90.2%;
  descent-override: 22.48%;
  line-gap-override: 0%;
  size-adjust: 107.4%;
}

:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f1f3f9;
  --text: #1a1c27;
  --muted: #5b6072;
  --faint: #8a8fa3;
  --border: #e6e8f0;
  --accent: #6366f1;
  --accent-2: #8b5cf6;
  --accent-3: #ec4899;
  --accent-ink: #4f46e5;
  --danger: #dc2626;
  --shadow: 0 1px 2px rgba(20,22,40,.04), 0 8px 24px rgba(20,22,40,.06);
  --radius: 14px;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: "Inter", "Inter Fallback", "Noto Sans KR", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

[data-theme="dark"] {
  --bg: #0c0e16;
  --surface: #161927;
  --surface-2: #1d2132;
  --text: #eef0f8;
  --muted: #aab0c6;
  --faint: #7a8099;
  --border: #262b3d;
  --accent: #818cf8;
  --accent-2: #a78bfa;
  --accent-3: #f472b6;
  --accent-ink: #a5b4fc;
  --danger: #f87171;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 10px 30px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--sans);
  color: var(--text);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--surface-2) 70%, transparent), transparent 340px),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, textarea, select { font: inherit; }
button { cursor: pointer; }

.shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 0 24px;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: blur(14px) saturate(145%);
}

.header-inner {
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  color: #fff;
  font-weight: 800;
  letter-spacing: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.brand strong, .brand small { display: block; }
.brand strong { font-size: 1rem; line-height: 1.1; }
.brand small { margin-top: 3px; color: var(--muted); font-size: .76rem; }

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-button {
  width: 40px;
  height: 40px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  background: var(--surface);
  transition: transform .16s ease, border-color .16s ease, background .16s ease;
}

.icon-button:hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--accent) 58%, var(--border));
  background: var(--surface-2);
}

.icon-button.filled {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.icon-button svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

[data-theme="dark"] .sun-icon { display: block; }
[data-theme="dark"] .moon-icon { display: none; }
[data-theme="light"] .sun-icon { display: none; }
[data-theme="light"] .moon-icon { display: block; }

.app-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  grid-template-areas: "top builder" "bottom builder";
  gap: 22px;
  padding-top: 24px;
  padding-bottom: 32px;
}
.ws-top { grid-area: top; }
.ws-bottom { grid-area: bottom; }

.workspace, .builder > section {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.workspace {
  padding: 24px;
  min-width: 0;
}

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  margin-bottom: 20px;
}

.eyebrow{margin:0 0 10px;display:inline-flex;align-items:center;gap:8px;font-family:var(--mono);color:var(--accent-ink);font-size:.72rem;font-weight:500;letter-spacing:.08em;text-transform:uppercase;background:color-mix(in srgb,var(--accent) 9%,transparent);border:1px solid color-mix(in srgb,var(--accent) 24%,transparent);padding:6px 14px;border-radius:999px}
.eyebrow::before{content:"";width:6px;height:6px;border-radius:50%;background:var(--accent);flex:none}

.eyebrow.compact { font-size: .68rem; }
h1, h2 { margin: 0; letter-spacing: 0; }
h1 { font-size: clamp(1.8rem, 4vw, 3rem); line-height: 1.05; }
h2 { font-size: 1.05rem; line-height: 1.2; }
.intro p:last-child { max-width: 72ch; margin: 0; color: var(--muted); line-height: 1.7; }

.top-result {
  display: grid;
  gap: 10px;
  margin: 0 0 18px;
  padding: 14px;
  border: 1px solid color-mix(in srgb, var(--accent) 24%, var(--border));
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent) 8%, transparent), transparent 52%),
    var(--bg);
}

.top-result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.copy-inline-button {
  height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 13px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  font-weight: 800;
}

.copy-inline-button:hover {
  filter: brightness(1.05);
}

.copy-inline-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#topPromptOutput {
  min-height: 92px;
  font-family: var(--mono);
  font-size: .86rem;
  background: var(--surface);
}

.inline-params {
  margin: 0 0 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}

.input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 176px;
  gap: 12px;
  align-items: stretch;
  margin-bottom: 12px;
}

.field {
  display: grid;
  gap: 7px;
}

.field span, .panel-label {
  color: var(--muted);
  font-size: .78rem;
  font-weight: 700;
}

textarea, input, select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  background: var(--bg);
  outline: none;
}

textarea {
  resize: vertical;
  padding: 12px 13px;
  line-height: 1.55;
}

input, select {
  height: 40px;
  padding: 0 11px;
}

textarea:focus, input:focus, select:focus {
  border-color: color-mix(in srgb, var(--accent) 70%, var(--border));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

.quick-panel {
  display: grid;
  gap: 8px;
  align-content: start;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}

.text-button, .mini-button {
  height: 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  background: var(--surface);
  font-weight: 700;
}

.text-button:hover, .mini-button:hover {
  border-color: color-mix(in srgb, var(--accent) 56%, var(--border));
  background: var(--surface-2);
}

.mini-button {
  height: 30px;
  padding: 0 10px;
  font-size: .78rem;
}

.search-wrap { margin-bottom: 16px; }

.category-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 9px;
  margin-bottom: 14px;
  min-height: 47px;
  scrollbar-width: thin;
}

.tab-button {
  flex: 0 0 auto;
  height: 38px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  background: var(--surface);
  font-weight: 800;
  font-size: .82rem;
}

.tab-button[aria-selected="true"] {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.keyword-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 10px;
  height: clamp(420px, 58vh, 680px);
  align-content: start;
  overflow: auto;
  padding-right: 4px;
  overscroll-behavior: contain;
}

.keyword-card {
  min-height: 96px;
  display: grid;
  gap: 7px;
  align-content: start;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  background: var(--bg);
  text-align: left;
  transition: border-color .16s ease, background .16s ease, transform .16s ease;
}

.keyword-card:hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--accent) 52%, var(--border));
  background: var(--surface);
}

.keyword-card.is-selected {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
}

.keyword-card strong {
  font-family: var(--mono);
  font-size: .86rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.keyword-card span {
  color: var(--muted);
  font-size: .82rem;
  line-height: 1.45;
}

.empty-state {
  grid-column: 1 / -1;
  padding: 26px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

.builder {
  grid-area: builder;
  min-width: 0;
  display: grid;
  align-content: start;
  align-self: start; /* natural height so sticky can pin it as the keyword column scrolls */
  gap: 14px;
  position: sticky;
  top: 84px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 2px; /* keep inner section shadows from clipping at the scroll edges */
}

.preview-strip {
  height: 86px;
  display: grid;
  grid-template-columns: 1.3fr .9fr 1fr .75fr;
  gap: 8px;
}

.preview-strip span {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background:
    linear-gradient(145deg, color-mix(in srgb, var(--accent) 44%, transparent), transparent 58%),
    linear-gradient(35deg, color-mix(in srgb, var(--accent-2) 38%, transparent), color-mix(in srgb, var(--accent-3) 28%, transparent)),
    var(--surface-2);
}

.preview-strip span:nth-child(2) { filter: saturate(.7) brightness(.96); }
.preview-strip span:nth-child(3) { filter: hue-rotate(24deg) saturate(.95); }
.preview-strip span:nth-child(4) { filter: hue-rotate(92deg) saturate(.75); }

.result-panel, .selected-panel, .params-panel {
  padding: 16px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-head.simple { margin-bottom: 10px; }

#promptOutput {
  min-height: 210px;
  font-family: var(--mono);
  font-size: .88rem;
  background: #0f172a;
  color: #e5edf8;
  border-color: #1f2a3a;
}

.result-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 9px;
  color: var(--faint);
  font-size: .78rem;
}

#copyStatus { color: var(--accent-3); font-weight: 800; }

.selected-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  min-height: 38px;
}

.selected-chip {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  gap: 7px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  background: var(--bg);
  font-family: var(--mono);
  font-size: .72rem;
}

.selected-chip button {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: var(--muted);
  background: var(--surface-2);
  line-height: 1;
}

.selected-chip button:hover {
  color: #fff;
  background: var(--danger);
}

.param-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.toggle-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.toggle-row label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: .8rem;
}

@media (max-width: 1100px) {
  .app-layout { grid-template-columns: 1fr; grid-template-areas: "top" "builder" "bottom"; }
  .builder { position: static; grid-template-columns: 1fr; }
  .preview-strip { order: -1; }
}

@media (max-width: 720px) {
  .shell { padding: 0 14px; }
  .header-inner { height: 62px; }
  .brand small { display: none; }
  .app-layout { padding-top: 14px; }
  .workspace { padding: 16px; }
  .input-row { grid-template-columns: 1fr; }
  .quick-panel { grid-template-columns: 1fr 1fr; }
  .panel-label { grid-column: 1 / -1; }
  .top-result-head { align-items: flex-start; }
  .copy-inline-button { flex: 0 0 auto; }
  .keyword-grid { grid-template-columns: 1fr; }
  .param-grid { grid-template-columns: 1fr; }
  .preview-strip { height: 66px; }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* ============================================================
   inblooms family chrome (brand, header controls, content, footer)
   ============================================================ */
.skip-link { position: absolute; left: -999px; top: 0; background: var(--accent); color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 100; }
.skip-link:focus { left: 12px; top: 12px; }

.brand-mark { font-size: 1.25rem; background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.brand > span:last-child { font-weight: 800; font-size: 1.12rem; letter-spacing: -.02em; }
.grad { background: linear-gradient(110deg, var(--accent), var(--accent-2) 45%, var(--accent-3)); -webkit-background-clip: text; background-clip: text; color: transparent; }

.header-actions { display: flex; align-items: center; gap: 10px; }
.lang-select { appearance: none; -webkit-appearance: none; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 12px; padding: 9px 30px 9px 12px; font-family: var(--sans); font-size: .88rem; font-weight: 600; cursor: pointer; height: 40px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a8fa3' stroke-width='3' stroke-linecap='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
.theme-toggle { width: 40px; height: 40px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-size: 1.05rem; display: grid; place-items: center; }
.theme-toggle:hover { background: var(--surface-2); }

/* Hero title (workspace intro h1) uses the family gradient accent */
.intro h1 { letter-spacing: -.02em; }

/* Guide + FAQ content (shared family look) */
.content { width: min(820px, 100%); margin: 0 auto; padding: 56px 24px 8px; }
.content .eyebrow { display: inline-block; margin-bottom: 14px; }
.content h2 { font-size: clamp(1.5rem, 4vw, 2.1rem); letter-spacing: -.02em; margin: 0 0 12px; }
.content h3 { font-size: 1.12rem; margin: 24px 0 8px; }
.content p { color: var(--muted); line-height: 1.75; margin: 0 0 14px; }
.content code { font-family: var(--mono); font-size: .88em; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; }
.faq { padding-top: 36px; }
.faq-item { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); margin-bottom: 10px; overflow: hidden; }
.faq-item[open] { border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.faq-item summary { cursor: pointer; list-style: none; padding: 16px 18px; font-weight: 600; display: flex; justify-content: space-between; align-items: center; gap: 14px; }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "+"; color: var(--accent); font-size: 1.4rem; line-height: 1; }
.faq-item[open] summary::after { content: "\2212"; }
.faq-a { padding: 0 18px 18px; color: var(--muted); line-height: 1.7; }
.faq-a p { margin: 0; }

/* Footer */
.site-footer { margin-top: 44px; border-top: 1px solid var(--border); padding: 26px 0; }
.footer-nav { display: flex; gap: 8px 22px; justify-content: center; flex-wrap: wrap; margin-bottom: 12px; }
.footer-nav a { color: var(--muted); text-decoration: none; font-size: .88rem; font-weight: 600; }
.footer-nav a:hover { color: var(--accent); }
.site-footer p { text-align: center; color: var(--faint); font-size: .85rem; margin: 0; }

/* Buttons + doc pages (about/privacy/contact) */
.btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); padding: 9px 15px; border-radius: 11px; font-weight: 600; font-size: .9rem; text-decoration: none; transition: all .15s ease; }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.content.doc h3 { margin: 26px 0 8px; }
.content.doc ul { color: var(--muted); line-height: 1.7; padding-left: 1.25em; }
.content.doc li { margin-bottom: 8px; }
.content.doc a { color: var(--accent); }
.doc-meta { font-size: .88rem; color: var(--faint); margin: 0 0 14px; }

/* Prompt history */
.history-list { display: flex; flex-direction: column; gap: 6px; max-height: 240px; overflow: auto; }
.history-empty { color: var(--faint); font-size: .78rem; }
.history-item { display: flex; align-items: center; gap: 6px; }
.history-restore { flex: 1; min-width: 0; text-align: left; border: 1px solid var(--border); background: var(--bg); color: var(--text); border-radius: 8px; padding: 7px 9px; font-family: var(--mono); font-size: .72rem; line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; transition: border-color .14s ease, color .14s ease; }
.history-restore:hover { border-color: var(--accent); color: var(--accent); }
.history-remove { width: 24px; height: 24px; flex: none; display: grid; place-items: center; border: 0; border-radius: 50%; background: transparent; color: var(--muted); font-size: 1rem; line-height: 1; cursor: pointer; }
.history-remove:hover { color: var(--accent-3); background: var(--surface-2); }

/* Mobile refinements */
@media (max-width: 720px) {
  .header-inner { gap: 10px; }
  .header-actions { gap: 6px; }
  .brand small { display: none; }
  .lang-select { font-size: .8rem; padding: 8px 26px 8px 10px; height: 38px; }
  .icon-button, .theme-toggle { width: 36px; height: 36px; }
  .category-tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .category-tabs::-webkit-scrollbar { display: none; }
  .tab-button { white-space: nowrap; }
  .builder { position: static; }
  .history-restore { font-size: .7rem; }
}

/* Output-format toggle + hide inactive panels */
[hidden] { display: none !important; }
.model-row { margin-top: 14px; }
.model-row .field { max-width: 300px; }

/* inblooms craft */
:focus-visible{outline:none;box-shadow:0 0 0 3px color-mix(in srgb,var(--accent) 38%,transparent);border-radius:7px}
.specbar{display:flex;justify-content:space-between;align-items:center;gap:12px;max-width:1180px;margin:0 auto;padding:10px 22px;border-bottom:1px solid var(--border);font-family:var(--mono);font-size:.7rem;letter-spacing:.13em;text-transform:uppercase;flex-wrap:wrap}
.specbar b{font-weight:600;color:var(--text);letter-spacing:.06em}
.specbar a{color:var(--muted);text-decoration:none}
.specbar a:hover{color:var(--accent-ink)}
