@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Source+Code+Pro:wght@400;600&display=swap");

:root {
  color-scheme: light dark;
  --bg: #f6f4f1;
  --bg-secondary: #efece7;
  --surface: #ffffff;
  --surface-strong: #f8f6f2;
  --border: rgba(20, 24, 28, 0.12);
  --text: #1b1d21;
  --text-muted: #5b616a;
  --accent: #ff7a1a;
  --accent-2: #f0b50e;
  --danger: #e5524a;
  --success: #1b9c61;
  --shadow: 0 12px 28px rgba(19, 21, 25, 0.08);
  --radius: 14px;
}

.theme-light {
  color-scheme: light;
}

.theme-dark {
  --bg: #0f1115;
  --bg-secondary: #141820;
  --surface: #171b23;
  --surface-strong: #1d2230;
  --border: rgba(255, 255, 255, 0.1);
  --text: #f3f4f6;
  --text-muted: #9aa3b2;
  --accent: #ff8a3d;
  --accent-2: #ffc247;
  --danger: #ff6b61;
  --success: #2bd47d;
  --shadow: 0 16px 32px rgba(0, 0, 0, 0.32);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  background: radial-gradient(circle at top left, var(--bg-secondary), var(--bg));
  color: var(--text);
  min-height: 100vh;
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 32px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(120deg, rgba(255, 122, 26, 0.08), transparent 45%);
}

.brand {
  display: flex;
  gap: 16px;
  align-items: center;
}

.logo {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  object-fit: cover;
  box-shadow: var(--shadow);
}

.brand-title {
  font-weight: 700;
  font-size: 18px;
}

.brand-subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

.topbar-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

button,
select,
input {
  font-family: inherit;
}

button {
  border: none;
  padding: 10px 16px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

button:active {
  transform: translateY(1px);
}

button.primary {
  background: var(--accent);
  color: #111;
  box-shadow: 0 12px 24px rgba(255, 122, 26, 0.35);
}

button.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

button.warning {
  background: transparent;
  border: 1px solid rgba(255, 122, 26, 0.6);
  color: var(--accent);
}

button.danger {
  background: transparent;
  border: 1px solid rgba(229, 82, 74, 0.45);
  color: var(--danger);
}

button.text-link {
  padding: 0;
  border: none;
  background: transparent;
  color: var(--accent);
  border-radius: 0;
  text-align: left;
  font-weight: 600;
}

button.text-link:hover {
  text-decoration: underline;
}

button:disabled,
button.is-disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

button.wide {
  width: 100%;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface-strong);
  border: 1px solid var(--border);
}

.user-avatar {
  min-width: 32px;
  height: 32px;
  max-width: 140px;
  border-radius: 50%;
  background: var(--accent-2);
  display: grid;
  place-items: center;
  font-weight: 700;
  color: #111;
  padding: 0 10px;
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-avatar.is-photo {
  padding: 0;
  min-width: 32px;
  width: 32px;
  max-width: 32px;
}

.user-name {
  font-weight: 600;
  font-size: 13px;
}

.user-email {
  font-size: 11px;
  color: var(--text-muted);
}

.auth-view {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 40px 24px;
}

.auth-panel {
  width: min(1100px, 100%);
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
  display: grid;
  gap: 32px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  border: 1px solid var(--border);
}

.auth-hero {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.hero-icon {
  width: 84px;
  height: 84px;
  border-radius: 20px;
  object-fit: cover;
  box-shadow: var(--shadow);
}

.hero-title {
  font-size: 28px;
  font-weight: 700;
}

.hero-subtitle {
  color: var(--text-muted);
  line-height: 1.5;
}

.hero-card {
  background: var(--surface-strong);
  border-radius: 16px;
  padding: 16px;
  border: 1px dashed var(--border);
}

.hero-card ul {
  margin-top: 10px;
  display: grid;
  gap: 8px;
  list-style: none;
  color: var(--text-muted);
  font-size: 14px;
}

.auth-forms {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.tabs {
  display: flex;
  gap: 8px;
}

.project-tabs {
  flex-wrap: wrap;
  margin: 8px 0 16px;
}

.tab {
  flex: 1;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface-strong);
}

.tab.active {
  background: var(--accent);
  color: #111;
  border-color: transparent;
}

.tab-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
}

.field input,
select,
input[type="search"] {
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

textarea,
input,
select {
  background-color: var(--surface);
  color: var(--text);
  color-scheme: inherit;
}

.form-hint {
  min-height: 18px;
  color: var(--danger);
  font-size: 12px;
}

.divider {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 6px;
}

.google-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.theme-dark #google-button {
  padding: 2px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  overflow: hidden;
}

.theme-dark #google-button iframe {
  border: 0 !important;
  border-radius: 999px;
  display: block;
}

