/* MCP ISI · Matelia theme — scoped, no external assets */
:root {
  color-scheme: light;
  --brand: #1AADA0;
  --background: #F7F8FA;
  --foreground: #222222;
  --card: #FFFFFF;
  --card-foreground: #222222;
  --popover: #FFFFFF;
  --popover-foreground: #222222;
  --primary: #1A9184;
  --primary-foreground: #000000;
  --primary-hover: #1FAFA0;
  --primary-strong: #0A4540;
  --primary-weak: #E8F4F2;
  --secondary: #F5F5F5;
  --muted: #F5F5F5;
  --muted-foreground: #6B6B6B;
  --border: #EDEDED;
  --input: #7D7D7D;
  --ring: #1A9184;
  --destructive: #8A0000;
  --destructive-weak: #FFE7E7;
  --success: #005416;
  --success-weak: #D8F3DA;
  --warning: #664700;
  --warning-weak: #FFEEC5;
  --info: #0066AC;
  --info-weak: #D5F1FA;
  --status-open: #6B6B6B;
  --status-wip: #0066AC;
  --status-done: #005416;
  --status-paused: #664700;
  --notice-bg: #FFEEC5;
  --notice-border: #BF7900;
  --notice-ink: #664700;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(10,30,25,.06),0 4px 16px rgba(10,30,25,.05);
}
:root[data-theme="light"] {
  color-scheme: light;
  --brand: #1AADA0;
  --background: #F7F8FA;
  --foreground: #222222;
  --card: #FFFFFF;
  --card-foreground: #222222;
  --popover: #FFFFFF;
  --popover-foreground: #222222;
  --primary: #1A9184;
  --primary-foreground: #000000;
  --primary-hover: #1FAFA0;
  --primary-strong: #0A4540;
  --primary-weak: #E8F4F2;
  --secondary: #F5F5F5;
  --muted: #F5F5F5;
  --muted-foreground: #6B6B6B;
  --border: #EDEDED;
  --input: #7D7D7D;
  --ring: #1A9184;
  --destructive: #8A0000;
  --destructive-weak: #FFE7E7;
  --success: #005416;
  --success-weak: #D8F3DA;
  --warning: #664700;
  --warning-weak: #FFEEC5;
  --info: #0066AC;
  --info-weak: #D5F1FA;
  --status-open: #6B6B6B;
  --status-wip: #0066AC;
  --status-done: #005416;
  --status-paused: #664700;
  --notice-bg: #FFEEC5;
  --notice-border: #BF7900;
  --notice-ink: #664700;
}
@media (prefers-color-scheme:dark) {
  :root {
    color-scheme: dark;
    --brand: #1AADA0;
    --background: #171717;
    --foreground: #EBEBEB;
    --card: #212121;
    --card-foreground: #EBEBEB;
    --popover: #292929;
    --popover-foreground: #EBEBEB;
    --primary: #1AADA0;
    --primary-foreground: #000000;
    --primary-hover: #1FCCBD;
    --primary-strong: #A3DED9;
    --primary-weak: #172624;
    --secondary: #292929;
    --muted: #171717;
    --muted-foreground: #999999;
    --border: #292929;
    --input: #7D7D7D;
    --ring: #1AADA0;
    --destructive: #FFCCCC;
    --destructive-weak: #552121;
    --success: #D5F2DC;
    --success-weak: #11321A;
    --warning: #FFEEC5;
    --warning-weak: #3D3010;
    --info: #00AEFF;
    --info-weak: #003553;
    --status-open: #999999;
    --status-wip: #00AEFF;
    --status-done: #D5F2DC;
    --status-paused: #FFEEC5;
    --notice-bg: #3D3010;
    --notice-border: #FFCC00;
    --notice-ink: #FFEEC5;
    --shadow: 0 1px 2px rgba(0,0,0,.5),0 4px 16px rgba(0,0,0,.4);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --brand: #1AADA0;
  --background: #171717;
  --foreground: #EBEBEB;
  --card: #212121;
  --card-foreground: #EBEBEB;
  --popover: #292929;
  --popover-foreground: #EBEBEB;
  --primary: #1AADA0;
  --primary-foreground: #000000;
  --primary-hover: #1FCCBD;
  --primary-strong: #A3DED9;
  --primary-weak: #172624;
  --secondary: #292929;
  --muted: #171717;
  --muted-foreground: #999999;
  --border: #292929;
  --input: #7D7D7D;
  --ring: #1AADA0;
  --destructive: #FFCCCC;
  --destructive-weak: #552121;
  --success: #D5F2DC;
  --success-weak: #11321A;
  --warning: #FFEEC5;
  --warning-weak: #3D3010;
  --info: #00AEFF;
  --info-weak: #003553;
  --status-open: #999999;
  --status-wip: #00AEFF;
  --status-done: #D5F2DC;
  --status-paused: #FFEEC5;
  --notice-bg: #3D3010;
  --notice-border: #FFCC00;
  --notice-ink: #FFEEC5;
  --shadow: 0 1px 2px rgba(0,0,0,.5),0 4px 16px rgba(0,0,0,.4);
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  font-family: system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;
  background: var(--background);
  color: var(--foreground);
  line-height: 1.5;
  font-size: .95rem;
  -webkit-font-smoothing: antialiased;
}
a {
  color: var(--primary-strong);
  text-decoration: underline;
  text-underline-offset: .14em;
}
a:hover {
  color: var(--primary-strong);
  text-decoration-thickness: 2px;
}
a:focus-visible,button:focus-visible,input:focus-visible,select:focus-visible,textarea:focus-visible,[tabindex]:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}
/* Header — compact top bar on all pages */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .65rem 1.25rem;
  background: var(--card);
  color: var(--foreground);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
