/* ============================================================
   moim.bio 웹 도구 — 공통 스타일
   블로그(Twenty Twenty-Five + Pretendard)와 같은 얼굴을 쓴다.
   도구는 워드프레스 밖 정적 파일이라 테마 CSS 가 안 오므로
   여기서 최소한을 다시 정의한다.
   ============================================================ */

:root {
  --ko: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont,
    "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", "JetBrains Mono", Menlo,
    Consolas, "D2Coding", monospace;

  --bg: #fff;
  --bg-sunken: #f7f7f6;
  --fg: #1c1c1c;
  --fg-dim: #6a6a68;
  --line: #e3e3e0;
  --line-strong: #c9c9c4;
  --accent: #1c1c1c;
  --accent-fg: #fff;
  --ok: #197a4b;
  --err: #b3261e;
  --err-bg: #fdf0ef;
  --radius: 8px;
}

/* 개발자 도구는 어두운 화면에서 오래 본다. 시스템 설정을 그대로 따른다. */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16171a;
    --bg-sunken: #1e1f23;
    --fg: #e8e8e6;
    --fg-dim: #9a9a97;
    --line: #2d2f34;
    --line-strong: #43464d;
    --accent: #e8e8e6;
    --accent-fg: #16171a;
    --ok: #5bc98d;
    --err: #ff8a80;
    --err-bg: #2a1d1c;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--ko);
  font-size: 16px;
  line-height: 1.6;
  /* 한글은 어절 단위로 끊어야 읽힌다. 긴 URL·영문만 예외를 연다. */
  word-break: keep-all;
  overflow-wrap: break-word;
}

a { color: inherit; }

.wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* ── 머리말 ───────────────────────────────────────────────── */

.site-head {
  border-bottom: 1px solid var(--line);
}

.site-head .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 62px;
}

.site-head .brand {
  font-weight: 700;
  letter-spacing: -0.5px;
  text-decoration: none;
  font-size: 1.05rem;
}

.site-head nav {
  display: flex;
  gap: 1.25rem;
  font-size: 0.94rem;
}

.site-head nav a { text-decoration: none; color: var(--fg-dim); }
.site-head nav a:hover,
.site-head nav a[aria-current="page"] { color: var(--fg); }

/* ── 제목 영역 ────────────────────────────────────────────── */

.crumbs {
  font-size: 0.83rem;
  color: var(--fg-dim);
  margin: 1.5rem 0 0.75rem;
}
.crumbs a { text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
.crumbs span::before { content: "›"; margin: 0 0.45em; opacity: 0.6; }

h1 {
  font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.3rem);
  line-height: 1.3;
  letter-spacing: -0.02em;
  margin: 0 0 0.4rem;
}

.lede {
  color: var(--fg-dim);
  margin: 0 0 1.75rem;
  max-width: 62ch;
}

/* ── 작업대 ───────────────────────────────────────────────── */

.bench {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* 좁은 화면에서는 위아래로. 입력을 먼저 보여준다. */
@media (max-width: 780px) {
  .bench { grid-template-columns: 1fr; }
}

.pane {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  min-width: 0;
}

.pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--line);
  background: var(--bg-sunken);
  border-radius: var(--radius) var(--radius) 0 0;
  font-size: 0.83rem;
  color: var(--fg-dim);
  min-height: 42px;
}

.pane-title { font-weight: 600; color: var(--fg); }

.pane-tools { display: flex; gap: 0.35rem; align-items: center; }

.pane textarea {
  width: 100%;
  border: 0;
  outline: 0;
  resize: vertical;
  padding: 0.85rem;
  min-height: 300px;
  background: transparent;
  color: inherit;
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.6;
  tab-size: 2;
  /* 코드는 어절 단위로 끊으면 안 된다 — body 의 keep-all 을 되돌린다. */
  word-break: normal;
  white-space: pre;
  overflow-wrap: normal;
  overflow-x: auto;
}

