﻿:root {
  color-scheme: dark;
  --bg: #070a0d;
  --panel: rgba(9, 14, 18, 0.76);
  --panel-strong: rgba(14, 22, 28, 0.92);
  --line: rgba(255, 255, 255, 0.12);
  --text: #eef6f3;
  --muted: #93aaa6;
  --brand: #76f7b0;
  --brand-2: #57c7ff;
  --warn: #ffd166;
  --danger: #ff6b7a;
  --radius: 8px;
  --shadow: 0 28px 90px rgba(0, 0, 0, 0.42);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: Inter, "Noto Sans TC", system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 50% 105%, rgba(118, 247, 176, 0.2), transparent 34%),
    radial-gradient(circle at 15% 15%, rgba(87, 199, 255, 0.14), transparent 28%),
    linear-gradient(155deg, #050708 0%, #0b1113 52%, #071012 100%);
  overflow-x: hidden;
}

button, input, textarea, select {
  font: inherit;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

button {
  cursor: pointer;
  min-height: 42px;
  padding: 0 16px;
  border: 0;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #04120d;
  font-weight: 800;
  transition: transform 0.18s ease, filter 0.18s ease, box-shadow 0.18s ease;
}

button:hover { transform: translateY(-1px); filter: brightness(1.05); }
button:disabled { cursor: not-allowed; opacity: 0.55; transform: none; }

input, textarea, select {
  width: 100%;
  background: rgba(3, 7, 9, 0.62);
  color: var(--text);
  outline: none;
}

input, select { padding: 11px 12px; }
textarea { resize: none; padding: 12px 13px; line-height: 1.5; }
label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; font-weight: 700; }
h1, h2, p { margin: 0; }
h2 { font-size: 18px; }

.motion-field {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.motion-field::before {
  content: "";
  position: absolute;
  inset: -40%;
  background:
    linear-gradient(115deg, transparent 0 45%, rgba(118, 247, 176, 0.08) 50%, transparent 55% 100%),
    linear-gradient(65deg, transparent 0 48%, rgba(87, 199, 255, 0.07) 52%, transparent 56% 100%);
  animation: scan 8s linear infinite;
}

.motion-field span {
  position: absolute;
  width: 34vw;
  height: 34vw;
  border: 1px solid rgba(118, 247, 176, 0.22);
  border-radius: 50%;
  filter: blur(0.2px);
  animation: orbit 16s ease-in-out infinite alternate;
}

.motion-field span:nth-child(1) { left: -12vw; top: 8vh; }
.motion-field span:nth-child(2) { right: -10vw; top: 18vh; width: 28vw; height: 28vw; border-color: rgba(87, 199, 255, 0.24); animation-delay: -3s; }
.motion-field span:nth-child(3) { left: 42vw; bottom: -20vw; width: 42vw; height: 42vw; animation-delay: -7s; }
.motion-field span:nth-child(4) { left: 18vw; top: 62vh; width: 18vw; height: 18vw; border-color: rgba(255, 209, 102, 0.16); animation-delay: -9s; }
.motion-field span:nth-child(5) { right: 18vw; bottom: 12vh; width: 14vw; height: 14vw; animation-delay: -12s; }
.motion-field span:nth-child(6) { left: 56vw; top: 6vh; width: 10vw; height: 10vw; border-color: rgba(255,255,255,0.14); animation-delay: -5s; }

.motion-field i {
  position: absolute;
  left: var(--x, 50%);
  bottom: -20px;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 18px var(--brand);
  animation: particle 7s linear infinite;
  animation-delay: var(--d, 0s);
}

.motion-field i:nth-of-type(1) { --x: 9%; --d: -1s; }
.motion-field i:nth-of-type(2) { --x: 21%; --d: -5s; background: var(--brand-2); box-shadow: 0 0 18px var(--brand-2); }
.motion-field i:nth-of-type(3) { --x: 33%; --d: -2.5s; }
.motion-field i:nth-of-type(4) { --x: 45%; --d: -6.5s; background: var(--brand-2); box-shadow: 0 0 18px var(--brand-2); }
.motion-field i:nth-of-type(5) { --x: 57%; --d: -3.2s; }
.motion-field i:nth-of-type(6) { --x: 69%; --d: -4.4s; background: var(--brand-2); box-shadow: 0 0 18px var(--brand-2); }
.motion-field i:nth-of-type(7) { --x: 81%; --d: -0.8s; }
.motion-field i:nth-of-type(8) { --x: 93%; --d: -5.8s; background: var(--brand-2); box-shadow: 0 0 18px var(--brand-2); }

@keyframes scan {
  from { transform: translate3d(-8%, -6%, 0) rotate(0deg); }
  to { transform: translate3d(8%, 6%, 0) rotate(360deg); }
}

@keyframes orbit {
  from { transform: translate3d(0, 0, 0) scale(1); opacity: 0.35; }
  to { transform: translate3d(28px, -34px, 0) scale(1.08); opacity: 0.95; }
}

@keyframes particle {
  0% { transform: translate3d(0, 0, 0) scale(0.8); opacity: 0; }
  14% { opacity: 0.9; }
  100% { transform: translate3d(18px, -110vh, 0) scale(1.8); opacity: 0; }
}

.app-shell {
  position: relative;
  z-index: 1;
  height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
  padding: 14px;
  overflow: hidden;
}

.chat-stage {
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(13, 20, 25, 0.82), rgba(7, 10, 13, 0.72));
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,0.08);
  backdrop-filter: blur(22px);
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
  animation: enterStage 0.5s ease both;
}

