/* 알토 다이어리(/diary)·일기 쓰기(/diary/write). blog.css(바탕색·글자·상단 바·바닥) 위에 얹는다.
   블루(--glow·--glow-text)는 누른 좋아요, 오늘 표시, 포커스 링에만. 반경은 역할별 두 값, 간격은 4의 배수. */

:root {
  --r-control: 8px; /* 버튼·입력칸·칩 */
  --r-surface: 12px; /* 달력 판·댓글 판 */
  --rail: 96px; /* 시간 기둥 폭 */
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --r-bar: 4px; /* 불러오는 중 막대 */
  --danger-text: #ff9b8f; /* check-allow: B1 다이어리 오류 글자 토큰(검정 바탕 대비 8.9:1) */
  --shadow-pop: 0 12px 32px rgba(0, 0, 0, 0.5); /* check-allow: B1 떠 있는 달력 판 그림자 토큰 */
}

.diary,
.write {
  width: min(100% - 2 * var(--gutter), var(--measure));
  margin: 0 auto;
}

/* ── 날짜 넘기기 ── */
.day-nav {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 12px 0;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.day-step {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 44px;
  padding: 0 8px;
  border: 0;
  border-radius: var(--r-control);
  background: none;
  color: var(--ink-2);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}
.day-step:hover:not(:disabled) {
  background: var(--bg-2);
  color: var(--ink);
}
.day-step:disabled {
  color: var(--ink-3);
  opacity: 0.45;
  cursor: default;
}
.day-step.prev {
  justify-self: start;
  margin-left: -8px;
}
.day-step.next {
  justify-self: end;
  margin-right: -8px;
}
.day-step svg {
  width: 16px;
  height: 16px;
  flex: none;
}
.day-mid {
  position: relative;
}
.day-title {
  margin: 0;
  font-size: 17px;
  line-height: 1.4;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.day-pick {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  min-height: 44px;
  padding: 4px 12px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-control);
  background: none;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}
.day-pick:hover,
.day-pick[aria-expanded="true"] {
  background: var(--bg-2);
}
.day-pick .day-sub {
  font-size: 12px;
  line-height: 1.4;
  color: var(--ink-3);
}

/* ── 달력 ── */
.cal {
  position: absolute;
  left: 50%;
  top: calc(100% + 8px);
  width: min(320px, calc(100vw - 2 * var(--gutter)));
  transform: translateX(-50%);
  padding: 16px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-surface);
  background: var(--bg-2);
  box-shadow: var(--shadow-pop);
}
.cal[hidden] {
  display: none;
}
.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.cal-head strong {
  font-size: 15px;
}
.cal-head button,
.cal-day {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  min-height: 40px;
  border: 0;
  border-radius: var(--r-control);
  background: none;
  color: var(--ink-2);
  font: inherit;
  font-size: 14px;
}
.cal-head button {
  cursor: pointer;
}
.cal-head button:hover {
  background: var(--bg-3);
  color: var(--ink);
}
.cal-head svg {
  width: 16px;
  height: 16px;
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  text-align: center;
}
.cal-wd {
  font-size: 12px;
  color: var(--ink-3);
  line-height: 24px;
}
.cal-day {
  position: relative;
  width: 100%;
  color: var(--ink-3);
}
.cal-day.has {
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
}
.cal-day.has::after {
  content: "";
  position: absolute;
  bottom: 6px;
  left: 50%;
  width: 4px;
  height: 4px;
  margin-left: -2px;
  border-radius: 50%;
  background: var(--ink-2);
}
.cal-day.has:hover {
  background: var(--bg-3);
}
.cal-day.on {
  background: var(--ink);
  color: var(--bg);
}
.cal-day.on::after {
  background: var(--bg);
}
.cal-day.today:not(.on) {
  box-shadow: inset 0 0 0 1px var(--glow-text);
}
.cal-note {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--ink-3);
  text-align: center;
}

