:root {
  color-scheme: only light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --sidebar: #ffffff;
  --sidebar-soft: #f1f5f9;
  --sidebar-hover: #e8edf5;
  --sidebar-active: #dbeafe;
  --sidebar-border: #d9dee7;
  --sidebar-text-muted: #667085;
  --text: #1d2430;
  --muted: #667085;
  --line: #d9dee7;
  --accent: #1f6feb;
  --accent-dark: #1959bd;
  --assistant: #ffffff;
  --user: #e8f1ff;
  --toolbar: #ffffff;
  --chat-user: #edf4ff;
  --composer-bg: linear-gradient(180deg, rgba(246, 247, 249, 0.7), #f6f7f9 32%);
  --input-bg: #ffffff;
  --source-bg: #fbfcff;
  --avatar-bg: #263241;
  --menu-bg: #ffffff;
  --menu-hover: #f1f5f9;
  --shadow: rgba(16, 19, 24, 0.18);
  --chip-bg: #ffffff;
  --chip-hover: #eef2f7;
  --card-bg: #ffffff;
  --download-border: #eef2f7;
}

:root[data-theme="dark"] {
  --bg: #000000;
  --panel: #000000;
  --sidebar: #000000;
  --sidebar-soft: #101010;
  --sidebar-hover: #1a1a1a;
  --sidebar-active: #222222;
  --sidebar-border: #2b2b2b;
  --sidebar-text-muted: #9aa8bd;
  --text: #e5edf8;
  --muted: #9aa8bd;
  --line: #2b2b2b;
  --accent: #60a5fa;
  --accent-dark: #3b82f6;
  --assistant: #000000;
  --user: #000000;
  --toolbar: #000000;
  --chat-user: #000000;
  --composer-bg: #000000;
  --input-bg: #101010;
  --source-bg: #101010;
  --avatar-bg: #1f2937;
  --menu-bg: #111827;
  --menu-hover: #1f2937;
  --shadow: rgba(0, 0, 0, 0.38);
  --chip-bg: #182235;
  --chip-hover: #223049;
  --card-bg: #111827;
  --download-border: #263244;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000;
    --panel: #000000;
    --sidebar: #000000;
    --sidebar-soft: #101010;
    --sidebar-hover: #1a1a1a;
    --sidebar-active: #222222;
    --sidebar-border: #2b2b2b;
    --sidebar-text-muted: #9aa8bd;
    --text: #e5edf8;
    --muted: #9aa8bd;
    --line: #2b2b2b;
    --accent: #60a5fa;
    --accent-dark: #3b82f6;
    --assistant: #000000;
    --user: #000000;
    --toolbar: #000000;
    --chat-user: #000000;
    --composer-bg: #000000;
    --input-bg: #101010;
    --source-bg: #101010;
    --avatar-bg: #1f2937;
    --menu-bg: #111827;
    --menu-hover: #1f2937;
    --shadow: rgba(0, 0, 0, 0.38);
    --chip-bg: #182235;
    --chip-hover: #223049;
    --card-bg: #111827;
    --download-border: #263244;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.is-hidden {
  display: none !important;
}

.login-screen {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 28px;
  background: var(--bg);
}

.login-panel {
  display: grid;
  justify-items: center;
  width: min(100%, 440px);
  padding: 34px 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  text-align: center;
  box-shadow: 0 18px 50px var(--shadow);
}

.login-mark {
  width: 80px;
  height: 80px;
  margin-bottom: 18px;
}

.login-panel h1 {
  margin: 0;
  font-size: 25px;
  line-height: 1.35;
}

.login-panel p {
  margin: 10px 0 22px;
  color: var(--muted);
  line-height: 1.6;
}

.login-copy {
  width: 100%;
  max-width: 390px;
  word-break: keep-all;
}

.login-copy span {
  display: block;
}

.login-primary {
  max-width: 280px;
}

.webview-notice {
  margin-top: 18px;
  padding: 16px;
  border: 1px solid #e2a03f;
  border-radius: 8px;
  background: var(--panel);
  text-align: center;
  width: 100%;
}

.webview-notice p {
  margin: 0 0 12px;
  font-size: 14px;
  line-height: 1.6;
  color: #6b4e1b;
}

.copy-url-btn {
  display: block;
  margin: 8px auto 0;
  padding: 8px 20px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  font-size: 14px;
  cursor: pointer;
  color: var(--text);
}

.copy-url-hint {
  display: block;
  margin-top: 8px;
  font-size: 13px;
  color: #2e7d32;
}

.trial-note {
  margin-top: 14px;
  color: var(--accent-dark);
  font-size: 14px;
  font-weight: 800;
}

.login-panel small {
  margin-top: 14px;
  color: #7a8697;
  line-height: 1.5;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  background: var(--sidebar);
  color: var(--text);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
}

.brand-admin-btn {
  margin-left: auto;
  padding: 4px 10px;
  border: 1px solid var(--sidebar-border);
  border-radius: 6px;
  background: transparent;
  color: var(--sidebar-text-muted);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.brand-admin-btn:hover {
  color: var(--text);
  border-color: rgba(203, 213, 225, 0.42);
}

.brand-logo {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  object-fit: contain;
  forced-color-adjust: none;
  -webkit-filter: none;
  filter: none;
}

.brand-logo.login-mark {
  width: 80px;
  height: 80px;
}

:root[data-theme="dark"] .brand-logo {
  -webkit-filter: invert(1);
  filter: invert(1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brand-logo {
    -webkit-filter: invert(1);
    filter: invert(1);
  }
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 15px;
}

.brand small {
  margin-top: 2px;
  color: var(--sidebar-text-muted);
  font-size: 12px;
}

.sidebar-auth {
  position: relative;
  margin-top: 0;
  padding: 0;
  border: 0;
  border-radius: 8px;
}

.credit-panel {
  display: grid;
  gap: 6px;
  margin-top: auto;
  padding: 10px;
  border: 1px solid var(--sidebar-border);
  border-radius: 8px;
  background: var(--sidebar-soft);
}

.credit-line {
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
}

.credit-meter {
  width: 100%;
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(203, 213, 225, 0.16);
}

.credit-meter span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.credit-extra {
  color: var(--sidebar-text-muted);
  font-size: 11px;
}

.infinity-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  color: #ffffff;
  font-size: 18px;
  line-height: 1;
  vertical-align: -1px;
}

.google-login {
  width: 100%;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: #4285f4;
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.google-login:hover {
  background: #3367d6;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0;
  color: var(--text);
  font-size: 12px;
}

.user-menu-trigger {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
  min-height: 40px;
  gap: 8px;
  padding: 8px 9px;
  border: 0;
  border-radius: 8px;
  background: var(--sidebar-soft);
  color: var(--text);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  text-align: left;
}

.user-menu-trigger:hover,
.user-menu-trigger[aria-expanded="true"] {
  background: var(--sidebar-hover);
}

.user-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
}

.user-menu-trigger span {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logout-btn {
  min-height: 40px;
  padding: 0 8px;
  border: 0;
  border-radius: 8px;
  background: var(--sidebar-soft);
  color: var(--sidebar-text-muted);
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.logout-btn:hover {
  background: var(--sidebar-hover);
  color: var(--text);
}

.account-menu {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 8px);
  z-index: 30;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--menu-bg);
  color: var(--text);
  box-shadow: 0 18px 44px var(--shadow);
}

.account-menu-panel {
  display: grid;
  gap: 2px;
}

.account-menu-item,
.account-menu-back {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 36px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.account-menu-item:hover,
.account-menu-back:hover,
.account-menu-item.is-selected {
  background: var(--menu-hover);
}

.account-menu-back {
  color: var(--muted);
}

.new-chat,
.chat-item,
.composer button {
  border: 0;
  border-radius: 8px;
  font: inherit;
  cursor: pointer;
}

.new-chat {
  min-height: 38px;
  background: #eaf2ff;
  color: #0b1536;
  font-size: 14px;
  font-weight: 700;
}

.chat-search {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--sidebar-border);
  border-radius: 8px;
  background: var(--sidebar-soft);
  color: var(--sidebar-text-muted);
}

.chat-search svg {
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chat-search input {
  min-width: 0;
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13px;
}

.chat-search input::placeholder {
  color: var(--sidebar-text-muted);
}

.chat-list {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  gap: 6px;
  margin: 0 -2px;
  padding: 0 2px 14px;
  overflow-y: auto;
}

.chat-item {
  display: block;
  flex: 0 0 auto;
  width: 100%;
  height: auto;
  min-height: 40px;
  padding: 9px 10px;
  text-align: left;
  background: var(--sidebar-soft);
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
  white-space: normal;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.chat-item {
  position: relative;
  padding-right: 28px;
}

.chat-item.is-active {
  outline: 1px solid rgba(203, 213, 225, 0.38);
  background: var(--sidebar-active);
}

.chat-item-delete {
  position: absolute;
  right: 7px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0;
  color: var(--sidebar-text-muted);
  font-size: 16px;
  line-height: 1;
}

.chat-item:hover .chat-item-delete {
  opacity: 1;
}

.chat-item-delete:hover {
  color: #ff6b6b;
}


.chat-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  grid-column: 2;
  grid-row: 1;
  background: var(--bg);
}

.chat-toolbar {
  grid-row: 1;
  display: flex;
  justify-content: flex-end;
  min-height: 48px;
  padding: 10px 28px 8px;
  border-bottom: 1px solid var(--line);
  background: var(--toolbar);
}

.messages {
  grid-row: 2;
  background: var(--bg);
}

.composer {
  grid-row: 3;
}

.share-chat-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
}

.share-chat-btn:hover {
  background: var(--menu-hover);
}

.share-chat-btn svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}


.admin-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(16, 19, 24, 0.45);
}

