

:root {
  --bg: transparent;
  --card: #ffffff;
  --border: #e5e7eb;
  --border-soft: #f1f5f9;
  --border-strong: #d1d5db;
  --text-light: #9ca3af;
  --text: #111827;
  --muted: #6b7280;
  --brand-soft: #eaf3ff;        /* Soft, light blue */
  --brand: #3f9cff;             /* Main brand color */
  --brand-strong: #0b3a82;      /* Strong blue for contrast */
  --brand-hover: #1e6fd0;       /* Slightly darker hover state */
  --brand-active: #1666c1;      /* Active state */
  --brand-button: #1d72d2;      /* Darker shade of the brand color */
  --shadow-soft: 0 2px 4px rgba(0, 0, 0, 0.04);
  --shadow-form: 0 3px 8px rgba(0, 0, 0, 0.05);
}

body {
  margin: 0;
  height: 100vh;
  background: var(--bg);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: var(--text);
  overflow-y: auto;
}

.kbd {
  display: inline-block;
  padding: 3px 6px 1px 6px;
  border-radius: 3px;
  background: #e5e7eb;
  color: var(--text);
  font-size: 0.85em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  border: 1px solid var(--border-strong); /* subtle edge */
  margin: 0 3px 0 3px;
}

.kbd-light {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 3px;
  background: #fff;
  color: var(--text);
  font-size: 0.85em;
  border: 1px solid var(--border-strong);
  margin: 0 3px 0 3px;
}

#page {
  min-height: calc(100vh - 56px); /* header height */
  display: flex;
  justify-content: center;
  padding-top: 32px;
}

#app-shell {
  width: 100%;
  max-width: 1450px;
  height: 100%;
  display: flex;
  flex-direction: column;
}

#app-header {
  height: 62px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 16px;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
}

.header-left {
  gap: 16px;
}

.header-right {
  gap: 16px;
}

#appBtn {
  display: flex;
  width: 34px;
  height: 34px;
  cursor: pointer;
}

#app-header .material-icons {
  cursor: pointer;
  color: var(--brand);
  font-size: 32px;
}

#app-header .material-icons:hover {
  color: #1f7fe5;
}

.auth-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  background: #fff;
  color: #374151;
  cursor: default;
}

.auth-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-light);
}

/* states */
.auth-badge.success {
  background: #fff; /* #ecfdf5; */
  color: #10b981;
}
.auth-badge.success .auth-dot {
  background: #10b981;
}

.auth-badge.info {
  background: #fff; /* #eef2ff; */
  color: #6366f1;
}
.auth-badge.info .auth-dot {
  background: #6366f1;
}

.auth-badge.error {
  background: #fff; /* #fef2f2; */
  color: #ef4444;
}
.auth-badge.error .auth-dot {
  background: #ef4444;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  border:1px solid var(--border);
  background: var(--bg);
  color: #475569;                  /* slate-600 */
  text-decoration: none;
  cursor: pointer;
  transition:.12s ease;
  box-sizing:unset;
}

.icon-btn:hover {
  color: #0f172a;                  /* slate-900 */
  border-color: #94a3b8;           /* slate-400 */
}

.icon-btn:active {
  color: #0f172a;
  border-color: #94a3b8;           /* slate-400 */
}

#timeline {
  flex: 1;
  overflow-y: auto;
  padding: 24px 16px 24px 16px;
  background: var(--bg);
  min-height: 0; /* CRITICAL for flex scroll containers */
}

.bubble {
  position: relative;
  background: #ffffff;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 64px;
  border: 1px solid var(--border);
}
.bubble.info {
  width: 50%;
}

.bubble svg {
  width: 100%;
  height: auto;
  max-width: 100%;
  display: block;
}

.bubble-time {
  position: absolute;
  bottom: -24px;
  left: 10px;
  font-size: 0.65rem;
  color: var(--text-light);
  cursor: pointer;
}

.bubble-time:hover {
  color: var(--text);
}

.bubble-link {
  position: absolute;
  bottom: 14px;
  right: 20px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.65rem;
  text-decoration: none;
  color: var(--text-light);
  cursor: pointer;
}

.bubble-link .material-symbols-outlined {
  font-size: 18px;
  line-height: 1;
}

.bubble-link:hover {
  color: var(--text);
}

.bubble-close {
  position: absolute;
  top: 10px;
  right: 10px;
  border: none;
  background: #f6f6f6;
  border-radius: 999px;
  padding: 4px;
  cursor: pointer;
  line-height: 1;
}

.material-icons.bubble-close {
  font-size: 14px;
}


.bubble-close:hover {
  background: #fee2e2;;
  color: #991b1b;
}

