/* ==========================================================================
   Monochrome Design System & Desktop Layout
   ========================================================================== */

:root {
  --bg-body: #ffffff;
  --bg-sidebar: #fbfbfb;
  --bg-card: #ffffff;
  --bg-subtle: #f4f4f5;
  --bg-hover: #f0f0f2;
  --text-main: #09090b;
  --text-secondary: #52525b;
  --text-muted: #71717a;
  --border-main: #e4e4e7;
  --border-dark: #09090b;
  --border-subtle: #f0f0f2;
  --radius: 4px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-body);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

/* ==========================================================================
   Desktop Shell (Navbar to Left, Collapsible Sidebar, Left-Aligned Content)
   ========================================================================== */

.app-layout {
  display: flex;
  min-height: 100vh;
  width: 100%;
  margin: 0;
  background-color: var(--bg-body);
}

/* Sidebar Navigation */
.app-sidebar {
  width: 260px;
  flex-shrink: 0;
  height: 100vh;
  position: sticky;
  top: 0;
  border-right: 1px solid var(--border-main);
  background-color: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 24px 18px;
  box-sizing: border-box;
  transition: width 0.22s cubic-bezier(0.4, 0, 0.2, 1), padding 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.sidebar-top {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
}

.sidebar-brand {
  padding: 4px 6px;
  white-space: nowrap;
}

.brand-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--text-main);
  text-transform: uppercase;
}

.brand-square {
  width: 12px;
  height: 12px;
  background-color: var(--text-main);
  display: inline-block;
  flex-shrink: 0;
}

.brand-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: inline-block;
  border-radius: 5px;
  color: var(--text-main);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.brand-logo:hover .brand-icon {
  transform: scale(1.08);
}

.btn-sidebar-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.btn-sidebar-toggle:hover {
  background-color: var(--bg-hover);
  color: var(--text-main);
  border-color: var(--border-main);
}

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

.nav-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 8px 10px 4px 10px;
  white-space: nowrap;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: background-color 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}

.nav-item:hover {
  background-color: var(--bg-hover);
  color: var(--text-main);
}

.nav-item.active {
  background-color: var(--text-main);
  color: #ffffff;
}

.nav-item.active .nav-icon {
  stroke: #ffffff;
}

.nav-icon {
  flex-shrink: 0;
  stroke: currentColor;
}


/* Sidebar Footer & Bottom Logout */
.sidebar-footer {
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid var(--border-main);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background-color: var(--text-main);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}