header a {
  color: var(--foreground);
}
header a:hover {
  color: var(--primary-strong);
  text-decoration: none;
}
.brand {
  font-weight: 700;
  letter-spacing: .01em;
  display: inline-flex;
  align-items: center;
  gap: .5rem;
}
.brand::before {
  content: "";
  width: 18px;
  height: 18px;
  border-radius: 6px;
  background: var(--brand);
  box-shadow: inset 0 0 0 3px var(--card),inset 0 0 0 4px var(--brand);
}
nav {
  display: flex;
  align-items: center;
  gap: .25rem;
  flex-wrap: wrap;
}
nav a {
  padding: .35rem .65rem;
  border-radius: var(--radius-sm);
  color: var(--muted-foreground);
  font-size: .9rem;
}
nav a:hover {
  background: var(--secondary);
  color: var(--foreground);
  text-decoration: none;
}
nav a[aria-current] {
  background: var(--primary-weak);
  color: var(--primary-strong);
  font-weight: 600;
}
.who {
  opacity: .85;
  font-size: .85rem;
  color: var(--muted-foreground);
  padding: .25rem .5rem;
}
@media (prefers-color-scheme:dark) {
  nav a[aria-current] {
    color: var(--primary-strong);
  }
}
main {
  max-width: 1180px;
  margin: 1.25rem auto;
  padding: 0 1.25rem 3rem;
}
footer {
  max-width: 1180px;
  margin: 2rem auto;
  padding: 1rem 1.25rem;
  color: var(--muted-foreground);
  font-size: .8rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  border-top: 1px solid var(--border);
}
h1 {
  font-size: 1.5rem;
  margin: 0 0 .75rem;
  letter-spacing: -.01em;
}
h2 {
  font-size: 1.1rem;
  margin: 1.25rem 0 .5rem;
}
h3 {
  font-size: .98rem;
  margin: 1rem 0 .4rem;
}
/* Cards & surfaces */
.card {
  background: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  margin: .9rem 0;
  box-shadow: var(--shadow);
}
.muted {
  color: var(--muted-foreground);
  font-size: .86rem;
}
/* Messages */
.notice {
  background: var(--primary-weak);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  padding: .6rem .85rem;
  border-radius: var(--radius-sm);
  color: var(--foreground);
}
.error {
  background: var(--destructive-weak);
  border: 1px solid var(--border);
  border-left: 3px solid var(--destructive);
  padding: .6rem .85rem;
  border-radius: var(--radius-sm);
  color: var(--destructive);
}
.devbanner {
  background: var(--notice-bg);
  border: 1px solid var(--border);
  border-left: 3px solid var(--notice-border);
  color: var(--notice-ink);
  padding: .5rem .85rem;
  border-radius: var(--radius-sm);
  font-size: .84rem;
}
/* Forms */
label {
  display: block;
  margin: .6rem 0 .25rem;
  font-weight: 600;
  font-size: .86rem;
  color: var(--foreground);
}
input[type=text],input[type=password],input[type=file],select,textarea {
  width: 100%;
  padding: .55rem .7rem;
  border: 1px solid var(--input);
  border-radius: var(--radius-sm);
  font: inherit;
  background: var(--card);
  color: var(--foreground);
  transition: border-color .12s,box-shadow .12s;
}
input[type=text]:hover,input[type=password]:hover,select:hover,textarea:hover {
  border-color: var(--input);
}
textarea {
  resize: vertical;
  min-height: 4.5rem;
}
/* Buttons */
button,.button {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .52rem .95rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: var(--primary-foreground);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background .12s,box-shadow .12s,transform .06s;
}
button:hover,.button:hover {
  background: var(--primary-hover);
  text-decoration: none;
  color: var(--primary-foreground);
}
button:active,.button:active {
  transform: translateY(1px);
}
button.secondary,.button.secondary {
  background: var(--secondary);
  color: var(--foreground);
  border-color: var(--border);
}
button.secondary:hover {
  background: var(--border);
  color: var(--foreground);
}
button.danger,.button.danger {
  background: var(--destructive-weak);
  color: var(--destructive);
  border-color: var(--border);
}
button.danger:hover {
  background: var(--destructive);
  color: var(--card);
}
button.link {
  background: none;
  color: var(--muted-foreground);
  padding: 0;
  text-decoration: underline;
  font-weight: 500;
  border: 0;
}
button.link:hover {
  color: var(--primary-strong);
  background: none;
}
button:disabled,.button:disabled {
  opacity: .5;
  cursor: not-allowed;
  transform: none;
}
.inline {
  display: inline;
}
/* Layout helpers */
.row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: end;
}
.row>div {
  flex: 1 1 220px;
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit,minmax(220px,1fr));
  gap: .9rem;
}
.kv {
  font-size: .9rem;
}
.kv dt {
  color: var(--muted-foreground);
  font-size: .82rem;
  margin-top: .35rem;
}
.kv dd {
  margin: 0 0 .5rem;
}
pre {
  background: var(--secondary);
  color: var(--foreground);
  padding: .85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-size: .82rem;
}
/* Badges */
.badge {
  display: inline-block;
  padding: .12rem .55rem;
  border-radius: 999px;
  font-size: .76rem;
  font-weight: 600;
  background: var(--secondary);
  color: var(--muted-foreground);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.badge.ok {
  background: var(--success-weak);
  color: var(--success);
  border-color: transparent;
}
.badge.warn {
  background: var(--warning-weak);
  color: var(--warning);
  border-color: transparent;
}
.badge.bad {
  background: var(--destructive-weak);
  color: var(--destructive);
  border-color: transparent;
}
/* ---------- Workspace: desktop vertical app sidebar ---------- */
.workspace {
  display: grid;
  grid-template-columns: 14rem minmax(0,1fr);
  gap: 1.5rem;
  align-items: start;
}
.work-sidebar {
  align-self: start;
  position: sticky;
  top: calc(3.3rem + .75rem);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem;
  box-shadow: var(--shadow);
}
.work-sidebar nav {
  display: grid;
  gap: .2rem;
  flex-wrap: nowrap;
}
.work-sidebar a {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .6rem .75rem;
  color: var(--muted-foreground);
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  border: 1px solid transparent;
}
.work-sidebar a::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: .35;
  flex: none;
}
.work-sidebar a:hover {
  background: var(--secondary);
  color: var(--foreground);
  text-decoration: none;
}
.work-sidebar a[aria-current] {
  background: var(--primary-weak);
  color: var(--primary-strong);
  font-weight: 650;
  border-color: var(--border);
}
.work-sidebar a[aria-current]::before {
  background: var(--primary);
  opacity: 1;
}
@media (prefers-color-scheme:dark) {
  .work-sidebar a[aria-current] {
    color: var(--primary-strong);
  }
}
.work-content {
  min-width: 0;
}
/* Upload dropzone */
.file-drop {
  margin-top: 1rem;
  padding: 1.6rem 1.4rem;
  border: 1.5px dashed var(--input);
  border-radius: var(--radius);
  background: var(--card);
  transition: border-color .15s,background .15s;
}
.file-drop:hover {
  border-color: var(--primary);
}
.file-drop.dragging,.file-drop:focus-within {
  border-color: var(--primary);
  background: var(--primary-weak);
}
.drop-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 650;
  color: var(--foreground);
}
.drop-title::before {
  content: "↑";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  background: var(--primary);
  color: var(--primary-foreground);
  font-size: .95rem;
  margin-right: .6rem;
  vertical-align: -2px;
}
.file-drop p {
  margin: .4rem 0 .8rem;
}
.file-drop input[type=file] {
  max-width: 32rem;
}
#upload-status {
  margin-top: .5rem;
}
/* Sections */
.work-section {
  margin-top: 1.75rem;
}
.work-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  flex-wrap: wrap;
}
.work-section-title h2 {
  margin: .4rem 0;
}
/* Document table */
.work-table {
  overflow-x: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.work-table table {
  margin: 0;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}
th,td {
  text-align: left;
  padding: .65rem .85rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
thead th {
  background: var(--secondary);
  color: var(--muted-foreground);
  font-weight: 600;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .03em;
}
tbody tr:last-child td {
  border-bottom: 0;
}
tbody tr:hover {
  background: var(--primary-weak);
}
.work-table td:first-child {
  min-width: 12rem;
  overflow-wrap: anywhere;
}
/* Chat */
.chat-history {
  display: grid;
  gap: .65rem;
  margin: 1rem 0;
  max-width: 60rem;
}
.chat-message {
  justify-self: start;
  max-width: 86%;
  padding: .7rem 1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-wrap: anywhere;
  box-shadow: var(--shadow);
}
.chat-message strong {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted-foreground);
  font-weight: 600;
}
.chat-message.from-user {
  justify-self: end;
  background: var(--primary);
  color: var(--primary-foreground);
  border-color: transparent;
}
.chat-message.from-user strong {
  color: var(--primary-foreground);
  opacity: .8;
}
.chat-message p {
  margin: .3rem 0 0;
  white-space: pre-wrap;
}
.chat-compose {
  max-width: 60rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
}
.chat-compose button {
  margin-top: .6rem;
}
/* Mobile responsive */
@media (max-width:760px) {
  header {
    padding: .55rem .9rem;
    flex-wrap: wrap;
  }
  header nav {
    gap: .15rem;
  }
  main {
    padding: 0 .9rem 2rem;
    margin-top: .9rem;
  }
  .workspace {
    grid-template-columns: 1fr;
    gap: .9rem;
  }
  .work-sidebar {
    position: static;
    padding: .5rem;
    top: auto;
  }
  .work-sidebar nav {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
  }
  .work-sidebar a {
    flex: none;
    padding: .5rem .7rem;
  }
  .chat-message {
    max-width: 92%;
  }
  footer {
    flex-direction: column;
    gap: .3rem;
  }
}
@media (max-width:480px) {
  h1 {
    font-size: 1.3rem;
  }
  th,td {
    padding: .55rem .6rem;
  }
  .brand {
    font-size: .95rem;
  }
}
/* Reduced motion */
@media (prefers-reduced-motion:reduce) {
  * {
    transition: none;
  }
}
.card.review-warning {
  background: var(--warning-weak);
  color: var(--warning);
  border-color: var(--notice-border);
}

.theme-switch {
  display: flex;
  gap: .15rem;
}

.theme-switch button {
  padding: .28rem .55rem;
  color: var(--primary-strong);
  background: var(--secondary);
  font-size: .85rem;
}

.theme-switch button[aria-pressed="true"] {
  color: var(--primary-foreground);
  background: var(--primary);
}

.work-card {
  padding: .9rem 1rem;
  margin: .7rem 0;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--card);
  overflow-wrap: anywhere;
}