/* 안내 문구는 한글이라 고정폭으로 그리면 글자 사이가 벌어져 읽기 나쁘다.
   입력한 내용은 코드이므로 고정폭 그대로 둔다. */
.pane textarea::placeholder {
  color: var(--fg-dim);
  opacity: 0.7;
  font-family: var(--ko);
  letter-spacing: 0;
}

.pane-foot {
  padding: 0.4rem 0.75rem;
  border-top: 1px solid var(--line);
  font-size: 0.78rem;
  color: var(--fg-dim);
  font-variant-numeric: tabular-nums;
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
}

/* 파일을 끌어다 놓는 중 */
.pane.dropping { border-color: var(--fg); box-shadow: 0 0 0 3px var(--line); }

/* ── 조작 버튼 ────────────────────────────────────────────── */

button, .btn {
  font-family: inherit;
  font-size: 0.83rem;
  line-height: 1;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--bg);
  color: var(--fg);
  cursor: pointer;
  white-space: nowrap;
}

button:hover { border-color: var(--fg); }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.45; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
button.done { color: var(--ok); border-color: var(--ok); }

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 1rem;
  margin: 1rem 0 0;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-sunken);
  font-size: 0.88rem;
}

.controls label { display: inline-flex; align-items: center; gap: 0.35rem; cursor: pointer; }
.controls select, .controls input[type="number"], .controls input[type="text"] {
  font-family: inherit;
  font-size: 0.88rem;
  padding: 0.3rem 0.45rem;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--bg);
  color: var(--fg);
}
.controls .spacer { flex: 1 1 auto; }
.controls .hint { color: var(--fg-dim); font-size: 0.8rem; }

/* ── 오류 ─────────────────────────────────────────────────── */

.err {
  display: none;
  margin: 0.75rem 0 0;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--err);
  border-radius: var(--radius);
  background: var(--err-bg);
  color: var(--err);
  font-size: 0.88rem;
}
.err.on { display: block; }
.err pre {
  margin: 0.5rem 0 0;
  font-family: var(--mono);
  font-size: 12px;
  white-space: pre;
  overflow-x: auto;
  opacity: 0.85;
}

/* ── 설명 본문 ────────────────────────────────────────────── */

.about {
  margin: 3rem 0 0;
  max-width: 68ch;
}
.about h2 { font-size: 1.25rem; letter-spacing: -0.02em; margin: 2rem 0 0.6rem; }
.about h3 { font-size: 1.02rem; margin: 1.5rem 0 0.4rem; }
.about p, .about li { line-height: 1.75; letter-spacing: -0.003em; }
.about code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.1em 0.35em;
  word-break: break-all;
}
.about table { border-collapse: collapse; width: 100%; margin: 1rem 0; font-size: 0.92rem; }
.about th, .about td { border: 1px solid var(--line); padding: 0.5em 0.7em; text-align: left; vertical-align: top; }
.about th { background: var(--bg-sunken); font-weight: 600; }
.about .faq { margin: 0.9rem 0; }
.about .faq summary { cursor: pointer; font-weight: 600; }
.about .faq p { margin: 0.5rem 0 0; }

/* ── 다른 도구 목록 ───────────────────────────────────────── */

.other {
  margin: 3.5rem 0 0;
  padding-top: 1.75rem;
  border-top: 1px solid var(--line);
}
.other h2 { font-size: 1.05rem; margin: 0 0 0.9rem; }

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 0.6rem;
  padding: 0;
  margin: 0;
  list-style: none;
}

/* li 를 flex 로 두고 a 가 늘어나게 한다. a 에 height:100% 를 주면 그리드 행
   높이와 서로를 참조해, 카드가 내용보다 짧게 잘리고 글자가 테두리를 넘는다. */
.tool-grid li { display: flex; }

