:root {
  color-scheme: light;
  font-family: Inter, Segoe UI, Arial, sans-serif;
  --ink: #172026;
  --muted: #66727c;
  --line: #d8dee4;
  --soft: #f5f7f8;
  --panel: #ffffff;
  --accent: #0f766e;
  --accent-soft: #e9f6f4;
}

* { box-sizing: border-box; }
html,
body {
  height: 100%;
}
body {
  margin: 0;
  color: var(--ink);
  background: var(--panel);
  overflow: hidden;
}
.layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  height: 100vh;
  max-height: 100vh;
  min-height: 0;
  overflow: hidden;
}
.sidebar {
  border-right: 1px solid var(--line);
  padding: 16px 12px;
  background: #fafbfc;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 14px;
  height: 100vh;
  min-height: 0;
  overflow: hidden;
}
.brand { font-weight: 700; font-size: 21px; }
.login-pane,
.conversation-pane {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}
.conversation-pane {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  min-height: 0;
  overflow: hidden;
}
.sidebar-label {
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.conversation-list {
  display: flex;
  min-height: 0;
  height: 100%;
  overflow: auto;
  flex-direction: column;
  gap: 2px;
  padding-right: 4px;
  overscroll-behavior: contain;
}
.conversation-item {
  width: 100%;
  background: transparent;
  color: var(--ink);
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 24px;
  align-items: center;
  gap: 4px;
  text-align: left;
  min-height: 36px;
}
.conversation-open {
  min-width: 0;
  height: 36px;
  padding: 8px 8px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}
.conversation-open:hover {
  background: transparent;
}
.conversation-item:hover {
  background: white;
  border-color: var(--line);
}
.conversation-item.active {
  background: var(--accent-soft);
  border-color: #cfe7e3;
}
.conversation-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.conversation-title {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.25;
}
.conversation-actions {
  width: 24px;
  height: 24px;
  padding: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  opacity: 0;
}
.conversation-item:hover .conversation-actions,
.conversation-item:focus-within .conversation-actions {
  opacity: 1;
}
.conversation-actions:hover {
  background: var(--soft);
  color: var(--ink);
}
.conversation-rename-input {
  height: 26px;
  padding: 3px 6px;
  font-size: 13px;
  border-radius: 5px;
}
.conversation-empty {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}
.logout-button {
  margin-top: auto;
}
label { font-size: 13px; color: var(--muted); }
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  font: inherit;
  background: white;
}
textarea { resize: vertical; }
button {
  border: 0;
  border-radius: 6px;
  padding: 10px 14px;
  background: var(--accent);
  color: white;
  font-weight: 650;
  cursor: pointer;
}
#newConversation {
  padding: 9px 12px;
  font-size: 14px;
}
button.ghost {
  background: white;
  color: var(--ink);
  border: 1px solid var(--line);
}
.hidden { display: none !important; }
.status { margin-top: 8px; font-size: 13px; color: var(--muted); min-height: 20px; }
.model-info {
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}
.workspace {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
  background: white;
}
.topbar {
  border-bottom: 1px solid var(--line);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  gap: 16px;
  justify-content: space-between;
}
h1 { margin: 0; font-size: 20px; }
h2 { margin: 0; font-size: 18px; }
p { margin: 4px 0 0; color: var(--muted); }
.tabs { display: flex; gap: 8px; padding: 8px 28px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab { background: white; color: var(--ink); border: 1px solid var(--line); }
.tab.active { background: var(--accent); color: white; border-color: var(--accent); }
.panel { display: none; min-height: 0; height: 100%; overflow: hidden; }
.panel.active { display: grid; min-height: 0; height: 100%; overflow: hidden; }
#chatPanel.active {
  grid-template-rows: minmax(0, 1fr) auto;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}