.admin-card {
  width: min(100%, 520px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 22px 60px var(--shadow);
}

.admin-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.admin-card-header h2 {
  margin: 0;
  font-size: 18px;
}

.admin-close-btn {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 8px;
  background: var(--menu-hover);
  color: var(--text);
  font-size: 22px;
  cursor: pointer;
}

.admin-grid {
  display: grid;
  gap: 18px;
  padding: 20px;
}

.admin-grid p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.admin-note {
  font-size: 13px;
}

.admin-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.admin-actions button {
  min-height: 40px;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.admin-actions button:disabled {
  background: #9ab8e9;
  cursor: wait;
}

.messages {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  overflow-y: auto;
  padding: 24px 0 116px;
}

.message {
  display: grid;
  grid-template-columns: 34px minmax(0, 820px);
  justify-content: center;
  gap: 14px;
  width: 100%;
  padding: 16px 28px;
}

.message-user {
  background: var(--chat-user);
}

.message-assistant {
  background: var(--assistant);
}

.avatar {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--avatar-bg);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
}

.message-user .avatar {
  background: var(--accent);
}

.bubble {
  min-width: 0;
  line-height: 1.58;
  font-size: 14px;
}

.bubble p {
  margin: 0 0 10px;
  white-space: pre-wrap;
}

.bubble p:last-child {
  margin-bottom: 0;
}

.answer-content {
  display: grid;
  gap: 10px;
}

.answer-content h3 {
  margin: 8px 0 0;
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
}

.answer-content h3:first-child {
  margin-top: 0;
}

.answer-content p {
  margin: 0;
  white-space: pre-wrap;
}

.answer-content ul {
  margin: 0;
  padding-left: 18px;
}

.answer-content li {
  margin: 4px 0;
}

.answer-table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.answer-table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
  font-size: 13px;
  line-height: 1.45;
}