.user-meta {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.user-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.user-email {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-sidebar-logout {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 12px;
  background-color: transparent;
  border: 1px solid var(--border-main);
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-sidebar-logout:hover {
  background-color: var(--text-main);
  border-color: var(--text-main);
  color: #ffffff;
}

.auth-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn-sidebar-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 9px 14px;
  background-color: var(--text-main);
  color: #ffffff;
  border: 1px solid var(--text-main);
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  transition: background-color 0.15s ease;
}

.btn-sidebar-primary:hover {
  background-color: #27272a;
}

.sidebar-secondary-link {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  padding: 4px;
  transition: color 0.15s ease;
}

.sidebar-secondary-link:hover {
  color: var(--text-main);
  text-decoration: underline;
}

/* Mobile Header & Backdrop Base Declarations (Hidden on Desktop) */
.mobile-header {
  display: none;
}

.btn-mobile-close {
  display: none;
}

.sidebar-backdrop {
  display: none;
}

/* User-Collapsible Sidebar State (Desktop Only) */
@media (min-width: 769px) {
  .sidebar-collapsed .app-sidebar {
    width: 68px;
    padding: 24px 10px;
    align-items: center;
  }

  .sidebar-collapsed .sidebar-header {
    flex-direction: column;
    align-items: center;
    gap: 16px;
  }

  .sidebar-collapsed .brand-text,
  .sidebar-collapsed .nav-section-title,
  .sidebar-collapsed .nav-item span,
  .sidebar-collapsed .user-meta,
  .sidebar-collapsed .btn-sidebar-logout span,
  .sidebar-collapsed .btn-sidebar-primary span,
  .sidebar-collapsed .sidebar-secondary-link {
    display: none !important;
  }

  .sidebar-collapsed .sidebar-brand {
    padding: 0;
  }

  .sidebar-collapsed .nav-item {
    justify-content: center;
    padding: 10px 0;
    width: 44px;
    margin: 0 auto;
  }

  .sidebar-collapsed .user-profile {
    padding: 0;
    justify-content: center;
  }

  .sidebar-collapsed .btn-sidebar-logout {
    width: 44px;
    height: 38px;
    padding: 0;
    margin: 0 auto;
    justify-content: center;
  }

  .sidebar-collapsed .btn-sidebar-primary {
    width: 44px;
    height: 38px;
    padding: 0;
    margin: 0 auto;
    justify-content: center;
  }
}

/* ==========================================================================
   Mobile Responsive Navigation & Off-Canvas Drawer (<= 768px)
   ========================================================================== */

@media (max-width: 768px) {
  .app-layout {
    flex-direction: column;
    width: 100%;
    min-height: 100vh;
  }

  /* Mobile Top Navigation Header */
  .mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    padding: 0 16px;
    background-color: var(--bg-sidebar);
    border-bottom: 1px solid var(--border-main);
    position: sticky;
    top: 0;
    z-index: 900;
    width: 100%;
    box-sizing: border-box;
  }

  .btn-mobile-menu {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    background: transparent;
    border: 1px solid var(--border-main);
    border-radius: var(--radius);
    color: var(--text-main);
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
  }

  .btn-mobile-menu:hover {
    background-color: var(--bg-hover);
    border-color: var(--border-dark);
  }

  .mobile-brand .brand-logo {
    font-size: 14px;
    letter-spacing: 0.12em;
  }

  .mobile-actions {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .mobile-user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background-color: var(--text-main);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
  }

  .mobile-login-link {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
    padding: 6px 12px;
    border: 1px solid var(--border-main);
    border-radius: var(--radius);
    transition: background-color 0.15s ease;
  }

  .mobile-login-link:hover {
    background-color: var(--bg-hover);
  }

  /* Off-Canvas Mobile Sidebar Drawer */
  .app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    max-width: 85vw;
    height: 100vh;
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: none;
    border-right: 1px solid var(--border-main);
  }

  .mobile-sidebar-open .app-sidebar {
    transform: translateX(0);
    box-shadow: 6px 0 28px rgba(0, 0, 0, 0.18);
  }

  /* Drawer Header Controls on Mobile */
  .btn-sidebar-toggle {
    display: none !important;
  }

  .btn-mobile-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background: transparent;
    border: 1px solid var(--border-main);
    border-radius: var(--radius);
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.15s ease;
  }

  .btn-mobile-close:hover {
    background-color: var(--bg-hover);
    border-color: var(--border-dark);
  }

  /* Backdrop Overlay */
  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.45);
    z-index: 998;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }

  .mobile-sidebar-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  /* Mobile Content Padding */
  .app-main {
    padding: 20px 16px !important;
    min-height: calc(100vh - 56px);
  }

  /* Mobile Toolbar */
  .crud-toolbar {
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
  }

  .crud-title-group {
    gap: 8px;
  }

  /* Mobile CRUD & Contact Card Layout */
  .contact-card,
  .crud-card {
    flex-direction: column;
    align-items: stretch;
    padding: 16px;
    gap: 14px;
    box-sizing: border-box;
  }

  .contact-main {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    width: 100%;
    min-width: 0;
  }

  .contact-avatar {
    width: 38px;
    height: 38px;
    font-size: 14px;
    flex-shrink: 0;
  }

  .contact-info {
    flex: 1;
    min-width: 0;
    gap: 6px;
  }

  .contact-name-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 8px;
  }

  .contact-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-main);
    word-break: break-word;
  }

  .contact-tag {
    font-size: 11px;
    padding: 1px 6px;
  }

  .contact-details {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    margin-top: 3px;
    width: 100%;
  }

  .contact-detail {
    font-size: 12px;
    color: var(--text-secondary);
    word-break: break-all;
  }

  .contact-meta-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    padding-top: 12px;
    border-top: 1px solid var(--border-main);
    box-sizing: border-box;
  }

  .contact-meta-actions .code-badge {
    font-size: 11px;
    padding: 3px 8px;
    white-space: nowrap;
  }

  .table-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
  }

  .table-actions .btn-sm {
    padding: 6px 10px;
    font-size: 12px;
  }

  /* Mobile Thought Card Layout */
  .thought-card {
    flex-direction: column;
    align-items: stretch;
    padding: 16px;
    gap: 14px;
  }

  .thought-actions {
    display: flex;
    justify-content: flex-end;
    padding-top: 10px;
    border-top: 1px solid var(--border-main);
    width: 100%;
    box-sizing: border-box;
  }

  /* Mobile Forms Layout */
  .form-grid-2,
  .form-grid-3 {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .crud-inline-form {
    padding: 18px 16px;
  }

  .crud-form-actions {
    flex-wrap: wrap;
    gap: 8px;
  }
}