.app-view {
  flex: 1;
  display: flex;
  min-height: 0;
}

.side-nav {
  width: 220px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-right: 1px solid var(--border);
  background: var(--surface);
}

.side-support-link {
  margin-top: auto;
  padding: 12px 8px 0;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
}

.side-support-link:hover {
  color: var(--accent);
}

.nav-item {
  text-align: left;
  padding: 12px 16px;
  border-radius: 14px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
}

.nav-item.active {
  background: var(--surface-strong);
  border-color: var(--border);
}

.main-content {
  flex: 1;
  padding: 24px 32px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.quota-warning-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fef3c7;
  border: 1px solid #f59e0b;
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 0.875rem;
  color: #92400e;
}

.quota-warning-banner a {
  white-space: nowrap;
  font-weight: 600;
  color: #92400e;
  text-decoration: underline;
  margin-left: auto;
}

.theme-dark .quota-warning-banner {
  background: #422006;
  border-color: #b45309;
  color: #fde68a;
}

.theme-dark .quota-warning-banner a {
  color: #fde68a;
}

.view {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.view-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.view-header h2 {
  font-size: 26px;
}

.view-header p {
  color: var(--text-muted);
}

.view-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.panel {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 16px;
  box-shadow: var(--shadow);
}

.panel-title {
  font-weight: 600;
  margin-bottom: 12px;
}

.split {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 560px;
  overflow: auto;
}

.list-item {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-strong);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.list-item.active {
  border-color: var(--accent);
  box-shadow: 0 10px 16px rgba(255, 122, 26, 0.2);
}

.list-item small {
  color: var(--text-muted);
}

.status-history-text {
  white-space: pre-wrap;
  line-height: 1.5;
}

.recording-item:hover {
  border-color: rgba(255, 122, 26, 0.45);
  box-shadow: 0 6px 14px rgba(255, 122, 26, 0.14);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.badge.success {
  color: var(--success);
  border-color: rgba(27, 156, 97, 0.3);
}

.badge.warning {
  color: #e5a600;
}

.badge.error {
  color: var(--danger);
}

.recording-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 10px;
  align-items: center;
}

.recording-title {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recording-meta {
  grid-column: 1 / 2;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--text-muted);
  font-size: 12px;
}

.recording-meta span {
  white-space: nowrap;
}

.detail {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.project-tab-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.detail h3 {
  font-size: 18px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}

.detail-grid div {
  background: var(--surface-strong);
  padding: 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  font-size: 13px;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.billing-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

.billing-kpi {
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
}

.billing-kpi-label {
  font-size: 12px;
  color: var(--text-muted);
}

.billing-kpi-value {
  font-size: 18px;
  font-weight: 600;
  margin-top: 6px;
}

.billing-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.billing-plan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.billing-plan-card {
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.billing-plan-card h4 {
  font-size: 16px;
}

.billing-plan-meta {
  color: var(--text-muted);
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.billing-usage-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
}

.billing-transactions-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
}

.billing-transactions-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.billing-transactions-table th,
.billing-transactions-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.billing-transactions-table th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12px;
}

.billing-transactions-table td:last-child,
.billing-transactions-table th:last-child {
  text-align: right;
}

.approval-banner {
  background: rgba(255, 122, 26, 0.12);
  border: 1px solid rgba(255, 122, 26, 0.3);
  color: var(--text);
  padding: 12px 16px;
}

.approval-banner.pending {
  background: rgba(240, 181, 14, 0.14);
  border-color: rgba(240, 181, 14, 0.35);
}

.approval-banner.approved {
  background: rgba(27, 156, 97, 0.14);
  border-color: rgba(27, 156, 97, 0.35);
}
.generation-counter {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
}

.generation-counter.is-empty {
  opacity: 0.75;
}

.panel-collapsible {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-strong);
}

.panel-collapsible summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  font-weight: 600;
}

.panel-collapsible summary::-webkit-details-marker {
  display: none;
}

.panel-collapsible[open] summary {
  border-bottom: 1px solid var(--border);
}

.panel-collapsible .panel-body {
  padding: 12px;
}

.empty {
  color: var(--text-muted);
  font-size: 14px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-bottom: 12px;
}

.task-add-row {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

textarea {
  width: 100%;
  min-height: 120px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-strong);
  color: var(--text);
  font-family: "Source Code Pro", monospace;
  font-size: 12px;
}

.pager {
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text-muted);
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.toast.show {
  opacity: 1;
}

.hidden {
  display: none !important;
}

