/* PromptForge — style.css */

:root {
  --bg: #f6f7f9;
  --bg-elev: #ffffff;
  --bg-sunk: #eef0f4;
  --text: #16191f;
  --text-dim: #5c6472;
  --border: #dce0e7;
  --border-strong: #c3c9d4;
  --accent: #4a5bd6;
  --accent-hover: #3d4cbd;
  --accent-soft: #eaecfb;
  --good: #1f8a5f;
  --warn: #b8791a;
  --danger: #c2453c;
  --radius: 12px;
  --radius-sm: 8px;
  --mono: ui-monospace, "Cascadia Code", Consolas, "D2Coding", monospace;
  --sans: "Pretendard", -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic", sans-serif;
  --shadow: 0 1px 2px rgba(16, 20, 30, .06), 0 8px 24px rgba(16, 20, 30, .06);
}

html[data-theme="dark"] {
  --bg: #0b0e14;
  --bg-elev: #141922;
  --bg-sunk: #0f141c;
  --text: #e6e9ef;
  --text-dim: #98a1b1;
  --border: #262d3a;
  --border-strong: #38414f;
  --accent: #7b8cf5;
  --accent-hover: #93a1ff;
  --accent-soft: #1c2233;
  --good: #4ec48d;
  --warn: #e0a94b;
  --danger: #f0776c;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .35);
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    --bg: #0b0e14;
    --bg-elev: #141922;
    --bg-sunk: #0f141c;
    --text: #e6e9ef;
    --text-dim: #98a1b1;
    --border: #262d3a;
    --border-strong: #38414f;
    --accent: #7b8cf5;
    --accent-hover: #93a1ff;
    --accent-soft: #1c2233;
    --good: #4ec48d;
    --warn: #e0a94b;
    --danger: #f0776c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  /* 한글은 음절 단위로 아무 데서나 줄바꿈될 수 있어("세 가지"가 "세 가" / "지"로
     쪼개지는 등) 어절(공백) 단위로만 줄바꿈되게 고정한다. */
  word-break: keep-all;
  overflow-wrap: break-word;
}

.wrap { width: 100%; max-width: 960px; margin: 0 auto; padding: 0 20px; }

/* ---------- 상단바 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 58px; }
.brand {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: inherit; cursor: pointer;
  border-radius: var(--radius-sm);
}
.brand:hover .brand-text strong { color: var(--accent); }
.brand:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.brand-mark {
  display: grid; place-items: center;
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--accent); color: #fff; font-size: 16px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 15px; letter-spacing: -.01em; }
.brand-text small { color: var(--text-dim); font-size: 11.5px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

/* ---------- 테마 선택 (시스템 / 블랙 / 화이트) ---------- */
.theme-switch {
  display: inline-flex; align-items: center; gap: 2px;
  background: var(--bg-sunk);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
}
.theme-opt {
  display: inline-flex; align-items: center; gap: 5px;
  background: transparent; border: none; border-radius: 999px;
  color: var(--text-dim); font-family: inherit; font-size: 12.5px; font-weight: 600;
  padding: 5px 11px; cursor: pointer; white-space: nowrap; transition: .15s;
}
.theme-opt:hover { color: var(--text); }
.theme-opt[aria-checked="true"] {
  background: var(--bg-elev);
  color: var(--accent);
  box-shadow: 0 1px 2px rgba(16, 20, 30, .12);
}
.theme-opt:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.theme-ico { font-size: 12.5px; line-height: 1; }

/* ---------- 히어로 ---------- */
.hero { padding: 44px 0 28px; }
.hero h1 { margin: 0 0 14px; font-size: 30px; line-height: 1.35; letter-spacing: -.02em; }
.hero h1 em { font-style: normal; color: var(--accent); }
.hero-sub { margin: 0; color: var(--text-dim); max-width: 640px; }

/* ---------- 카드 ---------- */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head h2 { margin: 0; font-size: 16px; letter-spacing: -.01em; }
.card-head-actions { display: flex; gap: 8px; }
.hidden { display: none !important; }

/* ---------- 폼 ---------- */
textarea, input[type="text"], select {
  width: 100%;
  background: var(--bg-sunk);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14.5px;
  line-height: 1.6;
  resize: vertical;
}
textarea:focus, input:focus, select:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
}
#rawInput { font-size: 15.5px; min-height: 118px; }

