:root {
  --green: #06c167;
  --green-2: #00a64f;
  --green-dark: #029a48;
  --green-ink: #0c7a3e;

  --bg: #eef1f0;
  --bg-2: #f7f9f8;
  --panel: #ffffff;

  --ink: #0f1719;
  --ink-soft: #56656c;
  --ink-faint: #8a979d;

  --line: #e7ebe9;
  --line: #e6eae8;
  --line-soft: #eef1f0;

  --shadow-sm: 0 1px 2px rgba(16, 30, 36, 0.04), 0 1px 3px rgba(16, 30, 36, 0.06);
  --shadow-md: 0 6px 24px -8px rgba(16, 36, 30, 0.12), 0 2px 8px rgba(16, 36, 30, 0.05);
  --shadow-lg: 0 24px 60px -20px rgba(12, 40, 28, 0.28);
  --ring: 0 0 0 4px rgba(6, 193, 103, 0.15);

  --radius-xl: 22px;
  --radius-lg: 16px;
  --radius-md: 12px;
}

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

/* hidden 속성 항상 우선 (클릭 가로채기 방지 — 유지) */
[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: "Noto Sans KR", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  background: var(--bg);
  background-image:
    radial-gradient(60rem 40rem at 12% -8%, rgba(6, 193, 103, 0.10), transparent 60%),
    radial-gradient(48rem 36rem at 108% 8%, rgba(0, 166, 79, 0.08), transparent 55%),
    linear-gradient(180deg, var(--bg-2), var(--bg) 40%);
  background-attachment: fixed;
  min-height: 100vh;
}

.app {
  max-width: 1140px;
  margin: 0 auto;
  padding: 56px 24px 72px;
}

/* ───────────── Hero ───────────── */
.hero {
  text-align: center;
  margin-bottom: 40px;
  position: relative;
}
.key-btns {
  position: absolute;
  top: -6px;
  right: 0;
  display: flex;
  gap: 8px;
}
.key-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.16s ease, border-color 0.16s, color 0.16s, box-shadow 0.16s;
}
.key-btn:hover {
  border-color: rgba(6, 193, 103, 0.5);
  color: var(--green-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.key-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e0564f;
  box-shadow: 0 0 0 3px rgba(224, 86, 79, 0.16);
  transition: all 0.2s;
}
.key-dot.on {
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(6, 193, 103, 0.18);
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 13px;
}
.logo-mark {
  font-size: 30px;
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: linear-gradient(145deg, #ffffff, #eef4f1);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
}
.hero h1 {
  font-size: 32px;
  font-weight: 900;
  letter-spacing: -0.8px;
  color: var(--ink);
}
.hero h1 {
  background: linear-gradient(120deg, #0f1719 0%, #0c7a3e 55%, #06c167 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.subtitle {
  margin-top: 14px;
  color: var(--ink-soft);
  font-size: 15px;
  max-width: 38ch;
  margin-left: auto;
  margin-right: auto;
}

@media (max-width: 620px) {
  .app { padding: 32px 16px 56px; }
  .key-btns { position: static; justify-content: center; margin: 0 auto 20px; }
  .hero h1 { font-size: 27px; }
}

/* ───────────── Layout ───────────── */
.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}
@media (max-width: 880px) {
  .grid { grid-template-columns: 1fr; }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  padding: 28px;
}
@media (min-width: 881px) {
  .output-panel { position: sticky; top: 24px; }
}
.panel-title {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.2px;
  color: var(--ink);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ───────────── Fields ───────────── */
.field { display: block; margin-bottom: 18px; }
.field-label {
  display: block;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 8px;
  letter-spacing: 0.1px;
}
.optional { color: var(--ink-faint); font-weight: 500; }

textarea,
input[type="text"],
input[type="password"],
select {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  padding: 13px 15px;
  font-family: inherit;
  font-size: 15px;
  color: var(--ink);
  background: #fbfcfc;
  transition: border-color 0.16s, background 0.16s, box-shadow 0.16s;
}
textarea { resize: vertical; min-height: 76px; line-height: 1.6; }
::placeholder { color: var(--ink-faint); }

select {
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%235b6573' d='M6 8 0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}
textarea:focus,
input[type="text"]:focus,
input[type="password"]:focus,
select:focus {
  outline: none;
  border-color: var(--green);
  background: #fff;
  box-shadow: var(--ring);
}
.hint {
  display: block;
  margin-top: 8px;
  font-size: 12px;
  color: var(--ink-faint);
  line-height: 1.55;
}
.hint b { color: var(--green-dark); font-weight: 700; }
.hint a, .modal-desc a { color: var(--green-dark); font-weight: 700; text-decoration: none; }
.hint a:hover, .modal-desc a:hover { text-decoration: underline; }

.field-row { display: flex; gap: 14px; margin-bottom: 18px; }
.field-row .field { flex: 1; margin-bottom: 0; min-width: 0; }
@media (max-width: 520px) {
  .field-row { flex-direction: column; gap: 0; }
  .field-row .field { margin-bottom: 18px; }
}

/* Examples */
.examples { margin-bottom: 22px; }
.examples-label {
  display: block;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ink-faint);
  margin-bottom: 10px;
  letter-spacing: 0.2px;
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-soft);
  font-size: 12.5px;
  font-family: inherit;
  padding: 8px 13px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s;
}
.chip:hover {
  border-color: rgba(6, 193, 103, 0.55);
  color: var(--green-dark);
  background: #f1fbf5;
  transform: translateY(-1px);
}

/* Segmented (생성 AI) */
.segmented {
  display: flex;
  gap: 5px;
  background: #f0f3f2;
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 5px;
}
.seg {
  flex: 1;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-soft);
  padding: 10px;
  border-radius: 9px;
  cursor: pointer;
  transition: all 0.16s;
}
.seg:hover { color: var(--ink); }
.seg-active {
  background: #fff;
  color: var(--green-dark);
  box-shadow: var(--shadow-sm);
}

