:root {
  --ink: #17241f;
  --forest: #173b31;
  --forest-dark: #0d2d25;
  --cream: #f6f2e9;
  --paper: #fffdf8;
  --line: #d9ddd7;
  --gold: #d7a845;
  --red: #9c3d31;
  --muted: #64736e;
  --soft-green: #edf4ef;
  --shadow: 0 18px 55px rgba(14, 45, 37, .12);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--cream); }
body {
  min-height: 100%;
  margin: 0;
  background:
    radial-gradient(circle at 50% -20%, rgba(215, 168, 69, .12), transparent 38%),
    var(--cream);
  color: var(--ink);
  font: 15px/1.55 Arial, sans-serif;
}
button, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  background: rgba(255, 253, 248, .94);
  border-bottom: 1px solid rgba(21, 35, 31, .12);
  backdrop-filter: blur(14px);
}
.project-brand {
  display: flex;
  align-items: center;
  gap: 13px;
  color: inherit;
  text-decoration: none;
}
.project-brand strong, .project-brand small { display: block; }
.project-brand strong {
  font: 700 18px Georgia, serif;
  letter-spacing: -.02em;
}
.project-brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 8px;
  letter-spacing: .13em;
  text-transform: uppercase;
}
.mudbug-mark {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-content: center;
  gap: 3px;
  background: var(--forest);
  box-shadow: 0 0 0 5px rgba(23, 59, 49, .07);
}
.mudbug-mark i {
  display: block;
  height: 2px;
  background: var(--gold);
  border-radius: 2px;
}
.mudbug-mark i:nth-child(1), .mudbug-mark i:nth-child(3) { width: 13px; }
.mudbug-mark i:nth-child(2) { width: 22px; }
.project-actions { display: flex; align-items: center; gap: 10px; }
.workspace-status {
  margin-right: 8px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}
.workspace-status i {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-radius: 50%;
  background: #4e9c71;
  box-shadow: 0 0 0 4px rgba(78, 156, 113, .13);
}
.text-button, .settings-button {
  border: 1px solid transparent;
  background: transparent;
  color: var(--forest);
  padding: 8px 12px;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
}
.settings-button { border-color: var(--line); background: white; }
.text-button:hover, .settings-button:hover { background: var(--soft-green); }