.samples { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin-top: 12px; }
.samples-label { font-size: 12.5px; color: var(--text-dim); margin-right: 2px; }
.chip {
  background: var(--bg-sunk); border: 1px solid var(--border); color: var(--text-dim);
  border-radius: 999px; padding: 4px 11px; font-size: 12.5px; cursor: pointer;
  font-family: inherit; transition: .15s;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }

.opts { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 14px; }
.opts summary { cursor: pointer; font-weight: 600; font-size: 14.5px; list-style: revert; }
.opt-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px; margin-top: 14px;
}
.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--text-dim); }
.field-wide { grid-column: 1 / -1; }
.switch-row { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 14px; }
.switch { display: flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--text-dim); cursor: pointer; }
.switch input { accent-color: var(--accent); width: 15px; height: 15px; }

.actions { display: flex; align-items: center; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.hint { font-size: 12.5px; }

/* ---------- 버튼 ---------- */
.primary-btn, .ghost-btn {
  font-family: inherit; font-size: 14px; font-weight: 600;
  border-radius: var(--radius-sm); padding: 9px 18px; cursor: pointer;
  border: 1px solid transparent; transition: .15s; text-decoration: none; display: inline-block;
}
.primary-btn { background: var(--accent); color: #fff; }
.primary-btn:hover { background: var(--accent-hover); }
.ghost-btn { background: transparent; color: var(--text-dim); border-color: var(--border-strong); }
.ghost-btn:hover { color: var(--text); border-color: var(--accent); }
.primary-btn.small, .ghost-btn.small { padding: 6px 13px; font-size: 13px; }

.badge {
  background: var(--accent-soft); color: var(--accent);
  border-radius: 999px; padding: 3px 11px; font-size: 12.5px; font-weight: 600; white-space: nowrap;
}
.muted { color: var(--text-dim); font-weight: 400; }
.small { font-size: 12.8px; }

/* ---------- 진단 ---------- */
.score-row { display: flex; align-items: center; gap: 18px; margin-bottom: 16px; flex-wrap: wrap; }
.score { flex: 1 1 180px; min-width: 150px; }
.score-label { display: block; font-size: 12.5px; color: var(--text-dim); }
.score-value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.score.good .score-value { color: var(--good); }
.score-arrow { font-size: 20px; color: var(--text-dim); }
.meter { height: 6px; background: var(--bg-sunk); border-radius: 999px; overflow: hidden; margin-top: 4px; }
.meter i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .5s ease; }
.score.good .meter i { background: var(--good); }

.diag-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.diag-list li {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--bg-sunk); border: 1px solid var(--border);
  border-left-width: 3px; border-radius: var(--radius-sm); padding: 9px 12px;
}
.diag-list li.high { border-left-color: var(--danger); }
.diag-list li.medium { border-left-color: var(--warn); }
.diag-list li.low { border-left-color: var(--border-strong); }
.diag-title { font-weight: 600; font-size: 13.5px; }
.diag-hint { color: var(--text-dim); font-size: 13px; }

/* ---------- 결과 ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 10px; flex-wrap: wrap; }
.tab {
  background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--text-dim); font-family: inherit; font-size: 14px; font-weight: 600;
  padding: 9px 14px; cursor: pointer; margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-note { margin: 0 0 10px; }

.out {
  background: var(--bg-sunk); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 14px 16px; margin: 0;
  font-family: var(--mono); font-size: 13px; line-height: 1.7;
  white-space: pre-wrap; word-break: break-word;
  max-height: 460px; overflow-y: auto; overflow-x: auto;
}
.small-out { max-height: 160px; font-size: 12.5px; }
.out-actions { display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.copied { color: var(--good); font-size: 13px; font-weight: 600; }
.sysmsg { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 12px; }
.sysmsg summary { cursor: pointer; font-size: 13.5px; font-weight: 600; }
.sysmsg .out { margin-top: 10px; }
.sysmsg .ghost-btn { margin-top: 8px; }

/* ---------- 히스토리 ---------- */
.hist-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.hist-list li {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  background: var(--bg-sunk); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 12px; cursor: pointer;
}
.hist-list li:hover { border-color: var(--accent); }
.hist-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; }
.hist-meta { color: var(--text-dim); font-size: 12px; white-space: nowrap; }

