/* 흑백: 어두운 회랑과 끝의 흰 빛. 입력창은 둥근 어두운 유리, 답은 흰 말풍선. */
@import url("https://fonts.googleapis.com/css2?family=Gowun+Batang:wght@400;700&family=Gowun+Dodum&display=swap");
:root {
  --black: #050505;
  --ink: #111111;
  --ink-soft: #555555;
  --marble: #efefed;
  --marble-edge: #cdcdcb;
  --glass: rgba(8, 8, 8, .58);
  --glass-edge: rgba(255, 255, 255, .22);
  --light: #f5f5f5;
  --light-soft: #b5b5b5;
  --serif: "Gowun Batang", "Noto Serif KR", "Nanum Myeongjo", "AppleMyungjo", "Batang", "Times New Roman", serif;
  --sans: "Gowun Dodum", "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  --col: 600px;          /* 입력창·대화 폭: 구글 검색창 정도 */
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  font-family: var(--sans);
  color: var(--light);
  background: var(--black);
  line-height: 1.6;
}

.scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  display: block;
}

.page {
  max-width: 980px;
  margin: 0 auto;
  /* 메인: 제목+입력창 묶음을 화면 위에서 약 1/4 지점에 둔다 */
  padding: max(64px, 30vh) 20px 28px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; }

/* 머리글 */
.masthead { text-align: center; color: var(--light); margin-bottom: 36px; text-shadow: 0 2px 16px rgba(0, 0, 0, .8); }
.greek { margin: 0; font-family: var(--serif); letter-spacing: .6em; font-size: clamp(13px, 1.8vw, 16px); opacity: .7; padding-left: .6em; }
.masthead h1 { margin: 6px 0 8px; font-family: var(--serif); font-weight: 700; font-size: clamp(32px, 6vw, 56px); letter-spacing: .06em; }

/* 입력판: 어두운 유리 */
.tablet {
  position: relative;
  background: var(--glass);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid var(--glass-edge);
  border-radius: 22px;
  padding: 22px 22px 18px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .55);
  max-width: var(--col);
  margin: 0 auto;
}


.tablet h2 { font-family: var(--serif); margin: 6px 0 14px; font-size: 20px; }

textarea, input[type="password"], input[type="text"] {
  width: 100%;
  font: inherit;
  font-family: var(--serif);
  font-size: 18px;
  color: var(--light);
  background: rgba(255, 255, 255, .06);
  border: 1px solid var(--glass-edge);
  border-radius: 12px;
  padding: 12px 14px;
  margin-top: 6px;
  resize: vertical;
}
textarea::placeholder, input::placeholder { color: #8a8a8a; }

textarea:focus-visible, input:focus-visible, button:focus-visible, summary:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 2px;
}

/* 질문창: 채팅 앱처럼 둥근 입력창 안에 보내기 버튼 */
#ask { border-radius: 999px; padding: 6px 6px 6px 24px; }
#ask-form { display: flex; align-items: center; gap: 10px; }
#ask input { flex: 1; min-width: 0; background: none; border: 0; padding: 8px 0; margin: 0; font-size: 17px; }
#ask input:focus-visible { outline: none; }
#ask:focus-within { border-color: rgba(255, 255, 255, .5); }
.ask-row { flex: none; }