.answer-table th,
.answer-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.answer-table th {
  background: var(--soft-blue);
  font-weight: 800;
}

.answer-table tr:last-child td {
  border-bottom: 0;
}

.message-loading .bubble p {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
}

.typing-dots {
  display: inline-flex;
  gap: 3px;
}

.typing-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #7a8697;
  animation: typing-bounce 1s infinite ease-in-out;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes typing-bounce {
  0%, 80%, 100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

.subtle {
  color: var(--muted);
  font-size: 14px;
}

.sources {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--source-bg);
}

.sources summary {
  padding: 12px 14px;
  cursor: pointer;
  font-weight: 800;
}

.source-item {
  padding: 12px 14px;
  border-top: 1px solid var(--line);
}

.source-item strong {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
}

.source-item p {
  color: var(--muted);
  font-size: 13px;
}

.source-download {
  display: inline-flex;
  margin-top: 8px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.source-download:hover {
  text-decoration: underline;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 820px) 48px;
  justify-content: center;
  gap: 10px;
  padding: 16px 28px 22px;
  border-top: 1px solid var(--line);
  background: var(--composer-bg);
}

.composer textarea {
  width: 100%;
  min-height: 48px;
  max-height: 180px;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px 15px;
  background: var(--input-bg);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  line-height: 1.5;
}

.composer textarea:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(31, 111, 235, 0.14);
}

.composer button {
  display: grid;
  place-items: center;
  min-height: 48px;
  width: 48px;
  padding: 0;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.composer button:hover:not(:disabled) {
  background: var(--accent-dark);
}

.composer button:disabled {
  background: #9ab8e9;
  cursor: wait;
}

.send-icon {
  width: 22px;
  height: 22px;
  overflow: visible;
}

.send-icon path {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.45;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.sidebar-downloads-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--sidebar-border);
  border-radius: 8px;
  background: var(--sidebar-soft);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.sidebar-downloads-btn:hover {
  background: var(--sidebar-hover);
  color: var(--text);
}

.sidebar-downloads-btn svg {
  flex-shrink: 0;
}

.downloads-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  padding: 28px;
  background: var(--bg);
  grid-column: 2;
  grid-row: 1;
}

.downloads-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.downloads-header h2 {
  margin: 0;
  font-size: 22px;
}

.downloads-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--chip-bg);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.downloads-back-btn:hover {
  background: var(--chip-hover);
}

.downloads-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.downloads-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.category-pill {
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--chip-bg);
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.category-pill.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.category-pill:hover:not(.is-active) {
  background: var(--chip-hover);
  color: var(--text);
}

.downloads-search {
  flex: 1;
  min-width: 180px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--input-bg);
  font: inherit;
  font-size: 14px;
  color: var(--text);
}

