:root {
  color-scheme: light;
  --bg: #ffffff;
  --panel: #ffffff;
  --ink: #111827;
  --muted: #64748b;
  --line: #e5e7eb;
  --deep: #0b1220;
  --accent: #2563eb;
  --accent-ink: #ffffff;
  --soft: #eef7f2;
  --warn: #8a5a00;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
}

header {
  min-height: 74px;
  padding: 14px clamp(18px, 4vw, 56px);
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.header-inner { width: min(100%, 1280px); margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.logo { display: flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; }
.brand-logo { display: block; width: auto; height: 42px; max-width: min(52vw, 260px); object-fit: contain; }
.header-tools { display: flex; align-items: center; gap: 12px; }
.header-tools a { color: var(--accent); font-size: 14px; font-weight: 900; text-decoration: none; }

h1, h2, p { margin: 0; letter-spacing: 0; }

h1 { font-size: 22px; line-height: 1.2; }
h2 { font-size: 16px; }
p { margin-top: 5px; color: var(--muted); font-size: 13px; }

main {
  display: grid;
  grid-template-columns: minmax(320px, 430px) minmax(0, 1fr);
  gap: 16px;
  width: min(100%, 1180px);
  margin: 0 auto;
  padding: 28px 20px 36px;
}

.hero { padding: 48px 20px 42px; background: #f8fafc; border-bottom: 1px solid var(--line); }
.hero-copy { width: min(100%, 1180px); margin: 0 auto; }
.hero h1 { margin: 0 0 10px; color: var(--deep); font-size: clamp(30px, 4vw, 48px); }
.hero p { max-width: 760px; margin: 7px 0 0; font-size: 16px; line-height: 1.65; }

section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.input-panel { padding: 16px; align-self: start; }
.results-panel { padding: 16px; min-height: calc(100vh - 108px); }

label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

.status-message {
  margin: -6px 0 16px;
  border: 1px solid #dbe3de;
  border-radius: 7px;
  padding: 10px 12px;
  background: #f8fafc;
  color: #315344;
  font-size: 13px;
  line-height: 1.5;
}

textarea {
  width: 100%;
  min-height: 154px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  color: var(--ink);
  font: inherit;
  font-size: 17px;
  line-height: 1.55;
}

textarea:focus {
  outline: 2px solid rgba(10, 122, 67, 0.2);
  border-color: var(--accent);
}

button {
  min-height: 40px;
  border: 0;
  border-radius: 7px;
  padding: 0 14px;
  background: var(--accent);
  color: var(--accent-ink);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

button:disabled {
  cursor: default;
  opacity: 0.45;
}

.ghost {
  background: var(--deep);
  color: #fff;
}

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

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

.section-head span {
  min-width: 34px;
  height: 26px;
  border-radius: 13px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  background: var(--soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
}

.spaced { margin-top: 22px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 10px;
}

.card {
  min-height: 116px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
  display: grid;
  gap: 10px;
}

.keyword {
  font-size: 18px;
  font-weight: 800;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.meta {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.copy {
  align-self: end;
  width: 100%;
}

.near .keyword { color: var(--warn); }

.empty::before {
  content: "결과 없음";
  color: var(--muted);
  font-size: 14px;
}

#toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  padding: 10px 14px;
  border-radius: 20px;
  background: rgba(23, 33, 28, 0.94);
  color: #fff;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}

#toast.show { opacity: 1; }

@media (max-width: 820px) {
  main { grid-template-columns: 1fr; }
  header { align-items: flex-start; }
  .header-inner, .header-tools { align-items: flex-start; }
  .header-tools { flex-direction: column; gap: 8px; }
  .brand-logo { height: 34px; max-width: 50vw; }
}
