/* Mobile Optimizations for Lexicon Clip
 * These styles improve the mobile experience by reducing clutter
 * and maximizing space for note content
 */

/* ============================================
   TAG PILL STYLING (Global - Mobile & Desktop)
   ============================================ */
.note-tag-pill {
  display: inline-flex !important;
  align-items: center;
  padding: 0.25rem 0.625rem !important;
  font-size: 0.8125rem !important;
  line-height: 1.25;
  color: var(--md-primary) !important;
  background-color: color-mix(in srgb, var(--md-primary) 10%, transparent) !important;
  border: 1px solid color-mix(in srgb, var(--md-primary) 25%, transparent) !important;
  border-radius: 1rem !important;
  text-decoration: none !important;
  transition: all 0.2s;
  white-space: nowrap;
  margin-right: 0.5rem;
  margin-bottom: 0.375rem;
}

.note-tag-pill:hover {
  background-color: color-mix(in srgb, var(--md-primary) 15%, transparent) !important;
  border-color: color-mix(in srgb, var(--md-primary) 35%, transparent) !important;
  color: var(--md-primary) !important;
}

/* ============================================
   MOBILE TOP BAR
   ============================================ */
@media (max-width: 640px) {
  .md-navigation-bar-top {
    background-color: var(--md-surface);
    box-shadow: var(--md-elevation-2);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--md-outline-variant);
  }
}

/* ============================================
   MOBILE BOTTOM NAVIGATION
   ============================================ */
@media (max-width: 640px) {
  .md-navigation-bar-bottom {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: var(--md-surface);
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.15);
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    border-top: 1px solid var(--md-outline-variant);
  }
  
  .md-bottom-nav-items {
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 0.5rem 0;
  }
  
  .md-bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem 0.75rem;
    text-decoration: none;
    color: var(--md-on-surface-variant);
    font-size: 0.625rem;
    font-weight: 500;
    flex: 1;
    border-radius: 0.5rem;
    transition: all 0.2s cubic-bezier(0.2, 0, 0, 1);
    min-height: 64px;
    justify-content: center;
  }
  
  .md-bottom-nav-item svg {
    width: 1.5rem;
    height: 1.5rem;
    stroke-width: 2;
  }
  
  .md-bottom-nav-label {
    font-size: 0.625rem;
    line-height: 1rem;
    text-align: center;
  }
  
  .md-bottom-nav-item-active {
    color: var(--md-primary);
    background-color: color-mix(in srgb, var(--md-primary) 8%, transparent);
  }
  
  .md-bottom-nav-item:active {
    background-color: color-mix(in srgb, var(--md-primary) 12%, transparent);
  }
  
  /* Add padding to main content for bottom nav */
  main.pb-bottom-nav {
    padding-bottom: calc(4rem + env(safe-area-inset-bottom, 0px)) !important;
  }
  
  /* Add margin to footer for bottom nav */
  .mb-bottom-nav-footer {
    margin-bottom: calc(4rem + env(safe-area-inset-bottom, 0px)) !important;
  }
}

/* Desktop: Remove bottom padding/margin */
@media (min-width: 641px) {
  main.pb-bottom-nav {
    padding-bottom: inherit !important;
  }
  
  .mb-bottom-nav-footer {
    margin-bottom: inherit !important;
  }
}

/* ============================================
   MENU DRAWER (Mobile and Desktop)
   ============================================ */
.md-drawer-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 199;
  transition: opacity 0.3s ease;
}

.md-drawer-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.md-drawer {
  position: fixed;
  top: 0;
  right: -320px;
  width: 320px;
  max-width: 85vw;
  height: 100vh;
  background-color: var(--md-surface);
  box-shadow: -2px 0 8px rgba(0, 0, 0, 0.15);
  z-index: 200;
  transition: right 0.3s cubic-bezier(0.2, 0, 0, 1);
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.md-drawer:not(.hidden) {
  right: 0;
}

.md-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--md-outline-variant);
}

.md-drawer-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.5rem 0;
}

.md-drawer-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  text-decoration: none;
  color: var(--md-on-surface);
  font-size: 0.9375rem;
  font-weight: 400;
  border-bottom: 1px solid var(--md-outline-variant);
  transition: background-color 0.2s ease;
  width: 100%;
}

