:root {
  color-scheme: dark;
  --bg: #171813;
  --panel: #1f201a;
  --panel-2: #272820;
  --line: #383a2f;
  --text: #f1efe6;
  --muted: #a4a492;
  --accent: #c9f07a;
  --accent-ink: #17200b;
  --danger: #ff8b83;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
button, input, textarea { font: inherit; }
button { color: inherit; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 260px minmax(0, 1fr); }
.sidebar {
  height: 100vh; position: sticky; top: 0; border-right: 1px solid var(--line);
  padding: 24px 16px; display: flex; flex-direction: column; background: #191a15;
}
.brand { display: flex; gap: 12px; align-items: center; padding: 0 8px 24px; }
.brand strong { display: block; letter-spacing: .02em; }
.brand span { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.mark {
  width: 36px; height: 36px; display: grid; place-items: center; color: var(--accent-ink);
  background: var(--accent); border-radius: 10px; font-family: Georgia, serif; font-weight: 800;
}
.new-chat {
  border: 1px solid var(--line); background: var(--panel-2); border-radius: 10px;
  text-align: left; padding: 12px 14px; cursor: pointer; margin-bottom: 18px;
}
#chat-list { display: grid; gap: 5px; overflow: auto; }
.chat-row { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 32px; }
.chat-link {
  min-width: 0; border: 0; background: transparent; padding: 11px 12px; border-radius: 8px;
  text-align: left; cursor: pointer; color: var(--muted);
}
.chat-link span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-link.active { background: var(--panel-2); color: var(--text); }
.chat-actions summary {
  height: 100%; display: grid; place-items: center; border-radius: 8px; color: var(--muted);
  cursor: pointer; list-style: none;
}
.chat-actions summary::-webkit-details-marker { display: none; }
.chat-actions[open] summary, .chat-actions summary:hover { background: var(--panel-2); color: var(--text); }
.chat-actions > div {
  position: absolute; z-index: 10; top: calc(100% - 3px); right: 0; min-width: 130px;
  padding: 5px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel);
  box-shadow: 0 12px 28px rgba(0, 0, 0, .35);
}
.chat-actions button {
  width: 100%; border: 0; border-radius: 6px; background: transparent; color: var(--muted);
  padding: 8px 10px; text-align: left; cursor: pointer;
}
.chat-actions button:hover { background: var(--panel-2); color: var(--text); }
.sidebar-footer { margin-top: auto; display: grid; gap: 4px; border-top: 1px solid var(--line); padding-top: 12px; }
.text-button { border: 0; background: transparent; color: var(--muted); padding: 8px; cursor: pointer; text-align: left; }

.chat-panel { min-width: 0; height: 100vh; display: grid; grid-template-rows: auto 1fr auto; }
.topbar {
  min-height: 80px; border-bottom: 1px solid var(--line); display: flex; align-items: center;
  gap: 14px; padding: 14px 28px; background: rgba(23, 24, 19, .92); backdrop-filter: blur(12px);
}
.topbar h1 { margin: 0; font-size: 18px; }
.menu-button { display: none; border: 0; background: transparent; font-size: 22px; }
.usage-wrap { position: relative; margin-left: auto; }
.usage-pill {
  border: 1px solid var(--line); border-radius: 99px; background: var(--panel);
  color: var(--accent); padding: 7px 12px; cursor: pointer; font-size: 12px;
}
.usage-details {
  position: absolute; z-index: 10; top: calc(100% + 9px); right: 0; width: 210px;
  display: grid; gap: 10px; padding: 14px; border: 1px solid var(--line);
  border-radius: 12px; background: var(--panel); box-shadow: 0 14px 34px rgba(0, 0, 0, .35);
}
.usage-details[hidden] { display: none; }
.usage-details div { display: flex; justify-content: space-between; gap: 20px; }
.usage-details span { color: var(--muted); font-size: 12px; }
.usage-details strong { color: var(--accent); font-size: 12px; font-variant-numeric: tabular-nums; }
.messages { overflow-y: auto; padding: 48px max(24px, calc((100% - 780px) / 2)); }
.empty-state { max-width: 580px; margin: 12vh auto; text-align: center; }
.empty-state span, .eyebrow { font-size: 11px; letter-spacing: .18em; color: var(--accent); }
.empty-state h2 { font: 500 38px/1.2 Georgia, serif; margin: 16px 0; }
.empty-state p { color: var(--muted); line-height: 1.8; }
.message { margin-bottom: 30px; }
.message.user { margin-left: 16%; }
.message-label { font-size: 10px; letter-spacing: .16em; color: var(--muted); margin-bottom: 8px; }
.message.user .message-content {
  background: var(--panel-2); border: 1px solid var(--line); padding: 15px 17px; border-radius: 14px 14px 3px 14px;
}
.message.assistant .message-label { color: var(--accent); }
.message-content { line-height: 1.75; overflow-wrap: anywhere; }
.message-content > :first-child { margin-top: 0; }
.message-content > :last-child { margin-bottom: 0; }
.message-content p { margin: 0 0 1em; }
.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4 {
  margin: 1.35em 0 .55em; line-height: 1.35; color: var(--text);
}
.message-content h1 { font-size: 1.55em; }
.message-content h2 { font-size: 1.35em; }
.message-content h3 { font-size: 1.17em; }
.message-content h4 { font-size: 1em; }
.message-content ul,
.message-content ol { margin: 0 0 1em; padding-left: 1.6em; }
.message-content li + li { margin-top: .28em; }
.message-content blockquote {
  margin: 0 0 1em; padding: .1em 0 .1em 1em;
  border-left: 3px solid var(--line); color: var(--muted);
}
.message-content a { color: var(--accent); text-underline-offset: 3px; }
.message-content hr { margin: 1.4em 0; border: 0; border-top: 1px solid var(--line); }
.message-content table { width: 100%; margin: 0 0 1em; border-collapse: collapse; }
.message-content th,
.message-content td {
  padding: 7px 10px; border: 1px solid var(--line); text-align: left; vertical-align: top;
}
.message-content th { background: var(--panel-2); color: var(--text); }
.message-content.streaming { white-space: pre-wrap; }
.thinking { display: inline-flex; align-items: center; gap: 9px; color: var(--muted); }
.thinking-dots { display: inline-flex; gap: 4px; }
.thinking-dots i {
  width: 4px; height: 4px; border-radius: 50%; background: currentColor;
  animation: thinking-dot 1.1s ease-in-out infinite;
}
.thinking-dots i:nth-child(2) { animation-delay: .14s; }
.thinking-dots i:nth-child(3) { animation-delay: .28s; }
.message-content pre {
  overflow-x: auto; margin: 0 0 1em; padding: 14px;
  border: 1px solid var(--line); border-radius: 8px; background: #12130f;
}
.message-content code {
  padding: .12em .32em; border-radius: 4px;
  background: #12130f; color: #d8eeb0; font-size: .9em;
}
.message-content pre code { padding: 0; border-radius: 0; background: none; font-size: inherit; }
.artifact-cards { display: grid; gap: 9px; margin-top: 14px; }
.artifact-card {
  width: 100%; display: grid; grid-template-columns: 38px 1fr auto; gap: 11px;
  align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--panel); text-align: left; cursor: pointer;
}
.artifact-card:hover { border-color: #66704b; background: var(--panel-2); }
.artifact-card-icon {
  width: 38px; height: 38px; display: grid; place-items: center; border-radius: 9px;
  background: color-mix(in srgb, var(--accent) 15%, var(--panel)); color: var(--accent);
  font: 700 18px Georgia, serif;
}
.artifact-card strong, .artifact-card small { display: block; }
.artifact-card strong { margin-bottom: 3px; }
.artifact-card small { color: var(--muted); font-size: 10px; letter-spacing: .05em; }
.artifact-card-open { color: var(--accent); font-size: 12px; }
.agent-activity {
  min-height: 24px; margin: -18px 0 26px;
  color: var(--muted); font-size: 13px;
}
.execution-profile {
  width: fit-content; display: inline-flex; align-items: baseline; gap: 7px;
  margin-bottom: 10px; padding: 5px 9px; border: 1px solid var(--line);
  border-radius: 999px; background: color-mix(in srgb, var(--panel) 82%, transparent);
}
.execution-profile[hidden] { display: none; }
.execution-profile span {
  color: #858678; font-size: 10px; letter-spacing: .04em;
}
.execution-profile strong { color: var(--text); font-size: 12px; }
.execution-profile small {
  color: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums;
}
.execution-profile[data-mode="quick"] strong { color: #b9d986; }
.execution-profile[data-mode="deep"] {
  border-color: color-mix(in srgb, var(--accent) 48%, var(--line));
}
.execution-profile[data-mode="deep"] strong { color: var(--accent); }
.model-activity-list {
  display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 10px;
}
.model-activity-list:empty { display: none; }
.model-activity-item {
  min-width: 178px; display: grid; grid-template-columns: 9px auto; column-gap: 8px;
  align-items: center; padding: 7px 10px; border: 1px solid var(--line);
  border-radius: 10px; background: color-mix(in srgb, var(--panel) 82%, transparent);
}
.model-activity-dot {
  grid-row: 1 / span 2; width: 7px; height: 7px; border-radius: 50%; background: #6f7064;
}
.model-activity-item.running .model-activity-dot {
  background: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 13%, transparent);
  animation: model-pulse 1.4s ease-in-out infinite;
}
.model-activity-item.complete .model-activity-dot { background: #747665; }
.model-activity-item.error .model-activity-dot { background: var(--danger); }
.model-activity-identity { display: flex; align-items: baseline; gap: 7px; min-width: 0; }
.model-activity-identity strong { color: var(--text); font-size: 12px; }
.model-activity-label { color: #858678; font-size: 10px; }
.model-activity-detail {
  grid-column: 2; color: var(--muted); font-size: 10px; overflow-wrap: anywhere;
}
.model-activity-item.complete { opacity: .7; }
.model-activity-item.error .model-activity-detail { color: var(--danger); }
.activity-current { display: flex; align-items: center; gap: 9px; }
.activity-history {
  margin: 8px 0 0 23px; padding: 0; display: grid; gap: 5px; list-style: none;
  color: #858678; font-size: 12px;
}
.activity-history:empty { display: none; }
.activity-history li { display: flex; justify-content: space-between; gap: 16px; }
.activity-step-text, .activity-text { min-width: 0; overflow-wrap: anywhere; }
.activity-history time { flex: 0 0 auto; color: #6f7064; font-variant-numeric: tabular-nums; }
.activity-indicator {
  width: 14px; height: 14px; flex: 0 0 14px; display: grid; place-items: center;
  border: 2px solid #666858; border-top-color: var(--accent); border-radius: 50%;
}
.agent-activity.running .activity-indicator { animation: activity-spin .8s linear infinite; }
.agent-activity.complete .activity-indicator, .agent-activity.error .activity-indicator {
  border: 0; font-size: 14px; font-weight: 700;
}
.agent-activity.complete .activity-indicator::before { content: "✓"; color: var(--accent); }
.agent-activity.error { color: var(--danger); }
.agent-activity.error .activity-indicator::before { content: "!"; color: var(--danger); }
.page-error {
  margin-bottom: 24px; padding: 12px 14px; border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent);
  border-radius: 10px; color: var(--danger); background: color-mix(in srgb, var(--danger) 8%, transparent);
}
@keyframes activity-spin { to { transform: rotate(360deg); } }
@keyframes model-pulse {
  0%, 100% { opacity: .55; }
  50% { opacity: 1; }
}
@keyframes thinking-dot {
  0%, 60%, 100% { opacity: .35; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}
@media (prefers-reduced-motion: reduce) {
  .agent-activity.running .activity-indicator,
  .model-activity-item.running .model-activity-dot,
  .thinking-dots i { animation: none; }
}

.composer-wrap { padding: 12px max(24px, calc((100% - 780px) / 2)) max(16px, env(safe-area-inset-bottom)); }
.composer {
  border: 1px solid #4a4d3c; background: var(--panel); border-radius: 16px; padding: 10px 10px 10px 16px;
  display: flex; gap: 10px; align-items: flex-end; box-shadow: 0 12px 40px rgba(0, 0, 0, .2);
}
.composer textarea {
  resize: none; flex: 1; min-height: 26px; max-height: 180px; border: 0; outline: 0;
  background: transparent; color: var(--text); padding: 6px 0;
}
.composer button {
  width: 40px; height: 40px; border: 0; border-radius: 11px; background: var(--accent);
  color: var(--accent-ink); font-size: 22px; cursor: pointer; font-weight: 700;
}
.composer button:disabled { opacity: .4; cursor: wait; }
.composer-note { text-align: center; color: #777869; font-size: 10px; margin: 8px 0 0; }

.notes-panel {
  position: fixed; z-index: 20; inset: 0 0 0 auto; width: min(1120px, 96vw); background: var(--bg);
  border-left: 1px solid var(--line); transform: translateX(100%); transition: transform .2s ease;
}
.integration-panel {
  position: fixed; z-index: 20; inset: 0 0 0 auto; width: min(480px, 94vw);
  background: var(--bg); border-left: 1px solid var(--line);
  transform: translateX(100%); transition: transform .2s ease;
}
.integration-panel.open { transform: translateX(0); }
.integration-panel > header {
  height: 72px; padding: 0 22px; display: flex; align-items: center;
  border-bottom: 1px solid var(--line);
}
.integration-panel h2 { margin: 3px 0 0; font-size: 17px; }
.integration-panel header button {
  margin-left: auto; border: 0; background: transparent; font-size: 26px; cursor: pointer;
}
.integration-body { height: calc(100vh - 72px); overflow: auto; padding: 26px 22px; }
.integration-lead { margin: 0 0 22px; color: var(--muted); line-height: 1.7; }
.integration-status {
  padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel);
}
.integration-notice strong { color: var(--accent); }
.integration-notice p { margin: 8px 0 0; color: var(--muted); line-height: 1.6; }
.integration-grid { margin: 0; display: grid; gap: 12px; }
.integration-grid div { display: flex; justify-content: space-between; gap: 20px; }
.integration-grid dt { color: var(--muted); }
.integration-grid dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
.integration-error {
  margin-top: 15px; padding: 10px; border-radius: 8px;
  background: color-mix(in srgb, var(--danger) 10%, transparent); color: var(--danger);
  font-size: 12px; overflow-wrap: anywhere;
}
.integration-actions { margin-top: 18px; display: flex; flex-wrap: wrap; gap: 9px; }
.integration-actions button {
  border: 1px solid var(--line); border-radius: 9px; background: var(--panel-2);
  padding: 10px 13px; cursor: pointer;
}
.integration-actions button:disabled { opacity: .5; cursor: wait; }
.integration-actions .primary-action {
  border-color: var(--accent); background: var(--accent); color: var(--accent-ink);
  font-weight: 700;
}
.integration-actions .danger-action { color: var(--danger); }
.archived-thread-list { display: grid; gap: 10px; }
.archived-thread {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px; border: 1px solid var(--line); border-radius: 11px; background: var(--panel);
}
.archived-thread div { min-width: 0; }
.archived-thread strong, .archived-thread small { display: block; }
.archived-thread strong { overflow-wrap: anywhere; font-size: 13px; }
.archived-thread small { margin-top: 5px; color: var(--muted); font-size: 11px; }
.archived-thread button {
  flex: none; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2);
  padding: 8px 11px; cursor: pointer;
}
.archived-thread button:hover { border-color: var(--accent); color: var(--accent); }
.secret-cards { display: grid; gap: 14px; }
.secret-card {
  padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel);
}
.secret-card-heading {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 14px;
  margin-bottom: 14px;
}
.secret-card h3 { margin: 0; font-size: 15px; }
.secret-card-heading p, .secret-help {
  margin: 4px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5;
}
.secret-badge {
  flex: none; padding: 4px 7px; border-radius: 999px; background: var(--panel-2);
  color: var(--muted); font-size: 11px;
}
.secret-badge.configured { color: var(--accent); }
.secret-card label, .secret-confirmation {
  display: grid; gap: 6px; margin-top: 11px; color: var(--muted); font-size: 12px;
}
.secret-card input, .secret-confirmation input {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; background: var(--bg);
  color: var(--text); padding: 10px 11px; font: inherit;
}
.secret-actions { display: flex; gap: 8px; margin-top: 13px; }
.secret-actions button {
  border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2);
  padding: 8px 11px; cursor: pointer;
}
.secret-actions .primary-action {
  border-color: var(--accent); background: var(--accent); color: var(--accent-ink);
  font-weight: 700;
}
.secret-actions .danger-action { color: var(--danger); }
.secret-confirmation { margin-top: 20px; }
.secret-feedback { min-height: 1.5em; color: var(--muted); font-size: 12px; }
.secret-feedback.error { color: var(--danger); }
.notes-panel.open { transform: translateX(0); }
.notes-panel > header { height: 72px; padding: 0 22px; display: flex; align-items: center; border-bottom: 1px solid var(--line); }
.notes-panel h2 { margin: 3px 0 0; font-size: 17px; }
.notes-total { margin-left: auto; color: var(--muted); font-size: 12px; }
.notes-panel header button { margin-left: 12px; background: transparent; border: 0; font-size: 26px; cursor: pointer; }
.notes-body { height: calc(100vh - 72px); display: grid; grid-template-columns: 340px 1fr; }
.notes-browser {
  min-width: 0; overflow: hidden; display: grid; grid-template-rows: auto 1fr;
  border-right: 1px solid var(--line); background: #191a15;
}
.notes-browser-tools { padding: 16px; border-bottom: 1px solid var(--line); }
.notes-search { display: grid; gap: 7px; color: var(--muted); font-size: 11px; }
.notes-search input {
  width: 100%; border: 1px solid var(--line); border-radius: 9px; background: var(--bg);
  color: var(--text); padding: 10px 11px; outline: none;
}
.notes-search input:focus { border-color: var(--accent); }
.notes-collections {
  display: flex; gap: 7px; margin-top: 12px; overflow-x: auto; scrollbar-width: thin;
  padding-bottom: 2px;
}
.notes-collection {
  flex: none; display: flex; align-items: center; gap: 7px; border: 1px solid var(--line);
  border-radius: 999px; background: transparent; color: var(--muted); padding: 6px 9px;
  cursor: pointer; font-size: 11px;
}
.notes-collection strong { color: inherit; font-size: 10px; font-variant-numeric: tabular-nums; }
.notes-collection.active { border-color: var(--accent); background: var(--panel-2); color: var(--accent); }
#notes-tree { overflow: auto; padding: 10px; }
.note-folder { margin: 2px 0; }
.note-folder summary {
  display: flex; align-items: center; gap: 7px; min-height: 36px; padding: 7px 8px;
  border-radius: 8px; color: var(--muted); cursor: pointer; list-style: none;
}
.note-folder summary::-webkit-details-marker { display: none; }
.note-folder summary:hover { background: var(--panel-2); color: var(--text); }
.note-folder-chevron { font-size: 18px; line-height: 1; transition: transform .15s ease; }
.note-folder[open] > summary .note-folder-chevron { transform: rotate(90deg); }
.note-folder-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-folder-count {
  margin-left: auto; color: #777869; font-size: 10px; font-variant-numeric: tabular-nums;
}
.note-folder-children { margin-left: 11px; padding-left: 7px; border-left: 1px solid var(--line); }
.note-item {
  width: 100%; min-height: 36px; display: flex; align-items: center; gap: 9px;
  border: 0; border-radius: 8px; background: transparent; color: var(--muted);
  text-align: left; padding: 7px 8px; cursor: pointer;
}
.note-item:hover { background: var(--panel-2); color: var(--text); }
.note-item.active { background: var(--panel-2); color: var(--accent); }
.note-item-mark {
  flex: none; width: 20px; height: 20px; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 5px; color: #777869;
  font: 700 9px ui-monospace, monospace;
}
.note-item.active .note-item-mark { border-color: var(--accent); color: var(--accent); }
.note-item-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notes-empty {
  min-height: 160px; display: grid; place-content: center; gap: 7px; padding: 20px;
  text-align: center; color: var(--muted);
}
.notes-empty strong { color: var(--text); font-size: 13px; }
.notes-empty span { font-size: 11px; }
#note-content { padding: 28px; overflow: auto; line-height: 1.7; }
#note-content a { color: var(--accent); text-underline-offset: 3px; }
#note-content img { display: block; max-width: 100%; height: auto; margin: 14px 0; border-radius: 8px; }
.note-path { color: var(--accent); font: 11px ui-monospace, monospace; }

.kindle-panel {
  position: fixed; z-index: 20; inset: 0 0 0 auto; width: min(1100px, 96vw);
  background: var(--bg); border-left: 1px solid var(--line);
  transform: translateX(100%); transition: transform .2s ease;
}
.kindle-panel.open { transform: translateX(0); }
.kindle-panel > header {
  height: 72px; padding: 0 22px; display: flex; align-items: center;
  border-bottom: 1px solid var(--line); background: var(--panel);
}
.kindle-panel h2 { margin: 3px 0 0; font-size: 17px; }
.kindle-panel > header > button {
  margin-left: auto; border: 0; background: transparent; font-size: 26px; cursor: pointer;
}
.kindle-body {
  height: calc(100vh - 72px); display: grid; grid-template-rows: auto minmax(0, 1fr);
}
.kindle-controls { padding: 20px 22px; border-bottom: 1px solid var(--line); }
.kindle-status-line { display: flex; align-items: center; gap: 12px; }
.kindle-status-line strong { font-size: 14px; }
.kindle-status-badge {
  flex: 0 0 auto; padding: 5px 9px; border: 1px solid var(--line);
  border-radius: 999px; color: var(--muted); font-size: 10px;
}
.kindle-status-badge.connected {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  color: var(--accent);
}
.kindle-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.kindle-actions button {
  min-height: 38px; padding: 0 13px; border: 1px solid var(--line);
  border-radius: 9px; background: var(--panel-2); cursor: pointer;
}
.kindle-actions button.primary {
  border-color: var(--accent); background: var(--accent); color: var(--accent-ink);
  font-weight: 700;
}
.kindle-actions button:disabled { opacity: .42; cursor: not-allowed; }
.kindle-controls progress {
  display: block; width: 100%; height: 6px; margin-top: 16px; accent-color: var(--accent);
}
.kindle-controls progress[hidden] { display: none; }
.kindle-detail, .kindle-warning, .kindle-error {
  margin: 12px 0 0; font-size: 12px; line-height: 1.55;
}
.kindle-detail { color: var(--muted); }
.kindle-warning { color: #f1c86f; }
.kindle-error { color: var(--danger); }
.kindle-browser-wrap { min-height: 0; background: #111; }
.kindle-browser-wrap[hidden] { display: none; }
#kindle-browser { display: block; width: 100%; height: 100%; border: 0; background: #111; }

.app-shell.artifact-open {
  grid-template-columns: 260px minmax(360px, .82fr) minmax(520px, 1.18fr);
}
.artifact-panel {
  display: none; min-width: 0; height: 100vh; border-left: 1px solid var(--line);
  background: #12130f;
}
.artifact-panel.open { display: grid; grid-template-rows: 72px 1fr; }
.artifact-header {
  min-width: 0; padding: 0 16px 0 20px; display: flex; align-items: center;
  gap: 16px; border-bottom: 1px solid var(--line); background: var(--panel);
}
.artifact-header h2 {
  max-width: 360px; margin: 3px 0 0; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; font-size: 16px;
}
.artifact-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.artifact-actions select, .artifact-action {
  height: 34px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel-2); color: var(--text); padding: 0 9px; font-size: 12px;
}
.artifact-action { display: inline-flex; align-items: center; text-decoration: none; }
.artifact-actions button {
  width: 34px; height: 34px; border: 0; background: transparent; cursor: pointer;
  font-size: 25px;
}
.artifact-body { min-height: 0; display: grid; grid-template-columns: 210px minmax(0, 1fr); }
#artifact-list {
  min-height: 0; overflow: auto; padding: 12px; border-right: 1px solid var(--line);
  background: #171813;
}
#artifact-list button {
  width: 100%; display: block; padding: 11px; border: 1px solid transparent;
  border-radius: 9px; background: transparent; text-align: left; cursor: pointer;
}
#artifact-list button.active {
  border-color: var(--line); background: var(--panel-2);
}
#artifact-list strong, #artifact-list small { display: block; }
#artifact-list strong { overflow-wrap: anywhere; font-size: 12px; }
#artifact-list small { margin-top: 4px; color: var(--muted); font-size: 9px; }
.artifact-empty { padding: 8px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.artifact-viewer { min-width: 0; min-height: 0; display: grid; grid-template-rows: 43px 1fr; }
.artifact-tabs {
  padding: 6px 10px; display: flex; gap: 3px; border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.artifact-tabs button {
  border: 0; border-radius: 7px; background: transparent; color: var(--muted);
  padding: 0 12px; cursor: pointer; font-size: 11px;
}
.artifact-tabs button.active { background: var(--panel-2); color: var(--text); }
.artifact-stage { min-height: 0; overflow: auto; background: #fff; color: #181818; }
.artifact-stage > .muted { padding: 30px; color: #666; }
.artifact-frame { display: block; width: 100%; height: 100%; border: 0; background: #fff; }
.artifact-stage > pre {
  min-height: 100%; margin: 0; padding: 24px; overflow: auto; white-space: pre-wrap;
  overflow-wrap: anywhere; background: #11130f; color: #e3ead5; font: 12px/1.65 ui-monospace, monospace;
}
.scrim { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.58); z-index: 15; }
.scrim.show { display: block; }

.login-body { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 50% 0, #303326, var(--bg) 50%); }
.login-card { width: min(420px, 100%); border: 1px solid var(--line); background: rgba(31,32,26,.95); border-radius: 20px; padding: 34px; }
.login-card .mark { margin-bottom: 28px; }
.login-card h1 { font: 500 36px Georgia, serif; margin: 10px 0; }
.muted { color: var(--muted); }
.login-form { margin-top: 28px; display: grid; gap: 18px; }
.login-form label span { display: block; font-size: 11px; color: var(--muted); margin-bottom: 7px; }
.login-form input { width: 100%; border: 1px solid var(--line); background: #161711; color: var(--text); border-radius: 10px; padding: 13px; outline: none; }
.login-form input:focus { border-color: var(--accent); }
.login-form button { border: 0; background: var(--accent); color: var(--accent-ink); border-radius: 10px; padding: 13px; font-weight: 700; cursor: pointer; }
.error-banner { color: var(--danger); font-size: 13px; }

@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; z-index: 20; inset: 0 auto 0 0; width: 280px; transform: translateX(-100%); transition: transform .2s ease; }
  .sidebar.open { transform: translateX(0); }
  .chat-panel { height: 100dvh; }
  .menu-button { display: block; }
  .topbar { padding: 10px 14px; min-height: 66px; }
  .messages { padding: 28px 16px; }
  .message.user { margin-left: 8%; }
  .model-activity-item { min-width: min(178px, 100%); flex: 1 1 160px; }
  .composer-wrap { padding: 10px 12px max(10px, env(safe-area-inset-bottom)); }
  .composer-note { display: none; }
  .notes-panel { z-index: 30; width: 100vw; height: 100dvh; }
  .notes-panel > header { height: 66px; padding: 0 14px; }
  .notes-body { height: calc(100dvh - 66px); grid-template-columns: 1fr; grid-template-rows: minmax(220px, 42vh) 1fr; }
  .notes-browser { border-right: 0; border-bottom: 1px solid var(--line); }
  .notes-browser-tools { padding: 11px 14px; }
  #notes-tree { min-height: 0; }
  #note-content { padding: 18px; }
  .kindle-panel {
    z-index: 30; width: 100vw; height: 100dvh;
  }
  .kindle-panel > header { height: 66px; padding: 0 14px; }
  .kindle-body { height: calc(100dvh - 66px); }
  .kindle-controls { padding: 14px; }
  .kindle-status-line { align-items: flex-start; flex-direction: column; gap: 8px; }
  .kindle-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kindle-actions button { width: 100%; min-width: 0; }
  .artifact-panel.open {
    position: fixed; z-index: 30; inset: 0; width: 100vw; height: 100dvh;
  }
  .artifact-header { height: 66px; padding: 0 10px 0 14px; }
  .artifact-header h2 { max-width: 38vw; }
  .artifact-actions { gap: 4px; }
  .artifact-body { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  #artifact-list {
    display: flex; gap: 7px; max-height: 88px; border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  #artifact-list button { min-width: 150px; width: auto; }
  .artifact-card { grid-template-columns: 38px 1fr; }
  .artifact-card-open { display: none; }
}

@media (min-width: 761px) and (max-width: 1180px) {
  .app-shell.artifact-open { grid-template-columns: 260px minmax(0, 1fr); }
  .artifact-panel.open {
    position: fixed; z-index: 20; inset: 0 0 0 auto; width: min(880px, calc(100vw - 80px));
    box-shadow: -20px 0 50px rgba(0, 0, 0, .4);
  }
}