.chat-workspace {
  width: min(1040px, 100%);
  min-height: calc(100vh - 76px);
  margin: 0 auto;
  padding: 0 28px 180px;
}
.chat-thread { padding: 64px 0 20px; }
.chat-message {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 15px;
  width: 100%;
  margin-bottom: 36px;
}
.assistant-avatar, .user-avatar {
  width: 34px;
  height: 34px;
  display: grid;
  place-content: center;
  border-radius: 50%;
  font: 700 12px Georgia, serif;
}
.assistant-avatar { background: var(--forest); color: var(--gold); }
.user-avatar { background: #dfe5e1; color: var(--forest); font: 700 8px Arial, sans-serif; }
.message-content { min-width: 0; padding-top: 2px; }
.message-label {
  display: block;
  margin-bottom: 8px;
  color: var(--red);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.message-content h1 {
  margin: 0 0 13px;
  font: 700 clamp(22px, 3.2vw, 30px)/1.15 Georgia, serif;
  letter-spacing: -.035em;
}
.message-content > p {
  max-width: 760px;
  margin: 0;
  color: #34453f;
  line-height: 1.7;
  white-space: pre-wrap;
}
.welcome-message { margin-bottom: 48px; }
.welcome-message .message-content > p { max-width: 690px; color: var(--muted); }
.user-message .message-content {
  width: fit-content;
  max-width: min(720px, 100%);
  padding: 13px 17px;
  border-radius: 4px 18px 18px 18px;
  background: #e8ede9;
}
.user-message .message-label { margin-bottom: 4px; color: var(--muted); }
.user-message .message-content p { color: var(--ink); line-height: 1.55; }
.message-attachments { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.message-attachments span {
  border: 1px solid rgba(21, 35, 31, .13);
  border-radius: 16px;
  background: rgba(255,255,255,.7);
  padding: 5px 9px;
  color: var(--forest);
  font-size: 9px;
  font-weight: 700;
}
.action-hint { margin-top: 12px !important; color: var(--muted) !important; font-size: 10px; }
.artifact-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.artifact-links a {
  border-radius: 18px;
  background: var(--forest);
  color: white;
  padding: 8px 13px;
  font-size: 9px;
  font-weight: 700;
  text-decoration: none;
}
.artifact-links a:hover { background: var(--forest-dark); }

.prompt-suggestions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
  margin-top: 27px;
}
.prompt-suggestions.compact {
  display: flex;
  flex-wrap: wrap;
  margin-top: 17px;
}
.prompt-suggestions button {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 253, 248, .9);
  color: var(--forest);
  padding: 11px 13px;
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color .16s ease, background .16s ease, transform .16s ease;
}
.prompt-suggestions.compact button { min-height: auto; border-radius: 20px; }
.prompt-suggestions button:hover {
  border-color: #a7b8b1;
  background: white;
  transform: translateY(-1px);
}

.thinking-message { margin-bottom: 25px; }
.thinking-dots { display: flex; align-items: center; gap: 4px; min-height: 34px; }
.thinking-dots i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  animation: thinking 1.1s infinite ease-in-out;
}
.thinking-dots i:nth-child(2) { animation-delay: .15s; }
.thinking-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes thinking {
  0%, 60%, 100% { opacity: .3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

.composer-dock {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 15;
  width: min(1040px, 100%);
  padding: 24px 28px 18px;
  transform: translateX(-50%);
  background: linear-gradient(to bottom, rgba(246, 242, 233, 0), var(--cream) 24%, var(--cream));
}
.attachment-tray {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  min-height: 0;
  padding: 0 10px;
}
.attachment-tray:not(:empty) { margin-bottom: 8px; }
.attachment-chip {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: white;
  color: var(--forest);
  padding: 6px 10px;
  font-size: 9px;
  cursor: pointer;
}
.chat-composer {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  width: 100%;
  min-height: 64px;
  padding: 10px 10px 10px 19px;
  border: 1px solid rgba(21, 35, 31, .19);
  border-radius: 18px;
  background: white;
  box-shadow: 0 12px 38px rgba(14, 45, 37, .14);
}
.attach-button {
  width: 42px;
  height: 42px;
  flex: none;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--paper);
  color: var(--forest);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.attach-button:hover { background: #eef3ef; }
.attach-button:disabled { opacity: .45; cursor: wait; }
.chat-composer:focus-within {
  border-color: #9aada5;
  box-shadow: 0 12px 38px rgba(14, 45, 37, .16), 0 0 0 3px rgba(23, 59, 49, .06);
}
.chat-composer textarea {
  flex: 1;
  min-height: 42px;
  max-height: 180px;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  padding: 9px 0 6px;
  line-height: 1.5;
}
.chat-composer textarea::placeholder { color: #87938e; }
.send-button {
  width: 42px;
  height: 42px;
  flex: none;
  border: 0;
  border-radius: 50%;
  background: var(--forest);
  color: white;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.send-button:hover { background: var(--forest-dark); }
.send-button:disabled { opacity: .45; cursor: wait; }
.composer-dock > p {
  margin: 8px 12px 0;
  color: var(--muted);
  font-size: 8px;
  text-align: center;
}

.settings-dialog {
  width: min(560px, calc(100vw - 34px));
  max-height: min(760px, calc(100vh - 40px));
  border: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 28px 90px rgba(0, 0, 0, .3);
}
.settings-dialog::backdrop { background: rgba(13, 45, 37, .68); }
.settings-dialog form { padding: 28px; }
.dialog-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
}
.dialog-heading span {
  color: var(--red);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: .15em;
  text-transform: uppercase;
}
.dialog-heading h2 { margin: 5px 0 0; font: 700 24px Georgia, serif; }
.dialog-heading button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 24px;
  cursor: pointer;
}
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}
.setting-row span strong, .setting-row span small { display: block; }
.setting-row span strong { font-size: 11px; }
.setting-row span small { margin-top: 3px; color: var(--muted); font-size: 8px; }
.status-pill {
  border-radius: 20px;
  background: #e7ebe8;
  color: var(--muted);
  padding: 5px 9px;
  font-size: 7px;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.status-pill.ready { background: #e1f0e6; color: #2c6d48; }
.status-pill.warning { background: #f6e9d6; color: #965c25; }
.settings-help { margin: 18px 0 0; color: var(--muted); font-size: 9px; line-height: 1.6; }

@media (max-width: 760px) {
  .topbar { height: 68px; padding: 0 16px; }
  .project-brand small, .workspace-status, .text-button { display: none; }
  .project-brand strong { font-size: 15px; }
  .mudbug-mark { width: 36px; height: 36px; }
  .chat-workspace { min-height: calc(100vh - 68px); padding: 0 16px 166px; }
  .chat-thread { padding-top: 36px; }
  .chat-message { grid-template-columns: 30px minmax(0, 1fr); gap: 10px; }
  .assistant-avatar, .user-avatar { width: 30px; height: 30px; }
  .prompt-suggestions { grid-template-columns: 1fr 1fr; }
  .composer-dock { padding: 20px 16px 12px; }
}

@media (max-width: 470px) {
  .settings-button { padding: 7px 9px; }
  .prompt-suggestions { grid-template-columns: 1fr; }
  .message-content h1 { font-size: 22px; }
}


/* Skill library */
.library-page { background: #f5f6f7; color: #1b2330; font-family: "Segoe UI", system-ui, sans-serif; margin: 0; }
.library-page .topbar { padding: 0.9rem 1.5rem; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #d9dde2; background: #fff; }
.library-page .topbar a { color: #3f5a7a; text-decoration: none; font-weight: 600; }
.library-main { max-width: 1080px; margin: 0 auto; padding: 2rem 1.25rem 4rem; }
.library-main h1 { font-size: 1.8rem; margin: 0 0 0.3rem; }
.library-lede { color: #5b6573; max-width: 64ch; margin: 0 0 1.5rem; }
.library-counts { display: flex; gap: 1rem; margin-bottom: 2rem; font-size: 0.9rem; color: #5b6573; }
.library-counts b { color: #1b2330; font-size: 1.1rem; margin-right: 0.25rem; }
.library-category { margin-top: 2.25rem; }
.library-category h2 { font-size: 1.2rem; margin: 0 0 0.75rem; padding-bottom: 0.35rem; border-bottom: 1px solid #d9dde2; }
.library-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 0.85rem; }
.library-card { background: #fff; border: 1px solid #d9dde2; padding: 0.9rem 1rem; display: flex; flex-direction: column; gap: 0.4rem; }
.library-card.planned { background: #fafbfc; border-style: dashed; }
.library-card h3 { margin: 0; font-size: 1rem; }
.library-card p { margin: 0; font-size: 0.88rem; color: #5b6573; line-height: 1.45; }
.library-card .tag { align-self: flex-start; font-size: 0.7rem; letter-spacing: 0.08em; text-transform: uppercase; padding: 0.1rem 0.45rem; border-radius: 3px; background: #e1efe6; color: #2e6b46; }
.library-card.planned .tag { background: #f7e6e2; color: #b5321f; }
.library-card a { color: #3f5a7a; font-size: 0.85rem; }
.library-card .areas { font-size: 0.75rem; color: #8a94a0; }


/* ---- Phase 5: accounts, status, legal, disclaimers ---- */
.disclaimer { font-size: 0.78rem; color: #6b6f76; line-height: 1.4; margin: 0.5rem 0 0; }
.disclaimer a { color: inherit; }
.auth-page { display: grid; place-items: center; min-height: 100vh; background: #f4f5f7; padding: 1.5rem; }
.auth-card { width: min(460px, 100%); background: #fff; border: 1px solid #e4e6ea; border-radius: 14px; padding: 1.75rem; display: grid; gap: 0.9rem; }
.auth-card h1 { font-size: 1.35rem; margin: 0.25rem 0 0; }
.auth-lede, .auth-switch, .auth-footer, .auth-consent { font-size: 0.9rem; color: #4b5058; margin: 0; }
.auth-form { display: grid; gap: 0.7rem; }
.auth-form label { display: grid; gap: 0.25rem; font-size: 0.85rem; font-weight: 600; }
.auth-form input, .inline-form input, .inline-form select { font: inherit; padding: 0.5rem 0.6rem; border: 1px solid #cfd3d9; border-radius: 8px; }
.primary-button { font: inherit; font-weight: 600; padding: 0.6rem 0.9rem; border: 0; border-radius: 8px; background: #1f6f5f; color: #fff; cursor: pointer; }
.form-error { background: #fdecec; color: #8a1c1c; padding: 0.6rem 0.8rem; border-radius: 8px; font-size: 0.9rem; margin: 0; }
.notice { background: #eef6f3; color: #1f4f45; padding: 0.6rem 0.8rem; border-radius: 8px; }
.account-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; margin-top: 1rem; }
.account-card { background: #fff; border: 1px solid #e4e6ea; border-radius: 12px; padding: 1rem 1.1rem; display: grid; gap: 0.6rem; align-content: start; }
.account-card h2 { font-size: 1.05rem; margin: 0; }
.account-card h3 { font-size: 0.9rem; margin: 0.4rem 0 0; }
.account-card dl { display: grid; grid-template-columns: auto 1fr; gap: 0.25rem 0.8rem; margin: 0; font-size: 0.9rem; }
.account-card dt { color: #6b6f76; }
.usage-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.usage-table th, .usage-table td { text-align: left; padding: 0.35rem 0.4rem; border-bottom: 1px solid #eceef1; vertical-align: top; }
.inline-form { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: end; }
.inline-form label { display: grid; gap: 0.2rem; font-size: 0.8rem; }
.text-button.danger { color: #8a1c1c; }
.small-list { font-size: 0.85rem; padding-left: 1.1rem; margin: 0; display: grid; gap: 0.3rem; }
.legal-main h1 { font-size: 1.5rem; } .legal-main h2 { font-size: 1.15rem; margin-top: 1.4rem; } .legal-main p, .legal-main li { line-height: 1.55; max-width: 72ch; }
.status-page h1 .status-pill { vertical-align: middle; }


/* ---- in-app viewer (roadmap 3.3a) ---- */
.artifact-group { display: inline-flex; border-radius: 18px; overflow: hidden; }
.artifact-group a { border-radius: 0 18px 18px 0 !important; }
.artifact-view { font: inherit; font-size: 9px; font-weight: 700; padding: 8px 11px; border: 0; background: var(--forest-dark, #1a4d40); color: #fff; cursor: pointer; border-right: 1px solid rgba(255,255,255,.25); }
.artifact-view:hover { background: #123a30; }
.viewer-dialog { width: min(1100px, 96vw); height: 92vh; padding: 0; border: 0; border-radius: 12px; background: #2b2f36; color: #eef1f4; }
.viewer-dialog::backdrop { background: rgba(10, 12, 16, .7); }
.viewer-bar { display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: #1f2329; font-size: 0.85rem; }
.viewer-status { flex: 1; color: #b9c0c9; }
.viewer-actions { display: inline-flex; gap: 6px; align-items: center; }
.viewer-actions button, .viewer-actions a { font: inherit; font-size: 0.95rem; min-width: 32px; padding: 4px 8px; border-radius: 6px; border: 1px solid #3b414a; background: #2b2f36; color: #eef1f4; cursor: pointer; text-decoration: none; }
.viewer-actions button:disabled { opacity: .4; cursor: default; }
.viewer-canvas { height: calc(92vh - 48px); overflow: auto; padding: 16px; text-align: center; background: #3a3f47; }
.viewer-page { width: 100%; max-width: 100%; background: #fff; box-shadow: 0 2px 18px rgba(0,0,0,.5); }