.md-drawer-item:hover,
.md-drawer-item:active {
  background-color: color-mix(in srgb, var(--md-primary) 8%, transparent);
}

.md-drawer-item-active {
  background-color: color-mix(in srgb, var(--md-primary) 12%, transparent);
  color: var(--md-primary);
  font-weight: 500;
}

.md-drawer-item-danger {
  color: var(--md-error);
}

.md-drawer-item-danger:hover,
.md-drawer-item-danger:active {
  background-color: color-mix(in srgb, var(--md-error) 8%, transparent);
}

.md-drawer-item svg {
  width: 1.5rem;
  height: 1.5rem;
  flex-shrink: 0;
}

/* Desktop-specific drawer adjustments - Hide drawer on desktop */
@media (min-width: 641px) {
  .md-drawer,
  .md-drawer-overlay {
    display: none !important;
  }
  
  /* Ensure dropdown menu appears above everything */
  [data-dropdown-target="menu"] {
    z-index: 9999 !important;
  }
}

/* ============================================
   DROPDOWN MENU (Desktop)
   ============================================ */
[data-controller="dropdown"] {
  position: relative;
  z-index: 50;
}

[data-dropdown-target="menu"] {
  min-width: 14rem;
  max-height: 80vh;
  overflow-y: auto;
}

[data-dropdown-target="menu"] a:first-child {
  border-top-left-radius: 0.5rem;
  border-top-right-radius: 0.5rem;
}

[data-dropdown-target="menu"] a:last-child {
  border-bottom-left-radius: 0.5rem;
  border-bottom-right-radius: 0.5rem;
  border-bottom: none;
}

[data-dropdown-target="menu"] a:hover {
  background-color: var(--md-surface-variant);
}

[data-dropdown-target="menu"] a:focus {
  outline: 2px solid var(--md-primary);
  outline-offset: -2px;
}

/* Ensure dropdown is not cut off by parent containers */
@media (min-width: 641px) {
  .md-navigation-bar {
    overflow-x: auto;
    overflow-y: visible !important;
  }

  .md-navigation-bar > div,
  .md-navigation-bar > div > div {
    overflow: visible !important;
  }
}

/* ============================================
   COMPACT NAVIGATION (Desktop fallback)
   ============================================ */
@media (min-width: 641px) {
  /* Hide mobile-only elements on desktop */
  .md-navigation-bar-top,
  .md-navigation-bar-bottom {
    display: none !important;
  }
}

/* ============================================
   COMPACT CARDS AND SPACING
   ============================================ */
@media (max-width: 640px) {
  /* Reduced card padding */
  .md-card {
    padding: 0.75rem;
    margin-bottom: 0.75rem;
  }
  
  /* Reduced spacing between sections */
  .mb-8 {
    margin-bottom: 1rem !important;
  }
  
  .mb-6 {
    margin-bottom: 0.75rem !important;
  }
  
  .mb-4 {
    margin-bottom: 0.5rem !important;
  }
  
  /* Reduce gap in flex containers */
  .gap-4 {
    gap: 0.75rem;
  }
  
  .gap-6 {
    gap: 1rem;
  }
  
  /* Compact space-y utilities */
  .space-y-6 > * + * {
    margin-top: 1rem;
  }
  
  .space-y-8 > * + * {
    margin-top: 1rem;
  }
}

/* ============================================
   SMALLER TITLES AND HEADINGS
   ============================================ */
@media (max-width: 640px) {
  /* Reduce headline sizes */
  .md-headline-large {
    font-size: 1.5rem;
    line-height: 1.75rem;
    margin: 0;
    font-weight: 500;
  }
  
  /* Inline badge with headline */
  .md-headline-large .md-badge {
    font-size: 0.75rem !important;
    vertical-align: middle;
    margin-left: 0.5rem;
  }
  
  /* Fix tag title spacing */
  .tag-title-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
  }
  
  .tag-badge-row {
    margin-top: 0.25rem;
  }
  
  .md-headline-medium {
    font-size: 1.25rem;
    line-height: 1.5rem;
  }
  
  .md-headline-small {
    font-size: 1rem;
    line-height: 1.25rem;
  }
  
  /* Reduce title sizes */
  .md-title-large {
    font-size: 1.125rem;
    line-height: 1.5rem;
    margin-bottom: 0.25rem;
  }
  
  .md-title-medium {
    font-size: 0.9375rem;
    line-height: 1.375rem;
  }
  
  /* Reduce label sizes */
  .md-label-large {
    font-size: 0.8125rem;
    line-height: 1.125rem;
  }
}