.work-card h2 {
  margin: 0;
}

button.link.danger {
  color: var(--destructive);
}

progress {
  max-width: 100%;
  accent-color: var(--primary);
}

#workspace-delete-dialog {
  width: min(32rem, calc(100% - 2rem));
  border: 1px solid var(--input);
  border-radius: var(--radius);
  padding: 1.25rem;
  background: var(--card);
  color: var(--card-foreground);
  box-shadow: var(--shadow);
  overflow-wrap: anywhere;
}

#workspace-delete-dialog::backdrop {
  background: rgb(0 0 0 / 42%);
}

#workspace-delete-dialog h2 {
  margin-top: 0;
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  justify-content: flex-end;
}

/* Compact Matelia workspace chrome. */
body {
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1 {
  font-size: clamp(1.4rem, 1.15rem + 1vw, 2rem);
  letter-spacing: -.028em;
  line-height: 1.16;
}

h2 { letter-spacing: -.016em; }
main, footer { max-width: 1180px; }

header, .work-sidebar, .file-drop {
  background: linear-gradient(150deg, var(--primary-weak), var(--card) 68%);
}

header {
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.work-table {
  scrollbar-width: thin;
}

th, td {
  padding: .72rem .9rem;
}

.theme-switch button {
  display: inline-grid;
  place-items: center;
  width: 2.1rem;
  height: 2.1rem;
  padding: 0;
  line-height: 1;
  border: 1px solid transparent;
  border-radius: 50%;
  font-size: 1.1rem;
}

.theme-switch button[aria-pressed="true"] {
  border-color: var(--ring);
}

.knowledge-note { white-space: pre-wrap; overflow-wrap: anywhere; }
.knowledge-list { padding-left: 1.25rem; }
.knowledge-list li { margin: .35rem 0; }
.knowledge-consents summary { cursor: pointer; font-weight: 650; }

@media (max-width: 680px) {
  th, td { padding: .5rem .6rem; }
  header { position: static; }
}

.work-content code {
  overflow-wrap: anywhere;
}

@media (max-width: 760px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .work-sidebar { min-width: 0; }
  .work-sidebar nav { max-width: 100%; }
}
