/* 종이 노트 느낌의 따뜻하고 차분한 화면. 외부 폰트 없이 기기 기본 글꼴만 쓴다. */

:root {
  --paper: #f4edde;
  --sheet: #fbf7ec;
  --ink: #2c2219;
  --ink-soft: #5d4f40;
  --line: #d8cbb0;
  --line-soft: #e6dcc6;
  --stamp: #a2402a;
  --stamp-deep: #86331f;
  --pen: #2d4f6e;
  --amber: #7a4f10;
  --green: #3a6838;
  --error: #9b2c1c;

  --serif: "Nanum Myeongjo", "Noto Serif KR", "Noto Serif CJK KR", "AppleMyungjo", "Batang", serif;
  --sans: "Apple SD Gothic Neo", "Noto Sans KR", "Noto Sans CJK KR", "Malgun Gothic", system-ui, sans-serif;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.65 var(--sans);
  word-break: keep-all;
  overflow-wrap: anywhere;
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

::selection { background: #e7c9a4; color: var(--ink); }
:focus-visible { outline: 2px solid var(--pen); outline-offset: 2px; }

.page {
  max-width: 34rem;
  margin: 0 auto;
  padding: 2.25rem 1.125rem 4rem;
}

/* ---------- 제목 ---------- */

h1, h2 {
  font-family: var(--serif);
  font-weight: 800;
  color: var(--ink);
  text-wrap: balance;
}

h1 {
  margin: 0 0 0.75rem;
  font-size: 1.75rem;
  line-height: 1.35;
  letter-spacing: -0.02em;
}

h2 {
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.4;
}

.lede {
  margin: 0;
  color: var(--ink-soft);
  font-size: 1rem;
  text-wrap: pretty;
}

/* ---------- 초대 안내 ---------- */

.gate {
  max-width: 28rem;
  margin: 0 auto;
  padding: 18vh 1.5rem 3rem;
}

.gate p { color: var(--ink-soft); margin: 0.75rem 0 0; }

/* ---------- 쓰기 폼 ---------- */

.write {
  margin-top: 2rem;
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: 4px;
  box-shadow: 0 1px 2px rgba(70, 45, 20, 0.1), 0 10px 20px -14px rgba(70, 45, 20, 0.35);
}

.write > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 3.25rem;
  padding: 0.5rem 1.125rem;
  font-family: var(--serif);
  font-weight: 800;
  font-size: 1.125rem;
  cursor: pointer;
  list-style: none;
  -webkit-tap-highlight-color: transparent;
}

.write > summary::-webkit-details-marker { display: none; }

.write > summary::after {
  content: "";
  width: 0.6rem;
  height: 0.6rem;
  margin-right: 0.25rem;
  border-right: 2px solid var(--ink-soft);
  border-bottom: 2px solid var(--ink-soft);
  transform: rotate(-135deg) translate(-2px, -2px);
  transition: transform 0.25s var(--ease-out);
}

.write:not([open]) > summary::after { transform: rotate(45deg); }

form { padding: 0.25rem 1.125rem 1.25rem; }

.field { margin: 0 0 1.25rem; }

.field label,
.field .label {
  display: block;
  margin-bottom: 0.375rem;
  font-weight: 700;
  font-size: 0.9375rem;
}

.hint {
  font-weight: 400;
  color: var(--ink-soft);
  font-size: 0.875rem;
}

.field .example {
  margin: 0.375rem 0 0;
  color: var(--ink-soft);
  font-size: 0.875rem;
}

input[type="text"],
select,
textarea {
  display: block;
  width: 100%;
  min-height: 2.875rem;
  padding: 0.5rem 0.75rem;
  background: #fffdf6;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 3px;
  font: inherit; /* iOS 확대를 막으려고 16px 유지 */
  font-size: 1rem;
  caret-color: var(--stamp);
  appearance: none;
  -webkit-appearance: none;
}

select {
  padding-right: 2.25rem;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--ink-soft) 50%),
    linear-gradient(135deg, var(--ink-soft) 50%, transparent 50%);
  background-position: calc(100% - 1.125rem) 1.2rem, calc(100% - 0.8rem) 1.2rem;
  background-size: 0.4rem 0.4rem;
  background-repeat: no-repeat;
}

input::placeholder,
textarea::placeholder { color: #85776a; opacity: 1; }

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--pen);
  outline-offset: 0;
  border-color: var(--pen);
}

/* 공책 줄 느낌: 줄 간격과 배경 줄을 맞춘다 */
textarea {
  min-height: 9.5rem;
  padding: 0.375rem 0.75rem 0.25rem;
  line-height: 1.75rem;
  resize: vertical;
  background-image: repeating-linear-gradient(to bottom, transparent 0 1.6875rem, var(--line-soft) 1.6875rem 1.75rem);
  background-attachment: local;
  background-position: 0 0.375rem;
  background-color: #fffdf6;
}