.chat-stage.empty-mode .minimal-chat {
  align-items: center;
}

.chat-stage.empty-mode .messages {
  justify-content: center;
  padding-bottom: 8px;
}

.chat-stage.empty-mode .messages::before {
  display: none;
}

.chat-stage.empty-mode .minimal-composer {
  width: min(640px, calc(100% - 24px));
  justify-self: center;
  margin-bottom: 18px;
  border: 1px solid rgba(118, 247, 176, 0.18);
  border-radius: 8px;
  box-shadow: 0 18px 54px rgba(0, 0, 0, 0.28);
}

@keyframes enterStage {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.chat-topbar {
  min-height: 50px;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.chat-title {
  min-width: 0;
  flex: 1;
  display: grid;
  gap: 2px;
}

.chat-title span {
  color: var(--muted);
  font-size: 12px;
}

.chat-topbar select {
  width: min(300px, 32vw);
  min-height: 38px;
  padding: 8px 10px;
  font-size: 13px;
}

.quiet-button, .quiet-link, .back-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,0.07);
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  font-weight: 800;
}

.menu-button {
  display: inline-flex;
}

.auth-sheet {
  align-self: center;
  justify-self: center;
  width: min(420px, calc(100% - 28px));
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  background: rgba(7, 11, 14, 0.7);
  box-shadow: 0 18px 60px rgba(0,0,0,0.32);
  padding: 14px;
  display: grid;
  gap: 14px;
  animation: floatIn 0.42s ease both;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.tab-button {
  background: rgba(255,255,255,0.07);
  color: var(--muted);
  border: 1px solid var(--line);
}

.tab-button.active {
  color: #04120d;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
}

.auth-form {
  display: grid;
  gap: 12px;
}

.minimal-chat {
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  overflow: hidden;
}

.messages {
  min-height: 0;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 12px clamp(14px, 5vw, 54px);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.messages::before {
  content: "";
  margin-top: auto;
}

.empty-chat {
  justify-self: center;
  align-self: center;
  width: min(420px, 100%);
  display: grid;
  gap: 8px;
  text-align: center;
  color: var(--muted);
  animation: pulseText 2.6s ease-in-out infinite;
}

.empty-chat strong {
  color: var(--text);
  font-size: 28px;
}

.message {
  width: fit-content;
  max-width: min(520px, 68%);
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 10px;
  background: transparent;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.48;
  font-size: 14px;
  animation: messageIn 0.28s cubic-bezier(.2,.8,.2,1) both;
}

.message p {
  margin: 0 0 8px;
}

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

.message strong {
  font-weight: 800;
}

.inline-code {
  border: 1px solid rgba(255,255,255,0.13);
  border-radius: 4px;
  background: rgba(255,255,255,0.08);
  padding: 1px 4px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.92em;
}

.code-shell {
  max-width: 100%;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.32);
  margin: 8px 0;
  overflow: hidden;
}

.code-toolbar {
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.055);
}

