/* AOY University hub — paper/charcoal, mirrors NH/SB/AOY design tokens. */

:root {
  --bg: #fdfcf8;
  --paper: #ffffff;
  --text: #2a2824;
  --text-muted: rgba(42, 40, 36, 0.62);
  --text-subtle: rgba(42, 40, 36, 0.38);
  --border: rgba(42, 40, 36, 0.12);
  --hover: rgba(42, 40, 36, 0.05);
  --card-bg: #ffffff;
  --card-shadow: rgba(15, 15, 15, 0.07) 0 0 0 1px, rgba(15, 15, 15, 0.08) 0 3px 8px;
  --card-shadow-hover: rgba(15, 15, 15, 0.1) 0 0 0 1px, rgba(15, 15, 15, 0.14) 0 10px 24px;
  --accent: #d4a017;
  --accent-soft: rgba(212, 160, 23, 0.12);
  --blue: #2383e2;
  --radius: 14px;

  --mode-icon-light-display: inline;
  --mode-icon-dark-display: none;
}

html[data-mode="dark"] {
  --bg: #1c1a16;
  --paper: #24211c;
  --text: #ece6d6;
  --text-muted: rgba(236, 230, 214, 0.65);
  --text-subtle: rgba(236, 230, 214, 0.4);
  --border: rgba(236, 230, 214, 0.14);
  --hover: rgba(236, 230, 214, 0.06);
  --card-bg: #2a2620;
  --card-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4), 0 4px 12px rgba(0, 0, 0, 0.4);
  --card-shadow-hover: 0 0 0 1px rgba(236, 230, 214, 0.2), 0 14px 30px rgba(0, 0, 0, 0.5);
  --accent: #f0c252;
  --accent-soft: rgba(240, 194, 82, 0.14);
  --blue: #7ab5ff;

  --mode-icon-light-display: none;
  --mode-icon-dark-display: inline;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
a:visited { color: inherit; }

/* ---------- Hub header ---------- */

.hub-header {
  max-width: 1280px;
  margin: 0 auto;
  padding: 80px 64px 32px 64px;
}

.hub-brand {
  display: flex;
  align-items: center;
  gap: 18px;
}

.hub-mark {
  font-size: 44px;
  line-height: 1;
}

.hub-titles h1 {
  font-size: 36px;
  font-weight: 700;
  margin: 0 0 4px 0;
  letter-spacing: -0.02em;
}

.hub-subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: 15px;
}

/* ---------- Sub-header (used on /mcp-setup) ---------- */

.hub-subheader {
  max-width: 920px;
  margin: 0 auto;
  padding: 32px 32px 0 32px;
}

.back-link {
  color: var(--text-muted);
  font-size: 14px;
  display: inline-block;
  padding: 6px 0;
}
.back-link:hover { color: var(--text); }

/* ---------- 6-card grid ---------- */

.hub-grid {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 64px 64px 64px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

@media (max-width: 980px) {
  .hub-grid { grid-template-columns: repeat(2, 1fr); padding: 0 32px 48px 32px; }
  .hub-header { padding: 56px 32px 24px 32px; }
}
@media (max-width: 620px) {
  .hub-grid { grid-template-columns: 1fr; }
}

.hub-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 28px 26px 24px 26px;
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 200px;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.hub-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--card-shadow-hover);
}

.hub-card-icon {
  font-size: 32px;
  line-height: 1;
  margin-bottom: 6px;
}

.hub-card h2 {
  font-size: 19px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.01em;
}

.hub-card p {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
  flex-grow: 1;
}

.hub-card-meta {
  font-size: 12px;
  color: var(--text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  margin-top: 8px;
}

.hub-card-disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

/* ---------- Footer ---------- */

.hub-footer {
  text-align: center;
  padding: 24px 32px 48px 32px;
  color: var(--text-subtle);
  font-size: 12px;
}

/* ---------- MCP setup card ---------- */

.setup-wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 32px 64px 32px;
}

.setup-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  padding: 36px 36px 32px 36px;
}

.setup-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}

.setup-brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--accent);
  color: #1c1a16;
  font-weight: 800;
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.setup-brand h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 10px;
}