body:not(.authed) #user-chip,
body:not(.authed) #logout-btn {
  display: none;
}

body.booting .auth-view,
body.booting .app-view {
  visibility: hidden;
}

body.booting #loading {
  display: grid !important;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 16, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  max-width: 520px;
  width: 100%;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.modal-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 12px;
}

.modal-body {
  max-height: 300px;
  overflow: auto;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.6;
}

.modal-body.form-body {
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.loading {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.65);
  backdrop-filter: blur(4px);
  color: var(--text);
}

.audio-player {
  width: 100%;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
}

.photo-card {
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-strong);
  overflow: hidden;
}

.photo-card img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  display: block;
}

.photo-lightbox {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.photo-lightbox.hidden {
  display: none;
}

.photo-lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 14, 22, 0.82);
  backdrop-filter: blur(2px);
}

.photo-lightbox-body {
  position: relative;
  z-index: 1;
  max-width: min(90vw, 1100px);
  max-height: 90vh;
  padding: 12px;
  border-radius: 18px;
  background: rgba(20, 24, 34, 0.8);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
}

.photo-lightbox-body img {
  display: block;
  max-width: min(88vw, 1060px);
  max-height: 86vh;
  width: auto;
  height: auto;
  border-radius: 12px;
}

.speaker-row {
  display: grid;
  gap: 8px;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-strong);
}

.speaker-row select,
.speaker-row input {
  width: 100%;
}

.theme-dark .loading {
  background: rgba(0, 0, 0, 0.55);
}

/* Chat paywall */
.chat-paywall {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 2rem;
}

.chat-paywall-content {
  text-align: center;
  color: var(--text-muted);
}

.chat-paywall-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.chat-paywall-text {
  font-size: 1rem;
  line-height: 1.5;
  max-width: 400px;
}

.billing-scheduled-info {
  padding: 8px 12px;
  margin-top: 8px;
  background: var(--color-primary-bg, #e3f2fd);
  border-radius: 6px;
  font-size: 0.9rem;
  color: var(--color-primary, #1976d2);
  font-weight: 500;
}

.billing-free-hint {
  margin-top: 8px;
  padding: 8px 12px;
  background: var(--surface-strong);
  border-left: 3px solid var(--text-muted);
  border-radius: 4px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Chat styles */
.chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 220px);
  background: var(--surface);
  border-radius: 12px;
  border: 1px solid var(--border);
  overflow: hidden;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.chat-message {
  max-width: 80%;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-message-user {
  align-self: flex-end;
  background: var(--primary);
  color: white;
}

.chat-message-assistant {
  align-self: flex-start;
  background: var(--surface-strong);
  border: 1px solid var(--border);
}

.chat-input-area {
  display: flex;
  gap: 0.5rem;
  padding: 1rem;
  border-top: 1px solid var(--border);
  background: var(--surface-strong);
}

.chat-input-area textarea {
  flex: 1;
  resize: none;
  min-height: 2.5rem;
  max-height: 6rem;
}

.chat-citations-list {
  margin-top: 0.5rem;
  padding: 0.5rem;
  background: var(--surface);
  border-radius: 8px;
  font-size: 0.85rem;
}

.chat-citation-card {
  padding: 0.5rem;
  margin-top: 0.25rem;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
}

.chat-citation-card:hover {
  background: var(--surface);
}

.chat-citation-card strong {
  display: block;
  font-size: 0.8rem;
  margin-bottom: 0.25rem;
}

.chat-citation-card small {
  color: var(--text-muted);
}

.chat-streaming {
  opacity: 0.7;
}

.chat-streaming::after {
  content: "...";
  animation: blink 1s infinite;
}

@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

/* Task styles */
.task-status-select {
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.85rem;
  cursor: pointer;
}

.task-done {
  opacity: 0.6;
}

.task-done strong {
  text-decoration: line-through;
}

.task-overdue {
  border-left: 3px solid var(--danger);
}

/* Workspace settings */
.workspace-settings-section {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--surface-strong);
  border-radius: 12px;
  border: 1px solid var(--border);
}

.workspace-settings-section .field {
  margin-bottom: 1rem;
}

.workspace-settings-section textarea {
  min-height: 80px;
  resize: vertical;
}

.char-count {
  display: block;
  text-align: right;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-direction: row;
}

.checkbox-field input[type="checkbox"] {
  width: auto;
  margin: 0;
}

@media (max-width: 900px) {
  .topbar {
    flex-direction: column;
    gap: 16px;
    align-items: flex-start;
  }

  .side-nav {
    width: 100%;
    flex-direction: row;
    overflow: auto;
  }

  .app-view {
    flex-direction: column;
  }
}