.bubble-info {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.bubble-info-icon {
  font-size: 20px;
  line-height: 1;
}

.bubble-info-icon.error {
  color: #ef4444;
}

.bubble-info-icon.warning {
  color: #f59e0b;
}

.bubble-info-icon.info {
  color: #1f7fe5;
}

.bubble-info-header {
  font-weight: 600;
  margin-bottom: 2px;
}

.bubble-info-body {
  font-size: 0.9rem;
  line-height: 1.3;
}

.user-menu {
  width: 240px;
  background: #ffffff;
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 16px 16px 12px 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
  display: none;
  text-align: center;
  z-index: 1000;
  cursor: default;
}

.user-avatar {
  width: 56px;
  height: 56px;
  margin: 0 auto 8px;
  border-radius: 50%;
  background: #eaf3ff;
  color: #1f7fe5;
  font-size: 24px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.header-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: #fff;
  color: #374151;
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.header-avatar.hidden {
  display: none;
}

.header-avatar.visible {
  display: flex;
}

.user-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
}

.user-email {
  font-size: 0.8rem;
  color: #6b7280;
  margin-bottom: 10px;
}

.user-role {
  display: inline-block;
  font-size: 0.7rem;
  padding: 3px 8px;
  border-radius: 4px;
  background: #eaf3ff;
  color: #1f7fe5;
  margin-bottom: 12px;
  cursor: pointer;
}

.user-usage {
  display: inline-block;
  font-size: 0.7rem;
  padding: 3px 8px;
  border-radius: 4px;
  background: #eaf3ff;
  color: #1f7fe5;
  margin-bottom: 12px;
  cursor: pointer;
}

.user-usage.ok {
  background: #e6f9f0; /* light green, still visible */
  color: #047857;
}

.user-usage.error {
  background: #fdecec; /* light red, still visible */
  color: #b91c1c;
}

.app-menu {
  position: fixed;
  width: 220px;
  background: #ffffff;
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 4px 0 0 0;
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
  display: none;
  z-index: 1000;
}

#app-menu .material-icons {
  color: var(--text);
  font-size: 28px;
}

#app-menu .material-symbols-outlined {
  color: var(--text);
  font-size: 26px;
}

.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(48px, 1fr));
  gap: 8px;
  padding: 12px;
  max-width: 260px;
}

.app-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.label {
  font-size: 12px;
  text-align: center;
  color: #222;
}

.app-tile:hover .icon-box {
  background: var(--brand-soft);
  border: 1px solid var(--brand);
}

.icon-box {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  border: 1px solid #d0d4d9;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
}

.settings-menu {
  position: fixed;
  width: 260px;
  background: #ffffff;
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 14px 16px 12px 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
  display: none;
  z-index: 1000;
}

.settings-title {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 6px;
  color: var(--text);
}

.settings-menu .input-text {
  width: 90%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: #ffffff;
  color: var(--text);
  font-size: 0.9rem;
  margin-bottom: 10px;
}

.input-title {
  font-weight: 600;
  font-size: 0.9rem;
  margin: 10px 0 8px 0;
  color: var(--text);
}

.dropdown-title {
  font-weight: 600;
  font-size: 0.9rem;
  margin: 6px 0 10px 0;
  color: var(--text);
}

.settings-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  color: #374151;
  padding: 6px 0;
  cursor: pointer;
}

.settings-item input {
  cursor: pointer;
}

.settings-divider {
  height: 1px;
  background: #e5e7eb;
  margin: 10px 0;
}

.settings-menu select {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  color: #1f2937;

  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background-color: #ffffff;

  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;

  background-image:
  url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%236b7280' stroke-width='2' viewBox='0 0 24 24'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
}

.user-menu, .settings-menu {
  position: fixed;   /* IMPORTANT: fixed, not absolute */
  display: none;
  z-index: 1000;
}

#input-wrapper {
  position: fixed;
  bottom: 0px;
  left: 0;
  width: 100%;
  padding: 16px 0 10px;
  background: var(--bg);
}

#input-bar {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  width: calc(100% - 32px);
  max-width: 960px;
  margin: 0 auto;
  padding: 12px 14px;
  background: #ffffff;
  border-radius: 24px;
  border: 1px solid var(--border);
  /*box-shadow: var(--shadow-soft);*/
}

#input-bar textarea {
  flex: 1;
  resize: none;
  border: none;
  outline: none;
  background: transparent;
  font-size: 14px;
  line-height: 20px;
  min-height: 20px;
  max-height: 490px; /* Change here for input height */
  box-sizing: border-box;
  padding: 0;
  margin: 0;
  overflow-y: hidden;
}

