/* Phil visual identity: deep green + gold, cream text. Matches 3wphil.desktend.com. */
:root {
  --bg: #0f1f17;
  --card: #14261c;
  --surface: #1b2f23;
  --border: #2a3d31;
  --text: #f2ecd9;
  --muted: #9db0a3;
  --accent: #eab308;
  --accent-ink: #14261c;
  --green: #2f9e75;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
/* display rules below (.login/.topbar flex) must never beat the hidden attribute */
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); }
main { max-width: 780px; margin: 0 auto; padding: 24px 16px 64px; }

h1 { font-size: 1.5rem; }
h2, h3 { color: var(--text); }

/* Top bar */
.topbar {
  /* Left-aligned (logo → user → sign out) so nothing is pinned to the right
     edge and shifts when the Phil panel docks (body gets padding-right). */
  display: flex; align-items: center; gap: 20px;
  padding: 12px 20px; border-bottom: 1px solid var(--border); background: var(--card);
}
.topbar .brand { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.topbar .brand img { height: 28px; width: 28px; border-radius: 6px; }
.topbar .user { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 0.9rem; }

.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; padding: 16px 20px; margin-bottom: 16px;
}
.card h2 { font-size: 1.05rem; margin-top: 0; }

.row { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.spacer { flex: 1; }

input[type="text"], input[type="password"], textarea, select {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: 6px; font: inherit; background: var(--surface); color: var(--text);
}
input::placeholder, textarea::placeholder { color: var(--muted); }
textarea { resize: vertical; margin-bottom: 8px; }
select { width: auto; }

button {
  font: inherit; padding: 7px 14px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer;
}
button:hover { border-color: var(--accent); color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
button.primary:hover { opacity: 0.9; color: var(--accent-ink); }
button.ghost { background: none; border: none; color: var(--muted); }
button.ghost:hover { color: var(--accent); }

.tabs { display: flex; gap: 4px; margin-bottom: 12px; }
.tab { border: none; background: none; padding: 6px 10px; color: var(--muted); border-bottom: 2px solid transparent; border-radius: 0; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

#dropzone {
  display: block; text-align: center; padding: 32px 16px;
  border: 2px dashed var(--border); border-radius: 10px; cursor: pointer;
}
#dropzone.dragover { border-color: var(--accent); background: rgba(234,179,8,0.08); }
#dropzone .hint { color: var(--muted); font-size: 0.85rem; margin-top: 6px; }

.status { margin-top: 10px; color: var(--muted); }
.status.error { color: #f0999b; }

.meetings { list-style: none; margin: 0; padding: 0; }
.meetings li { border-bottom: 1px solid var(--border); }
.meetings li:last-child { border-bottom: none; }
.m-link {
  display: flex; gap: 10px; align-items: center; padding: 10px 4px;
  cursor: pointer; text-decoration: none; color: inherit;
}
.meetings li:hover .m-title { color: var(--accent); }
.m-title { flex: 1; }

.back-link { display: inline-block; margin-bottom: 12px; color: var(--muted); text-decoration: none; font-size: 0.9rem; }
.back-link:hover { color: var(--accent); }
.m-status { font-size: 0.75rem; padding: 2px 8px; border-radius: 999px; background: var(--surface); color: var(--muted); }
.m-status.completed { background: rgba(47,158,117,0.2); color: #7fdcb9; }
.m-status.failed { background: rgba(226,75,74,0.2); color: #f0999b; }
.m-status.transcribing { background: rgba(234,179,8,0.2); color: #f5d67a; }
.m-status.recording { background: rgba(226,75,74,0.2); color: #f0999b; animation: pulse 1.5s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.55; } }

.pane .hint { color: var(--muted); font-size: 0.9rem; margin-top: 0; }

.qa { margin-top: 18px; border-top: 1px solid var(--border); padding-top: 12px; }
.qa h3 { font-size: 0.95rem; margin: 0 0 10px; }
.qa .row input { flex: 1; }
.qa-item { margin-top: 12px; }
.qa-q { font-weight: 600; }
.qa-a { white-space: pre-wrap; margin: 6px 0; line-height: 1.5; }
.qa-a.pending, .qa-a.failed { color: var(--muted); }
.qa-a.failed { color: #f0999b; }
.qa-cites { display: flex; gap: 6px; flex-wrap: wrap; }
.qa-cite {
  font-size: 0.75rem; padding: 2px 8px; border-radius: 999px;
  background: var(--surface); color: var(--muted); border: 1px solid var(--border);
}

.detail-tools { margin-bottom: 8px; }
a.button-link {
  font: inherit; font-size: 0.95rem; padding: 7px 14px; border-radius: 6px;
  border: 1px solid var(--border); background: #fff;
  color: var(--accent); text-decoration: none;
}
a.button-link:hover { border-color: var(--accent); }
.report-status { margin: 4px 0 10px; font-size: 0.9rem; color: #f5d67a; }
.notes-edit { margin-top: 14px; }
.notes-edit h3 { font-size: 0.95rem; margin: 0 0 8px; }
.toggle { color: var(--muted); font-size: 0.9rem; display: flex; gap: 6px; align-items: center; }
.transcript {
  white-space: pre-wrap; font: inherit; line-height: 1.55;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 14px; min-height: 80px; margin: 0;
}

/* Contact report interstitial. Sits above the Phil panel (z-index 60–62), which
   is docked on this page and would otherwise overlap the dialog. */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 24px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.6); }
.modal-card {
  position: relative; display: flex; flex-direction: column;
  width: min(720px, 100%); max-height: min(80vh, 100%);
  background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: 0 18px 48px rgba(0,0,0,0.45);
}
.modal-head { display: flex; align-items: center; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.modal-head h2 { flex: 1; font-size: 1.05rem; margin: 0; }
.modal-foot { padding: 12px 20px 16px; border-top: 1px solid var(--border); }
.modal-note { margin: 0 0 10px; color: var(--muted); font-size: 0.85rem; line-height: 1.5; }
.modal-actions { margin-bottom: 0; flex-wrap: wrap; }

/* The generated report itself — scrolls independently so the actions below
   stay reachable on a long report. */
.report-preview { overflow-y: auto; padding: 4px 20px 16px; line-height: 1.55; }
.report-preview h1 { font-size: 1rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--accent); margin: 20px 0 8px; }
.report-preview h2 { font-size: 0.92rem; color: var(--text); margin: 16px 0 6px; }
.report-preview p, .report-preview li { font-size: 0.92rem; }
.report-preview ul { margin: 6px 0; padding-left: 20px; }
.report-preview table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 0.85rem; }
.report-preview th, .report-preview td { border: 1px solid var(--border); padding: 6px 8px; text-align: left; vertical-align: top; }
.report-preview th { background: var(--surface); color: var(--muted); font-weight: 600; }

/* Login gate */
.login {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
}
.login-card {
  width: 100%; max-width: 360px; background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 32px 28px; text-align: center;
}
.login-logo { height: 56px; width: 56px; border-radius: 12px; margin-bottom: 12px; }
.login-card h1 { margin: 0 0 4px; font-size: 1.4rem; }
.login-sub { color: var(--muted); margin: 0 0 20px; font-size: 0.9rem; }
.login-card input { margin-bottom: 12px; }
.login-card button { width: 100%; }
.login-error { color: #f0999b; font-size: 0.85rem; margin: 12px 0 0; }

/* Organization picker after sign-in: Desktend's "Select an Organization"
   screen (desktend-app SelectOrganization), in Phil's colours. */
.org-picker { width: 100%; max-width: 448px; text-align: center; }
.org-picker h1 { margin: 0 0 4px; font-size: 1.25rem; }
.org-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 8px; text-align: left;
  box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.35), 0 4px 6px -4px rgb(0 0 0 / 0.35);
}
.org-card-head { padding: 24px 24px 16px; }
.org-card-head h3 { margin: 0; font-size: 1.125rem; font-weight: 600; }
.org-card-head p { margin: 6px 0 0; color: var(--muted); font-size: 0.875rem; }
.org-list {
  display: flex; flex-direction: column; gap: 8px; padding: 0 24px 24px; max-height: 500px; overflow: auto;
}
.org-row {
  width: 100%; display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 8px;
  border: 1px solid var(--border); background: none; color: var(--text); text-align: left;
}
.org-row:hover { border-color: rgb(234 179 8 / 0.5); background: var(--surface); color: var(--text); }
.org-row:hover .org-title { color: var(--accent); }
.org-row:disabled { opacity: 0.6; cursor: progress; }
.org-avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center;
  justify-content: center; background: rgb(234 179 8 / 0.1); color: var(--accent); font-size: 0.8rem; font-weight: 600;
}
.org-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.org-title, .org-slug { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.org-title { font-weight: 500; transition: color 0.15s; }
.org-slug { color: var(--muted); font-size: 0.875rem; }
.org-chevron { display: flex; flex-shrink: 0; color: var(--muted); }
.org-picker .ghost { margin-top: 16px; }

/* Phil — floating conversational assistant (meeting detail page only) */
.phil-launcher {
  position: fixed; right: 20px; bottom: 20px; z-index: 50;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-radius: 999px; font-weight: 600;
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink);
  box-shadow: 0 6px 20px rgba(0,0,0,0.35);
}
.phil-launcher:hover { color: var(--accent-ink); opacity: 0.92; }
.phil-launcher img { height: 20px; width: 20px; border-radius: 5px; }

/* The raised "TM" after PHIL's trademarked phrases, matching the web app's
   Trademark component; line-height 0 keeps it from growing the line. */
sup.tm {
  position: relative; top: -0.9em; vertical-align: baseline; line-height: 0;
  margin-left: 0.08em; font-size: 0.5em; font-weight: 400; letter-spacing: 0;
}

.phil-panel {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 60;
  width: 400px; max-width: 100vw;
  display: flex; flex-direction: column;
  background: var(--card); border-left: 1px solid var(--border);
}
/* Docked: reserve the panel's width on the right so content shifts beside it
   rather than being overlaid. The panel itself stays fixed in that gutter. */
body { transition: padding-right 0.15s ease; }
body.phil-open { padding-right: var(--phil-width, 400px); }
@media (max-width: 720px) {
  /* Too narrow to dock — let the panel overlay instead of crushing content. */
  body.phil-open { padding-right: 0; }
}
/* Drag handle straddling the left edge, with a visible centered grip pill. */
.phil-resize {
  position: absolute; left: -5px; top: 0; bottom: 0; width: 10px; z-index: 62;
  cursor: ew-resize;
  display: flex; align-items: center; justify-content: center;
}
.phil-resize::before {
  content: ""; width: 4px; height: 42px; border-radius: 3px;
  background: var(--border); transition: background 0.15s ease, height 0.15s ease;
}
.phil-resize:hover::before { background: var(--accent); height: 64px; }
.phil-resize:active::before { background: var(--accent); }
/* Borderless, minimalist header — brand mirrors the app top bar's treatment. */
.phil-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: var(--card);
}
.phil-brand { display: flex; align-items: center; gap: 10px; font-weight: 600; flex: 1; min-width: 0; }
.phil-brand img { height: 28px; width: 28px; border-radius: 6px; }
.phil-brand span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.phil-header-actions { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.phil-header-actions .ghost {
  padding: 4px 8px; font-size: 0.8rem; border-radius: 6px; color: var(--muted);
}
.phil-header-actions .ghost:hover { color: var(--accent); background: var(--surface); }

.phil-history { border-bottom: 1px solid var(--border); max-height: 220px; overflow-y: auto; }
.phil-history-row {
  display: block; width: 100%; text-align: left; border: none; border-radius: 0;
  background: none; color: var(--text); padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.phil-history-row:hover { color: var(--accent); background: var(--surface); }
.phil-history-empty { padding: 12px 14px; color: var(--muted); font-size: 0.9rem; }

.phil-messages { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.phil-msg { display: flex; }
.phil-user { justify-content: flex-end; }
.phil-assistant { justify-content: flex-start; }
.phil-bubble {
  max-width: 85%; padding: 9px 12px; border-radius: 12px;
  line-height: 1.5; white-space: normal; word-wrap: break-word;
}
.phil-user .phil-bubble { background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 4px; }
.phil-assistant .phil-bubble { background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.phil-bubble code { background: rgba(0,0,0,0.25); padding: 1px 5px; border-radius: 4px; font-size: 0.9em; }
.phil-bubble a { color: var(--accent); }

/* Rendered Markdown in Phil's replies (marked + DOMPurify output). */
.phil-assistant .phil-bubble > *:first-child { margin-top: 0; }
.phil-assistant .phil-bubble > *:last-child { margin-bottom: 0; }
.phil-assistant .phil-bubble p { margin: 8px 0; }
.phil-assistant .phil-bubble h1,
.phil-assistant .phil-bubble h2,
.phil-assistant .phil-bubble h3,
.phil-assistant .phil-bubble h4 { margin: 12px 0 6px; line-height: 1.25; }
.phil-assistant .phil-bubble h1 { font-size: 1.15rem; }
.phil-assistant .phil-bubble h2 { font-size: 1.05rem; }
.phil-assistant .phil-bubble h3,
.phil-assistant .phil-bubble h4 { font-size: 1rem; }
.phil-assistant .phil-bubble ul,
.phil-assistant .phil-bubble ol { margin: 8px 0; padding-left: 20px; }
.phil-assistant .phil-bubble li { margin: 3px 0; }
.phil-assistant .phil-bubble pre {
  background: rgba(0,0,0,0.3); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px; overflow-x: auto; margin: 8px 0; font-size: 0.85em;
}
.phil-assistant .phil-bubble pre code { background: none; padding: 0; }
.phil-assistant .phil-bubble blockquote {
  margin: 8px 0; padding-left: 12px; border-left: 3px solid var(--border); color: var(--muted);
}
.phil-assistant .phil-bubble hr { border: none; border-top: 1px solid var(--border); margin: 12px 0; }
.phil-assistant .phil-bubble table {
  border-collapse: collapse; margin: 8px 0; font-size: 0.9em; display: block; overflow-x: auto;
}
.phil-assistant .phil-bubble th,
.phil-assistant .phil-bubble td { border: 1px solid var(--border); padding: 4px 8px; text-align: left; }
.phil-assistant .phil-bubble th { background: rgba(0,0,0,0.2); }
.phil-thinking { color: var(--muted); animation: pulse 1.4s ease-in-out infinite; }
.phil-note { color: var(--muted); font-size: 0.8rem; margin-top: 4px; }
.phil-error { color: #f0999b; }
.phil-notice { color: #f2c46d; border: 1px solid #f2c46d55; border-radius: 6px; padding: 4px 8px; margin-bottom: 6px; font-size: 0.8rem; }

.phil-scroll-bottom {
  position: absolute; right: 18px; bottom: 84px; z-index: 61;
  width: 34px; height: 34px; border-radius: 999px; padding: 0;
  background: var(--surface); border: 1px solid var(--border);
}

.phil-form { padding: 12px; border-top: 1px solid var(--border); }
/* Bordered box with the send button tucked in the bottom-right corner. The
   textarea's padding-right reserves the button's column so the prompt text
   wraps beside it and never flows underneath. */
.phil-input-wrap {
  position: relative;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); padding: 10px 12px;
}
.phil-input-wrap:focus-within { border-color: var(--accent); }
.phil-form textarea {
  border: none; background: transparent; padding: 0; margin: 0; width: 100%;
  resize: none; min-height: 56px; max-height: 160px; overflow-y: auto;
  padding-right: 40px; /* clears the corner send button */
}
.phil-form textarea:focus { outline: none; }
/* Send/stop button, bottom-right corner of the input box. */
.phil-send-btn {
  position: absolute; right: 8px; bottom: 8px;
  width: 32px; height: 32px; padding: 0; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.05rem; line-height: 1; font-weight: 700;
  background: var(--accent); border: 1px solid var(--accent); color: var(--accent-ink);
}
.phil-send-btn:hover { opacity: 0.9; color: var(--accent-ink); border-color: var(--accent); }
.phil-send-btn:disabled {
  background: var(--surface); border-color: var(--border); color: var(--muted);
  cursor: default; opacity: 1;
}
.phil-send-btn.phil-stop { background: #e24b4a; border-color: #e24b4a; color: #fff; }