button {
  font: inherit;
  cursor: pointer;
  border: 0;
  border-radius: 999px;
  padding: 11px 22px;
  background: var(--light);
  color: var(--ink);
  font-weight: 700;
  letter-spacing: .04em;
  min-height: 44px;
}
button:hover { background: #ffffff; }
button:disabled { opacity: .5; cursor: progress; }

.chip {
  background: transparent;
  color: var(--light-soft);
  border: 1px solid var(--glass-edge);
  font-weight: 400;
  font-size: 13px;
  letter-spacing: 0;
  border-radius: 999px;
  padding: 6px 14px;
  min-height: 32px;
  text-align: left;
}
.chip:hover { background: rgba(255, 255, 255, .1); color: var(--light); }

.link { background: none; color: inherit; padding: 4px 0; min-height: 0; font-weight: 400; text-decoration: underline; text-underline-offset: 3px; }
.link:hover { background: none; opacity: .8; }

.remember { display: flex; gap: 8px; align-items: center; margin: 12px 0; font-size: 14px; color: var(--light-soft); }
.error { color: var(--light); font-weight: 700; min-height: 1.4em; margin: 10px 0 0; font-size: 14px; }
.fineprint { font-size: 13px; color: var(--light-soft); margin: 6px 0 0; }

/* 대화 */
.thread { max-width: var(--col); margin: 0 auto 44px; }
.messages { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 28px; }

.msg { display: flex; gap: 14px; align-items: flex-start; scroll-margin-bottom: 190px; animation: enter .35s ease both; }
@keyframes enter { from { opacity: 0; transform: translateY(10px); } }

.msg .body { min-width: 0; max-width: min(560px, 82%); }
.bubble { margin: 0; padding: 11px 15px; border-radius: 4px 16px 16px 16px; line-height: 1.65; overflow-wrap: anywhere; }

.msg.me { justify-content: flex-end; }
.msg.me .bubble {
  max-width: min(520px, 82%);
  background: var(--glass);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid var(--glass-edge);
  color: var(--light);
  border-radius: 16px 4px 16px 16px;
  font-family: var(--serif);
}

.msg.sage .bubble {
  background: linear-gradient(180deg, #fafafa, var(--marble));
  color: var(--ink);
  font-family: var(--serif);
  font-size: 16.5px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, .5);
}

.avatar {
  flex: none;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  object-fit: cover;
  object-position: 50% 22%;
  filter: grayscale(1) contrast(1.08);
  border: 1px solid rgba(255, 255, 255, .45);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .6);
  background: #1a1a1a;
}
.avatar.mono { display: grid; place-items: center; color: var(--light); font-family: var(--serif); font-weight: 700; font-size: 19px; }

.who { margin: 2px 0 8px; display: flex; align-items: baseline; gap: 8px; color: var(--light); text-shadow: 0 1px 8px rgba(0, 0, 0, .9); font-size: 14px; }
.who b { font-family: var(--serif); font-size: 15.5px; }
.who .meta { font-size: 12px; color: var(--light-soft); }
.concept { margin: 9px 0 0 4px; font-size: 12px; color: var(--light-soft); letter-spacing: .06em; text-shadow: 0 1px 6px rgba(0, 0, 0, .9); }
.concept::before { content: "— "; }

.typing .bubble { display: inline-flex; gap: 5px; padding: 15px 16px; }
.typing .who { font-size: 13px; color: var(--light-soft); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: #555555; animation: blink 1.2s infinite ease-in-out; }
.dot:nth-child(2) { animation-delay: .15s; }
.dot:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; transform: none; } 40% { opacity: 1; transform: translateY(-3px); } }

.msg.note { justify-content: center; margin-top: 4px; }
.msg.error { color: var(--light); font-weight: 700; text-shadow: 0 1px 8px rgba(0, 0, 0, .9); }
.msg.again .chip { background: rgba(0, 0, 0, .45); color: var(--light); }

/* 대화가 시작되면 머리글은 줄이고, 질문판은 화면 아래에 붙는다 */
body.chatting { --col: 680px; }
body.chatting .scene { filter: brightness(.6); }
.scene { transition: filter 1.2s ease; }
body.chatting .page { padding-top: 36px; }
body.chatting .masthead { margin-bottom: 52px; }
body.chatting .masthead h1 { font-size: clamp(22px, 3.6vw, 30px); margin: 2px 0 0; }
body.chatting #ask { position: sticky; bottom: 20px; z-index: 2; margin-bottom: 0; }

/* 지난 질문 */
.history {
  max-width: var(--col);
  margin: 28px auto 0;
  background: var(--glass);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid var(--glass-edge);
  border-radius: 18px;
  padding: 10px 20px;
}
.history summary { cursor: pointer; font-family: var(--serif); font-weight: 700; padding: 4px 0; }
.history ul { list-style: none; padding: 0; margin: 8px 0; }
.history li button {
  width: 100%;
  text-align: left;
  background: none;
  color: var(--light-soft);
  font-weight: 400;
  letter-spacing: 0;
  padding: 8px 0;
  min-height: 0;
  border-bottom: 1px dashed var(--glass-edge);
  border-radius: 0;
}
.history li button:hover { color: var(--light); background: none; }

.foot {
  margin-top: 40px;
  text-align: center;
  font-size: 12.5px;
  color: var(--light-soft);
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

[hidden] { display: none !important; }

@media (max-width: 600px) {
  .tablet { padding: 20px 16px 16px; }
  .avatar { width: 38px; height: 38px; }
  .msg .body { max-width: calc(100% - 50px); }
}

.credits { font-size: 12px; max-width: 640px; }
.credits summary { cursor: pointer; }
.credits ul { text-align: left; padding-left: 18px; margin: 8px 0 0; line-height: 1.7; }
.credits a { color: inherit; }

@media (prefers-reduced-motion: reduce) {
  .msg, .dot { animation: none; }
}
