:root {
  color-scheme: light;
  --page: #e9e5da;
  --surface: #f8f6ef;
  --surface-strong: #fffdf7;
  --panel: #f2efe6;
  --text: #17201d;
  --muted: #66706c;
  --line: #d7d2c7;
  --line-strong: #bcb8ad;
  --accent: #0d7054;
  --accent-deep: #07543e;
  --accent-soft: #d7ebe2;
  --saffron: #de8b21;
  --danger: #a33a2f;
  --success: #16704f;
  --focus: #126eac;
  --shadow: 0 16px 48px rgb(34 38 33 / 10%);
  --radius: 16px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--page); color: var(--text); overflow: hidden; }
button, input, textarea { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, textarea:focus-visible, [tabindex]:focus-visible { outline: 3px solid color-mix(in srgb, var(--focus) 70%, white); outline-offset: 2px; }
[hidden] { display: none !important; }

.app-shell { min-height: 100%; display: grid; grid-template-rows: 68px minmax(0, 1fr); }
.topbar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 20px; padding: 0 22px; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { justify-self: start; display: inline-flex; align-items: center; gap: 11px; color: inherit; text-decoration: none; }
.brand > span:last-child { display: grid; line-height: 1.08; }
.brand strong { font-family: Georgia, "Times New Roman", serif; font-size: 22px; font-weight: 600; letter-spacing: .01em; }
.brand small { margin-top: 4px; color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .12em; }
.brand-mark, .login-mark { width: 32px; height: 38px; display: flex; align-items: flex-end; gap: 3px; transform: skew(-5deg); }
.brand-mark span, .login-mark span { width: 8px; background: var(--accent); border-radius: 7px 7px 2px 2px; }
.brand-mark span:nth-child(1), .login-mark span:nth-child(1) { height: 21px; }
.brand-mark span:nth-child(2), .login-mark span:nth-child(2) { height: 34px; background: var(--saffron); }
.brand-mark span:nth-child(3), .login-mark span:nth-child(3) { height: 26px; }
.run-status { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; font-weight: 650; letter-spacing: .02em; }
.status-dot { width: 8px; height: 8px; border-radius: 999px; background: var(--line-strong); box-shadow: 0 0 0 4px rgb(188 184 173 / 20%); }
.run-status.online .status-dot { background: var(--success); box-shadow: 0 0 0 4px rgb(22 112 79 / 15%); }
.run-status.running .status-dot { background: var(--saffron); animation: pulse 1.2s infinite; }
.run-status.error .status-dot { background: var(--danger); }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px rgb(222 139 33 / 10%); } }
.top-actions { justify-self: end; display: flex; align-items: center; gap: 8px; }
.icon-button, .avatar-button { width: 36px; height: 36px; display: inline-grid; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-strong); cursor: pointer; transition: border-color .16s, background .16s, transform .16s; }
.icon-button:hover, .avatar-button:hover { border-color: var(--line-strong); background: white; }
.icon-button:active, .avatar-button:active { transform: translateY(1px); }
.avatar-button { border-radius: 50%; background: var(--text); color: white; border-color: var(--text); font-size: 12px; font-weight: 800; }

