:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg: #fff9fc;
  --sidebar: #fff4f8;
  --sidebar-hover: #ffe7f1;
  --surface: #ffffff;
  --surface-soft: #fff1f7;
  --line: #f1cadd;
  --line-strong: #e6aac7;
  --text: #2b2530;
  --muted: #826f7b;
  --muted-strong: #a5165d;
  --accent: #d92d7f;
  --danger: #b42318;
  --shadow: 0 18px 48px rgba(217, 45, 127, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(135deg, rgba(217, 45, 127, 0.05) 0 25%, transparent 25% 50%, rgba(217, 45, 127, 0.04) 50% 75%, transparent 75%) 0 0 / 34px 34px,
    var(--bg);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled,
input:disabled,
textarea:disabled {
  cursor: wait;
  opacity: 0.55;
}

.app-shell {
  min-height: 100vh;
}

.writer[hidden],
.access-card[hidden] {
  display: none;
}

.access-card {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  min-height: 100vh;
  padding: 56px 24px;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 58%, rgba(217, 45, 127, 0.12), transparent 24%),
    linear-gradient(180deg, #fff 0%, #fffafd 100%);
}

.access-card .brand-mark {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 78px;
  height: 78px;
  margin-bottom: 26px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 26px 72px rgba(217, 45, 127, 0.17);
}

.access-card .brand-mark svg {
  width: 42px;
  height: 42px;
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.access-card h1 {
  position: relative;
  z-index: 1;
  margin: 0 0 30px;
  color: #2a2330;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(3.2rem, 5.4vw, 5.4rem);
  font-weight: 520;
  line-height: 1.1;
  letter-spacing: 0;
}

.access-form {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 16px;
  width: min(590px, 100%);
  padding: 26px 24px 22px;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 34px 92px rgba(217, 45, 127, 0.18);
  backdrop-filter: blur(10px);
}

.access-form label {
  display: grid;
  gap: 9px;
  color: #7f6f7b;
  font-size: 0.9rem;
  font-weight: 760;
}

.access-form input {
  min-height: 50px;
  padding: 0 12px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  outline: 0;
}

.access-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(217, 45, 127, 0.12);
}

.access-form .send-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 50px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), #e6687e);
  border: 0;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 780;
  box-shadow: 0 20px 42px rgba(217, 45, 127, 0.22);
}

.access-form .send-button:hover {
  background: #a5165d;
}

.access-status {
  margin: 0;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.45;
  text-align: center;
}

.access-shape {
  position: absolute;
  width: 520px;
  height: 300px;
  border: 1px solid rgba(230, 170, 199, 0.38);
  border-radius: 8px;
  opacity: 0.9;
  pointer-events: none;
}

.access-shape::before,
.access-shape::after {
  position: absolute;
  content: "";
  pointer-events: none;
}

.access-shape::before {
  inset: 0;
  background: linear-gradient(18deg, transparent 48%, rgba(217, 45, 127, 0.13) 49%, rgba(217, 45, 127, 0.13) 51%, transparent 52%);
}

.access-shape::after {
  left: -10%;
  top: 32%;
  width: 118%;
  height: 5px;
  background: rgba(125, 192, 184, 0.12);
  transform: rotate(14deg);
}

.access-shape-left {
  left: 4%;
  top: 10%;
  transform: rotate(-12deg);
}

.access-shape-right {
  right: 3%;
  bottom: 2%;
  transform: rotate(-12deg);
}

.access-dot {
  position: absolute;
  width: 18px;
  height: 18px;
  border: 4px solid rgba(217, 45, 127, 0.24);
  border-radius: 50%;
  box-shadow: 0 0 0 10px rgba(217, 45, 127, 0.06);
  pointer-events: none;
}

.access-dot-left {
  left: 22%;
  bottom: 22%;
}

.access-dot-right {
  right: 18%;
  top: 31%;
  border-color: rgba(125, 192, 184, 0.34);
  box-shadow: 0 0 0 9px rgba(125, 192, 184, 0.08);
}

.writer {
  height: 100vh;
  overflow: hidden;
}

.workspace {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  height: 100vh;
  min-height: 0;
}