#chatPanel.empty-chat.active { grid-template-rows: minmax(0, 1fr) auto; align-content: stretch; }
#chatPanel.empty-chat .messages {
  min-height: 0;
  padding-bottom: 0;
}
#chatPanel.empty-chat .composer {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}
.messages {
  padding: 28px max(28px, calc((100vw - 1160px) / 2));
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
  height: 100%;
  min-height: 0;
  overscroll-behavior: contain;
}
.msg {
  max-width: 860px;
  border-radius: 10px;
  padding: 13px 15px;
  white-space: pre-wrap;
  line-height: 1.5;
}
.msg.user { align-self: flex-end; background: var(--accent-soft); border: 1px solid #cfe7e3; }
.msg.assistant { background: white; border: 0; padding-left: 0; }
.msg.pending { color: var(--muted); }
.message-actions {
  margin-top: 10px;
  display: flex;
  gap: 8px;
}
.download-button {
  width: fit-content;
  padding: 8px 12px;
  font-size: 13px;
}
.improvements-panel.active {
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 12px;
  padding: 18px 28px;
}
.improvement-header,
.improvement-actions,
.improvement-filters,
.improvement-detail-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.improvement-header { justify-content: space-between; }
.subtle-link {
  color: var(--muted);
  display: inline-block;
  font-size: 13px;
  margin-top: 6px;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.improvement-actions button,
.improvement-detail-actions button {
  padding: 8px 10px;
  font-size: 13px;
}
.improvement-filters select {
  max-width: 220px;
  padding: 8px 10px;
  font-size: 13px;
}
.improvement-layout {
  display: grid;
  grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
  gap: 14px;
  min-height: 0;
  overflow: hidden;
}
.improvements-list,
.improvement-detail {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  min-height: 0;
  overflow: auto;
}
.improvements-list {
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.improvement-row {
  background: white;
  color: var(--ink);
  border: 1px solid transparent;
  padding: 8px 9px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.improvement-row:hover,
.improvement-row.active {
  background: var(--accent-soft);
  border-color: #cfe7e3;
}
.improvement-row strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}
.improvement-row span,
.improvement-meta {
  color: var(--muted);
  font-size: 12px;
}
.improvement-row.critical { border-left: 4px solid #b42318; }
.improvement-row.high { border-left: 4px solid #b54708; }
.improvement-row.medium { border-left: 4px solid #0f766e; }
.improvement-row.low { border-left: 4px solid #66727c; }
.improvement-detail {
  padding: 14px;
}
.improvement-detail h3 {
  margin: 0 0 6px;
  font-size: 17px;
}
.improvement-fields {
  display: grid;
  gap: 10px;
  margin: 12px 0;
}
.improvement-fields pre {
  white-space: pre-wrap;
  margin: 4px 0 0;
  padding: 8px;
  background: var(--soft);
  border-radius: 6px;
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
}
.improvement-mini-chat {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-top: 12px;
}
.improvement-mini-chat textarea {
  min-height: 76px;
}
.mini-chat-feedback {
  color: var(--accent);
  font-size: 13px;
  min-height: 18px;
}
.danger-text {
  color: #b42318 !important;
}
.composer {
  padding: 14px max(28px, calc((100vw - 1160px) / 2)) 24px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: end;
  border-top: 1px solid var(--line);
  background: white;
  z-index: 5;
}
.composer-input {
  display: grid;
  gap: 5px;
  min-width: 0;
}
.composer textarea {
  border-radius: 10px;
  min-height: 56px;
  max-height: 180px;
  box-shadow: 0 1px 2px rgba(20, 31, 39, 0.05);
}
.composer-actions {
  display: flex;
  align-items: end;
  gap: 8px;
}
.voice-button {
  background: white;
  color: var(--accent);
  border: 1px solid #bfdad5;
  min-width: 76px;
}
.voice-button:hover {
  background: var(--accent-soft);
}
.voice-button.listening {
  background: #b42318;
  border-color: #b42318;
  color: white;
}
.voice-button:disabled {
  color: var(--muted);
  border-color: var(--line);
  cursor: not-allowed;
  opacity: 0.7;
}
.voice-status {
  color: var(--muted);
  font-size: 12px;
  min-height: 16px;
}
.voice-status.voice-error {
  color: #b42318;
}
.import-panel.active {
  padding: 24px;
  align-content: start;
  overflow: auto;
}
.artifact-panel.active {
  padding: 24px;
  align-content: start;
  gap: 18px;
  overflow: auto;
}
.artifact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  max-width: 980px;
}
.artifact-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  display: grid;
  gap: 6px;
}
.exports-list {
  display: grid;
  gap: 8px;
  max-width: 980px;
}
.export-item {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: white;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}
.export-item strong {
  font-size: 14px;
  grid-column: 1;
}
.export-item span,
.export-item code {
  color: var(--muted);
  font-size: 12px;
  grid-column: 1;
}
.export-item code {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.export-item .download-button {
  grid-column: 2;
  grid-row: 1 / span 3;
}
.artifact-item span,
.empty-state {
  color: var(--muted);
  font-size: 14px;
}
.empty-state {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  max-width: 760px;
  background: var(--soft);
}
.upload-zone {
  max-width: 720px;
  display: grid;
  gap: 12px;
}
.checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
}
.checkbox input { width: auto; }
pre {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  overflow: auto;
  white-space: pre-wrap;
}
.security-banner {
  max-width: 860px;
  border: 1px solid #f0c36d;
  background: #fff8e6;
  border-radius: 8px;
  padding: 14px;
  line-height: 1.45;
}
.secure-form {
  max-width: 720px;
  display: grid;
  gap: 12px;
}
.secure-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.identity-result {
  max-width: 860px;
}
.context-menu {
  position: fixed;
  z-index: 1000;
  min-width: 220px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: 0 12px 28px rgba(20, 31, 39, 0.15);
}
.context-menu button {
  width: 100%;
  background: white;
  color: var(--ink);
  text-align: left;
  border-radius: 6px;
  padding: 8px 10px;
}
.context-menu button:hover {
  background: var(--soft);
}
.context-menu button.danger {
  color: #9f1d1d;
}
.context-menu button.danger:hover {
  background: #fff1f1;
}
@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .topbar { align-items: stretch; flex-direction: column; }
  .composer { grid-template-columns: 1fr; }
  .composer-actions { justify-content: flex-end; }
}