/* ==========================================================================
   Main Content Area (Left-Aligned, Full Available Width)
   ========================================================================== */

.app-main {
  flex: 1;
  min-width: 0;
  min-height: 100vh;
  padding: 40px 48px;
  background-color: var(--bg-body);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  box-sizing: border-box;
}

.content-container {
  width: 100%;
  max-width: none;
  text-align: left;
}

/* Centering container for Devise pages (Centered and Middle) */
.content-container:has(.auth-wrapper) {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 80px);
  margin: auto;
}

/* Flash Messages */
@keyframes flashSlideIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.flash-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 24px;
  width: 100%;
  max-width: 600px;
  position: relative;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  animation: flashSlideIn 0.32s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  will-change: opacity, transform, max-height, margin-bottom, padding;
  overflow: hidden;
}

.content-container:has(.auth-wrapper) .flash-banner {
  max-width: 440px;
}

.flash-notice {
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-main);
  color: var(--text-main);
}

.flash-alert {
  background-color: #ffffff;
  border: 1px solid var(--border-dark);
  color: var(--text-main);
  font-weight: 500;
}

.flash-indicator {
  width: 6px;
  height: 6px;
  background-color: var(--text-main);
  border-radius: 50%;
  flex-shrink: 0;
}

.flash-text {
  flex: 1;
  line-height: 1.4;
}

.flash-close {
  background: transparent;
  border: none;
  padding: 4px;
  margin: -4px -4px -4px auto;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  transition: color 0.15s ease, background-color 0.15s ease;
  flex-shrink: 0;
}

.flash-close:hover {
  color: var(--text-main);
  background-color: var(--bg-hover);
}


/* ==========================================================================
   Devise Auth Form Styling (Centered and Middle)
   ========================================================================== */

.auth-wrapper {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  margin: auto;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-main);
  border-radius: 6px;
  padding: 32px 36px;
  box-sizing: border-box;
  margin: 0 auto;
}


.auth-header {
  margin-bottom: 24px;
}

.auth-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 6px 0;
  color: var(--text-main);
}

.auth-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0;
}

.auth-form {
  display: flex;
  flex-direction: column;
}

.auth-form .field {
  margin-bottom: 20px;
}

.auth-form .field p {
  margin: 0;
}

.auth-form label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-main);
  margin-bottom: 6px;
}

.auth-form input[type="text"],
.auth-form input[type="email"],
.auth-form input[type="password"],
.auth-form input[type="tel"],
.auth-form input[type="number"],
.auth-form input[type="date"],
.auth-form textarea {
  width: 100%;
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.5;
  border: 1px solid var(--border-main);
  border-radius: var(--radius);
  background-color: #ffffff;
  color: var(--text-main);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  box-sizing: border-box;
}

.auth-form input[type="date"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.15s ease;
}

.auth-form input[type="date"]::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
}

.auth-form textarea {
  min-height: 130px;
  line-height: 1.6;
  resize: vertical;
  display: block;
}

.auth-form input[type="text"]:focus,
.auth-form input[type="email"]:focus,
.auth-form input[type="password"]:focus,
.auth-form input[type="tel"]:focus,
.auth-form input[type="number"]:focus,
.auth-form input[type="date"]:focus,
.auth-form textarea:focus {
  outline: none;
  border-color: var(--text-main);
  box-shadow: 0 0 0 1px var(--text-main);
}

.field-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

.checkbox-group {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.checkbox-group input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--text-main);
  cursor: pointer;
  margin: 0;
}

.checkbox-group label {
  font-size: 13px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: normal;
  margin-bottom: 0;
  cursor: pointer;
}

.auth-form .actions {
  margin-top: 8px;
}