.downloads-search:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(31, 111, 235, 0.14);
}

.downloads-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.download-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card-bg);
  box-shadow: 0 2px 8px var(--shadow);
}

.download-card-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.4;
  word-break: break-word;
}

.download-card-category {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--chip-hover);
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 700;
  width: fit-content;
}

.download-card-desc {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.download-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid var(--download-border);
  color: var(--muted);
  font-size: 12px;
}

.download-card-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}

.download-card-btn:hover {
  background: var(--accent-dark);
}

.downloads-empty {
  text-align: center;
  color: var(--muted);
  padding: 40px 0;
  font-size: 15px;
}

.legal-page {
  min-height: 100vh;
  padding: 40px 20px;
  background: var(--bg);
  color: var(--text);
}

.legal-container {
  width: min(100%, 860px);
  margin: 0 auto;
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 50px var(--shadow);
}

.legal-nav {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}

.legal-nav a {
  color: var(--accent);
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
}

.legal-nav a:hover {
  text-decoration: underline;
}

.legal-container h1 {
  margin: 0 0 12px;
  font-size: 28px;
  line-height: 1.3;
}

.legal-container h2 {
  margin: 28px 0 10px;
  font-size: 18px;
}

.legal-container p,
.legal-container li {
  color: var(--muted);
  line-height: 1.75;
}

.legal-container ul {
  padding-left: 20px;
}

.legal-note {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--source-bg);
}

.admin-downloads-section {
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.admin-download-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.admin-download-form input,
.admin-download-form select {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  font-size: 13px;
  color: var(--text);
}

.admin-download-form input:first-child {
  grid-column: 1 / -1;
}

.admin-download-form input[placeholder="파일 URL"],
.admin-download-form input[placeholder="설명 (선택)"] {
  grid-column: 1 / -1;
}

.admin-download-form button {
  grid-column: 1 / -1;
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.admin-download-form button:disabled {
  background: #9ab8e9;
  cursor: wait;
}

.admin-download-list {
  display: grid;
  gap: 6px;
  margin-top: 12px;
  max-height: 200px;
  overflow-y: auto;
}

.admin-download-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
}

.admin-download-item span {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-download-item-tag {
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--chip-hover);
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

.admin-download-item button {
  padding: 4px 10px;
  border: 0;
  border-radius: 4px;
  background: #fee2e2;
  color: #b91c1c;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
}

.admin-download-item button:hover {
  background: #fca5a5;
}

.mobile-header {
  display: none;
}

.sidebar-backdrop {
  display: none;
}

@media (max-width: 820px) {
  .mobile-header.is-hidden {
    display: none !important;
  }

  .mobile-header {
    display: flex;
    align-items: center;
    gap: 12px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 90;
    height: 52px;
    padding: 0 16px;
    background: var(--sidebar);
    color: var(--text);
  }

  .menu-btn {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .menu-btn:active {
    background: rgba(255, 255, 255, 0.1);
  }

  .mobile-title {
    font-weight: 700;
    font-size: 16px;
  }

  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
    padding-top: 52px;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 80%;
    max-width: 320px;
    z-index: 200;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 199;
    background: rgba(0, 0, 0, 0.5);
    -webkit-tap-highlight-color: transparent;
  }

  .sidebar-backdrop.is-visible {
    display: block;
  }

  .chat-panel {
    height: calc(100vh - 52px);
    height: calc(100dvh - 52px);
  }

  .chat-toolbar {
    min-height: 44px;
    padding: 8px 18px;
  }

  .message {
    grid-template-columns: 32px minmax(0, 1fr);
    padding: 16px 18px;
  }

  .composer {
    grid-template-columns: minmax(0, 1fr) 44px;
    padding: 14px 18px 18px;
  }

  .composer button {
    width: 44px;
    min-height: 44px;
  }

  .downloads-page {
    grid-column: 1;
    height: calc(100vh - 52px);
    height: calc(100dvh - 52px);
    padding: 18px;
  }

  .downloads-header h2 {
    font-size: 18px;
  }

  .downloads-grid {
    grid-template-columns: 1fr;
  }

  .downloads-search {
    min-width: 0;
    width: 100%;
  }
}

@media print {
  body {
    background: #fff;
  }

  .login-screen,
  .mobile-header,
  .sidebar,
  .sidebar-backdrop,
  .chat-toolbar,
  .composer,
  .downloads-page,
  .admin-modal {
    display: none !important;
  }

  .app-shell {
    display: block !important;
    height: auto;
  }

  .chat-panel {
    display: block !important;
    height: auto;
    overflow: visible;
  }

  .messages {
    display: block;
    overflow: visible;
    padding: 0;
  }

  .message {
    break-inside: avoid;
    display: grid;
    grid-template-columns: 30px 1fr;
    justify-content: stretch;
    padding: 14px 0;
  }
}