/* Refine toggle */
.refine-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  padding: 12px 14px;
  background: #f7faf8;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  font-size: 12.5px;
  color: var(--ink-soft);
  cursor: pointer;
  line-height: 1.45;
}
.refine-toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--green);
  flex-shrink: 0;
  cursor: pointer;
}

/* ───────────── Buttons ───────────── */
.btn-primary {
  width: 100%;
  border: none;
  background: linear-gradient(135deg, var(--green), var(--green-2));
  color: #fff;
  font-family: inherit;
  font-size: 15.5px;
  font-weight: 800;
  letter-spacing: 0.2px;
  padding: 16px;
  border-radius: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 10px 22px -10px rgba(6, 193, 103, 0.7);
  transition: transform 0.12s ease, box-shadow 0.16s, filter 0.16s;
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 16px 30px -12px rgba(6, 193, 103, 0.75); filter: brightness(1.02); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled {
  background: #c2cbc7;
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
  filter: none;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2.5px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.btn-ghost {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 15px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-ghost:hover:not(:disabled) {
  border-color: rgba(6, 193, 103, 0.5);
  color: var(--green-dark);
  background: #f5fbf7;
}
.btn-ghost:disabled { opacity: 0.45; cursor: not-allowed; }

.error {
  margin-top: 16px;
  color: #c0392b;
  font-size: 13.5px;
  background: #fdf1f0;
  border: 1px solid #f8d4d0;
  border-radius: var(--radius-md);
  padding: 12px 14px;
  line-height: 1.55;
}

/* ───────────── Output ───────────── */
.output-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.output-head .panel-title { margin-bottom: 0; }
.output-actions { display: flex; align-items: center; gap: 12px; }
.char-count {
  font-size: 11.5px;
  color: var(--ink-faint);
  text-align: right;
  line-height: 1.4;
}

.output-body { min-height: 420px; }
.placeholder {
  height: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--ink-faint);
  gap: 16px;
  border: 1.5px dashed var(--line);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(24rem 16rem at 50% 0%, rgba(6, 193, 103, 0.05), transparent 70%);
}
.placeholder-emoji { font-size: 42px; opacity: 0.5; }
.placeholder p { font-size: 14px; }

.post {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.post-title {
  background: linear-gradient(180deg, #f3fbf6, #eef8f1);
  border-bottom: 1px solid #dcefe2;
  padding: 17px 20px;
  font-size: 16px;
  font-weight: 800;
  color: var(--ink);
  line-height: 1.5;
}
.post-body {
  padding: 20px;
  font-size: 14.5px;
  line-height: 1.85;
  color: #1c272b;
  white-space: pre-wrap;
  word-break: break-word;
  background: #fff;
}

/* ───────────── Modal ───────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(14, 24, 22, 0.5);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
  animation: fade 0.18s ease;
}
.modal {
  background: #fff;
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 450px;
  padding: 26px;
  box-shadow: var(--shadow-lg);
  animation: pop 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.modal-head h3 { font-size: 17px; font-weight: 800; }
.modal-close {
  border: none;
  background: none;
  font-size: 16px;
  color: var(--ink-faint);
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 8px;
  transition: background 0.15s;
}
.modal-close:hover { background: var(--bg); }
.modal-desc { font-size: 13px; color: var(--ink-soft); margin-bottom: 18px; line-height: 1.6; }
.key-input-row { display: flex; gap: 8px; }
.key-input-row input { flex: 1; }
.modal-error {
  margin-top: 12px;
  color: #c0392b;
  font-size: 13px;
  background: #fdf1f0;
  border: 1px solid #f8d4d0;
  border-radius: var(--radius-md);
  padding: 10px 12px;
}
.modal-actions { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 22px; }
.modal-save { width: auto; flex: 1; }

/* ───────────── Footer ───────────── */
.foot { margin-top: 36px; text-align: center; }
.foot p { font-size: 12px; color: var(--ink-faint); line-height: 1.6; }

/* ───────────── Anim ───────────── */
.fade-in { animation: fade 0.4s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }
