:root {
  color-scheme: light;
  font-family: system-ui, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  color: #16253d;
  background: #fff;
  --surface: #fff;
  --ink: #16253d;
  --muted: #52617a;
  --line: #dce5f1;
  --primary: #19345c;
  --on-primary: #fff;
  --accent: #2b58a8;
  --tile: #ebf2ff;
  --surface-tint: #f4f7fc;
  --green: #216345;
  --green-bg: #edf8f2;
  --notice: #735124;
  --notice-bg: #fff7e7;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: radial-gradient(ellipse at 50% 6%, #f1f6ff 0%, transparent 53%) no-repeat;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .48; }
:focus-visible { outline: 2px solid #3c6ac4; outline-offset: 3px; }
svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  width: 24px;
  height: 24px;
  flex: none;
}

.shell {
  width: min(100%, 750px);
  height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: max(12px, env(safe-area-inset-top)) clamp(16px, 4vw, 28px) max(12px, env(safe-area-inset-bottom));
}
.header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex: none;
  color: var(--ink);
  padding: 0 0 10px;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; color: var(--primary); font-size: 1.02rem; font-weight: 750; }
.brand img { display: block; object-fit: contain; }
.brand span { border-left: 1px solid var(--line); padding-left: 9px; }
.icon-button {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 14px;
}
.icon-button:hover:not(:disabled) { background: var(--tile); }
.icon-button svg { width: 21px; height: 21px; }
.menu {
  position: absolute;
  z-index: 2;
  top: 100%;
  left: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 15px;
  box-shadow: 0 12px 30px #142c5024;
  padding: 5px;
}
.menu button { display: block; width: 100%; min-height: 43px; padding: 8px 14px; border: 0; background: none; text-align: left; }
.menu button:hover { background: var(--surface-tint); border-radius: 10px; }
.connection-row { text-align: center; margin: 12px 0 10px; flex: none; }
.connection {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: .8rem;
  font-weight: 680;
  color: var(--notice);
  background: var(--notice-bg);
  border-radius: 30px;
  padding: 6px 12px;
  border: 1px solid #f2e8d1;
}
.connection::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.connection.ready { color: var(--green); background: var(--green-bg); border-color: #d7eddf; }

.login {
  width: min(100%, 440px);
  margin: clamp(12px, 5vh, 48px) auto 0;
  border-radius: 28px;
  border: 1px solid var(--line);
  padding: clamp(19px, 5.5vw, 32px);
  overflow-y: auto;
  background: var(--surface);
  box-shadow: 0 18px 48px #23416b12;
}
.login-art {
  display: grid;
  place-items: center;
  height: clamp(64px, 11vh, 96px);
  margin-bottom: 20px;
  background: radial-gradient(ellipse at 54% 68%, #e7f0ff, #f7faff 70%);
  border-radius: 18px;
  overflow: hidden;
}
.login-art img { width: 100%; height: 100%; object-fit: cover; }
.login h1, .welcome h1 { margin: 0; color: var(--ink); letter-spacing: -.045em; }
.login p, .welcome p { color: var(--muted); }
.login h1 { font-size: clamp(1.7rem, 5.5vw, 2rem); line-height: 1.22; }
.login p { margin: 8px 0 24px; }
.login form, .login label { display: grid; gap: 8px; }
.login form { gap: 16px; }
.login label { font-size: .9rem; font-weight: 660; }
.login input {
  border: 1px solid var(--line);
  border-radius: 13px;
  min-width: 0;
  padding: 12px 14px;
  min-height: 48px;
  background: var(--surface-tint);
  font-size: 1rem;
}
.login input:focus { background: var(--surface); }
.primary { min-height: 48px; border: 0; border-radius: 14px; padding: 9px 14px; background: var(--primary); color: var(--on-primary); font-weight: 700; }
.primary:hover:not(:disabled), .send:hover:not(:disabled) { background: var(--accent); }
.chat { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.scroll-area { min-height: 0; flex: 1; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.welcome { text-align: center; padding: 4px 8px clamp(21px, 4vh, 30px); }
.wave { display: block; width: 100%; height: clamp(100px, 18vh, 166px); margin: 0 auto 8px; }
.welcome h1 { text-wrap: balance; font-size: clamp(1.75rem, 5.4vw, 2.65rem); line-height: 1.2; }
.welcome p { margin: 8px 0 0; font-size: .93rem; line-height: 1.5; }
.modes {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  background: var(--surface-tint);
  border: 1px solid var(--line);
  border-radius: 17px;
}
.modes button {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 46px;
  padding: 6px 4px;
  border: 0;
  border-radius: 12px;
  color: var(--muted);
  background: transparent;
  font-weight: 690;
}
.modes svg { width: 17px; height: 17px; }
.modes button:hover[aria-pressed="false"] { color: var(--accent); background: var(--surface); }
.modes [aria-pressed="true"] { color: var(--on-primary); background: var(--primary); box-shadow: 0 2px 6px #19345c28; }
.mode-help { color: var(--muted); text-align: center; font-size: .83rem; margin: 9px 0 18px; }
.starters { display: grid; gap: 10px; padding-bottom: 12px; }
.starters button {
  min-width: 0;
  min-height: 69px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 13px;
  align-items: center;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  padding: 10px 14px;
  box-shadow: 0 3px 10px #2b477b08;
}
.starters button:hover { border-color: #8da8d7; background: #fafcff; }
.starters strong, .starters small { display: block; overflow-wrap: anywhere; }
.starters strong { font-size: .98rem; }
.starters small { margin-top: 3px; color: var(--muted); font-size: .83rem; }
.tile { display: grid; place-items: center; background: var(--tile); color: var(--accent); border-radius: 13px; width: 43px; height: 43px; }
.tile svg { width: 22px; height: 22px; }
.arrow { color: var(--accent); font-size: 26px; }
.messages { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; margin: 0 0 12px; }
.bubble {
  max-width: 88%;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.55;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 17px 17px 17px 6px;
  padding: 11px 14px;
}
.bubble.user { align-self: flex-end; background: var(--tile); border-radius: 17px 17px 6px 17px; }
.bubble small { display: block; margin-bottom: 3px; color: var(--muted); font-size: .78rem; font-weight: 650; }
.notice { border-radius: 13px; padding: 10px 13px; background: var(--notice-bg); color: var(--notice); font-size: .86rem; }
.composer {
  display: flex;
  align-items: end;
  gap: 8px;
  padding: 6px 7px 6px 17px;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 23px;
  background: var(--surface);
  box-shadow: 0 5px 20px #23416b1a;
}
.composer:focus-within { border-color: #8da8d7; }
.composer textarea {
  flex: 1;
  min-width: 0;
  min-height: 43px;
  max-height: 112px;
  resize: none;
  background: transparent;
  border: none;
  padding: 10px 0;
  line-height: 23px;
}
.composer textarea::placeholder { color: var(--muted); }
.send {
  display: grid;
  place-items: center;
  background: var(--primary);
  color: var(--on-primary);
  flex: none;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
}
dialog { width: min(92%, 410px); border: 1px solid var(--line); border-radius: 22px; background: var(--surface); color: var(--ink); padding: 22px; box-shadow: 0 18px 48px #1b305a30; }
dialog::backdrop { background: #20354d59; }
dialog h2 { margin: 0; font-size: 1.18rem; }
dialog p { color: var(--muted); line-height: 1.6; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.dialog-actions button:not(.primary) { background: var(--surface-tint); border: none; border-radius: 13px; padding: 9px 14px; }

@media (max-width: 355px) {
  .modes svg { display: none; }
  .starters button { gap: 8px; }
}
@media (max-height: 695px) {
  .wave { height: 78px; }
  .login { margin-top: 12px; }
  .login-art { margin-bottom: 14px; }
}