.auth-form input[type="submit"],
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 11px 16px;
  background-color: var(--text-main);
  color: #ffffff;
  border: 1px solid var(--text-main);
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease;
  text-decoration: none;
}

.auth-form input[type="submit"]:hover,
.btn-primary:hover {
  background-color: #27272a;
}

.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 16px;
  background-color: transparent;
  color: var(--text-main);
  border: 1px solid var(--border-main);
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-danger:hover {
  background-color: #000000;
  color: #ffffff;
  border-color: #000000;
}

.auth-links {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.auth-links p {
  margin: 0;
}

.auth-links a {
  font-size: 13px;
  color: var(--text-secondary);
  transition: color 0.15s ease;
}

.auth-links a:hover {
  color: var(--text-main);
  text-decoration: underline;
}

/* Error explanation box */
#error_explanation {
  border: 1px solid var(--border-dark);
  background-color: var(--bg-subtle);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 24px;
}

#error_explanation h2 {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 8px 0;
  color: var(--text-main);
}

#error_explanation ul {
  margin: 0;
  padding-left: 18px;
  font-size: 13px;
  color: var(--text-secondary);
}

#error_explanation li {
  margin-bottom: 4px;
}

/* ==========================================================================
   Brain Overview / Dashboard Styling
   ========================================================================== */

.page-header {
  margin-bottom: 32px;
}

.page-title {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 0 0 8px 0;
  color: var(--text-main);
}

.page-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0;
}

.grid-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  width: 100%;
  margin-bottom: 36px;
}

.stat-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-main);
  border-radius: 6px;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.stat-value {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-main);
}

.stat-desc {
  font-size: 12px;
  color: var(--text-secondary);
}

.content-panel {
  background-color: var(--bg-card);
  border: 1px solid var(--border-main);
  border-radius: 6px;
  padding: 24px 28px;
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 24px;
}

.panel-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 16px 0;
  color: var(--text-main);
}

.panel-body p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin: 0 0 14px 0;
}

.panel-body p:last-child {
  margin-bottom: 0;
}

.code-badge {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 3px;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-main);
  color: var(--text-main);
}

/* ==========================================================================
   Hotwire / Turbo Single-Page Index CRUD Styles
   ========================================================================== */

.crud-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  width: 100%;
}

.crud-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.counter-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 8px;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-main);
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
}

/* Turbo Frame Form Containers (Inline Create / Edit) */
.crud-inline-frame {
  display: block;
  width: 100%;
}

.crud-inline-form {
  background-color: var(--bg-card);
  border: 1px solid var(--border-dark);
  border-radius: 6px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  animation: fadeIn 0.18s ease-in-out;
}

.crud-form-header {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 16px 0;
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.crud-form-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  width: 100%;
  box-sizing: border-box;
}

.form-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
  width: 100%;
  box-sizing: border-box;
}

/* ==========================================================================
   Interval Compound Input & Dropdown Styling
   ========================================================================== */

.interval-compound-group {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--border-main);
  border-radius: var(--radius);
  background-color: #ffffff;
  overflow: hidden;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  max-width: 100%;
}

.interval-compound-group:hover {
  border-color: var(--border-dark);
}

.interval-compound-group:focus-within {
  border-color: var(--text-main);
  box-shadow: 0 0 0 1px var(--text-main);
}

.interval-addon {
  display: flex;
  align-items: center;
  padding: 0 14px;
  background-color: var(--bg-subtle);
  border-right: 1px solid var(--border-main);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  user-select: none;
}

.interval-number-input,
.auth-form input[type="number"].interval-number-input {
  width: 68px !important;
  min-width: 54px;
  padding: 10px 8px !important;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  color: var(--text-main);
  border: none !important;
  border-right: 1px solid var(--border-main) !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  outline: none !important;
}

.interval-number-input:focus {
  background-color: #ffffff !important;
  box-shadow: none !important;
  outline: none !important;
}

.interval-select-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.interval-select,
.auth-form select.interval-select {
  padding: 10px 36px 10px 14px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  color: var(--text-main);
  border: none !important;
  border-radius: 0 !important;
  background-color: transparent !important;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2318181b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 12px center !important;
  background-size: 14px 14px !important;
  box-shadow: none !important;
  outline: none !important;
  min-width: 110px;
}

.interval-select:focus {
  box-shadow: none !important;
  outline: none !important;
}