.chat-panel {
  display: grid;
  grid-template-rows: auto auto auto auto minmax(0, 1fr) auto;
  gap: 12px;
  min-width: 0;
  padding: 14px 10px;
  overflow: hidden;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
}

.chat-panel-head {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-height: 46px;
  padding: 0 8px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-icon {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 36px;
  height: 36px;
  color: var(--accent);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(217, 45, 127, 0.13);
}

.brand-icon svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brand-lockup strong {
  overflow: hidden;
  font-size: 1.02rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attach-button,
.context-button,
.sidebar-action,
.logout-button,
.message-tools button,
.context-clear-button,
.icon-button,
.send-button {
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
}

.attach-button:hover,
.context-button:hover,
.sidebar-action:hover,
.logout-button:hover,
.message-tools button:hover,
.context-clear-button:hover,
.icon-button:hover {
  background: var(--sidebar-hover);
}

.sidebar-action svg,
.sidebar-search svg,
.attach-button svg,
.context-button svg,
.icon-button svg,
.send-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar-actions {
  display: grid;
  gap: 6px;
  padding-top: 2px;
}

.sidebar-action,
.sidebar-search {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  width: 100%;
  padding: 0 9px;
  font-size: 0.9rem;
  text-align: left;
}

.sidebar-search {
  color: var(--muted-strong);
  border-radius: 8px;
}

.sidebar-search:focus-within {
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--line-strong);
}

.sidebar-search input {
  min-width: 0;
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.model-block {
  position: relative;
  display: grid;
  gap: 8px;
  padding: 10px;
  overflow: hidden;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.88), rgba(255, 239, 247, 0.72));
  border: 1px solid rgba(230, 170, 199, 0.72);
  border-radius: 8px;
  box-shadow: 0 12px 34px rgba(217, 45, 127, 0.08);
}

.model-label {
  position: relative;
  color: var(--muted-strong);
  font-size: 0.74rem;
  font-weight: 820;
  text-transform: uppercase;
}

.model-picker {
  display: grid;
  gap: 6px;
}

.model-button {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 40px;
  width: 100%;
  padding: 0 10px;
  color: var(--muted-strong);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 0.86rem;
  font-weight: 730;
  letter-spacing: 0;
  line-height: 1.2;
  text-align: left;
}