.counter {
  margin: 0.25rem 0 0;
  text-align: right;
  font-size: 0.8125rem;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.consent {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  margin: 0 0 0.5rem;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: #f7f0df;
  cursor: pointer;
}

.consent input {
  flex: none;
  width: 1.375rem;
  height: 1.375rem;
  margin: 0.125rem 0 0;
  accent-color: var(--stamp);
}

.consent span { font-size: 0.9375rem; line-height: 1.55; }

.notice {
  margin: 0 0 1.25rem;
  font-size: 0.875rem;
  color: var(--ink-soft);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  min-height: 2.875rem;
  padding: 0.5rem 1.25rem;
  border: 1px solid transparent;
  border-radius: 3px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.15s, transform 0.15s var(--ease-out);
}

.btn:active { transform: translateY(1px); }

.btn-primary {
  width: 100%;
  background: var(--stamp);
  color: #fffaf0;
}
.btn-primary:hover { background: var(--stamp-deep); }
.btn-primary:disabled { background: #b9a393; cursor: default; transform: none; }

.btn-quiet {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}
.btn-quiet:hover { background: #efe6d1; }
.btn-quiet:disabled { color: #8a7c6c; cursor: default; }

.form-msg {
  margin: 0.75rem 0 0;
  font-size: 0.9375rem;
  font-weight: 600;
}
.form-msg.is-error { color: var(--error); }
.form-msg.is-ok { color: var(--green); }

/* ---------- 목록 ---------- */

.list-head { margin: 2.75rem 0 1rem; }

.list { display: grid; gap: 1.125rem; margin: 0; padding: 0; list-style: none; }

.entry {
  padding: 1.125rem 1.125rem 0.875rem;
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: 4px;
  box-shadow: 0 1px 2px rgba(70, 45, 20, 0.1), 0 10px 20px -14px rgba(70, 45, 20, 0.35);
}

.entry.is-new { animation: settle 0.55s var(--ease-out); }

@keyframes settle {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.entry-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.when {
  margin: 0;
  font-family: var(--serif);
  font-weight: 800;
  font-size: 1.0625rem;
  line-height: 1.5;
}

.when .where { font-family: var(--sans); font-weight: 400; color: var(--ink-soft); font-size: 0.9375rem; }

.badge {
  flex: none;
  padding: 0.0625rem 0.5rem;
  border: 1px solid currentColor;
  border-radius: 2px;
  font-size: 0.8125rem;
  font-weight: 700;
  line-height: 1.6;
  white-space: nowrap;
}
.badge-received { color: var(--ink-soft); }
.badge-checking { color: var(--pen); }
.badge-making { color: var(--amber); }
.badge-published { color: var(--green); }

.story {
  margin: 0.75rem 0 0;
  font-family: var(--serif);
  font-size: 1.0625rem;
  line-height: 1.85;
  white-space: pre-wrap;
  text-wrap: pretty;
}

.detail {
  margin: 0.875rem 0 0;
  padding: 0.5rem 0.75rem;
  background: #f4ecd9;
  border-radius: 3px;
  font-size: 0.9375rem;
  color: var(--ink-soft);
}
.detail strong { color: var(--ink); font-weight: 700; margin-right: 0.25rem; }

.entry-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  margin-top: 0.875rem;
  padding-top: 0.625rem;
  border-top: 1px dashed var(--line);
}

.by { margin: 0; font-size: 0.9375rem; color: var(--ink-soft); }

.actions { display: flex; align-items: center; gap: 0.5rem; }

.video-link {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  padding: 0 0.5rem;
  color: var(--pen);
  font-weight: 700;
  text-underline-offset: 0.25em;
}

.like {
  min-height: 2.75rem;
  padding: 0.25rem 1rem;
  background: transparent;
  color: var(--stamp);
  border: 1px solid var(--stamp);
  border-radius: 999px;
  font: inherit;
  font-weight: 700;
  font-size: 0.9375rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.15s, color 0.15s, transform 0.15s var(--ease-out);
}
.like:active { transform: scale(0.96); }
.like[aria-pressed="true"] { background: var(--stamp); color: #fffaf0; }
.like .n { margin-left: 0.375rem; font-variant-numeric: tabular-nums; }

.entry-msg { margin: 0.5rem 0 0; color: var(--error); font-size: 0.875rem; font-weight: 600; }

.state {
  margin: 0;
  padding: 2rem 1rem;
  text-align: center;
  color: var(--ink-soft);
  border: 1px dashed var(--line);
  border-radius: 4px;
}
.state .btn { margin-top: 0.75rem; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- 관리자 ---------- */

.admin-page { max-width: 80rem; }

.admin-login { display: grid; gap: 0.75rem; max-width: 22rem; margin-top: 1.5rem; }
.admin-login .field { margin: 0; }

.admin-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin: 1.5rem 0 1rem;
}
.admin-bar .btn { width: auto; }
.admin-bar .form-msg { margin: 0; }

.table-wrap {
  overflow-x: auto;
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: 4px;
}

table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }

th, td {
  padding: 0.625rem 0.75rem;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--line-soft);
}

th { font-size: 0.8125rem; color: var(--ink-soft); white-space: nowrap; background: #f4ecd9; }
tr.is-hidden td { background: #efe6d3; color: var(--ink-soft); }
tr:last-child td { border-bottom: 0; }

td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
td.what { min-width: 15rem; max-width: 26rem; }
td.what .meta { color: var(--ink-soft); font-size: 0.8125rem; }
td.what .text { margin: 0.125rem 0 0; white-space: pre-wrap; }
td.what .extra { margin: 0.25rem 0 0; color: var(--ink-soft); font-size: 0.875rem; }

td select, td input[type="text"] { min-height: 2.5rem; font-size: 0.9375rem; }
td input[type="text"] { min-width: 14rem; }
td .check { display: flex; align-items: center; gap: 0.375rem; white-space: nowrap; min-height: 2.5rem; }
td .check input { width: 1.25rem; height: 1.25rem; accent-color: var(--stamp); }
td .row-msg { display: block; white-space: nowrap; margin-top: 0.25rem; font-size: 0.8125rem; font-weight: 600; }
td .row-msg.is-error { color: var(--error); }
td .row-msg.is-ok { color: var(--green); }
td .btn { min-height: 2.5rem; padding: 0.25rem 1rem; white-space: nowrap; }

@media (min-width: 40rem) {
  .page { padding-top: 3.5rem; }
  h1 { font-size: 2.125rem; }
}