#input-bar .material-symbols-outlined {
  cursor: pointer;
  color: #6b7280;
  font-size: 22px;
}

#input-bar .material-symbols-outlined:hover {
  color: var(--text);
}

#input-bar.drag-active {
  background: #eef6ff;
  box-shadow: 0 0 0 2px var(--brand);
}

#input-bar.drag-active textarea {
  max-height: 220px;
}

#input-bar.drag-active::after {
  content: "DROP THE FILE TO UPLOAD";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  font-size: 14px;
  font-weight: bold;
  color: var(--brand);
  pointer-events: none;
}

#fileBtn.material-symbols-outlined {
  color: #6b7280;
}

#fileBtn.material-symbols-outlined:hover {
  color: var(--text);
}

#fileBtn.hidden {
  display: none;
}

#discoverBtn.material-symbols-outlined {
  background: var(--brand);
  border-radius: 99px;
  padding: 1px;
  color: #fff;
  margin: -2px 0 -2px 0;
}

#discoverBtn.material-symbols-outlined:hover {
  background: #1f7fe5;
  color: #fff;
}

#discoverBtn.material-symbols-outlined:active {
  background: #1666c1;
  color: #fff;
}

#input-footer {
  margin-top: 8px;
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-light);
}

.menu-footer {
  margin-top: 2px;
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-light);
  cursor: pointer;
}

.menu-footer:hover {
  color: var(--text);
}

.input-action-hint {
  max-width: 220px;
  padding: 4px 8px;
  font-size: 0.75rem;
  border-radius: 6px;
  background: #eef2ff;
  color: #3730a3;
  white-space: nowrap;
  cursor: pointer;
}

.input-action-hint.hidden {
  display: none;
}

/* color variants */
.input-action-hint.info {
  background: #eef2ff;
  color: #3730a3;
}

.input-action-hint.success {
  background: #ecfdf5;
  color: #065f46;
}

.input-action-hint.error {
  background: #fef2f2;
  color: #991b1b;
}

.input-action-hint.error:hover {
  background: #fee2e2; /* darker */
  color: #7f1d1d;      /* darker */
}

.signin-btn,
.signout-btn {
  width: 100%;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  color: #000;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 9px;;
}

.signin-btn:hover,
.signout-btn:hover {
  background: var(--brand-soft);
  border: 1px solid var(--brand);
}

.spinner {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.material-icons {
  font-family: 'Material Icons';
  font-weight: normal;
  font-style: normal;
  font-size: 24px;
  line-height: 1;
  display: inline-block;
  white-space: nowrap;
  letter-spacing: normal;
  text-transform: none;
  -webkit-font-feature-settings: 'liga';
  -webkit-font-smoothing: antialiased;
}

.material-symbols-outlined {
  font-size: 24px;
  line-height: 1;
}

/* ==============================
   Mobile adjustments (<= 768px)
   ============================== */
@media (max-width: 768px) {

  html, body {
    max-width: 100%;
    overflow-x: hidden;
  }

  body {
    background: var(--bg);
  }

  #app-shell {
    overflow-x: hidden;
  }

  #timeline {
    overflow-x: hidden;
  }

  .bubble {
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 32px;
    padding: 14px;
    border-radius: 12px;
  }

  /* bubbles should be full-width on mobile */
  .bubble.info {
    width: 100%;
  }

  .bubble-time {
    font-size: 0.6rem;
    bottom: -20px;
  }

  .bubble-link {
    right: 14px;
    bottom: 12px;
  }

  .bubble img,
  .bubble pre {
    max-width: 100%;
    overflow-x: auto;
  }

  /* Mobile header */
  #app-header {
    height: 62px;
  }

  #page {
    padding-top: 52px; /* match header height */
  }

  .header-left,
  .header-right {
    gap: 10px;
  }

  #app-header .material-icons {
    font-size: 26px;
  }

  #timeline {
    padding: 4px 16px 4px 16px;
  }

  #input-wrapper {
    padding: 10px 0;
  }

  #input-bar {
    width: 100%;
    max-width: calc(100% - 48px);
    margin: 0 auto;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 12px;
  }

  #input-bar textarea {
    font-size: 15px;
    line-height: 22px;
  }

  .app-grid {
    grid-template-columns: repeat(auto-fit, minmax(56px, 1fr));
  }

  .icon-btn {
    width: 34px;
    height: 34px;
  }
}

/* Very small devices */
@media (max-width: 420px) {

  .bubble {
    padding: 12px;
  }

  .bubble-info-body {
    font-size: 0.85rem;
  }

  #input-footer,
  .menu-footer {
    font-size: 0.65rem;
  }
}