.tool-grid a {
  display: block;
  flex: 1;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-decoration: none;
}
.tool-grid a:hover { border-color: var(--fg); background: var(--bg-sunken); }
.tool-grid a[aria-current="page"] { border-color: var(--line-strong); background: var(--bg-sunken); opacity: 0.6; }
.tool-grid .t { font-weight: 600; font-size: 0.93rem; display: block; }
.tool-grid .d { color: var(--fg-dim); font-size: 0.8rem; display: block; margin-top: 0.15rem; }

/* ── 허브 ─────────────────────────────────────────────────── */

.group { margin: 2.25rem 0 0; }
.group h2 {
  font-size: 0.83rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--fg-dim);
  margin: 0 0 0.75rem;
}

/* ── 꼬리말 ───────────────────────────────────────────────── */

.site-foot {
  margin-top: 4rem;
  padding: 1.75rem 0 2.5rem;
  border-top: 1px solid var(--line);
  color: var(--fg-dim);
  font-size: 0.85rem;
}
.site-foot .wrap { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; justify-content: space-between; }

/* 화면에는 안 보이지만 스크린리더와 검색엔진은 읽는다 */
.sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* 복사 알림 */
.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%) translateY(1rem);
  background: var(--accent);
  color: var(--accent-fg);
  padding: 0.55rem 1rem;
  border-radius: 999px;
  font-size: 0.85rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s, transform 0.15s;
  z-index: 50;
}
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (prefers-reduced-motion: reduce) {
  .toast { transition: none; }
}

/* 입력이 없는 생성기 도구 — 결과 판 하나만 쓴다 */
.bench.single { grid-template-columns: 1fr; }

/* ── 계산기 ───────────────────────────────────────────────
   변환 도구는 두 칸이 같은 무게지만, 계산기는 결과가 주인공이다.
   입력은 좁게, 결과는 넓게 잡는다. */

.bench.calc { grid-template-columns: minmax(280px, 22rem) 1fr; align-items: start; }

/* 채울 칸이 없는 도구(내 IP)는 결과 판 하나뿐이다. 두 칸 격자를 풀되 화면
   끝까지 늘리지는 않는다 — 라벨과 값 사이가 벌어지면 어느 줄인지 놓친다.
   .bench.single 만으로는 안 된다. 위 규칙과 특이도가 같고 뒤에 있어서 진다. */
.bench.calc.single { grid-template-columns: minmax(0, 34rem); }

@media (max-width: 780px) {
  .bench.calc { grid-template-columns: 1fr; }
}

.calc-fields { padding: 1rem; display: grid; gap: 1rem; }

.field { display: grid; gap: 0.35rem; }
.field > label,
.field .field-label { font-size: 0.85rem; font-weight: 600; }
.field-hint { margin: 0; font-size: 0.78rem; color: var(--fg-dim); line-height: 1.5; }

.field input[type="text"],
.field input[type="date"],
.field select {
  width: 100%;
  font-family: inherit;
  font-size: 1rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--bg);
  color: var(--fg);
}

/* 금액은 오른쪽 정렬에 고정폭 숫자라야 자릿수가 눈에 들어온다 */
.field .with-unit { display: flex; align-items: center; gap: 0.4rem; }
.field .with-unit input {
  text-align: right;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}
.field .unit { font-size: 0.85rem; color: var(--fg-dim); white-space: nowrap; }

.field label.inline { display: flex; align-items: center; gap: 0.45rem; font-weight: 400; }