.code-toolbar span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.code-toolbar button {
  min-height: 26px;
  padding: 0 9px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.08);
  color: var(--text);
  box-shadow: none;
  font-size: 12px;
}

.code-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.code-block {
  max-width: 100%;
  overflow: auto;
  padding: 10px;
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre;
}

.preview-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  padding: clamp(10px, 3vw, 28px);
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(12px);
}

.preview-dialog {
  width: min(1100px, 100%);
  height: min(760px, 100%);
  min-height: 420px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(8, 13, 17, 0.96);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.preview-header {
  min-height: 48px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--line);
}

.preview-header div {
  display: flex;
  gap: 8px;
}

.preview-dialog iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}

.table-wrap {
  max-width: 100%;
  overflow: auto;
  margin: 8px 0;
}

.table-wrap table {
  width: 100%;
  min-width: 420px;
  border-collapse: collapse;
  font-size: 13px;
}

.table-wrap th,
.table-wrap td {
  border: 1px solid rgba(255,255,255,0.14);
  padding: 7px 8px;
  text-align: left;
  vertical-align: top;
}

.table-wrap th {
  background: rgba(255,255,255,0.08);
  font-weight: 800;
}

.office-artifact {
  width: min(760px, 100%);
  border: 1px solid rgba(118, 247, 176, 0.24);
  border-radius: 8px;
  background: rgba(7, 12, 15, 0.72);
  overflow: hidden;
  margin: 10px 0;
}

.office-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.045);
}