.interval-select option {
  background-color: #ffffff;
  color: var(--text-main);
  padding: 6px 10px;
}

.crud-form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
}

/* Table Style for Single-Page CRUD */
.crud-table-wrapper {
  width: 100%;
  border: 1px solid var(--border-main);
  border-radius: 6px;
  overflow: hidden;
  background-color: var(--bg-card);
}

.crud-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}

.crud-table th {
  padding: 12px 16px;
  background-color: var(--bg-subtle);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-main);
}

.crud-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-main);
  vertical-align: middle;
}

.crud-table tr:last-child td {
  border-bottom: none;
}

.crud-table tbody tr {
  transition: background-color 0.12s ease;
}

.crud-table tbody tr:hover {
  background-color: var(--bg-hover);
}

.table-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
}

/* Card / List Layout for Single-Page CRUD */
.crud-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.crud-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-main);
  border-radius: 6px;
  padding: 18px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.crud-card:hover {
  border-color: var(--border-dark);
}

.crud-item-frame {
  display: block;
  width: 100%;
}

.contact-main {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.contact-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background-color: var(--text-main);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  flex-shrink: 0;
}

.contact-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.contact-name-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.contact-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-main);
}

.contact-tag {
  display: inline-block;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 500;
  border-radius: 3px;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-main);
  color: var(--text-secondary);
}

.contact-details {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 12px;
  color: var(--text-secondary);
  flex-wrap: wrap;
}

.contact-detail {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.contact-detail svg {
  stroke: var(--text-muted);
}

.contact-meta-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

/* Action Buttons for CRUD */

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  background-color: #ffffff;
  color: var(--text-main);
  border: 1px solid var(--border-main);
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
}

.btn-secondary:hover {
  border-color: var(--border-dark);
  background-color: var(--bg-subtle);
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  background-color: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 12px;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
}

.btn-ghost:hover {
  background-color: var(--bg-subtle);
  color: var(--text-main);
  border-color: var(--border-main);
}

.btn-danger-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  background-color: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 12px;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
}

.btn-danger-ghost:hover {
  background-color: #000000;
  color: #ffffff;
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  border: 1px dashed var(--border-main);
  border-radius: 6px;
  background-color: var(--bg-sidebar);
  text-align: center;
  width: 100%;
}

.empty-state-icon {
  width: 40px;
  height: 40px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.empty-state-title {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 6px 0;
  color: var(--text-main);
}

.empty-state-desc {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 360px;
  margin: 0 0 18px 0;
}

/* ==========================================================================
   Thought Cards Styling
   ========================================================================== */

.thought-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 24px;
}

.thought-main {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.thought-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-main);
  margin: 0;
  line-height: 1.4;
  letter-spacing: -0.01em;
}

.thought-details {
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}

.thought-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
}

.thought-time {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-muted);
}

.thought-time svg {
  stroke: var(--text-muted);
}

.thought-actions {
  flex-shrink: 0;
}

/* Turbo Highlight Animation */
@keyframes turboHighlight {
  0% { background-color: #f4f4f5; }
  100% { background-color: transparent; }
}

.turbo-highlight {
  animation: turboHighlight 1.5s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Quick Thought Capture (Minimalist Inline) */
.quick-thought-wrapper {
  margin-bottom: 24px;
  width: 100%;
}

.quick-thought-inline-form {
  width: 100%;
}

.quick-thought-errors {
  margin-bottom: 10px;
  padding: 8px 12px;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius);
}

.quick-thought-error-msg {
  font-size: 13px;
  color: var(--text-main);
  font-weight: 500;
}

.quick-thought-inline-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.quick-thought-inline-input {
  flex: 1;
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.5;
  border: 1px solid var(--border-main);
  border-radius: var(--radius);
  background-color: var(--bg-card);
  color: var(--text-main);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  box-sizing: border-box;
}

.quick-thought-inline-input:focus {
  outline: none;
  border-color: var(--text-main);
  box-shadow: 0 0 0 1px var(--text-main);
}

.quick-thought-inline-btn {
  width: auto !important;
  padding: 10px 22px !important;
  font-size: 13px !important;
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
}

@media (max-width: 480px) {
  .quick-thought-inline-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .quick-thought-inline-btn {
    width: 100% !important;
  }
}