.radios { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.radios button { flex: 1 1 auto; }

.calc-out { padding: 1rem 1.1rem 1.25rem; }

.headline {
  display: grid;
  gap: 0.15rem;
  padding: 0 0 1rem;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid var(--line);
}
.headline-label { font-size: 0.85rem; color: var(--fg-dim); }
.headline-value {
  font-size: clamp(1.7rem, 1.2rem + 2vw, 2.4rem);
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.headline-hint { font-size: 0.82rem; color: var(--fg-dim); }

.calc-group {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--fg-dim);
  margin: 1.4rem 0 0.5rem;
}

.calc-rows {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.1rem 1rem;
  margin: 0;
  font-size: 0.93rem;
}
.calc-rows dt { display: flex; align-items: baseline; gap: 0.4rem; padding: 0.3rem 0; }
.calc-rows dd {
  margin: 0;
  padding: 0.3rem 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.calc-rows dd.strong { font-weight: 700; }
.calc-rows dt .row-hint { font-size: 0.78rem; color: var(--fg-dim); }

.calc-note {
  margin: 1rem 0 0;
  font-size: 0.8rem;
  color: var(--fg-dim);
  line-height: 1.6;
  padding-left: 0.9em;
  text-indent: -0.9em;
}
.calc-note::before { content: "· "; }

/* ── 작업실 — 결과가 그림인 도구 ─────────────────────────
   변환 도구와 판 구조는 같다. 텍스트 상자가 있던 자리에 그림이 온다.
   투명한 PNG 를 흰 판에 얹으면 어디까지가 그림인지 안 보이므로
   체크무늬를 깐다 — 편집기들이 다 그렇게 하는 이유다. */

:root {
  --check: #ebebe8;
  --check-bg: #fff;
}

@media (prefers-color-scheme: dark) {
  :root {
    --check: #26272c;
    --check-bg: #1a1b1f;
  }
}

/* 결과가 그림이면 두 판의 높이가 안 맞는다. 격자가 맞춰 늘려 준 만큼
   입력 상자도 같이 늘어나야 판 아래에 빈 띠가 남지 않는다. */
.bench.studio .pane textarea { flex: 1 1 auto; }
.bench.studio .stage { flex: 1 1 auto; }

.stage {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.85rem;
  min-height: 300px;
  overflow: auto;
}

.stage > * { max-width: 100%; }

/* 목록이나 표가 오는 도구(팔레트·파일 정보)는 판을 가득 쓴다 */
.stage > .fill { align-self: stretch; width: 100%; }
.stage:has(> .fill) { align-items: flex-start; }

.stage img,
.stage canvas {
  display: block;
  max-width: 100%;
  max-height: 460px;
  height: auto;
  border-radius: 3px;
  background-color: var(--check-bg);
  background-image:
    linear-gradient(45deg, var(--check) 25%, transparent 25%),
    linear-gradient(-45deg, var(--check) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--check) 75%),
    linear-gradient(-45deg, transparent 75%, var(--check) 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}

/* 흐릿하게 늘어난 픽셀아트보다 계단이 낫다 — 파비콘·QR 미리보기 */
.stage canvas.sharp,
.stage img.sharp { image-rendering: pixelated; }

.shot { position: relative; line-height: 0; max-width: 100%; }

.drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  width: 100%;
  min-height: 268px;
  padding: 1rem;
  border: 2px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--bg-sunken);
  color: var(--fg-dim);
  text-align: center;
  cursor: pointer;
}
.drop:hover, .drop:focus-visible { border-color: var(--fg); color: var(--fg); outline: 0; }
.drop-main { font-size: 0.94rem; font-weight: 600; }
.drop-sub { font-size: 0.78rem; }

/* 슬라이더는 라벨·손잡이·현재값 세 조각이라 줄에서 자리를 더 먹는다 */
.controls label.ranged { gap: 0.5rem; }
.controls label.ranged.off { opacity: 0.4; }
.controls input[type="range"] { width: 8rem; accent-color: var(--fg); }
.controls .range-read {
  min-width: 3.6rem;
  font-variant-numeric: tabular-nums;
  color: var(--fg-dim);
  font-size: 0.83rem;
}

/* ── 자르기 선택 틀 ──────────────────────────────────────── */