/* ============================================
   COMPACT BUTTONS
   ============================================ */
@media (max-width: 640px) {
  /* Smaller buttons */
  .md-button {
    padding: 0.5rem 0.75rem;
    min-height: 40px;
    font-size: 0.8125rem;
  }
  
  .md-button-text {
    padding: 0.375rem 0.5rem;
    min-height: 36px;
  }
  
  /* Icon-only buttons for actions */
  .action-button-icon-only {
    padding: 0.5rem;
    min-width: 40px;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  
  /* Hide button text on mobile, show only icons */
  .md-button-icon-only span:not(.sr-only) {
    display: none;
  }
  
  .md-button-icon-only {
    padding: 0.5rem;
    min-width: 40px;
  }
  
  /* Compact FAB */
  .md-fab {
    width: 3rem;
    height: 3rem;
    bottom: 0.75rem;
    right: 0.75rem;
  }
}

/* ============================================
   COMPACT TAGS
   ============================================ */
@media (max-width: 640px) {
  /* Smaller tag chips */
  .md-chip {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    line-height: 1rem;
    min-height: 28px;
    border-radius: 0.375rem;
  }
  
  /* Inline tag links (not pills) */
  .note-tag-link {
    font-size: 0.8125rem;
    color: var(--md-primary);
    text-decoration: none;
    transition: opacity 0.2s;
  }
  
  .note-tag-link:hover {
    opacity: 0.7;
    text-decoration: underline;
  }
  
  .note-tag-separator {
    font-size: 0.75rem;
    color: var(--md-on-surface-variant);
    opacity: 0.5;
  }
  
  .note-tag-add-btn {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.25rem;
    border-radius: 0.25rem;
    transition: background-color 0.2s;
  }
  
  .note-tag-add-btn:hover {
    background-color: color-mix(in srgb, var(--md-primary) 8%, transparent);
  }
  
  /* Note card content first layout */
  .note-card-content-first {
    display: flex;
    flex-direction: column;
  }
  
  /* Note content expanded by default */
  .note-content-expanded {
    max-height: none !important;
    overflow: visible !important;
  }
  
  /* Ensure tags always have pill styling, especially in expanded/fullscreen view */
  .note-card-content-first .note-tags-compact .note-tag-pill,
  .note-card-content-first .note-tag-pill {
    display: inline-flex !important;
    align-items: center;
    padding: 0.25rem 0.625rem;
    font-size: 0.8125rem;
    line-height: 1.25;
    color: var(--md-primary);
    background-color: color-mix(in srgb, var(--md-primary) 10%, transparent);
    border: 1px solid color-mix(in srgb, var(--md-primary) 25%, transparent);
    border-radius: 1rem;
    text-decoration: none;
    transition: all 0.2s;
    white-space: nowrap;
    margin-right: 0.5rem;
    margin-bottom: 0.375rem;
  }
  
  .note-card-content-first .note-tags-compact .note-tag-pill:hover,
  .note-card-content-first .note-tag-pill:hover {
    background-color: color-mix(in srgb, var(--md-primary) 15%, transparent);
    border-color: color-mix(in srgb, var(--md-primary) 35%, transparent);
  }
  
  /* Metadata footer - small text at bottom */
  .note-metadata-footer {
    margin-left: auto;
  }
  
  .note-batch-ref {
    font-size: 0.6875rem;
    color: var(--md-on-surface-variant);
    opacity: 0.7;
  }
  
  .note-metadata-link:hover .note-batch-ref {
    opacity: 1;
    color: var(--md-primary);
  }
  
  /* Deep Research button in footer */
  .deep-research-button-footer {
    padding: 0.375rem 0.5rem;
    font-size: 0.75rem;
  }
  
  /* Hide expand toggle by default, only show if content is actually long */
  .expand-toggle {
    display: none;
  }
  
  /* Horizontal scrolling tag container */
  .tag-container-scrollable {
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 0.5rem;
    padding-bottom: 0.25rem;
    scrollbar-width: thin;
  }
  
  .tag-container-scrollable::-webkit-scrollbar {
    height: 2px;
  }
  
  .tag-container-scrollable::-webkit-scrollbar-track {
    background: transparent;
  }
  
  .tag-container-scrollable::-webkit-scrollbar-thumb {
    background-color: var(--md-outline-variant);
    border-radius: 1px;
  }
  
  /* Show first N tags, then "+X more" */
  .tag-container-compact {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    max-height: 2.5rem;
    overflow: hidden;
  }
  
  .tag-container-compact.expanded {
    max-height: none;
  }
  
  .tag-more-indicator {
    font-size: 0.75rem;
    color: var(--md-on-surface-variant);
    padding: 0.25rem 0.5rem;
    cursor: pointer;
  }
  
  /* Compact inline tags - subtle pills */
  .note-tags-compact {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
  }
  
  /* Base pill styling for all note tag pills */
  .note-tag-pill {
    display: inline-flex !important;
    align-items: center;
    padding: 0.25rem 0.625rem !important;
    font-size: 0.8125rem !important;
    line-height: 1.25;
    color: var(--md-primary) !important;
    background-color: color-mix(in srgb, var(--md-primary) 10%, transparent) !important;
    border: 1px solid color-mix(in srgb, var(--md-primary) 25%, transparent) !important;
    border-radius: 1rem !important;
    text-decoration: none;
    transition: all 0.2s;
    white-space: nowrap;
    margin-right: 0.5rem;
    margin-bottom: 0.375rem;
  }
  
  .note-tag-pill:hover {
    background-color: color-mix(in srgb, var(--md-primary) 15%, transparent) !important;
    border-color: color-mix(in srgb, var(--md-primary) 35%, transparent) !important;
    color: var(--md-primary) !important;
  }
  
  /* Ensure tags have pill styling in fullscreen/expanded view - apply to all note cards */
  .note-card-content-first .note-tag-pill,
  .note-card-content-first .note-tags-compact .note-tag-pill {
    display: inline-flex !important;
    align-items: center;
    padding: 0.25rem 0.625rem !important;
    font-size: 0.8125rem !important;
    line-height: 1.25;
    color: var(--md-primary) !important;
    background-color: color-mix(in srgb, var(--md-primary) 10%, transparent) !important;
    border: 1px solid color-mix(in srgb, var(--md-primary) 25%, transparent) !important;
    border-radius: 1rem !important;
    text-decoration: none;
    transition: all 0.2s;
    white-space: nowrap;
    margin-right: 0.5rem;
    margin-bottom: 0.375rem;
  }
  
  .note-card-content-first .note-tag-pill:hover,
  .note-card-content-first .note-tags-compact .note-tag-pill:hover {
    background-color: color-mix(in srgb, var(--md-primary) 15%, transparent) !important;
    border-color: color-mix(in srgb, var(--md-primary) 35%, transparent) !important;
  }
  
  .note-tag-add-btn {
    display: inline-flex;
    align-items: center;
    padding: 0.1875rem 0.375rem;
    border-radius: 0.25rem;
    transition: background-color 0.2s;
    margin-left: 0.125rem;
  }
  
  .note-tag-add-btn:hover {
    background-color: color-mix(in srgb, var(--md-primary) 8%, transparent);
  }
  
  /* Note card content first layout */
  .note-card-content-first {
    display: flex;
    flex-direction: column;
  }
  
  /* Note content expanded by default */
  .note-content-expanded {
    max-height: none !important;
    overflow: visible !important;
    padding: 0 !important;
  }
  
  /* Generate Highlights button - not full width on larger screens */
  #refresh-tag-highlights-empty {
    width: 100%;
  }
  
  @media (min-width: 640px) {
    #refresh-tag-highlights-empty {
      width: auto;
      display: inline-flex;
    }
  }
  
  /* Metadata footer - small text at bottom */
  .note-metadata-footer {
    margin-left: auto;
  }
  
  .note-batch-ref {
    font-size: 0.6875rem;
    color: var(--md-on-surface-variant);
    opacity: 0.7;
  }
  
  .note-metadata-link:hover .note-batch-ref {
    opacity: 1;
    color: var(--md-primary);
  }
  
  /* Deep Research button in footer */
  .deep-research-button-footer {
    padding: 0.375rem 0.5rem;
    font-size: 0.75rem;
  }
  
  /* Hide expand toggle by default, only show if content is actually long */
  .expand-toggle {
    display: none;
  }
  