/* ── 위쪽 줄: 아티클/다이어리 나눔 + (관리자) 일기 쓰기 ── */
.diary-top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-top: 32px;
  border-bottom: 1px solid var(--line);
}
.diary-top .section-tabs {
  margin: 0;
  border-bottom: 0;
}
.diary-top .btn {
  margin-bottom: 4px;
}
.btn-sm {
  min-height: 36px;
  padding: 0 12px;
  font-size: 14px;
}
.btn[hidden] {
  display: none;
}
.site-foot a[hidden] {
  display: none;
}

/* ── 그날의 일기(타임라인) ── */
.entries {
  margin: 0;
  padding: 0;
  list-style: none;
}
.entry {
  position: relative;
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  padding: 32px 0 8px;
}
/* 시간 기둥: 점과 세로선으로 같은 날 글을 잇는다 */
.entry::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 52px;
  bottom: -32px;
  width: 1px;
  background: var(--line-2);
}
.entry:last-child::before {
  display: none;
}
.entry-time {
  position: relative;
  padding: 2px 0 0 20px;
  white-space: nowrap;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.entry-time::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink-2);
}
.entry-time small {
  display: block;
  font-size: 12px;
}
.entry-main {
  min-width: 0;
}
.entry-title {
  margin: 0 0 12px;
  font-size: 21px;
  line-height: 1.45;
  font-weight: 700;
  letter-spacing: -0.012em;
}
.entry-flag {
  display: inline-block;
  margin: 0 0 8px;
  padding: 0 8px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-control);
  font-size: 12px;
  line-height: 22px;
  color: var(--ink-2);
}
.entry-body p {
  margin: 0 0 1.1em;
  font-size: 17px;
  line-height: 1.85;
  color: var(--ink);
}
.entry-body p:last-child {
  margin-bottom: 0;
}

.entry-acts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin: 16px 0 0 -8px;
}
.act {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 40px;
  padding: 0 8px;
  border: 0;
  border-radius: var(--r-control);
  background: none;
  color: var(--ink-3);
  font: inherit;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 150ms var(--ease), color 150ms var(--ease);
}
.act:hover {
  background: var(--bg-2);
  color: var(--ink);
}
.act svg {
  width: 18px;
  height: 18px;
  flex: none;
}
.act[aria-pressed="true"] {
  color: var(--glow-text);
}
.act[aria-pressed="true"] svg path {
  fill: currentColor;
}
.act-num {
  font-variant-numeric: tabular-nums;
}
.act-status {
  font-size: 13px;
  color: var(--ink-2);
}

/* ── 댓글 ── */
.cmts {
  margin: 12px 0 0;
  padding: 16px;
  border-radius: var(--r-surface);
  background: var(--bg-2);
}
.cmts[hidden] {
  display: none;
}
.cmt-list {
  margin: 0 0 16px;
  padding: 0;
  list-style: none;
}
.cmt-list:empty {
  display: none;
}
.cmt {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.cmt:first-child {
  padding-top: 0;
}
.cmt-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-3);
}
.cmt-head b {
  color: var(--ink);
  font-size: 14px;
}
.cmt-del {
  margin-left: auto;
  min-height: 32px;
  padding: 0 8px;
  border: 0;
  border-radius: var(--r-control);
  background: none;
  color: var(--ink-3);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.cmt-del:hover {
  background: var(--bg-3);
  color: var(--ink);
}
.cmt-body {
  margin: 4px 0 0;
  font-size: 15px;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.cmt-empty {
  margin: 0 0 12px;
  font-size: 14px;
  color: var(--ink-3);
}
.cmt-form {
  display: grid;
  gap: 8px;
}

/* ── 입력칸 공통(댓글·일기 쓰기) ── */
.field {
  display: grid;
  gap: 4px;
}
.field label,
.field legend {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}
.input,
.textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-control);
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  line-height: 1.5;
  word-break: keep-all;
}
.input:focus,
.textarea:focus {
  outline: 2px solid var(--glow-text);
  outline-offset: 0;
  border-color: transparent;
}
.textarea {
  resize: vertical;
  min-height: 88px;
}
.form-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.form-msg {
  margin: 0;
  font-size: 13px;
  color: var(--ink-2);
}
.form-msg.err {
  color: var(--danger-text);
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-control);
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 150ms var(--ease);
}
.btn:hover {
  background: var(--bg-3);
}
.btn-primary {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--bg);
}
.btn-primary:hover {
  background: var(--ink-2);
}
.btn:disabled {
  opacity: 0.5;
  cursor: progress;
}
.hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* ── 상태(불러오는 중·빈 날·실패) ── */
.state {
  padding: 64px 0;
  text-align: center;
  color: var(--ink-2);
}
.state p {
  margin: 0 0 16px;
}
.skel {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  padding: 32px 0;
}
.skel i {
  display: block;
  height: 14px;
  margin-bottom: 12px;
  border-radius: var(--r-bar);
  background: var(--bg-2);
}
.skel i:nth-child(1) {
  width: 40%;
  height: 20px;
}
.skel i:nth-child(3) {
  width: 85%;
}
.skel i:nth-child(4) {
  width: 60%;
}