.office-head div:first-child {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.office-head span,
.office-muted {
  color: var(--muted);
  font-size: 12px;
}

.office-head small {
  color: var(--brand);
  font-size: 11px;
  font-weight: 800;
}

.office-head strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.office-actions,
.office-edit-actions {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.office-actions button,
.office-edit-actions button {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.08);
  color: var(--text);
  box-shadow: none;
  font-size: 12px;
}

.office-preview {
  display: grid;
  gap: 10px;
  padding: 12px;
  max-height: 460px;
  overflow: auto;
}

.office-section,
.office-sheet,
.office-slide {
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  background: rgba(255,255,255,0.035);
  padding: 12px;
}

.office-section h3,
.office-sheet h3,
.office-slide h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.office-section p,
.office-slide p {
  margin: 0 0 8px;
}

.office-section ul,
.office-slide ul {
  margin: 0;
  padding-left: 20px;
}

.office-slides {
  display: grid;
  gap: 10px;
}

.office-slide {
  aspect-ratio: 16 / 9;
  min-height: 190px;
  position: relative;
  overflow: hidden;
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 18px;
  border-color: rgba(118, 247, 176, 0.24);
  background:
    linear-gradient(180deg, #122033 0 28%, transparent 28% 100%),
    linear-gradient(135deg, rgba(118,247,176,0.13), transparent 42%),
    #f6f8fb;
  color: #17212b;
}

.office-slide::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 28%;
  height: 3px;
  background: var(--brand);
}

.office-slide.theme-teaching {
  background:
    linear-gradient(180deg, #25324a 0 28%, transparent 28% 100%),
    linear-gradient(135deg, rgba(255,209,102,0.18), transparent 42%),
    #fbf8f1;
}

.office-slide.theme-teaching::after {
  background: #ffd166;
}

.office-slide.theme-teaching small {
  color: #ffe7a3;
}

.office-slide.theme-data {
  background:
    linear-gradient(180deg, #0e2f3f 0 28%, transparent 28% 100%),
    linear-gradient(135deg, rgba(87,199,255,0.18), transparent 42%),
    #f4f8fa;
}

.office-slide.theme-data::after {
  background: #57c7ff;
}

.office-slide.theme-data small {
  color: #bcebff;
}

.office-slide small {
  color: #b8f7d2;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.office-slide h3 {
  max-width: 86%;
  color: #fff;
  font-size: clamp(18px, 2.5vw, 30px);
  line-height: 1.12;
  margin-bottom: 22px;
}

.office-slide ul,
.office-slide p {
  width: min(92%, 820px);
  margin-left: 0;
  border: 1px solid #d9e2ec;
  border-radius: 8px;
  background: rgba(255,255,255,0.92);
  padding: 14px 18px;
  box-shadow: 0 12px 34px rgba(18, 32, 51, 0.12);
}

.office-slide li {
  margin: 6px 0;
}

.office-table-wrap {
  max-width: 100%;
  overflow: auto;
}

.office-table-wrap table {
  width: 100%;
  min-width: 420px;
  border-collapse: collapse;
}

.office-table-wrap th,
.office-table-wrap td {
  border: 1px solid rgba(255,255,255,0.14);
  padding: 7px 8px;
  text-align: left;
  vertical-align: top;
}

.office-editor {
  width: calc(100% - 24px);
  min-height: 320px;
  margin: 12px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
}

.message.user {
  justify-self: end;
  align-self: flex-end;
  max-width: min(460px, 72%);
  background: linear-gradient(150deg, rgba(87, 199, 255, 0.18), rgba(118, 247, 176, 0.08));
  border-color: rgba(87, 199, 255, 0.16);
}

.message.assistant {
  justify-self: start;
  align-self: flex-start;
  max-width: min(680px, 74%);
  padding-left: 0;
  padding-right: 0;
}

.message-label { display: block; color: var(--muted); font-size: 11px; margin-bottom: 5px; }

.message.user .message-label {
  display: none;
}

.typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
}

.typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 14px rgba(118, 247, 176, 0.68);
  animation: typingDot 0.9s ease-in-out infinite;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.14s;
  background: var(--brand-2);
  box-shadow: 0 0 14px rgba(87, 199, 255, 0.68);
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.28s;
}

@keyframes typingDot {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.38; }
  40% { transform: translateY(-5px); opacity: 1; }
}

.reasoning {
  border: 1px solid rgba(255, 209, 102, 0.35);
  border-radius: 8px;
  background: rgba(255, 209, 102, 0.08);
  color: #ffe8a9;
  padding: 7px 8px;
  margin-bottom: 7px;
  font-size: 13px;
}

.reasoning summary {
  cursor: pointer;
  font-weight: 800;
  margin-bottom: 6px;
}

@keyframes messageIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); filter: blur(4px); }
  to { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }
}

@keyframes pulseText {
  0%, 100% { opacity: 0.58; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-4px); }
}

@keyframes floatIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.minimal-composer {
  padding: 8px clamp(10px, 4vw, 44px);
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 72px;
  gap: 8px;
  border-top: 1px solid rgba(255,255,255,0.08);
  background: rgba(3, 6, 8, 0.58);
}

.file-status {
  grid-column: 1 / -1;
  min-height: 0;
  font-size: 12px;
  line-height: 1.35;
  color: var(--muted);
}

.file-status:empty {
  display: none;
}

.minimal-composer textarea {
  min-height: 36px;
  max-height: 96px;
  padding: 8px 10px;
  line-height: 1.35;
  border-color: rgba(255,255,255,0.13);
  box-shadow: inset 0 0 0 1px transparent;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.minimal-composer textarea:focus {
  border-color: rgba(118, 247, 176, 0.68);
  box-shadow: 0 0 0 4px rgba(118, 247, 176, 0.1);
  transform: translateY(-1px);
}

.minimal-composer button {
  min-height: 38px;
  position: relative;
  overflow: hidden;
}

.minimal-composer .attach-button {
  background: rgba(255,255,255,0.07);
  color: var(--text);
  border-color: rgba(255,255,255,0.14);
  box-shadow: none;
}

.skill-strip {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  color: var(--muted);
  font-size: 12px;
}

.skill-chip {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.07);
  color: var(--text);
  box-shadow: none;
  font-size: 12px;
}