.badge-recommended {
  background: var(--blue);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  letter-spacing: 0.02em;
}

.setup-brand-sub {
  margin: 2px 0 0 0;
  color: var(--text-muted);
  font-size: 13px;
}

.setup-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-top: 8px;
}

.setup-steps li {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 12px;
  align-items: start;
}

.step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  flex-shrink: 0;
}

.step-text {
  font-size: 14px;
  color: var(--text);
  line-height: 1.55;
}
.step-text a { color: var(--blue); }
.step-text a:hover { text-decoration: underline; }

.setup-code {
  grid-column: 2 / -1;
  margin-top: 8px;
  background: var(--hover);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  position: relative;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
}
.setup-code pre {
  margin: 0;
  white-space: pre-wrap;
  color: var(--text);
}
.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--paper);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.copy-btn:hover { color: var(--text); border-color: var(--text-muted); }
.copy-btn.copied { color: var(--blue); border-color: var(--blue); }

.setup-note {
  margin-top: 24px;
  background: var(--accent-soft);
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
}

.setup-cta {
  display: block;
  text-align: center;
  margin-top: 22px;
  background: #2c4f8a;
  color: #fff;
  font-weight: 600;
  font-size: 15px;
  padding: 14px 18px;
  border-radius: 10px;
  transition: background 0.15s;
}
.setup-cta:hover { background: #355faa; }

/* ---------- Databases shell (Claude-style sidebar) ---------- */

body.db-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: 100vh;
  margin: 0;
  overflow: hidden;
}

.db-sidebar {
  background: var(--paper);
  border-right: 1px solid var(--border);
  padding: 28px 18px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}

.db-back {
  font-size: 13px;
  color: var(--text-muted);
  padding: 6px 8px;
}
.db-back:hover { color: var(--text); }

.db-sidebar-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-subtle);
  margin: 14px 8px 4px 8px;
}

.db-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.db-nav-item {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: background 0.12s;
  text-decoration: none;
}

.db-nav-item:hover { background: var(--hover); }

.db-nav-item.active {
  background: var(--accent-soft);
  border-color: var(--border);
}

.db-nav-icon {
  font-size: 18px;
  line-height: 1;
}

.db-nav-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.db-nav-name {
  font-size: 14px;
  font-weight: 600;
}

.db-nav-meta {
  font-size: 11.5px;
  color: var(--text-subtle);
  letter-spacing: 0.02em;
}

.db-sidebar-foot {
  margin-top: auto;
  padding: 10px 8px;
  font-size: 12px;
  color: var(--text-subtle);
}
.db-sidebar-foot p { margin: 0; }

.db-main {
  height: 100vh;
  background: var(--bg);
  overflow: hidden;
}

.db-main iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--bg);
  display: block;
}

.db-preview-pane {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
}

.db-welcome {
  text-align: center;
  max-width: 480px;
  color: var(--text-muted);
}
.db-welcome-icon {
  font-size: 60px;
  line-height: 1;
  margin-bottom: 16px;
  opacity: 0.85;
}
.db-welcome h1 {
  font-size: 28px;
  font-weight: 700;
  margin: 0 0 12px 0;
  color: var(--text);
  letter-spacing: -0.02em;
}
.db-welcome p {
  font-size: 14.5px;
  line-height: 1.55;
  margin: 0;
}

@media (max-width: 720px) {
  body.db-shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .db-sidebar { border-right: 0; border-bottom: 1px solid var(--border); padding: 14px; }
  .db-nav { flex-direction: row; flex-wrap: wrap; }
}

/* ---------- Mode toggle (shared with NH/SB/AOY) ---------- */

.mode-toggle {
  position: fixed;
  bottom: 22px;
  left: 22px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--card-bg);
  border: 1px solid var(--border);
  box-shadow: var(--card-shadow);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--text);
  transition: transform 0.15s, box-shadow 0.15s;
  z-index: 50;
}
.mode-toggle:hover { transform: scale(1.06); box-shadow: var(--card-shadow-hover); }
.mode-icon-light { display: var(--mode-icon-light-display); }
.mode-icon-dark  { display: var(--mode-icon-dark-display); }