/* Dashboard tag list - compact on mobile */
.dashboard-tag-list .md-card {
  padding: 0.75rem;
}

.dashboard-tag-list .md-title-small {
  font-size: 0.9375rem;
}

.dashboard-tag-list .md-badge {
  font-size: 0.6875rem;
  padding: 0.125rem 0.375rem;
}

/* Mobile Filter Modal - Full Screen */
@media (max-width: 640px) {
  [data-dashboard-filter-target="mobileFilterModal"] {
    position: fixed !important;
    inset: 0 !important;
    z-index: 100 !important;
  }
  
  [data-dashboard-filter-target="mobileFilterModal"] > div {
    position: fixed !important;
    inset: 0 !important;
    background-color: var(--md-background) !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
  }
  
  /* Ensure search input fills width */
  [data-dashboard-filter-target="mobileFilterModal"] .md-search-bar input {
    width: 100% !important;
  }
  
  /* Results scrolling */
  [data-dashboard-filter-target="mobileResults"] {
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 1rem) !important;
  }
}

/* Star Toggle Button */
[data-controller="star-toggle"] button[data-star-toggle-target="button"] {
  position: relative;
  z-index: 10;
  cursor: pointer;
  transition: transform 0.2s ease, background-color 0.2s ease;
}

[data-controller="star-toggle"] button[data-star-toggle-target="button"]:hover {
  transform: scale(1.1);
}