.model-button svg {
  display: grid;
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  color: var(--accent);
  padding: 4px;
  background: var(--surface-soft);
  border-radius: 6px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.model-button-copy {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.model-button-copy strong {
  overflow: hidden;
  font-size: 0.84rem;
  font-weight: 760;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-button-copy small {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 620;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-button:hover {
  background: var(--sidebar-hover);
}

.model-button.is-locked-out {
  opacity: 0.58;
}

.model-button.is-locked-out:hover {
  background: #fff;
}

.model-button.is-active {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), #e85b97);
  border-color: transparent;
  box-shadow: 0 8px 18px rgba(217, 45, 127, 0.18);
}

.model-button.is-active svg {
  color: var(--accent);
  background: #fff;
}

.model-button.is-active small {
  color: rgba(255, 255, 255, 0.78);
}

.chat-section-title {
  padding: 10px 8px 0;
  color: #1f1f1f;
  font-size: 0.78rem;
  font-weight: 760;
}

.chat-list {
  display: grid;
  align-content: start;
  gap: 2px;
  min-height: 0;
  overflow: auto;
  padding: 0 2px 8px 0;
}

.chat-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 32px;
  align-items: center;
  width: 100%;
  min-height: 38px;
  border-radius: 8px;
}

.chat-row:hover,
.chat-row.is-active {
  background: var(--sidebar-hover);
}

.chat-item {
  display: grid;
  gap: 2px;
  min-width: 0;
  min-height: 44px;
  padding: 7px 6px 7px 9px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  text-align: left;
}

.chat-delete-button {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin-right: 4px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 7px;
  opacity: 0.72;
}

.chat-delete-button:hover {
  color: var(--danger);
  background: #fff;
  opacity: 1;
}

.chat-delete-button svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chat-title {
  overflow: hidden;
  color: var(--text);
  font-size: 0.88rem;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-meta,
.chat-empty {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.72rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-empty {
  padding: 8px 9px;
}

.sidebar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 44px;
  padding: 8px;
  border-top: 1px solid var(--line);
}

.sidebar-footer span {
  min-width: 0;
  overflow: hidden;
  font-size: 0.88rem;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logout-button {
  min-height: 30px;
  padding: 0 8px;
  color: var(--muted-strong);
  font-size: 0.8rem;
}

.writer-main {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(217, 45, 127, 0.05) 1px, transparent 1px) 0 0 / 42px 42px,
    linear-gradient(180deg, rgba(217, 45, 127, 0.04) 1px, transparent 1px) 0 0 / 42px 42px,
    var(--bg);
}

.writer-main::before {
  position: absolute;
  right: -120px;
  top: 96px;
  width: 360px;
  height: 360px;
  border: 1px solid rgba(230, 170, 199, 0.36);
  border-radius: 8px;
  transform: rotate(18deg);
  content: "";
  pointer-events: none;
}

.writer-main::after {
  position: absolute;
  left: 18%;
  bottom: 112px;
  width: 180px;
  height: 180px;
  border: 1px solid rgba(230, 170, 199, 0.28);
  border-radius: 8px;
  transform: rotate(-12deg);
  content: "";
  pointer-events: none;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 56px;
  padding: 8px 22px;
  background: rgba(255, 249, 252, 0.94);
  backdrop-filter: blur(12px);
}

.topbar-title {
  min-width: 0;
  overflow: hidden;
  color: var(--muted-strong);
  font-size: 0.95rem;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-panel {
  position: relative;
  min-height: 0;
  overflow: hidden;
}

.conversation-messages {
  position: relative;
  z-index: 1;
  height: 100%;
  overflow: auto;
  padding: 34px max(24px, calc((100vw - 260px - 760px) / 2)) 140px;
}

.empty-chat {
  display: grid;
  gap: 14px;
  place-items: center;
  min-height: 50vh;
  color: var(--muted);
  font-size: 1.05rem;
  text-align: center;
}

.empty-chat-icon {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  color: var(--accent);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.empty-chat-icon svg {
  width: 34px;
  height: 34px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.conversation-message {
  display: grid;
  gap: 9px;
  max-width: 760px;
  margin: 0 auto 26px;
}

.conversation-message.is-user {
  justify-items: end;
}

.conversation-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.conversation-message.is-user .conversation-label {
  display: none;
}

.conversation-body {
  max-width: min(760px, 100%);
  color: var(--text);
  overflow-wrap: break-word;
  font-size: 0.98rem;
  line-height: 1.72;
}

.conversation-message.is-user .conversation-body {
  max-width: 78%;
  padding: 10px 14px;
  background: var(--surface-soft);
  border-radius: 18px;
  white-space: pre-wrap;
}

.conversation-message.is-user .conversation-body:has(.document-upload) {
  width: min(460px, 78%);
  padding: 12px 14px;
  white-space: normal;
}

.document-upload {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.document-upload-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: var(--accent);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
}

.document-upload-icon svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.document-upload-content {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.document-upload-label {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  line-height: 1.2;
  text-transform: uppercase;
}

.document-upload-name {
  overflow: hidden;
  color: var(--text);
  font-weight: 760;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.document-upload-meta {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.25;
}

.conversation-message.is-assistant .conversation-body {
  padding-top: 2px;
}

.conversation-message.is-pending .conversation-body {
  color: var(--muted);
}

.conversation-body h3 {
  margin: 18px 0 10px;
  color: var(--text);
  font-size: 1rem;
  line-height: 1.45;
}

.conversation-body h3:first-child {
  margin-top: 0;
}

.conversation-body p {
  margin: 0 0 16px;
}

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

.conversation-body strong {
  font-weight: 760;
}

.conversation-body ul {
  margin: 0 0 16px 22px;
  padding: 0;
}

.conversation-body li {
  margin-bottom: 8px;
}

.message-tools {
  display: flex;
  gap: 6px;
  margin-top: -2px;
}

.message-tools button {
  min-height: 30px;
  padding: 0 9px;
  color: var(--muted);
  font-size: 0.78rem;
}

.composer-wrap {
  position: sticky;
  bottom: 0;
  display: grid;
  justify-items: center;
  gap: 7px;
  padding: 14px 24px 12px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0), #fff 24%);
}

.composer {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: end;
  gap: 8px;
  width: min(760px, 100%);
  min-height: 54px;
  padding: 8px;
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  box-shadow: 0 18px 48px rgba(217, 45, 127, 0.14);
}

.composer:focus-within {
  border-color: var(--accent);
  box-shadow: 0 20px 55px rgba(217, 45, 127, 0.2);
}

.composer textarea {
  width: 100%;
  max-height: 180px;
  min-height: 34px;
  padding: 8px 2px;
  resize: none;
  color: var(--text);
  background: transparent;
  border: 0;
  outline: 0;
  font-size: 0.96rem;
  line-height: 1.45;
}

.composer textarea::placeholder {
  color: #8a8a8a;
}

.context-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.attach-button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  color: var(--muted-strong);
}

.context-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 0;
  min-height: 38px;
  max-width: 172px;
  padding: 0 10px;
  color: var(--muted-strong);
  font-size: 0.82rem;
  font-weight: 760;
  line-height: 1.15;
  text-align: left;
}

.context-button span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.context-button.is-active {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), #e85b97);
}

.context-button.is-active:hover {
  background: #a5165d;
}

.send-button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), #e6687e);
}

.send-button span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.send-button:hover {
  background: #a5165d;
}

.status-text {
  min-height: 18px;
  color: var(--muted);
  font-size: 0.76rem;
  text-align: center;
}

.context-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: min(760px, 100%);
  min-height: 34px;
  padding: 6px 8px 6px 11px;
  color: var(--muted-strong);
  background: rgba(255, 241, 247, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.78rem;
}

.context-status[hidden] {
  display: none;
}

.context-status span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.context-status.is-inactive {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.9);
}

.context-clear-button {
  flex: 0 0 auto;
  min-height: 26px;
  padding: 0 8px;
  color: var(--muted-strong);
  font-size: 0.76rem;
  font-weight: 740;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: var(--muted-strong);
}

.result-panel {
  display: none;
}

.thinking-box[hidden] {
  display: none;
}

.thinking-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid #dedede;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spinThinking 900ms linear infinite;
}