.skill-chip.active {
  border-color: rgba(118, 247, 176, 0.6);
  background: rgba(118, 247, 176, 0.14);
  color: var(--brand);
}

.skill-chip::after {
  display: none;
}

.skill-select {
  width: auto;
  min-height: 30px;
  padding: 4px 28px 4px 10px;
  border-color: rgba(255,255,255,0.14);
  background-color: rgba(255,255,255,0.07);
  color: var(--text);
  font-size: 12px;
}

.minimal-composer button::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-120%);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.48), transparent);
}

.minimal-composer button.sending::after {
  animation: sendGlow 0.9s linear infinite;
}

@keyframes sendGlow {
  to { transform: translateX(120%); }
}

.composer-disabled {
  opacity: 0.72;
}

.app-sidebar {
  position: fixed;
  z-index: 5;
  top: 14px;
  left: 14px;
  bottom: 14px;
  width: min(320px, calc(100vw - 28px));
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(8, 13, 17, 0.92);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  padding: 14px;
  display: grid;
  grid-template-rows: auto auto auto 1fr auto;
  gap: 12px;
  overflow: hidden;
  transform: translateX(calc(-100% - 28px));
  transition: transform 0.24s ease;
  animation: sidebarFade 0.35s ease both;
}

.app-sidebar.open {
  transform: translateX(0);
}

@keyframes sidebarFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.sidebar-brand {
  display: grid;
  gap: 3px;
  padding: 4px 2px;
}

.sidebar-brand strong {
  font-size: 20px;
}

.sidebar-brand small {
  color: var(--muted);
}

.new-chat-button {
  width: 100%;
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.drawer-actions {
  display: grid;
  gap: 8px;
}

.drawer-label {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.conversation-list {
  display: grid;
  gap: 8px;
  overflow: auto;
}

.conversation-item {
  min-height: 50px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,0.055);
  color: var(--text);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px;
  align-items: center;
}

.conversation-item.active {
  border-color: rgba(118, 247, 176, 0.72);
  background: rgba(118, 247, 176, 0.11);
}

.conversation-item small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.conversation-main {
  min-height: 38px;
  padding: 3px 4px;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-weight: 700;
  overflow: hidden;
}

.conversation-main:hover {
  transform: none;
  filter: none;
}

.conversation-main strong,
.conversation-main small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-menu {
  position: relative;
}

.conversation-item.menu-open {
  z-index: 3;
}

.conversation-menu-button {
  min-height: 32px;
  width: 34px;
  padding: 0;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.07);
  color: var(--text);
  font-size: 18px;
  line-height: 1;
}

.conversation-menu-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: min(238px, calc(100vw - 48px));
  display: none;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(8, 13, 17, 0.98);
  box-shadow: 0 18px 48px rgba(0,0,0,0.36);
}

.conversation-item.menu-open .conversation-menu-panel {
  display: grid;
  gap: 4px;
}

.conversation-menu-panel button {
  min-height: 0;
  padding: 8px;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 2px 8px;
  align-items: center;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-weight: 700;
}

.conversation-menu-panel button:hover {
  transform: none;
  background: rgba(255,255,255,0.08);
}

.conversation-menu-panel span {
  grid-row: span 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: rgba(255,255,255,0.09);
}

.conversation-menu-panel small {
  margin: 0;
  white-space: normal;
  line-height: 1.35;
}

.conversation-menu-panel .danger {
  color: var(--danger);
}

.empty-note, .usage-banner {
  color: var(--muted);
  font-size: 13px;
}

.usage-banner {
  border: 1px solid rgba(118, 247, 176, 0.22);
  border-radius: 8px;
  background: rgba(118, 247, 176, 0.08);
  padding: 10px;
}

.toast {
  position: fixed;
  z-index: 10;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%) translateY(20px);
  opacity: 0;
  pointer-events: none;
  background: rgba(238, 246, 243, 0.96);
  color: #06110c;
  border-radius: 8px;
  padding: 12px 16px;
  font-weight: 800;
  transition: 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.hidden { display: none !important; }