[data-controller="star-toggle"] button[data-star-toggle-target="button"]:active {
  transform: scale(0.95);
}

/* Prevent link click when clicking star */
[data-controller="star-toggle"] button[data-star-toggle-target="button"] {
  pointer-events: auto;
}

/* Image Preview Modal */
#image-preview-modal {
  backdrop-filter: blur(4px);
}

#image-preview-modal > div {
  animation: modalSlideUp 0.3s ease-out;
}

@keyframes modalSlideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Mobile optimizations for image preview */
@media (max-width: 640px) {
  #image-preview-modal > div {
    max-width: 100vw !important;
    max-height: 100vh !important;
    width: 100%;
    height: 100%;
    border-radius: 0;
  }
  
  #image-preview-modal .overflow-auto {
    max-height: calc(100vh - 120px) !important;
  }
}
}

/* ============================================
   COMPACT SEARCH BAR
   ============================================ */
@media (max-width: 640px) {
  .md-search-bar {
    padding: 0.5rem 0.75rem;
    border-radius: 1.5rem;
  }
  
  .md-search-bar input {
    font-size: 0.8125rem;
  }
  
  .md-search-bar svg {
    width: 1.125rem;
    height: 1.125rem;
  }
}

/* ============================================
   COMPACT STATUS BADGES
   ============================================ */
@media (max-width: 640px) {
  .md-badge {
    padding: 0.25rem 0.5rem;
    font-size: 0.6875rem;
    line-height: 1rem;
    border-radius: 0.375rem;
  }
  
  /* Inline status indicators */
  .status-inline {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
  }
  
  .status-inline svg {
    width: 0.875rem;
    height: 0.875rem;
  }
}

/* ============================================
   EXPAND CONTENT BY DEFAULT
   ============================================ */
@media (max-width: 640px) {
  /* Show more content by default - note cards */
  .note-card-content-first [data-expandable-notes-target="content"] {
    max-height: none !important;
    overflow: visible !important;
  }
  
  /* Only show expand toggle if content exceeds certain height */
  .note-card-content-first .expand-toggle {
    display: none;
  }
}