.send-button,
.logout-button,
.sidebar-action,
.model-button,
.chat-delete-button,
.attach-button,
.context-button,
.context-clear-button,
.icon-button,
.message-tools button {
  transition: background 140ms ease, color 140ms ease, border-color 140ms ease;
}

@keyframes spinThinking {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 820px) {
  .access-card {
    justify-content: center;
    padding: 34px 16px;
  }

  .access-card .brand-mark {
    width: 64px;
    height: 64px;
    margin-bottom: 18px;
  }

  .access-card .brand-mark svg {
    width: 36px;
    height: 36px;
  }

  .access-card h1 {
    margin-bottom: 22px;
    font-size: clamp(2.4rem, 13vw, 3.8rem);
    text-align: center;
  }

  .access-form {
    padding: 20px;
  }

  .access-shape {
    width: 280px;
    height: 170px;
  }

  .access-shape-left {
    left: -80px;
    top: 46px;
  }

  .access-shape-right {
    right: -96px;
    bottom: 34px;
  }

  .access-dot-left {
    left: 12%;
    bottom: 18%;
  }

  .access-dot-right {
    right: 10%;
    top: 18%;
  }

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

  .chat-panel {
    grid-template-rows: auto auto auto auto auto auto;
    max-height: 260px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .model-block {
    max-width: 360px;
  }

  .chat-list {
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 4px;
  }

  .chat-item {
    min-width: 190px;
  }

  .chat-row {
    min-width: 228px;
  }

  .writer-main {
    min-height: calc(100vh - 260px);
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 10px 14px;
  }

  .conversation-messages {
    padding: 24px 16px 136px;
  }

  .conversation-message.is-user .conversation-body {
    max-width: 92%;
  }

  .composer-wrap {
    padding: 12px 12px 10px;
  }

  .composer {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .context-button {
    grid-column: 1 / -1;
    width: 100%;
    max-width: none;
  }

  .composer textarea {
    grid-column: 1;
  }

}