.workspace { min-height: 0; display: grid; grid-template-columns: minmax(220px, 290px) minmax(420px, 1fr) minmax(280px, 390px); gap: 1px; background: var(--line); }
.panel { min-width: 0; min-height: 0; background: var(--surface); }
.files-panel { position: relative; display: grid; grid-template-rows: auto auto minmax(0, 1fr); }
.panel-heading, .conversation-heading { min-height: 74px; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 17px 18px 13px; }
.eyebrow { display: block; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .12em; line-height: 1.2; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
.panel-heading h1, .conversation-heading h2 { margin: 2px 0 0; font-size: 18px; line-height: 1.2; }
.heading-actions { display: flex; gap: 6px; }
.upload-label { cursor: pointer; }
.upload-label input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.breadcrumb { min-height: 42px; display: flex; align-items: center; gap: 3px; padding: 0 16px 10px; overflow-x: auto; white-space: nowrap; border-bottom: 1px solid var(--line); }
.breadcrumb button { border: 0; padding: 4px 5px; background: transparent; color: var(--muted); font-size: 12px; cursor: pointer; border-radius: 6px; }
.breadcrumb button:hover { background: var(--panel); color: var(--text); }
.breadcrumb i { color: var(--line-strong); font-style: normal; }
.file-list { overflow-y: auto; padding: 8px; }
.file-row { width: 100%; min-height: 48px; display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; gap: 9px; align-items: center; padding: 7px 9px; border: 1px solid transparent; border-radius: 10px; background: transparent; text-align: left; cursor: pointer; }
.file-row:hover { background: var(--panel); }
.file-row.selected { border-color: #a7cbbd; background: var(--accent-soft); }
.file-icon { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; background: #e2ded3; color: #4f5955; font-size: 12px; font-weight: 850; text-transform: uppercase; }
.file-icon.folder { background: #f3dbb8; color: #85561a; }
.file-icon.html { background: #d7ebe2; color: var(--accent-deep); }
.file-row strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.file-row small { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; }
.file-actions { display: flex; opacity: 0; }
.file-row:hover .file-actions, .file-row:focus-within .file-actions { opacity: 1; }
.file-actions button { width: 28px; height: 28px; border: 0; background: transparent; color: var(--muted); cursor: pointer; border-radius: 7px; }
.file-actions button:hover { background: var(--surface-strong); color: var(--danger); }
.file-empty { padding: 42px 20px; text-align: center; color: var(--muted); font-size: 13px; }
.drop-hint { position: absolute; inset: 10px; z-index: 4; display: none; place-content: center; gap: 5px; border: 2px dashed var(--accent); border-radius: var(--radius); background: rgb(242 239 230 / 94%); color: var(--accent-deep); text-align: center; }
.drop-hint span { color: var(--muted); font-size: 12px; }
.files-panel.dragging .drop-hint { display: grid; }

.conversation-panel { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; background: var(--surface-strong); }
.conversation-heading { border-bottom: 1px solid var(--line); }
.voice-output-toggle { min-height: 34px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--muted); font-size: 11px; font-weight: 700; cursor: pointer; }
.voice-output-toggle[aria-pressed="true"] { border-color: #9dc8b7; background: var(--accent-soft); color: var(--accent-deep); }
.messages { overflow-y: auto; padding: 28px clamp(18px, 4vw, 58px); scroll-behavior: smooth; }
.empty-state { max-width: 560px; margin: 7vh auto 0; text-align: center; }
.empty-symbol { width: 52px; height: 52px; display: grid; place-items: center; margin: 0 auto 16px; border: 1px solid #9dc8b7; border-radius: 15px; background: var(--accent-soft); color: var(--accent-deep); font-family: Georgia, serif; font-size: 25px; }
.empty-state h3 { margin-bottom: 9px; font-family: Georgia, "Times New Roman", serif; font-size: clamp(23px, 3vw, 31px); font-weight: 500; line-height: 1.15; }
.empty-state p { max-width: 520px; margin: 0 auto; color: var(--muted); font-size: 13px; line-height: 1.65; }
.suggestions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 25px; }
.suggestions button { min-height: 68px; padding: 11px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); font-size: 11px; line-height: 1.4; cursor: pointer; }
.suggestions button:hover { border-color: #9dc8b7; background: var(--accent-soft); }
.message { max-width: 760px; margin: 0 auto 24px; display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 10px; }
.message.user { grid-template-columns: minmax(0, 1fr); justify-items: end; }
.message-avatar { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 9px; background: var(--accent); color: white; font-family: Georgia, serif; font-size: 13px; }
.message-bubble { min-width: 0; }
.message.user .message-bubble { max-width: 84%; padding: 11px 14px; border-radius: 14px 14px 3px 14px; background: #e6e2d8; }
.message-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.message-head strong { font-size: 12px; }
.message-head time { color: var(--muted); font-size: 10px; }
.message-content { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.65; }
.message-content code { padding: 2px 5px; border-radius: 5px; background: var(--panel); color: var(--accent-deep); font-family: "SFMono-Regular", Consolas, monospace; font-size: .9em; }
.message-files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.message-files button { padding: 5px 8px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); font-size: 10px; cursor: pointer; }
.thinking-row { max-width: 760px; margin: 0 auto 24px; display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 12px; }
.thinking-bars { display: flex; align-items: end; gap: 2px; height: 14px; }
.thinking-bars i { width: 3px; background: var(--saffron); border-radius: 3px; animation: bars 1s infinite ease-in-out; }
.thinking-bars i:nth-child(1) { height: 7px; }.thinking-bars i:nth-child(2) { height: 13px; animation-delay: .12s; }.thinking-bars i:nth-child(3) { height: 9px; animation-delay: .24s; }
@keyframes bars { 50% { height: 4px; opacity: .55; } }
.composer { padding: 12px clamp(18px, 4vw, 58px) 16px; border-top: 1px solid var(--line); background: var(--surface-strong); }
.attachment-row { max-width: 760px; display: flex; flex-wrap: wrap; gap: 6px; margin: 0 auto 7px; }
.attachment-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 6px 5px 9px; border: 1px solid #a7cbbd; border-radius: 999px; background: var(--accent-soft); color: var(--accent-deep); font-size: 10px; }
.attachment-chip button { width: 18px; height: 18px; border: 0; border-radius: 50%; background: rgb(13 112 84 / 12%); cursor: pointer; }
.composer-box { max-width: 760px; min-height: 52px; display: grid; grid-template-columns: 40px minmax(0, 1fr) 38px; gap: 6px; align-items: end; margin: 0 auto; padding: 6px; border: 1px solid var(--line-strong); border-radius: 15px; background: white; box-shadow: 0 5px 18px rgb(42 44 37 / 7%); }
.composer-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgb(13 112 84 / 10%); }
.composer textarea { width: 100%; max-height: 170px; resize: none; padding: 9px 4px 7px; border: 0; outline: 0; background: transparent; color: var(--text); line-height: 1.45; }
.mic-button, .send-button { width: 38px; height: 38px; display: grid; place-items: center; border: 0; border-radius: 10px; cursor: pointer; }
.mic-button { background: transparent; color: var(--muted); }
.mic-button:hover { background: var(--panel); color: var(--accent); }
.mic-button.listening { background: #f4d7cf; color: var(--danger); animation: pulse-red 1.4s infinite; }
@keyframes pulse-red { 50% { box-shadow: 0 0 0 6px rgb(163 58 47 / 10%); } }
.mic-icon { width: 12px; height: 17px; display: block; border: 2px solid currentColor; border-radius: 8px; position: relative; }
.mic-icon::after { content: ""; position: absolute; width: 18px; height: 10px; left: 50%; bottom: -7px; transform: translateX(-50%); border: 2px solid currentColor; border-top: 0; border-radius: 0 0 12px 12px; }
.send-button { background: var(--accent); color: white; font-size: 19px; font-weight: 800; }
.send-button:hover { background: var(--accent-deep); }
.send-button:disabled { background: var(--line-strong); cursor: not-allowed; }
.composer-meta { max-width: 760px; display: flex; justify-content: space-between; gap: 12px; margin: 6px auto 0; color: var(--muted); font-size: 9px; }

.inspector-panel { display: grid; grid-template-rows: 48px minmax(0, 1fr); }
.inspector-tabs { display: grid; grid-template-columns: 1fr 1fr; border-bottom: 1px solid var(--line); }
.inspector-tabs button { position: relative; border: 0; background: transparent; color: var(--muted); font-size: 11px; font-weight: 750; cursor: pointer; }
.inspector-tabs button[aria-selected="true"] { color: var(--text); }
.inspector-tabs button[aria-selected="true"]::after { content: ""; position: absolute; height: 2px; left: 22%; right: 22%; bottom: -1px; background: var(--accent); }
.inspector-tabs span { min-width: 18px; display: inline-grid; place-items: center; margin-left: 3px; padding: 1px 4px; border-radius: 8px; background: var(--panel); font-size: 9px; }
.inspector-close, .mobile-files-button { display: none; }
.inspector-pane { min-height: 0; overflow: auto; }
.preview-empty { min-height: 100%; display: grid; place-content: center; padding: 28px; text-align: center; }
.preview-empty > div { color: var(--line-strong); font-size: 33px; }
.preview-empty h3 { margin: 9px 0 6px; font-size: 15px; }
.preview-empty p { max-width: 230px; margin: 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.preview-content { min-height: 100%; display: grid; grid-template-rows: auto minmax(0, 1fr); }
.preview-header { min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 13px; border-bottom: 1px solid var(--line); }
.preview-header div { min-width: 0; }
.preview-header strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.preview-header small { color: var(--muted); font-size: 9px; }
.preview-header a { padding: 6px 8px; border: 1px solid var(--line); border-radius: 7px; color: var(--text); text-decoration: none; font-size: 10px; }
.preview-body { min-height: 0; display: grid; place-items: stretch; overflow: auto; background: #e7e3d9; }
.preview-body iframe { width: 100%; height: 100%; min-height: 480px; border: 0; background: white; }
.preview-body img, .preview-body video { max-width: 100%; max-height: calc(100vh - 190px); margin: auto; object-fit: contain; }
.preview-body audio { align-self: center; width: calc(100% - 30px); margin: auto; }
.preview-body pre { min-width: 100%; margin: 0; padding: 18px; overflow: auto; background: #242a27; color: #ecf0ec; font: 11px/1.6 "SFMono-Regular", Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.module-intro { padding: 21px 17px 15px; border-bottom: 1px solid var(--line); }
.module-intro h3 { margin: 3px 0 7px; font-size: 16px; }
.module-intro p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.55; }
.module-list { display: grid; gap: 8px; padding: 12px; }
.module-card { padding: 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-strong); }
.module-card header { display: flex; justify-content: space-between; gap: 9px; }
.module-card h4 { margin: 0; font-size: 12px; }
.module-card p { margin: 8px 0; color: var(--muted); font-size: 10px; line-height: 1.5; }
.module-status { height: fit-content; padding: 3px 6px; border-radius: 7px; background: var(--accent-soft); color: var(--accent-deep); font-size: 8px; font-weight: 800; text-transform: uppercase; }
.module-status.pending { background: #f4dfbd; color: #7c511a; }
.module-status.disabled { background: #e3e1dc; color: var(--muted); }
.module-card footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 9px; }
.module-card footer button { padding: 5px 8px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); font-size: 9px; cursor: pointer; }

.button { min-height: 36px; padding: 8px 13px; border: 1px solid transparent; border-radius: 9px; font-weight: 750; font-size: 11px; cursor: pointer; }
.button-primary { background: var(--accent); color: white; }.button-primary:hover { background: var(--accent-deep); }
.button-quiet { border-color: var(--line); background: var(--surface-strong); }.button-quiet:hover { border-color: var(--line-strong); }
.modal { width: min(520px, calc(100% - 28px)); padding: 0; border: 1px solid var(--line); border-radius: 18px; background: var(--surface-strong); color: var(--text); box-shadow: var(--shadow); }
.modal::backdrop { background: rgb(23 32 29 / 54%); backdrop-filter: blur(3px); }
.modal form { display: grid; gap: 14px; padding: 24px; }
.modal-heading { display: flex; align-items: start; justify-content: space-between; gap: 15px; }
.modal h2 { margin: 3px 0 0; font-family: Georgia, serif; font-size: 25px; font-weight: 500; }
.modal p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.modal label { display: grid; gap: 6px; font-size: 11px; font-weight: 750; }
.modal input, .modal textarea { width: 100%; padding: 11px 12px; border: 1px solid var(--line-strong); border-radius: 9px; background: white; color: var(--text); resize: vertical; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.login-modal { width: min(390px, calc(100% - 28px)); }
.login-modal form { padding: 32px; }
.login-mark { margin-bottom: 3px; }
.form-error { min-height: 18px; color: var(--danger) !important; font-weight: 700; }
.toast-region { position: fixed; z-index: 20; right: 16px; bottom: 16px; display: grid; gap: 8px; pointer-events: none; }
.toast { width: min(350px, calc(100vw - 32px)); padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px; background: var(--text); color: white; box-shadow: var(--shadow); font-size: 11px; line-height: 1.45; animation: toast-in .2s ease-out; }
.toast.error { background: #712d27; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

@media (max-width: 1080px) {
  .workspace { grid-template-columns: 240px minmax(400px, 1fr); }
  .inspector-panel { position: fixed; z-index: 8; inset: 68px 0 0 auto; width: min(420px, 90vw); border-left: 1px solid var(--line); box-shadow: var(--shadow); transform: translateX(100%); transition: transform .2s ease; }
  .inspector-panel.open { transform: translateX(0); }
  .inspector-tabs { grid-template-columns: 1fr 1fr 44px; }
  .inspector-close { display: block; border: 0; border-left: 1px solid var(--line); background: transparent; color: var(--muted); cursor: pointer; font-size: 18px; }
  .file-row.selected::after { content: "Preview"; color: var(--accent); font-size: 9px; }
}

@media (max-width: 720px) {
  body { overflow: auto; }
  .app-shell { min-height: 100dvh; grid-template-rows: 58px minmax(0, 1fr); }
  .topbar { grid-template-columns: 1fr auto; height: 58px; padding: 0 12px; }
  .brand small, .run-status, .top-actions .button:not(.mobile-files-button) { display: none; }
  .mobile-files-button { display: inline-block; min-height: 32px; padding: 6px 9px; }
  .workspace { min-height: calc(100dvh - 58px); grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr); }
  .files-panel { position: fixed; z-index: 7; inset: 58px auto 0 0; width: min(310px, 90vw); border-right: 1px solid var(--line); box-shadow: var(--shadow); transform: translateX(-100%); transition: transform .2s ease; }
  .files-panel.open { transform: translateX(0); }
  .conversation-panel { min-height: calc(100dvh - 58px); }
  .conversation-heading { min-height: 62px; padding: 12px 14px; }
  .messages { padding: 20px 14px; }
  .empty-state { margin-top: 2vh; }
  .suggestions { grid-template-columns: 1fr; }
  .suggestions button { min-height: 48px; }
  .composer { position: sticky; bottom: 0; padding: 9px 10px 11px; }
  .composer-meta span:last-child { display: none; }
  .inspector-panel { inset-top: 58px; }
  .message.user .message-bubble { max-width: 94%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
