:root {
  --ink: #1E2A44;        /* 쪽빛 */
  --sun: #FFC53D;        /* 햇살 */
  --sun-soft: #FFF1C7;
  --jujube: #A23B2A;     /* 대추 */
  --leaf: #2C6E54;
  --ground: #EEF2EF;
  --paper: #FFFFFF;
  --line: #D3DAD6;
  --muted: #55607A;
  --display: "Gowun Batang", "Nanum Myeongjo", "Batang", serif;
  --body: "IBM Plex Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  --tabbar-h: 78px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--body);
  line-height: 1.6;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.app {
  max-width: 540px;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--ground);
  display: flex;
  flex-direction: column;
}

/* 상단 */
.top {
  background: var(--ink);
  color: #fff;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.top-name { display: flex; flex-direction: column; line-height: 1.3; }
.wordmark { font-family: var(--display); font-size: 1.45rem; color: var(--sun); }
.cafe { font-size: 0.85rem; color: #D9DEEA; }
.demo-badge {
  font-size: 0.8rem;
  border: 1.5px solid #8590AB;
  color: #D9DEEA;
  border-radius: 999px;
  padding: 2px 12px;
  white-space: nowrap;
}

main { flex: 1; padding: 24px 20px calc(var(--tabbar-h) + 40px + env(safe-area-inset-bottom)); }

h1 {
  font-family: var(--display);
  font-size: 1.75rem;
  line-height: 1.35;
  margin: 0 0 20px;
}
.today { margin: 0 0 4px; color: var(--muted); font-weight: 500; }

/* 마이크: 햇살 */
.mic-wrap { display: flex; justify-content: center; padding: 26px 0 8px; }
.mic {
  position: relative;
  width: 168px;
  height: 168px;
  border-radius: 50%;
  border: 0;
  background: var(--sun);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.mic svg, .mic .mic-label { position: relative; }
.rays {
  position: absolute;
  inset: -22px;
  border-radius: 50%;
  background: repeating-conic-gradient(var(--sun) 0 6deg, transparent 6deg 30deg);
  -webkit-mask: radial-gradient(circle, transparent 0 62%, #000 63% 100%);
          mask: radial-gradient(circle, transparent 0 62%, #000 63% 100%);
  opacity: 0.55;
}
.mic[aria-pressed="true"] { background: var(--jujube); color: #fff; }
.mic[aria-pressed="true"] .rays {
  background: repeating-conic-gradient(var(--jujube) 0 6deg, transparent 6deg 30deg);
  opacity: 0.8;
  animation: turn 6s linear infinite;
}
@keyframes turn { to { transform: rotate(360deg); } }

.status { min-height: 1.6em; margin: 14px 0 10px; text-align: center; color: var(--leaf); font-weight: 500; }

/* 입력 */
.field-label { display: block; font-weight: 500; margin: 0 0 8px; }
textarea, input[type="text"] {
  width: 100%;
  font: inherit;
  font-size: 1.1rem;
  color: var(--ink);
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 10px;
  padding: 14px 16px;
  resize: vertical;
}
textarea::placeholder, input::placeholder { color: #7A8399; }

.btn {
  display: block;
  width: 100%;
  min-height: 62px;
  margin-top: 12px;
  padding: 12px 18px;
  font: inherit;
  font-size: 1.15rem;
  font-weight: 700;
  border-radius: 10px;
  border: 2px solid var(--ink);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn.primary { background: var(--ink); color: #fff; }
.btn.ghost { background: transparent; color: var(--ink); font-weight: 500; min-height: 54px; }
.btn.sun { background: var(--sun); color: var(--ink); }
.btn.done { background: var(--leaf); border-color: var(--leaf); color: #fff; }
.btn:disabled { opacity: 0.6; cursor: default; }

:focus-visible { outline: 4px solid var(--jujube); outline-offset: 3px; }

/* 일지 카드: 장부 한 쪽 */
.entry {
  margin-top: 28px;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 6px;
  overflow: hidden;
}
.entry-head {
  background: var(--sun);
  padding: 12px 18px;
  font-family: var(--display);
  font-size: 1.25rem;
}
.entry dl { margin: 0; }
.entry .row {
  display: grid;
  grid-template-columns: 7.2em 1fr;
  align-items: baseline;
  gap: 10px;
  padding: 14px 18px;
  border-top: 1.5px solid var(--line);
}
.entry dt { color: var(--muted); font-weight: 500; }
.entry dd { margin: 0; font-size: 1.3rem; font-weight: 700; }
.entry dd.missing { font-size: 1rem; font-weight: 400; color: var(--jujube); }
.entry .said {
  margin: 0;
  padding: 14px 18px;
  border-top: 1.5px solid var(--line);
  color: var(--muted);
  font-size: 0.95rem;
}
.entry .actions { padding: 4px 18px 18px; }
.note { color: var(--muted); font-size: 0.9rem; margin: 12px 0 0; }

.saved-title { font-family: var(--display); font-size: 1.2rem; margin: 32px 0 0; }
.entry.small { margin-top: 12px; }

/* 홍보물 탭 */
.ptabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin-top: 28px;
  border: 2px solid var(--ink);
  border-radius: 10px 10px 0 0;
  overflow: hidden;
  background: var(--paper);
}
.ptabs button {
  font: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  min-height: 60px;
  padding: 6px 2px;
  border: 0;
  border-left: 1.5px solid var(--line);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  line-height: 1.25;
}
.ptabs button:first-child { border-left: 0; }
.ptabs button[aria-selected="true"] { background: var(--ink); color: #fff; font-weight: 700; }
.ppanel {
  border: 2px solid var(--ink);
  border-top: 0;
  border-radius: 0 0 10px 10px;
  background: var(--paper);
  padding: 18px;
}
.ptext { margin: 0; font: inherit; font-size: 1.05rem; white-space: pre-wrap; }
.ptext.poster {
  background: var(--ink);
  color: #fff;
  text-align: center;
  padding: 30px 18px;
  border-radius: 4px;
  line-height: 1.9;
}
.ptext.poster::first-line { font-family: var(--display); font-size: 1.7rem; color: var(--sun); }
.ptext.banner {
  background: var(--sun);
  text-align: center;
  font-weight: 700;
  font-size: 1.2rem;
  padding: 22px 14px;
  border-top: 6px solid var(--ink);
  border-bottom: 6px solid var(--ink);
}

/* 보고서 */
.doc {
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 6px;
  padding: 24px 20px;
}
.doc h1 { font-size: 1.55rem; margin-bottom: 6px; }
.doc .basis { margin: 0 0 6px; color: var(--muted); }
.doc .hint { margin: 0; background: var(--sun-soft); padding: 10px 14px; border-radius: 6px; font-size: 0.95rem; }
.doc h2 {
  font-family: var(--display);
  font-size: 1.25rem;
  margin: 30px 0 10px;
  padding-top: 18px;
  border-top: 2px solid var(--ink);
}
.doc p { margin: 0 0 8px; }
.big { font-size: 1.15rem; }
.doc ul, .doc ol { margin: 0; padding-left: 1.3em; }
.doc li { margin-bottom: 12px; }
.doc li strong { display: block; font-size: 1.1rem; }

.num {
  font: inherit;
  font-weight: 700;
  color: var(--jujube);
  background: var(--sun-soft);
  border: 0;
  border-bottom: 3px solid var(--jujube);
  border-radius: 4px 4px 0 0;
  padding: 2px 8px;
  margin: 2px 1px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.num.xl { font-size: 2.2rem; padding: 2px 12px; line-height: 1.3; }

/* 근거 일지 */
dialog {
  width: min(540px, 100%);
  max-width: 100%;
  max-height: 86dvh;
  margin: auto auto 0;
  padding: 22px 20px calc(20px + env(safe-area-inset-bottom));
  border: 0;
  border-top: 6px solid var(--sun);
  border-radius: 16px 16px 0 0;
  background: var(--paper);
  color: var(--ink);
  overflow-y: auto;
}
dialog::backdrop { background: rgba(30, 42, 68, 0.6); }
.ev-head h2 { font-family: var(--display); font-size: 1.35rem; margin: 0 0 6px; }
.ev-head p { margin: 0 0 14px; color: var(--muted); }
#ev-list { list-style: none; margin: 0; padding: 0; }
#ev-list li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  padding: 14px 0;
  border-top: 1.5px solid var(--line);
}
#ev-close { position: sticky; bottom: 0; }
#ev-list .d { font-weight: 700; }
#ev-list .v { font-weight: 700; color: var(--jujube); text-align: right; white-space: nowrap; }
#ev-list .q { grid-column: 1 / -1; color: var(--muted); font-size: 0.95rem; }

/* 하단 탭 */
.tabbar {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(540px, 100%);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--paper);
  border-top: 2px solid var(--ink);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 5;
}
.tabbar a {
  min-height: var(--tabbar-h);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  border-top: 5px solid transparent;
  -webkit-tap-highlight-color: transparent;
}
.tabbar a[aria-current="page"] {
  color: var(--ink);
  font-weight: 700;
  border-top-color: var(--sun);
  background: var(--sun-soft);
}
.tabbar a:focus-visible { outline-offset: -4px; }

@media (max-width: 360px) {
  html { font-size: 17px; }
  .tabbar a { font-size: 0.82rem; }
}

@media (prefers-reduced-motion: reduce) {
  .mic[aria-pressed="true"] .rays { animation: none; }
}
