/* Base styles shared by every shell and app. */
:root {
  color-scheme: light dark;
  --bg: #f7f7f5;
  --surface: #ffffff;
  --text: #1c1c1a;
  --muted: #6b6b66;
  --border: #deded8;
  --accent: #2f6f5e;
  --accent-text: #ffffff;
  --danger: #a33a2c;
  --radius: 8px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161615;
    --surface: #1f1f1d;
    --text: #ecece8;
    --muted: #a0a09a;
    --border: #34342f;
    --accent: #6fbfa8;
    --accent-text: #0e1f1a;
    --danger: #e0806f;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font);
}

header.ct-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

header.ct-bar .ct-title { font-weight: 600; margin-right: auto; }
header.ct-bar a, header.ct-bar button { font-size: 14px; }

/* Icon buttons in the header bar, after connected-water's test app header
   buttons. The icons are Font Awesome 4.7 (vendored in /public/vendor/). Each
   button has a title (tooltip) and an aria-label, and the icon itself is
   aria-hidden. */
header.ct-bar .ct-header-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  height: 27px;
  min-width: 34px;
  margin-left: -8px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--muted);
  font-size: 15px;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  flex-shrink: 0;
}
header.ct-bar .ct-header-btn[hidden] { display: none; }
/* The back link sits before the app name, at the start of the bar. */
header.ct-bar .ct-header-btn.ct-back { margin-left: 0; margin-right: -6px; }
header.ct-bar .ct-header-btn [data-user-name] {
  max-width: 16em;
  margin-left: 6px;
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
header.ct-bar .ct-header-btn:hover,
header.ct-bar .ct-header-btn:focus-visible { color: var(--text); border-color: var(--muted); }
header.ct-bar .ct-header-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Modal dialogs (/public/modal.js), after the jquery-modal dialogs in
   connected-water's test app. */
dialog.ct-modal {
  width: min(460px, 92vw);
  max-width: 460px;
  overflow: visible;
  padding: 14px 16px;
  border: none;
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 0 10px #000;
}
dialog.ct-modal::backdrop { background: rgba(0, 0, 0, 0.75); }

.ct-modal-close {
  position: absolute;
  top: -12px;
  right: -12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #000;
  color: #fff;
  font-size: 13px;
  box-shadow: 0 0 4px #000;
}

.ct-modal-title { margin: 0 0 14px; font-size: 16px; font-weight: 600; }
.ct-modal-body { margin-bottom: 18px; }
.ct-modal-section { border-top: 1px solid var(--border); padding-top: 12px; }
.ct-modal-actions { display: flex; gap: 8px; justify-content: flex-end; }

.ct-btn {
  padding: 5px 12px;
  border-radius: 4px;
  font-size: 14px;
}
.ct-btn-primary { background: var(--accent); color: var(--accent-text); border: 1px solid var(--accent); }
.ct-btn-primary:hover { filter: brightness(1.08); }
.ct-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.ct-btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.ct-btn-secondary:hover { background: var(--bg); border-color: var(--muted); }
.ct-btn-danger { background: #dc3545; color: #fff; border: 1px solid #bd2130; }
.ct-btn-danger:hover { background: #c82333; }

/* User modal */
.ct-user-row { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.ct-user-label { width: 110px; flex-shrink: 0; font-weight: 600; }
.ct-user-groups { display: flex; flex-wrap: wrap; gap: 4px; }
.ct-pill {
  padding: 1px 8px;
  border-radius: 10px;
  background: #e0f2fe;
  color: #075985;
  font-size: 12px;
}
@media (prefers-color-scheme: dark) {
  .ct-pill { background: #0c3a52; color: #bae6fd; }
}
@media (max-width: 480px) {
  .ct-user-row { flex-direction: column; gap: 2px; }
}

main { max-width: 760px; margin: 0 auto; padding: 24px 16px; }

a { color: var(--accent); }

button {
  font: inherit;
  padding: 6px 14px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-text);
  cursor: pointer;
}

button.ct-link {
  border: none;
  background: none;
  color: var(--accent);
  padding: 0;
  text-decoration: underline;
}

.ct-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.ct-muted { color: var(--muted); }
.ct-error { color: var(--danger); }

pre, code { font-family: var(--mono); font-size: 13px; }
pre { overflow-x: auto; white-space: pre-wrap; }