/* ─── Ask Tim widget ─────────────────────────────────────────────── */
/* Floating launcher (bottom-right) → expanding chat panel.           */
/* Self-contained: every selector is prefixed `at-` to avoid clashes  */
/* with the rest of the hub / NH / SB / AOY styles.                   */

.at-root { position: fixed; right: 22px; bottom: 22px; z-index: 100; font-size: 14px; }

.at-launcher {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 16px 8px 8px;
  background: var(--paper); color: var(--text);
  border: 1px solid var(--border); border-radius: 999px;
  box-shadow: var(--card-shadow); cursor: pointer;
  font: inherit; font-weight: 500;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.at-launcher:hover { transform: translateY(-2px); box-shadow: var(--card-shadow-hover); }
.at-launcher-label { padding-right: 4px; letter-spacing: 0.01em; }

.at-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px; overflow: hidden; flex: 0 0 auto;
}
.at-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.at-avatar-sm { width: 28px; height: 28px; font-size: 13px; }

.at-panel {
  position: absolute; right: 0; bottom: 56px;
  width: min(380px, calc(100vw - 44px));
  height: min(560px, calc(100vh - 100px));
  background: var(--paper); color: var(--text);
  border: 1px solid var(--border); border-radius: 16px;
  box-shadow: var(--card-shadow-hover);
  display: none; flex-direction: column; overflow: hidden;
  transform-origin: bottom right;
}
.at-root[data-open="true"] .at-panel { display: flex; animation: at-pop 0.22s ease-out; }
.at-root[data-open="true"] .at-launcher { opacity: 0.4; }

@keyframes at-pop { from { transform: scale(0.94); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.at-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border-bottom: 1px solid var(--border);
}
.at-header-brand { display: flex; align-items: center; gap: 10px; }
.at-header-titles { display: flex; flex-direction: column; line-height: 1.15; }
.at-header-titles strong { font-size: 14px; }
.at-header-sub { font-size: 11px; color: var(--text-muted); }

.at-close {
  background: transparent; border: 0; cursor: pointer;
  font-size: 22px; line-height: 1; color: var(--text-muted);
  padding: 4px 8px; border-radius: 8px;
}
.at-close:hover { background: var(--hover); color: var(--text); }

.at-messages {
  flex: 1 1 auto; overflow-y: auto; padding: 14px 12px;
  display: flex; flex-direction: column; gap: 8px;
  scrollbar-width: thin;
}
.at-messages::-webkit-scrollbar { width: 8px; }
.at-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.at-msg {
  max-width: 86%;
  padding: 9px 12px; border-radius: 14px;
  line-height: 1.45; white-space: pre-wrap; word-wrap: break-word;
}
.at-msg-user {
  align-self: flex-end;
  background: var(--accent); color: #1a1a1a;
  border-bottom-right-radius: 4px;
}
.at-msg-tim {
  align-self: flex-start;
  background: var(--hover); color: var(--text);
  border-bottom-left-radius: 4px;
}
.at-typing { font-style: italic; color: var(--text-muted); animation: at-blink 1.2s infinite; }
@keyframes at-blink { 0%, 100% { opacity: 0.4; } 50% { opacity: 1; } }

.at-input-row {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 10px; border-top: 1px solid var(--border);
}
.at-input {
  flex: 1 1 auto; resize: none;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 12px;
  padding: 9px 12px; font: inherit; line-height: 1.4; max-height: 140px;
  outline: none; transition: border-color 0.15s ease;
}
.at-input:focus { border-color: var(--accent); }
.at-send {
  flex: 0 0 auto;
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--accent); color: #1a1a1a; border: 0;
  font-size: 18px; font-weight: 700; cursor: pointer;
  transition: transform 0.12s ease, opacity 0.15s ease;
}
.at-send:hover:not(:disabled) { transform: scale(1.06); }
.at-send:disabled { opacity: 0.4; cursor: wait; }

@media (max-width: 480px) {
  .at-root { right: 12px; bottom: 12px; }
  .at-launcher-label { display: none; }
  .at-launcher { padding: 6px; }
  .at-panel { width: calc(100vw - 24px); height: calc(100vh - 90px); }
}