/* ---------- 모달 ---------- */
.modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(10, 12, 18, .55);
  display: grid; place-items: center; padding: 20px;
  overflow-y: auto;
}
.modal-box {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px;
  max-width: 620px; width: 100%; box-shadow: var(--shadow);
  max-height: 90vh; min-height: 0; overflow-y: auto;
}
.modal-box h2 { margin-top: 0; font-size: 19px; }
.modal-box h3 { font-size: 14.5px; margin: 20px 0 8px; }
.help-list { padding-left: 20px; margin: 0; display: flex; flex-direction: column; gap: 7px; font-size: 14px; }
.help-list code { background: var(--bg-sunk); padding: 1px 5px; border-radius: 4px; font-family: var(--mono); font-size: 12.5px; }
.modal-box .primary-btn { margin-top: 22px; }

/* ---------- 푸터 ---------- */
.foot { padding: 30px 20px 44px; color: var(--text-dim); font-size: 12.5px; text-align: center; }
.foot p { margin: 0; }
.foot-links { display: flex; justify-content: center; align-items: center; gap: 8px; margin-bottom: 10px; }
.foot-links a { color: var(--text-dim); text-decoration: none; font-size: 12.5px; }
.foot-links a:hover { color: var(--accent); }
.foot-links span { color: var(--border-strong); }

/* ---------- 정적 문서 페이지 (개인정보처리방침 / 이용약관 / 가이드) ---------- */
.doc { padding: 32px 0 60px; max-width: 760px; }
.doc .back-link {
  display: inline-flex; align-items: center; gap: 5px;
  color: var(--text-dim); text-decoration: none; font-size: 13.5px; margin-bottom: 20px;
}
.doc .back-link:hover { color: var(--accent); }
.doc h1 { font-size: 23px; margin: 0 0 6px; letter-spacing: -.02em; }
.doc-meta { color: var(--text-dim); font-size: 13px; margin: 0 0 26px; }
.doc h2 { font-size: 17px; margin: 1.9em 0 .6em; letter-spacing: -.01em; border-bottom: 1px solid var(--border); padding-bottom: .3em; }
.doc h3 { font-size: 14.5px; margin: 1.5em 0 .5em; color: var(--accent); }
.doc p, .doc li { margin: .55em 0; font-size: 14.5px; line-height: 1.75; }
.doc ul, .doc ol { padding-left: 1.4em; margin: .6em 0; }
.doc a { color: var(--accent); }
.doc code {
  background: var(--bg-sunk); padding: 1px 5px; border-radius: 4px;
  font-family: var(--mono); font-size: 12.8px;
}
.doc pre {
  background: var(--bg-sunk); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm); padding: 12px 14px; margin: .8em 0;
  overflow-x: auto; font-size: 12.8px; line-height: 1.65;
}
.doc pre code { background: none; padding: 0; }
.doc table { border-collapse: collapse; width: 100%; margin: .9em 0; font-size: 13px; }
.doc th, .doc td { border: 1px solid var(--border); padding: 7px 10px; text-align: left; vertical-align: top; }
.doc th { background: var(--bg-sunk); font-weight: 600; }
.doc hr { border: none; border-top: 1px solid var(--border); margin: 2em 0; }
.doc blockquote {
  margin: 1em 0; padding: .6em 1em; border-left: 3px solid var(--border-strong);
  background: var(--bg-sunk); color: var(--text-dim);
}
.doc blockquote p { margin: 0; }
.doc-note {
  background: var(--bg-sunk); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 14px; font-size: 13.5px; color: var(--text-dim); margin: 1.6em 0 0;
}

/* ---------- 반응형 ---------- */
@media (max-width: 620px) {
  .hero { padding: 30px 0 20px; }
  .hero h1 { font-size: 23px; }
  .card { padding: 16px; }
  .score-arrow { display: none; }
  .topbar-inner { height: 52px; }
  /* 좁은 화면에서는 아이콘만 남긴다 */
  .theme-label { display: none; }
  .theme-opt { padding: 5px 9px; }
  .theme-ico { font-size: 14px; }
}