.crop {
  position: absolute;
  inset: 0;
  cursor: crosshair;
  touch-action: none;
  /* 틀 바깥을 어둡게 하는 그림자가 페이지 전체로 번지지 않게 가둔다 */
  overflow: hidden;
}
.crop-box {
  position: absolute;
  outline: 1px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.55);
  cursor: move;
  /* 선택 안쪽만 가려지지 않게 어둠을 도려낸다 */
  background: transparent;
  backdrop-filter: none;
}
.crop-box::before {
  content: "";
  position: absolute;
  inset: 0;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
}
.crop-grip {
  position: absolute;
  width: 12px;
  height: 12px;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.5);
  border-radius: 2px;
}
.crop-grip.nw { left: -6px; top: -6px; cursor: nwse-resize; }
.crop-grip.ne { right: -6px; top: -6px; cursor: nesw-resize; }
.crop-grip.sw { left: -6px; bottom: -6px; cursor: nesw-resize; }
.crop-grip.se { right: -6px; bottom: -6px; cursor: nwse-resize; }

/* ── 색 견본 ─────────────────────────────────────────────── */

.swatches {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.swatch {
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  background: var(--bg);
  text-align: left;
  padding: 0;
  width: 100%;
  display: block;
}
.swatch:hover { border-color: var(--fg); }
.swatch .chip { display: block; height: 58px; }
.swatch .meta {
  display: block;
  padding: 0.35rem 0.5rem 0.45rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.5;
}
.swatch .meta small { display: block; color: var(--fg-dim); font-size: 0.92em; }

/* 색 하나를 크게 보여 주는 자리 (색상 변환·대비) */
/* 색 견본은 값 목록만큼 높이를 채운다. 가운데에 작게 띄워 두면 목록이
   길어질수록 "무슨 색 얘기인지"가 눈에서 멀어진다. */
.color-card {
  display: grid;
  grid-template-columns: 5.5rem 1fr;
  gap: 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.6rem;
  margin-bottom: 0.75rem;
}
.color-card .chip {
  min-height: 4.6rem;
  border-radius: 6px;
  border: 1px solid var(--line);
}

/* ── 사실 나열 (파일 정보·EXIF) ──────────────────────────── */

.facts { margin: 0; font-size: 0.9rem; }
.facts h3 {
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--fg-dim);
  margin: 1.1rem 0 0.4rem;
}
.facts h3:first-child { margin-top: 0; }
.facts dl {
  display: grid;
  grid-template-columns: minmax(6rem, auto) 1fr;
  gap: 0.1rem 0.9rem;
  margin: 0;
}
.facts dt { color: var(--fg-dim); padding: 0.22rem 0; }
.facts dd {
  margin: 0;
  padding: 0.22rem 0;
  font-family: var(--mono);
  font-size: 0.86rem;
  word-break: break-all;
}
.facts dd.warn { color: var(--err); font-family: var(--ko); font-weight: 600; }

/* ── 여러 장을 한 번에 보여 줄 때 (파비콘 크기들) ───────── */

.tiles {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  align-items: flex-end;
  justify-content: center;
}
.tile { text-align: center; font-size: 0.75rem; color: var(--fg-dim); }
.tile canvas { margin: 0 auto 0.3rem; }

/* ── 색 고르는 칸 ────────────────────────────────────────── */

.with-pick { display: flex; gap: 0.4rem; align-items: stretch; }
.with-pick input[type="text"] { flex: 1; font-family: var(--mono); font-size: 0.94rem; }
.with-pick input[type="color"] {
  width: 2.6rem;
  padding: 0.15rem;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--bg);
  cursor: pointer;
}

/* ── 눈으로 보는 결과 (대비 미리보기) ───────────────────── */

.preview {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem 1.2rem;
  margin: 0 0 1.1rem;
}
.preview p { margin: 0 0 0.5rem; }
.preview p:last-child { margin-bottom: 0; }
.preview-lg { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.35; }
.preview-md { font-size: 1.17rem; font-weight: 700; line-height: 1.45; }
.preview-sm { font-size: 1rem; line-height: 1.6; }
.preview-xs { font-size: 0.82rem; line-height: 1.6; }