.admin-body { overflow: auto; }
.admin-shell { position: relative; z-index: 1; min-height: 100vh; }
.admin-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 24px clamp(18px, 4vw, 42px);
  border-bottom: 1px solid var(--line);
  background: rgba(8, 12, 17, 0.48);
  backdrop-filter: blur(18px);
}
.admin-header h1 {
  font-size: clamp(30px, 5vw, 56px);
  line-height: 0.95;
  margin-top: 8px;
}
.admin-header p { color: var(--muted); margin-top: 8px; }
.auth-grid {
  padding: clamp(18px, 5vw, 52px);
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 440px));
  gap: 18px;
  align-content: start;
}
.auth-card, .admin-panel, .metric-card {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
}
.auth-card {
  padding: 22px;
  display: grid;
  gap: 16px;
}
.admin-grid {
  padding: 24px clamp(18px, 4vw, 42px) 46px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}
.metric-card { padding: 18px; }
.metric-card small { color: var(--muted); font-weight: 800; }
.metric-card strong { display: block; font-size: 34px; margin-top: 8px; }
.admin-panel {
  padding: 18px;
  display: grid;
  gap: 14px;
  min-width: 0;
}
.admin-panel.wide { grid-column: span 4; }
.panel-heading { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.panel-heading span { color: var(--muted); font-size: 13px; }
.panel-action {
  min-height: 34px;
  padding: 0 12px;
  font-size: 13px;
}
.settings-form { display: grid; gap: 13px; }
.settings-form textarea { min-height: 120px; }
.settings-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.save-status {
  color: var(--muted);
  font-size: 13px;
}
.model-admin {
  display: grid;
  gap: 10px;
}
.model-admin-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}
.model-admin-head div {
  display: grid;
  gap: 4px;
}
.model-admin-head span,
.model-admin-header {
  color: var(--muted);
  font-size: 12px;
}
.model-editor {
  display: grid;
  gap: 8px;
  max-height: 360px;
  overflow: auto;
  padding-right: 4px;
}
.model-admin-grid {
  display: grid;
  grid-template-columns: minmax(180px, 0.8fr) minmax(260px, 1.2fr) 90px 72px;
  gap: 8px;
  align-items: center;
}
.model-admin-header {
  padding: 0 4px;
  font-weight: 800;
}
.model-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,0.045);
  padding: 8px;
}
.model-row input {
  min-height: 38px;
  padding: 8px 10px;
}
.werewolf-settings-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) minmax(140px, 0.8fr) minmax(110px, 0.6fr);
  gap: 12px;
}
.settings-hint {
  color: var(--muted);
  line-height: 1.6;
}
.model-toggle {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 7px;
  color: var(--text);
  font-size: 13px;
}
.model-toggle input {
  width: auto;
}
.danger-button {
  color: var(--danger);
  background: rgba(255, 107, 122, 0.08);
  border-color: rgba(255, 107, 122, 0.24);
}
.model-usage, .debug-log { display: grid; gap: 10px; }
.usage-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}
.bar {
  height: 9px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  overflow: hidden;
  margin-top: 6px;
}
.bar span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
}
.debug-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: rgba(0,0,0,0.18);
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
}

.account-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(2, 8, 12, 0.72);
  backdrop-filter: blur(10px);
}

.account-modal.hidden {
  display: none;
}

.account-dialog {
  width: min(560px, 100%);
  max-height: min(760px, calc(100dvh - 36px));
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(13, 20, 24, 0.98);
  box-shadow: var(--shadow);
  padding: 18px;
}

.account-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.account-header strong {
  display: block;
  font-size: 20px;
}

.account-header span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
  word-break: break-all;
}

.account-form {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,0.04);
}

.account-form + .account-form {
  margin-top: 12px;
}

.account-form h2 {
  margin: 0;
  font-size: 15px;
}

.account-form p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.account-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.account-form input {
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(0,0,0,0.22);
  color: var(--text);
  padding: 9px 10px;
}