/* ============================================
   COMPACT METADATA
   ============================================ */
@media (max-width: 640px) {
  /* Smaller body text */
  .md-body-medium {
    font-size: 0.8125rem;
    line-height: 1.25rem;
  }
  
  .md-body-small {
    font-size: 0.6875rem;
    line-height: 1rem;
  }
  
  /* Inline metadata */
  .metadata-inline {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: var(--md-on-surface-variant);
  }
  
  /* Hide less important metadata */
  .metadata-secondary {
    display: none;
  }
}

/* ============================================
   COMPACT HIGHLIGHTS SECTION
   ============================================ */
@media (max-width: 640px) {
  /* Stack highlights header vertically */
  .highlights-header {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 0.75rem !important;
  }
  
  /* Compact action buttons */
  .highlights-actions {
    display: flex;
    gap: 0.5rem;
    width: 100%;
  }
  
  .highlights-actions .md-button {
    flex: 1;
  }
  
  /* Icon-only refresh button */
  .highlights-refresh-icon-only {
    padding: 0.5rem;
    min-width: 40px;
  }
  
  .highlights-refresh-icon-only span {
    display: none;
  }
}

/* ============================================
   HIGHLIGHTS OPTIMIZATION (Mobile & Desktop)
   ============================================ */
.highlights-header {
  padding: 1rem !important;
}

.highlights-header h2 {
  font-size: 1.125rem !important;
  line-height: 1.5rem !important;
  margin-bottom: 0 !important;
}

.highlights-actions {
  gap: 0.25rem !important;
}

.highlights-actions .md-button {
  padding: 0.375rem !important;
  min-width: auto !important;
}

.highlights-actions .md-button svg {
  width: 1rem !important;
  height: 1rem !important;
}

/* Show more content in highlights by default */
.highlights-header #tag-highlights-content {
  margin-top: 0.5rem !important;
}

.highlights-header [data-expandable-notes-target="button"] {
  padding: 0.25rem 0.5rem !important;
  font-size: 0.875rem !important;
  margin-top: 0.5rem !important;
}

.highlights-header [data-expandable-notes-target="button"] svg {
  width: 0.875rem !important;
  height: 0.875rem !important;
}

/* ============================================
   COMPACT NOTE CARDS
   ============================================ */
@media (max-width: 640px) {
  /* Compact note header */
  .note-header {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 0.5rem !important;
  }
  
  /* Inline note metadata */
  .note-metadata {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
  }
  
  /* Compact deep research button */
  .deep-research-button-compact {
    padding: 0.375rem 0.625rem;
    font-size: 0.75rem;
  }
  
  .deep-research-button-compact span {
    display: none;
  }
  
  /* Show note content by default */
  .note-content {
    max-height: none;
  }
  
  /* Compact prose content */
  .prose {
    font-size: 0.875rem;
    line-height: 1.5rem;
  }
  
  .prose-sm {
    font-size: 0.8125rem;
    line-height: 1.375rem;
  }
}

/* ============================================
   COMPACT BATCH PAGE
   ============================================ */
@media (max-width: 640px) {
  /* Compact batch header */
  .batch-header {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 0.75rem !important;
  }
  
  /* Inline batch metadata */
  .batch-metadata {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
  }
  
  /* Compact status badges */
  .batch-status {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
  }
  
  /* Stack image and text vertically */
  .note-image-text-grid {
    grid-template-columns: 1fr !important;
  }
  
  /* Compact note sections */
  .note-section {
    margin-bottom: 0.75rem;
  }
  
  .note-section-label {
    font-size: 0.8125rem;
    margin-bottom: 0.375rem;
  }
}

/* ============================================
   VERY SMALL SCREENS (iPhone SE, etc.)
   ============================================ */