.day-foot[hidden] {
  display: none;
}
.day-foot {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 40px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

/* ── 일기 쓰기 ── */
.write-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 40px 0 24px;
}
.write-head h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.3;
  letter-spacing: -0.02em;
}
.write-head a {
  font-size: 14px;
  color: var(--ink-2);
}
.write-form {
  display: grid;
  gap: 20px;
}
.write-meta {
  display: grid;
  grid-template-columns: minmax(0, 180px) minmax(0, 1fr);
  gap: 16px;
}
.write-title {
  font-size: 20px;
  font-weight: 700;
}
.write-body {
  min-height: 52vh;
  font-size: 18px;
  line-height: 1.85;
  padding: 16px;
}
.vis {
  display: inline-flex;
  margin: 0;
  padding: 4px;
  border: 1px solid var(--line-2);
  border-radius: calc(var(--r-control) + 4px);
}
.vis legend {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}
.vis label {
  position: relative;
}
.vis input {
  position: absolute;
  opacity: 0;
  inset: 0;
}
.vis span {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 12px;
  border-radius: var(--r-control);
  font-size: 14px;
  color: var(--ink-2);
  cursor: pointer;
}
.vis input:checked + span {
  background: var(--ink);
  color: var(--bg);
}
.vis input:focus-visible + span {
  outline: 2px solid var(--glow-text);
  outline-offset: 2px;
}
.write-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0 calc(12px + env(safe-area-inset-bottom));
  background: var(--bg);
  border-top: 1px solid var(--line);
}
.write-actions .btns {
  display: flex;
  gap: 8px;
}
.mine {
  margin-top: 56px;
}
.mine h2 {
  margin: 0 0 8px;
  font-size: 17px;
}
.mine ul {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line-2);
}
.mine li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.mine .m-text {
  flex: 1;
  min-width: 0;
  text-decoration: none;
}
.mine .m-date {
  display: block;
  font-size: 12px;
  color: var(--ink-3);
}
.mine .m-title {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
}
.mine .m-acts {
  display: flex;
  gap: 4px;
}
.mine .m-acts .act {
  min-height: 36px;
}
.login {
  padding: 64px 0;
  text-align: center;
}
.login p {
  margin: 0 0 16px;
  color: var(--ink-2);
}

@media (max-width: 560px) {
  :root {
    --rail: 0px;
  }
  .entry {
    grid-template-columns: minmax(0, 1fr);
    padding-top: 28px;
  }
  .entry::before {
    display: none;
  }
  .entry-time {
    padding: 0 0 0 16px;
    margin-bottom: 8px;
  }
  .entry-time::before {
    top: 7px;
  }
  .entry-time small {
    display: inline;
    margin-left: 4px;
  }
  .skel {
    grid-template-columns: minmax(0, 1fr);
  }
  .day-step .lbl-long {
    display: none;
  }
  .write-meta {
    grid-template-columns: minmax(0, 1fr);
  }
  .write-body {
    min-height: 56vh;
    font-size: 17px;
  }
}

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

/* ── 아티클 쓰기(blog/write.html)에서 더 쓰는 것 ── */
.write-summary {
  min-height: 0;
  font-size: 16px;
  line-height: 1.65;
}
.body-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.write-preview {
  min-height: 52vh;
  margin-top: 0;
  padding: 16px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-control);
}
.write-preview[hidden],
.write-body[hidden] {
  display: none;
}
