/* Sori 자치구역. 말꾸 네비는 코랄, 방 안은 청록 AI 셸. */
body.sori-stage {
  --sori-core: #2dd4bf;
  --sori-core-deep: #14b8a6;
  --sori-accent: #7dd3fc;
  --sori-ink: #0c29ab;
  --sori-paper: #fffbf8;
  --sori-wash: #ffdcbc;
}

.sori-app {
  --coral: var(--sori-core);
  --coral-dim: rgba(45, 212, 191, 0.16);
  --coral-glow: rgba(45, 212, 191, 0.28);
  --ink: #f4f1f8;
  --muted: #9aa3b2;
  --line: rgba(255, 255, 255, 0.1);
  --bg-card: transparent;
  color: var(--ink);
}

.sori-app a:hover { color: var(--sori-core); }

body.sori-stage {
  overflow: hidden;
  height: 100%;
}

html:has(body.sori-stage) {
  height: 100%;
}

body.sori-stage .page-wrapper {
  flex: 1 1 auto;
  min-height: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

body.sori-stage .malggu-footer,
body.sori-stage #malggu-footer {
  display: none !important;
}

.sori-app {
  position: relative;
  z-index: 2;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  width: 100%;
  margin: 0;
  padding: 0;
  gap: 0;
}

.sidebar {
  width: 260px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 10px 16px;
  background: rgba(8, 8, 12, 0.72);
  border: 0;
  border-right: 1px solid var(--line);
}

.sidebar.closed { display: none; }

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 10px;
}
.logo {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--coral-dim);
  color: var(--sori-core);
  border: 1px solid rgba(45, 212, 191, 0.4);
  display: grid;
  place-items: center;
  font-weight: 800;
}
.brand strong { display: block; font-size: 15px; }
.brand span { color: var(--muted); font-size: 12px; }

.new-chat {
  border: 0;
  background: transparent;
  color: var(--ink);
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}
.new-chat:hover { background: rgba(255, 255, 255, 0.06); }