@media (max-width: 480px) {
  /* Even more compact */
  .md-card {
    padding: 0.625rem;
  }
  
  .md-headline-large {
    font-size: 1.25rem;
    line-height: 1.5rem;
  }
  
  .md-button {
    padding: 0.5rem 0.625rem;
    font-size: 0.75rem;
  }
  
  /* Hide all non-essential text */
  .hide-on-mobile {
    display: none !important;
  }
  
  /* Show only icons */
  .icon-only-mobile {
    padding: 0.5rem;
    min-width: 40px;
    min-height: 40px;
  }
  
  .icon-only-mobile span:not(.sr-only) {
    display: none;
  }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
@media (max-width: 640px) {
  /* Screen reader only text */
  .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
  }
  
  /* Compact spacing utilities */
  .mobile-compact {
    padding: 0.5rem;
    margin-bottom: 0.5rem;
  }
  
  /* No margin on mobile */
  .mobile-no-margin {
    margin: 0 !important;
  }
  
  /* Full width on mobile */
  .mobile-full-width {
    width: 100% !important;
  }
  
  /* Hide elements on mobile */
  .hide-on-mobile {
    display: none !important;
  }
}

/* Show hide-on-mobile on larger screens */
@media (min-width: 641px) {
  .hide-on-mobile {
    display: inline !important;
  }
}

/* ============================================
   MODAL OPTIMIZATIONS
   ============================================ */
@media (max-width: 640px) {
  /* Full-screen modals on mobile */
  .deep-research-modal > div:last-child {
    align-items: stretch !important;
    padding: 0 !important;
    min-height: 100vh !important;
  }
  
  /* Modal wrapper - start below top nav */
  .deep-research-modal-wrapper {
    padding-top: 48px !important; /* Account for top nav bar height */
  }
  
  /* Modal panel fills screen on mobile - account for both nav bars */
  .deep-research-modal .md-card {
    border-radius: 0.75rem 0.75rem 0 0 !important;
    height: calc(100vh - 48px) !important; /* Subtract top nav height */
    max-height: calc(100vh - 48px) !important;
    display: flex !important;
    flex-direction: column !important;
    margin: 0 !important;
    box-shadow: none !important;
    padding-bottom: 0 !important; /* Remove default padding, handled by footer */
  }
  
  /* Modal content area scrolls - account for top nav bar */
  .deep-research-modal .md-card > div:first-child {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
    padding-top: calc(1rem + 48px) !important; /* 48px for top nav bar + 1rem padding */
    padding-left: 1rem !important;
    padding-right: 1rem !important;
    padding-bottom: 1rem !important;
  }
  
  /* Modal actions stay at bottom - account for bottom nav bar */
  .deep-research-modal .md-card > div:last-child {
    flex-shrink: 0;
    padding-bottom: calc(4rem + 0.75rem + env(safe-area-inset-bottom, 0px)) !important; /* 4rem for bottom nav + padding */
    margin-top: auto;
    position: sticky;
    bottom: 0;
    background-color: var(--md-surface-container);
  }
  
  /* Compact modal header on mobile */
  .deep-research-modal h3 {
    font-size: 1.125rem !important;
    margin-bottom: 0.5rem !important;
  }
  
  .deep-research-modal .md-body-medium {
    font-size: 0.8125rem !important;
    margin-bottom: 0.75rem !important;
  }
  
  /* Compact textarea on mobile */
  .deep-research-modal textarea {
    font-size: 16px !important; /* Prevents zoom on iOS */
    min-height: 100px !important;
  }
  
  /* Reduce spacing before note preview */
  .deep-research-modal .note-preview-section {
    padding-top: 0.5rem !important;
    margin-top: 0.25rem !important;
  }
  
  /* Reduce spacing in form sections */
  .deep-research-modal .mt-3 {
    margin-top: 0.75rem !important;
  }
  
  /* Reduce spacing after textarea hint */
  .deep-research-modal .md-body-small.mt-1 {
    margin-bottom: 0 !important;
  }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */
@media (max-width: 640px) {
  /* Ensure touch targets are at least 40x40px */
  button, a, [role="button"] {
    min-height: 40px;
    min-width: 40px;
  }
  
  /* Maintain readable font sizes */
  body {
    font-size: 16px; /* Prevents zoom on iOS */
  }
  
  input, textarea, select {
    font-size: 16px; /* Prevents zoom on iOS */
  }
}
