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

:root {
  --line: #e2e2e2;
  --ink: #111;
  --mute: #8a8a8a;
  --bg: #fff;
  --accent: #111;
}

body {
  font-family: "Paperlogy", -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.6;
}

/* 머리말 */
header {
  border-bottom: 1px solid var(--ink);
  padding: 18px 28px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}
header h1 { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; }
header .sub { font-size: 12px; color: var(--mute); margin-left: 10px; font-weight: 400; }
header a { color: var(--mute); font-size: 12px; text-decoration: none; white-space: nowrap; }
header a:hover { color: var(--ink); text-decoration: underline; }

/* 2단 */
.wrap { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); min-height: calc(100vh - 61px); }
.pane { padding: 24px 28px 60px; }
.pane + .pane { border-left: 1px solid var(--line); background: #fafafa; }

/* 업로드 */
.drop {
  display: block;                       /* label 은 기본이 inline 이라 상자가 안 커진다 */
  border: 1px dashed var(--line);
  padding: 18px;
  text-align: center;
  color: var(--mute);
  cursor: pointer;
  margin-bottom: 22px;
  transition: border-color .15s, color .15s, background .15s;
}
.drop:hover, .drop.over { border-color: var(--ink); color: var(--ink); background: #fafafa; }
.drop strong { color: var(--ink); font-weight: 700; }
.drop input { display: none; }

/* 폼 */
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 700; font-size: 12px; margin-bottom: 6px; }
.field .hint { font-weight: 400; color: var(--mute); margin-left: 6px; }
input[type=text], textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  padding: 9px 11px;
  font: inherit;
  color: var(--ink);
  background: #fff;
  border-radius: 0;
}
input[type=text]:focus, textarea:focus, select:focus { outline: none; border-color: var(--ink); }
textarea { resize: vertical; line-height: 1.7; }
textarea#본문 { min-height: 300px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* 도움말 */
details.help { margin: -6px 0 18px; font-size: 12px; color: var(--mute); }
details.help summary { cursor: pointer; }
details.help table { border-collapse: collapse; margin-top: 8px; width: 100%; }
details.help td { border: 1px solid var(--line); padding: 5px 8px; vertical-align: top; }
details.help code { font-family: ui-monospace, Menlo, Consolas, monospace; color: var(--ink); }

/* 단추 */
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 22px; }
button {
  font: inherit; font-weight: 700;
  border: 1px solid var(--ink);
  background: #fff; color: var(--ink);
  padding: 11px 20px;
  cursor: pointer;
  border-radius: 0;
  transition: background .15s, color .15s;
}
button:hover:not(:disabled) { background: var(--ink); color: #fff; }
button.primary { background: var(--ink); color: #fff; }
button.primary:hover:not(:disabled) { background: #000; }
button:disabled { opacity: .4; cursor: default; }

/* 미리보기 */
.pane h2 { font-size: 13px; font-weight: 700; margin-bottom: 12px; }
/* 아이폰 사파리는 iframe 안의 PDF 를 못 그리는 일이 있다 — 빠져나갈 길을 둔다 */
.pane h2 a { float: right; font-size: 12px; font-weight: 400; color: var(--mute); }
.pane h2 a:hover { color: var(--ink); }
#preview { width: 100%; height: calc(100vh - 140px); border: 1px solid var(--line); background: #fff; }
.placeholder {
  border: 1px solid var(--line); background: #fff;
  height: calc(100vh - 140px);
  display: flex; align-items: center; justify-content: center;
  color: var(--mute); text-align: center; padding: 24px;
}

/* 알림 */
#toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 11px 20px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .2s;
  max-width: 90vw;
}
#toast.show { opacity: 1; }

/* 로그인 */
body.login { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px; }
.card { width: 100%; max-width: 340px; }
.card h1 { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.card p.sub { color: var(--mute); font-size: 13px; margin: 6px 0 24px; }
.card button { width: 100%; margin-top: 12px; }
.err { color: #c0392b; font-size: 12px; margin-top: 10px; }

/* ── 좁은 화면 ── 앞의 규칙을 덮어써야 하므로 파일 맨 뒤에 둔다 ── */
@media (max-width: 900px) {
  .wrap { grid-template-columns: 1fr; }
  .pane + .pane { border-left: 0; border-top: 1px solid var(--line); }
  /* 위아래로 쌓이면 미리보기가 화면 하나를 통째로 잡아먹는다 */
  #preview, .placeholder { height: 65vh; }
}

@media (max-width: 700px) {
  header { padding: 14px 18px; }
  header .sub { display: none; }        /* 두 줄로 접히며 머리말이 무너진다 */
  .pane { padding: 18px 18px 48px; }
  .row { grid-template-columns: 1fr; }  /* 두 칸을 나란히 두기엔 좁다 */
  .row .field { margin-bottom: 16px; }
  textarea#본문 { min-height: 240px; }
  .actions button { flex: 1 1 auto; }   /* 손가락으로 누르기 좋게 */
}