.history-label {
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 8px;
}
.history-clear {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 11px;
  letter-spacing: 0;
  text-transform: none;
  cursor: pointer;
  padding: 0;
}
.history-clear:hover { color: var(--coral); }
.fold-label {
  width: 100%;
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 8px;
  border: 0;
  background: transparent;
  font: inherit;
  cursor: pointer;
}
.fold-label:hover { color: var(--ink); }
.fold-caret {
  font-size: 10px;
  transition: transform 0.15s ease;
}
.tools-box.folded .tool-list { display: none; }
.tools-box.folded .fold-caret { transform: rotate(-90deg); }
.history { flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 2px; }
.history-row {
  display: flex;
  align-items: center;
  gap: 2px;
  border-radius: 10px;
}
.history-row.on, .history-row:hover { background: rgba(255, 255, 255, 0.06); }
.history-open {
  flex: 1;
  min-width: 0;
  text-align: left;
  border: 0;
  background: transparent;
  border-radius: 10px;
  padding: 8px 10px;
  font: inherit;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-del {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border: 0;
  background: transparent;
  border-radius: 8px;
  color: var(--muted);
  font: inherit;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.history-del:hover { color: var(--ink); background: rgba(255, 255, 255, 0.08); }

.sidebar-foot { font-size: 12px; color: var(--muted); padding: 10px 8px 0; }
.sidebar-foot a { color: var(--sori-core); text-decoration: none; font-weight: 650; }
.login-cta {
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
}
.login-cta p { margin: 0 0 10px; line-height: 1.45; }
.login-cta .login-btn {
  display: block;
  text-align: center;
  border-radius: 999px;
  padding: 8px 12px;
  background: #fff;
  color: #111;
  font-weight: 700;
}
.login-cta .login-btn[hidden] {
  display: none;
}
.login-cta .login-btn:hover { color: #111; background: #f3f3f3; }

.sori-backdrop {
  display: none;
  border: 0;
  padding: 0;
  background: rgba(5, 5, 9, 0.55);
}

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: transparent;
  border: 0;
  overflow: hidden;
}

.main.is-home {
  display: grid;
  grid-template-rows: 56px 1fr auto 1.2fr;
  grid-template-columns: 1fr;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  position: relative;
  z-index: 5;
}
.sori-nav-fold {
  margin-left: auto;
  flex-shrink: 0;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  color: #e8d48a;
  border-radius: 999px;
  padding: 6px 12px;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  z-index: 6;
}
.sori-nav-fold:hover {
  background: rgba(232, 212, 138, 0.16);
  color: #fff;
}
body.sori-nav-min .malggu-nav,
body.sori-nav-min #malggu-nav > .malggu-nav {
  display: none !important;
}
.main.is-home .topbar {
  grid-row: 1;
}
.model-name {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.icon-btn {
  display: none;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
  border-radius: 10px;
  width: 36px;
  height: 36px;
  cursor: pointer;
}
.engine-pill { display: none; }

.thread {
  flex: 1;
  overflow: auto;
  padding: 20px 20px 28px;
  background: none;
}
.main.is-home .thread {
  grid-row: 2;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  overflow: hidden;
  padding: 0 20px 12px;
}

.empty {
  max-width: 720px;
  width: 100%;
  margin: 0;
  text-align: center;
}
.home-hello {
  margin: 0;
  font-size: clamp(1.7rem, 3.6vw, 2.15rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  color: #fff;
}

.msg {
  max-width: 720px;
  margin: 0 auto 28px;
  display: block;
}
.msg.user {
  display: flex;
  justify-content: flex-end;
}
.avatar { display: none; }
.msg-body { min-width: 0; max-width: 100%; }
.msg.user .msg-body {
  flex: 0 1 auto;
  width: fit-content;
  max-width: 80%;
}
.bubble {
  background: none;
  border: 0;
  border-radius: 0;
  padding: 0;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  color: #ececec;
  font-size: 16px;
}
.msg.user .bubble {
  display: inline-block;
  width: fit-content;
  max-width: 100%;
  background: #2f2f2f;
  color: #fff;
  border-radius: 22px;
  padding: 10px 16px;
  font-weight: 400;
}
.bubble b, .bubble strong { font-weight: 750; }
.bubble mark {
  background: rgba(45, 212, 191, 0.18);
  color: inherit;
  padding: 0 0.15em;
  border-radius: 4px;
}
.msg.user .bubble mark {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.practice-chip {
  max-width: 768px;
  margin: 0 auto 8px;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--sori-core);
  background: var(--coral-dim);
  border: 1px solid rgba(45, 212, 191, 0.28);
  border-radius: 999px;
  padding: 6px 12px;
}
.composer-wrap {
  padding: 0 16px 18px;
}
.main.is-home .composer-wrap {
  grid-row: 3;
  padding: 0 20px;
}

.composer {
  max-width: 768px;
  margin: 0 auto;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  background: #2f2f2f;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 28px;
  padding: 10px 10px 10px 18px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28);
}
.composer:focus-within {
  border-color: rgba(45, 212, 191, 0.45);
}
.composer textarea {
  flex: 1;
  border: 0;
  resize: none;
  font: inherit;
  line-height: 1.5;
  min-height: 28px;
  max-height: 160px;
  background: transparent;
  color: var(--ink);
  outline: none;
}
.composer textarea::placeholder { color: #8b8b8b; }
.composer button {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  color: #111;
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
}
.composer button:disabled {
  background: rgba(255, 255, 255, 0.1);
  color: #6b6b6b;
  cursor: default;
}
.composer button:not(:disabled) {
  background: var(--sori-core);
  color: #0c29ab;
}

.modes {
  display: none;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  max-width: 768px;
  margin: 12px auto 0;
  padding: 0;
  background: none;
  border: 0;
}
.sori-app:not(.is-home) .modes {
  display: none;
}
.modes button {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  border-radius: 999px;
  padding: 7px 14px;
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  color: var(--muted);
  cursor: pointer;
}
.modes button.on {
  background: var(--coral-dim);
  color: #fff;
  border-color: rgba(45, 212, 191, 0.4);
}

.tool-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0 0 8px;
}
.tool-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--ink);
  border-radius: 10px;
  padding: 8px 10px;
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.tool-row:hover { background: rgba(255, 255, 255, 0.06); }
.tool-ico {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 800;
  flex-shrink: 0;
}
.tool-ico.tone-teal { background: rgba(45, 212, 191, 0.2); color: #2dd4bf; }
.tool-ico.tone-sky { background: rgba(125, 211, 252, 0.18); color: #7dd3fc; }
.tool-ico.tone-gold { background: rgba(255, 220, 188, 0.2); color: #ffdcbc; }
.tool-ico.tone-violet { background: rgba(167, 139, 250, 0.2); color: #c4b5fd; }

.hint {
  display: none;
}
.sori-app:not(.is-home) .hint {
  display: none;
}

@media (max-width: 900px) {
  .sori-app { padding: 0; }
  .sidebar {
    position: fixed;
    top: var(--nav-h, 60px);
    left: 0;
    bottom: 0;
    z-index: 20;
    display: flex;
  }
  .sidebar.closed { display: none; }
  .sori-backdrop:not([hidden]) {
    display: block;
    position: fixed;
    inset: var(--nav-h, 60px) 0 0;
    z-index: 19;
  }
  .icon-btn { display: inline-grid; place-items: center; }
}

@media (min-width: 901px) {
  .sidebar.closed { display: none; }
}