.account-form button {
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid rgba(118, 247, 176, 0.32);
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #041014;
  font-weight: 900;
}

.danger-zone {
  border-color: rgba(255, 107, 122, 0.28);
}

.danger-zone button {
  border-color: rgba(255, 107, 122, 0.36);
  background: rgba(255, 107, 122, 0.12);
  color: #ff8b98;
}

@media (max-width: 760px) {
  html, body {
    height: 100%;
    overflow: hidden;
  }
  .app-shell {
    grid-template-columns: 1fr;
    gap: 0;
    padding: 0;
    height: 100dvh;
  }
  .app-sidebar {
    position: fixed;
    z-index: 4;
    top: 10px;
    left: 10px;
    bottom: max(10px, env(safe-area-inset-bottom));
    width: min(300px, calc(100vw - 20px));
    max-height: calc(100dvh - 20px);
    transform: translateX(calc(-100% - 20px));
    transition: transform 0.24s ease;
  }
  .app-sidebar.open {
    transform: translateX(0);
  }
  .chat-stage {
    width: 100%;
    height: 100dvh;
    min-height: 0;
    border: 0;
    border-radius: 0;
  }
  .chat-topbar {
    align-items: center;
    min-height: 48px;
    padding: max(8px, env(safe-area-inset-top)) 8px 8px;
    gap: 6px;
  }
  .menu-button {
    display: inline-flex;
    min-height: 34px;
    padding: 0 9px;
  }
  .chat-title strong { font-size: 14px; }
  .chat-title span {
    display: none;
  }
  .chat-topbar select {
    flex: 0 1 50vw;
    width: 50vw;
    min-height: 34px;
    padding: 6px 8px;
    font-size: 12px;
  }
  .messages {
    padding: 10px 12px;
    gap: 7px;
  }
  .empty-chat {
    width: min(320px, 100%);
    padding: 0 12px;
  }
  .empty-chat strong {
    font-size: 22px;
  }
  .minimal-composer {
    grid-template-columns: 58px minmax(0, 1fr) 58px;
    padding: 8px 8px max(8px, env(safe-area-inset-bottom));
    gap: 6px;
  }
  .minimal-composer textarea {
    min-height: 36px;
    max-height: 90px;
    padding: 9px 10px;
    font-size: 14px;
  }
  .minimal-composer button {
    min-height: 36px;
    padding: 0 8px;
  }
  .skill-strip {
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
  }
  .office-head {
    align-items: flex-start;
    flex-direction: column;
  }
  .office-actions,
  .office-edit-actions {
    justify-content: flex-start;
  }
  .office-preview {
    max-height: 360px;
  }
  .office-slide {
    min-height: 160px;
  }
  .message {
    max-width: 94%;
    font-size: 14px;
    padding: 7px 8px;
  }
  .code-block {
    font-size: 12px;
  }
  .preview-modal {
    padding: 0;
  }
  .preview-dialog {
    width: 100%;
    height: 100dvh;
    min-height: 0;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }
  .preview-header {
    padding: max(8px, env(safe-area-inset-top)) 8px 8px;
  }
  .preview-header .quiet-button {
    min-height: 32px;
    padding: 0 8px;
    font-size: 12px;
  }
  .table-wrap table {
    min-width: 360px;
  }
  .message.user {
    max-width: 82%;
  }
  .message.assistant {
    max-width: 94%;
  }
  .auth-sheet {
    width: calc(100% - 20px);
    padding: 12px;
  }
  .auth-tabs {
    gap: 6px;
  }
  .account-modal {
    padding: 0;
    place-items: stretch;
  }
  .account-dialog {
    width: 100%;
    max-height: 100dvh;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
  }
  .admin-header { align-items: flex-start; flex-direction: column; }
  .auth-grid, .admin-grid { grid-template-columns: 1fr; }
  .admin-panel.wide { grid-column: auto; }
  .model-admin-grid {
    grid-template-columns: 1fr;
  }
  .werewolf-settings-grid {
    grid-template-columns: 1fr;
  }
  .model-admin-header {
    display: none;
  }
}
