/* ============================================================
   bombaba - Bitacora Industrial
   Complete CSS - Mobile-first, Light/Dark, Utilitarian
   ============================================================ */

/* --- Custom Properties (Light Theme) --- */
:root {
  --bg: #f0f2f5;
  --bg-card: #ffffff;
  --bg-elevated: #ffffff;
  --bg-input: #f7f8fa;
  --text: #1a1a2e;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --brand: #1a1a2e;
  --accent: #4361ee;
  --accent-light: #5a7bff;
  --accent-bg: rgba(67, 97, 238, 0.1);
  --danger: #e63946;
  --danger-bg: rgba(230, 57, 70, 0.1);
  --success: #2ec4b6;
  --success-bg: rgba(46, 196, 182, 0.1);
  --warning: #e9c46a;
  --warning-bg: rgba(233, 196, 106, 0.15);
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.12);
  --shadow-xl: 0 16px 50px rgba(0, 0, 0, 0.15);
  --radius: 16px;
  --radius-sm: 12px;
  --radius-xs: 8px;
  --radius-full: 9999px;
  --transition: 0.2s ease;
  --transition-slow: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  --header-height: 60px;
  --overlay-bg: rgba(0, 0, 0, 0.4);
  color-scheme: light dark;
}

/* --- Dark Theme --- */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f0f1a;
    --bg-card: #1a1a2e;
    --bg-elevated: #222240;
    --bg-input: #16162a;
    --text: #e8e8f0;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --brand: #e8e8f0;
    --accent-bg: rgba(67, 97, 238, 0.2);
    --danger-bg: rgba(230, 57, 70, 0.2);
    --success-bg: rgba(46, 196, 182, 0.2);
    --warning-bg: rgba(233, 196, 106, 0.2);
    --border: #2d2d44;
    --border-strong: #3d3d5c;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2);
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.4);
    --shadow-xl: 0 16px 50px rgba(0, 0, 0, 0.5);
    --overlay-bg: rgba(0, 0, 0, 0.6);
  }
}

/* --- Reset & Base --- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  min-height: calc(100% + env(safe-area-inset-top));
  background: var(--bg);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
  font-size: 16px;
}

/* --- Screens --- */
.screen {
  display: none;
  min-height: 100dvh;
}

.screen.active {
  display: flex;
  flex-direction: column;
}

.hidden {
  display: none !important;
}

/* --- Auth Screen --- */
.auth-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  max-width: 420px;
  margin: 0 auto;
  width: 100%;
}

.brand {
  font-size: 56px;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -2px;
  margin-bottom: 4px;
  user-select: none;
}

.brand-subtitle {
  font-size: 16px;
  color: var(--text-secondary);
  margin-bottom: 48px;
  font-weight: 500;
  letter-spacing: 2px;
  text-transform: uppercase;
}

#login-form,
#register-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

#show-register,
#show-login {
  margin-top: 16px;
}

.username-field {
  position: relative;
  width: 100%;
}

.username-field input {
  padding-right: 40px;
}

.username-status {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 18px;
  line-height: 1;
}

.username-status.available::after {
  content: '\2713';
  color: var(--success);
}

.username-status.taken::after {
  content: '\2717';
  color: var(--danger);
}

.username-status.checking::after {
  content: '...';
  color: var(--text-muted);
  font-size: 14px;
}

/* --- Form Inputs --- */
input[type="text"],
input[type="password"],
input[type="date"],
input[type="email"],
textarea {
  width: 100%;
  padding: 16px 20px;
  font-size: 17px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg-input);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  -webkit-appearance: none;
  appearance: none;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="date"]:focus,
input[type="email"]:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-bg);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-muted);
}

textarea {
  resize: vertical;
  min-height: 100px;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 24px;
  font-size: 17px;
  font-weight: 600;
  font-family: inherit;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  user-select: none;
  text-decoration: none;
  line-height: 1.2;
  min-height: 56px;
  -webkit-appearance: none;
  appearance: none;
}

.btn:active {
  transform: scale(0.97);
}

.btn:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--accent);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--accent-light);
}

.btn-primary:active {
  background: #3a56d4;
}

.btn-secondary {
  background: var(--accent-bg);
  color: var(--accent);
}

.btn-secondary:hover {
  background: rgba(67, 97, 238, 0.2);
}

.btn-danger {
  background: var(--danger);
  color: #ffffff;
}

.btn-danger:hover {
  background: #d32f3d;
}

.btn-ghost {
  background: transparent;
  color: var(--accent);
  padding: 12px 16px;
  min-height: 48px;
}

.btn-ghost:hover {
  background: var(--accent-bg);
}

.btn-large {
  padding: 18px 32px;
  font-size: 18px;
  min-height: 60px;
}

.btn-small {
  padding: 10px 16px;
  font-size: 14px;
  min-height: 40px;
  border-radius: var(--radius-xs);
}

.btn-full {
  width: 100%;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* --- App Header --- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  padding-top: calc(8px + env(safe-area-inset-top));
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  min-height: var(--header-height);
  position: sticky;
  top: 0;
  z-index: 100;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.app-header.header-hidden {
  transform: translateY(-100%);
  opacity: 0;
  pointer-events: none;
}

.header-brand {
  font-size: 24px;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -1px;
  user-select: none;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.header-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  border-radius: var(--radius-xs);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}

.header-btn:hover {
  background: var(--accent-bg);
  color: var(--accent);
}

.header-btn:active {
  transform: scale(0.92);
}

.header-btn svg {
  width: 20px;
  height: 20px;
}

.user-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: #ffffff;
  font-weight: 700;
  font-size: 14px;
  margin-left: 2px;
}

.user-btn:hover {
  background: var(--accent-light);
  color: #ffffff;
}

#user-initial {
  font-size: 16px;
  line-height: 1;
}

.badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  font-size: 11px;
  font-weight: 700;
  color: #ffffff;
  background: var(--danger);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* --- Recording Panel --- */
.recording-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 24px 32px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}

.mic-container {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 140px;
  height: 140px;
  margin-bottom: 16px;
}

.pulse-ring {
  position: absolute;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  border: 3px solid var(--accent);
  opacity: 0;
  pointer-events: none;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(1);
}

.mic-container.recording .pulse-ring {
  animation: pulse-expand 2s ease-out infinite;
  border-color: var(--danger);
}

.mic-container.recording .pulse-ring:nth-child(2) {
  animation-delay: 0.4s;
}

.mic-container.recording .pulse-ring:nth-child(3) {
  animation-delay: 0.8s;
}

@keyframes pulse-expand {
  0% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 0.6;
  }
  100% {
    transform: translate(-50%, -50%) scale(2.5);
    opacity: 0;
  }
}

.mic-button {
  position: relative;
  z-index: 2;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--accent) 0%, #3a56d4 100%);
  color: #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 24px rgba(67, 97, 238, 0.35);
  transition: all var(--transition);
}

.mic-button:hover {
  box-shadow: 0 8px 32px rgba(67, 97, 238, 0.45);
  transform: scale(1.04);
}

.mic-button:active {
  transform: scale(0.96);
}

.mic-button.breathing {
  animation: breathing 3s ease-in-out infinite;
}

@keyframes breathing {
  0%, 100% {
    box-shadow: 0 6px 24px rgba(67, 97, 238, 0.35);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 8px 30px rgba(67, 97, 238, 0.5);
    transform: scale(1.03);
  }
}

.mic-button.recording {
  background: linear-gradient(135deg, var(--danger) 0%, #c62d3a 100%);
  box-shadow: 0 6px 24px rgba(230, 57, 70, 0.4);
  animation: recording-pulse 1.2s ease-in-out infinite;
}

@keyframes recording-pulse {
  0%, 100% {
    box-shadow: 0 6px 24px rgba(230, 57, 70, 0.4);
  }
  50% {
    box-shadow: 0 8px 36px rgba(230, 57, 70, 0.6);
  }
}

.mic-icon {
  width: 40px;
  height: 40px;
}

.recording-timer {
  font-size: 32px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--danger);
  margin-bottom: 8px;
  letter-spacing: 2px;
}

.waveform-canvas {
  width: 100%;
  max-width: 300px;
  height: 60px;
  margin-bottom: 8px;
  border-radius: var(--radius-xs);
}

.btn-cancel-record {
  margin-bottom: 12px;
  color: var(--danger);
  border-color: var(--danger);
  background: var(--danger-bg);
}

.btn-cancel-record:hover {
  background: var(--danger);
  color: #fff;
}

.recording-status {
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: 24px;
  font-weight: 500;
}

.secondary-actions {
  display: flex;
  gap: 16px;
}

.action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 28px;
  background: var(--bg-input);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  min-width: 100px;
  min-height: 72px;
}

.action-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-bg);
}

.action-btn:active {
  transform: scale(0.95);
}

.action-btn svg {
  width: 24px;
  height: 24px;
}

.action-btn-small {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 12px 20px;
  background: var(--bg-input);
  border: 2px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  min-height: 48px;
}

.action-btn-small:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.action-btn-small:active {
  transform: scale(0.95);
}

/* --- Entries Section --- */
.entries-section {
  padding: 24px 16px;
  flex: 1;
}

.section-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text);
}

.entries-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.entry-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition);
}

.entry-card:hover {
  box-shadow: var(--shadow);
}

.entry-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.entry-avatar {
  width: 40px;
  height: 40px;
  min-width: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-weight: 700;
  font-size: 16px;
  user-select: none;
}

.entry-meta {
  flex: 1;
  min-width: 0;
}

.entry-name {
  display: block;
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.entry-time {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
}

.entry-type {
  font-size: 18px;
  line-height: 1;
  opacity: 0.8;
}

.btn-delete {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  min-width: 36px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  border-radius: var(--radius-xs);
  transition: all var(--transition);
}

.btn-delete:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

.btn-delete:active {
  transform: scale(0.9);
}

.btn-restore {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  min-width: 36px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  border-radius: var(--radius-xs);
  transition: all var(--transition);
}

.btn-restore:hover {
  background: var(--success-bg);
  color: var(--success);
}

.btn-restore:active {
  transform: scale(0.9);
}

.badge-processing {
  display: inline-block;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--warning);
  background: var(--warning-bg);
  border-radius: var(--radius-full);
  margin-bottom: 8px;
  animation: processing-blink 1.5s ease-in-out infinite;
}

@keyframes processing-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.entry-text {
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  margin-bottom: 8px;
  word-break: break-word;
}

.entry-text.markdown-content.truncated {
  max-height: 150px;
  overflow: hidden;
  position: relative;
}

.entry-text.markdown-content.truncated::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 40px;
  background: linear-gradient(transparent, var(--bg-card));
  pointer-events: none;
}

.entry-read-more-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 0;
  margin-bottom: 8px;
}

.entry-read-more-btn:hover {
  text-decoration: underline;
}

/* --- ALT Pill & Photo Description Popover --- */
.entry-photo-wrap,
.photo-carousel {
  position: relative;
}

.entry-photo-wrap {
  margin-bottom: 10px;
}

.alt-pill {
  position: absolute;
  bottom: 14px;
  left: 8px;
  z-index: 2;
  padding: 3px 7px;
  font-size: 11px;
  font-weight: 800;
  font-family: inherit;
  letter-spacing: 0.5px;
  color: #fff;
  background: rgba(0, 0, 0, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 4px;
  cursor: pointer;
  line-height: 1;
  transition: background 0.15s ease;
}

.alt-pill:hover {
  background: rgba(0, 0, 0, 0.85);
}

.gallery-item .alt-pill {
  bottom: 30px;
  left: 4px;
  font-size: 9px;
  padding: 2px 5px;
}

.alt-popover {
  position: fixed;
  z-index: 5000;
  max-width: min(420px, calc(100vw - 24px));
  max-height: 350px;
  overflow-y: auto;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  box-shadow: var(--shadow-lg);
  animation: alt-popover-in 0.15s ease;
}

.alt-popover .alt-popover-content {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-secondary);
}

.alt-popover .alt-popover-content p:last-child {
  margin-bottom: 0;
}

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

.entry-section-label {
  font-weight: 700;
  color: var(--accent);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.entry-thumb {
  width: 100%;
  max-height: 200px;
  object-fit: cover;
  border-radius: var(--radius-xs);
  margin-bottom: 10px;
  border: 1px solid var(--border);
}

/* Custom audio player (iOS-compatible) */
.audio-player {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  padding: 8px 12px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.audio-play-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
}
.audio-play-btn:active {
  background: var(--accent-light);
}

.audio-progress-wrap {
  flex: 1;
  cursor: pointer;
  padding: 8px 0;
}

.audio-progress-bar {
  height: 4px;
  background: var(--border-strong);
  border-radius: 2px;
  overflow: hidden;
}

.audio-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.1s linear;
}

.audio-time {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
  white-space: nowrap;
  min-width: 90px;
  text-align: right;
}

.entry-related-section {
  margin-top: 8px;
}

.entry-related-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-bg);
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background 0.15s ease;
}

.entry-related-toggle:hover {
  background: var(--accent);
  color: #fff;
}

.entry-related-toggle .chevron {
  transition: transform 0.2s ease;
}

.entry-related-toggle[aria-expanded="true"] .chevron {
  transform: rotate(180deg);
}

.related-notes-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
}

.related-notes-list.hidden {
  display: none;
}

.related-note-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  margin-top: 4px;
  font-size: 13px;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
  line-height: 1.4;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.related-note-item:hover {
  background: var(--accent-bg);
  transform: translateX(2px);
}

.related-note-item:active {
  transform: translateX(0);
}

.related-note-text {
  flex: 1;
}

.related-note-arrow {
  flex-shrink: 0;
  opacity: 0.4;
  transition: opacity 0.15s ease;
}

.related-note-item:hover .related-note-arrow {
  opacity: 1;
}

/* Highlight flash when navigating to a related entry */
.entry-highlight {
  animation: entry-flash 2s ease;
}

@keyframes entry-flash {
  0%, 100% { box-shadow: 0 0 0 0 transparent; }
  10%, 40% { box-shadow: 0 0 0 3px var(--accent); }
}

.entry-card-linked {
  border-top: 2px solid var(--accent);
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  font-size: 16px;
  padding: 48px 24px;
  line-height: 1.6;
}

/* Entry appear animation */
.entry-appear {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.entry-visible {
  opacity: 1;
  transform: translateY(0);
}

/* --- Modals --- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal.hidden {
  display: none !important;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: var(--overlay-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity var(--transition-slow);
}

.modal.modal-visible .modal-backdrop {
  opacity: 1;
}

.modal-content {
  position: relative;
  z-index: 1;
  background: var(--bg-card);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-width: 560px;
  max-height: 90dvh;
  overflow-y: auto;
  padding: 24px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow-xl);
  transform: translateY(100%);
  transition: transform var(--transition-slow);
}

.modal.modal-visible .modal-content {
  transform: translateY(0);
}

.modal-content.modal-small {
  max-height: 50dvh;
}

.modal-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

.text-danger {
  color: var(--danger) !important;
}

.delete-warning {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 16px;
  line-height: 1.5;
}

.delete-confirm-text {
  font-size: 14px;
  margin-bottom: 8px;
}

#delete-confirm-input {
  margin-bottom: 16px;
}

#btn-confirm-delete:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.modal-content.modal-fullscreen {
  max-height: 95dvh;
  height: 95dvh;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-shrink: 0;
}

.modal-header h2 {
  font-size: 20px;
  font-weight: 700;
}

.modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: none;
  background: var(--bg-input);
  border-radius: var(--radius-xs);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}

.modal-close:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

.modal-close:active {
  transform: scale(0.9);
}

/* Desktop modal style */
@media (min-width: 768px) {
  .modal {
    align-items: center;
  }

  .modal-content {
    border-radius: var(--radius);
    max-height: 85vh;
    transform: scale(0.9) translateY(20px);
    opacity: 0;
    transition: transform var(--transition-slow), opacity var(--transition-slow);
  }

  .modal.modal-visible .modal-content {
    transform: scale(1) translateY(0);
    opacity: 1;
  }

  .modal-content.modal-fullscreen {
    max-height: 85vh;
    height: auto;
    min-height: 60vh;
  }
}

/* --- Camera / Photo Modal --- */
.camera-container {
  flex: 1;
  position: relative;
  background: #000;
  border-radius: var(--radius-xs);
  overflow: hidden;
  min-height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#camera-preview,
#photo-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.camera-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  flex-shrink: 0;
}

.capture-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 4px solid var(--text);
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.capture-btn:hover {
  border-color: var(--accent);
}

.capture-btn:active {
  transform: scale(0.9);
}

.capture-ring {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--text);
  transition: all var(--transition);
}

.capture-btn:hover .capture-ring {
  background: var(--accent);
}

.capture-btn:active .capture-ring {
  transform: scale(0.85);
}

.photo-msg-label {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 12px;
  margin-top: 16px;
}

.photo-msg-actions {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

#photo-recording-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--danger-bg);
  border-radius: var(--radius-xs);
  margin-bottom: 16px;
  color: var(--danger);
  font-weight: 600;
  font-size: 14px;
}

.recording-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--danger);
  animation: recording-dot-blink 1s ease-in-out infinite;
}

@keyframes recording-dot-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.2; }
}

/* --- AI Chat Header Actions --- */
.ai-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* --- AI Chat --- */
.ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ai-msg {
  max-width: 85%;
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  line-height: 1.5;
  word-break: break-word;
}

.ai-msg-bot {
  align-self: flex-start;
  background: var(--bg-input);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

.ai-msg-user {
  align-self: flex-end;
  background: var(--accent);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

.ai-msg.typing p {
  animation: processing-blink 1.5s ease-in-out infinite;
}

.ai-input-bar {
  display: flex;
  gap: 10px;
  padding-top: 16px;
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}

.ai-input-bar input {
  flex: 1;
}

.ai-input-bar .btn {
  min-width: 56px;
  min-height: 56px;
  padding: 16px;
}

/* --- Download Modal --- */
.download-options {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.download-option {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
}

.download-option input[type="date"] {
  font-size: 16px;
}

.download-includes {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.download-includes p {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.checkbox-large {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 16px;
  color: var(--text);
  cursor: pointer;
  padding: 10px 14px;
  border-radius: var(--radius-xs);
  transition: background var(--transition);
  min-height: 48px;
}

.checkbox-large:hover {
  background: var(--accent-bg);
}

.checkbox-large input[type="radio"] {
  width: 22px;
  height: 22px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* --- Settings Modal --- */
.settings-section {
  padding-bottom: 24px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.settings-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.settings-section h3 {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 6px;
}

.settings-hint {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 16px;
  line-height: 1.4;
}

.custom-words-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
  min-height: 20px;
}

.word-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--accent-bg);
  color: var(--accent);
  border-radius: var(--radius-full);
  font-size: 14px;
  font-weight: 600;
}

.word-chip button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border: none;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font-size: 16px;
  border-radius: 50%;
  transition: all var(--transition);
  line-height: 1;
}

.word-chip button:hover {
  background: var(--accent);
  color: #ffffff;
}

.word-input-row {
  display: flex;
  gap: 10px;
}

.word-input-row input {
  flex: 1;
}

.word-input-row .btn {
  min-width: 100px;
}

/* --- Notifications --- */
#notifications-modal .modal-content {
  display: flex;
  flex-direction: column;
  min-height: min(300px, 50dvh);
}

.notifications-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  overflow-y: auto;
  max-height: calc(90dvh - 120px);
  -webkit-overflow-scrolling: touch;
}

.notification-card {
  padding: 14px 16px;
  background: var(--bg-input);
  border-radius: var(--radius-xs);
  border-left: 4px solid var(--accent);
}

.notification-card.urgency-high {
  border-left-color: var(--danger);
  background: var(--danger-bg);
}

.notification-card.urgency-medium {
  border-left-color: var(--warning);
  background: var(--warning-bg);
}

.notification-card.urgency-low {
  border-left-color: var(--success);
  background: var(--success-bg);
}

.notification-card.notif-read {
  opacity: 0.55;
}

.notification-card p {
  font-size: 15px;
  line-height: 1.5;
  margin-bottom: 8px;
}

.notif-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.notif-time {
  font-size: 13px;
  color: var(--text-muted);
}

/* --- User Modal --- */
.user-detail {
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

/* --- Toast Notifications --- */
.toast-container {
  position: fixed;
  top: calc(16px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: calc(100% - 32px);
  max-width: 420px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  pointer-events: auto;
  animation: toast-in 0.35s ease forwards;
  border-left: 4px solid var(--accent);
}

.toast.toast-success {
  border-left-color: var(--success);
}

.toast.toast-error {
  border-left-color: var(--danger);
}

.toast.toast-warning {
  border-left-color: var(--warning);
}

.toast.toast-out {
  animation: toast-out 0.3s ease forwards;
}

@keyframes toast-in {
  0% {
    transform: translateY(-20px);
    opacity: 0;
  }
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes toast-out {
  0% {
    transform: translateY(0);
    opacity: 1;
  }
  100% {
    transform: translateY(-20px);
    opacity: 0;
  }
}

.toast-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
}

/* --- Responsive --- */
@media (min-width: 480px) {
  .recording-panel {
    padding: 48px 32px 36px;
  }

  .entries-section {
    padding: 28px 24px;
  }
}

@media (min-width: 480px) {
  .header-actions {
    gap: 4px;
  }

  .header-btn {
    width: 44px;
    height: 44px;
  }

  .header-btn svg {
    width: 22px;
    height: 22px;
  }

  .user-btn {
    width: 40px;
    height: 40px;
    font-size: 16px;
    margin-left: 4px;
  }
}

@media (min-width: 768px) {
  .header-actions {
    gap: 4px;
  }

  .header-btn {
    width: 48px;
    height: 48px;
  }

  .app-header {
    padding: 12px 24px;
  }

  .recording-panel {
    padding: 56px 32px 40px;
  }

  .entries-section {
    padding: 32px;
    max-width: 720px;
    margin: 0 auto;
    width: 100%;
  }

  .entries-list {
    gap: 16px;
  }

  .entry-card {
    padding: 20px;
  }

  .secondary-actions {
    gap: 20px;
  }

  .action-btn {
    padding: 20px 36px;
    min-width: 120px;
  }

  .auth-container {
    padding: 48px 32px;
  }

  .brand {
    font-size: 72px;
  }
}

@media (min-width: 1024px) {
  .app-header {
    padding: 12px 32px;
  }

  .recording-panel {
    padding: 64px 32px 48px;
  }

  .entries-section {
    max-width: 800px;
    padding: 40px 32px;
  }

  .modal-content {
    max-width: 600px;
  }
}

/* --- User Filter Bar --- */
.user-filter-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 12px;
  margin-bottom: 4px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.user-filter-bar::-webkit-scrollbar {
  display: none;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  white-space: nowrap;
  color: var(--text-secondary);
  background: var(--bg-input);
  border: 2px solid var(--border);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition);
}

.filter-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.filter-chip.active {
  background: var(--accent-bg);
  border-color: var(--accent);
  color: var(--accent);
}

.filter-chip-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  color: white;
  font-size: 11px;
  font-weight: 700;
}

/* --- Read More Link --- */
.entry-read-more {
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.entry-read-more:hover {
  text-decoration: underline;
}

/* --- Fullscreen Overlays (Read More + Photo Lightbox) --- */
.fullscreen-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fullscreen-overlay .overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.fullscreen-overlay .overlay-panel {
  position: relative;
  z-index: 1;
  background: var(--bg-card);
  border-radius: var(--radius);
  width: calc(100% - 32px);
  max-width: 560px;
  max-height: 85dvh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl);
}

.overlay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.overlay-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: none;
  background: var(--bg-input);
  border-radius: var(--radius-xs);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}

.overlay-close:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

.overlay-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
  font-size: 15px;
  color: var(--text);
}

.overlay-section-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent);
  margin-bottom: 8px;
}

/* Photo Lightbox */
.lightbox .overlay-backdrop {
  background: rgba(0, 0, 0, 0.9);
}

.lightbox-close {
  position: absolute;
  top: calc(16px + env(safe-area-inset-top));
  right: 16px;
  z-index: 2;
  background: rgba(0, 0, 0, 0.5) !important;
  color: white !important;
  border-radius: 50%;
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.2) !important;
  color: white !important;
}

.lightbox-img {
  position: relative;
  z-index: 1;
  max-width: calc(100% - 32px);
  max-height: calc(100dvh - 80px);
  object-fit: contain;
  border-radius: var(--radius-xs);
}

/* --- Photo Thumbnail Strip (Camera Modal) --- */
.photo-thumbstrip {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.photo-thumbstrip::-webkit-scrollbar {
  display: none;
}

.photo-thumb-item {
  position: relative;
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-xs);
  overflow: hidden;
  border: 2px solid var(--border);
}

.photo-thumb-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.photo-thumb-remove {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 22px;
  height: 22px;
  border: none;
  background: var(--danger);
  color: white;
  font-size: 14px;
  line-height: 1;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.photo-thumb-add {
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-xs);
  border: 2px dashed var(--border-strong);
  background: var(--bg-input);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.photo-thumb-add:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-bg);
}

.photo-thumb-pdf {
  background: var(--bg-input);
  display: flex;
  align-items: center;
  justify-content: center;
}

.pdf-thumb-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-muted);
  width: 100%;
  height: 100%;
  padding: 4px;
}

.pdf-thumb-name {
  font-size: 7px;
  line-height: 1;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

/* --- Photo Carousel (Entry Cards) --- */
.photo-carousel {
  margin-bottom: 10px;
}

.carousel-track {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  gap: 0;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
}

.carousel-track::-webkit-scrollbar {
  display: none;
}

.carousel-slide {
  flex: 0 0 100%;
  width: 100%;
  max-height: 200px;
  object-fit: cover;
  scroll-snap-align: start;
  display: block;
}

.carousel-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 8px 0 0;
}

.carousel-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: none;
  background: var(--border-strong);
  cursor: pointer;
  padding: 0;
  transition: all var(--transition);
}

.carousel-dot.active {
  background: var(--accent);
  transform: scale(1.3);
}

/* --- Photo Gallery --- */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  overflow-y: auto;
  flex: 1;
  padding: 0 0 16px;
  align-content: start;
}

.gallery-date-header {
  grid-column: 1 / -1;
  padding: 12px 4px 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: capitalize;
}

.gallery-item {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  cursor: pointer;
  border-radius: 2px;
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.15s ease;
}

.gallery-item:hover img {
  transform: scale(1.05);
}

.gallery-item:active img {
  transform: scale(0.97);
}

.gallery-item-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.65));
}

.gallery-item-author {
  font-size: 10px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: calc(100% - 30px);
}

.gallery-goto-entry {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: none;
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border-radius: 50%;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease;
}

.gallery-goto-entry:hover {
  background: rgba(255, 255, 255, 0.4);
}

.gallery-goto-entry:active {
  transform: scale(0.9);
}

@media (min-width: 480px) {
  .gallery-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
  }
}

@media (min-width: 768px) {
  .gallery-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
  }

  .gallery-item {
    border-radius: var(--radius-xs);
  }
}

/* --- Lightbox Navigation --- */
.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  width: 48px;
  height: 48px;
  border: none;
  background: rgba(0, 0, 0, 0.5);
  color: white;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
}

.lightbox-nav:hover {
  background: rgba(255, 255, 255, 0.2);
}

.lightbox-prev {
  left: 16px;
}

.lightbox-next {
  right: 16px;
}

.lightbox-counter {
  position: absolute;
  bottom: calc(64px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  font-size: 14px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.8);
  background: rgba(0, 0, 0, 0.5);
  padding: 6px 14px;
  border-radius: var(--radius-full);
}

.lightbox-bottom-bar {
  position: absolute;
  bottom: calc(16px + env(safe-area-inset-bottom));
  left: 16px;
  right: 16px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}

.lightbox-bottom-bar > * {
  pointer-events: auto;
}

.lightbox-alt-pill {
  padding: 5px 10px;
  font-size: 13px;
  font-weight: 800;
  font-family: inherit;
  letter-spacing: 0.5px;
  color: #fff;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 6px;
  cursor: pointer;
  line-height: 1;
  transition: background 0.15s ease;
}

.lightbox-alt-pill:hover {
  background: rgba(0, 0, 0, 0.85);
}

.lightbox-goto-entry {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  background: rgba(0, 0, 0, 0.5);
  color: white;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.15s ease;
}

.lightbox-goto-entry:hover {
  background: rgba(255, 255, 255, 0.2);
}

.lightbox-goto-entry:active {
  transform: scale(0.9);
}

/* --- Markdown Content --- */
.markdown-content {
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
  word-break: break-word;
}

.markdown-content h1,
.markdown-content h2,
.markdown-content h3,
.markdown-content h4,
.markdown-content h5,
.markdown-content h6 {
  margin-top: 1em;
  margin-bottom: 0.5em;
  font-weight: 700;
  line-height: 1.3;
}

.markdown-content h1 { font-size: 1.4em; }
.markdown-content h2 { font-size: 1.25em; }
.markdown-content h3 { font-size: 1.1em; }

.markdown-content p {
  margin-bottom: 0.75em;
}

.markdown-content p:last-child {
  margin-bottom: 0;
}

.markdown-content ul,
.markdown-content ol {
  margin-bottom: 0.75em;
  padding-left: 1.5em;
}

.markdown-content li {
  margin-bottom: 0.25em;
}

.markdown-content strong {
  font-weight: 700;
}

.markdown-content em {
  font-style: italic;
}

.markdown-content code {
  background: var(--bg-input);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

.markdown-content pre {
  background: var(--bg-input);
  border: 1px solid var(--border);
  padding: 12px 16px;
  border-radius: var(--radius-xs);
  overflow-x: auto;
  margin-bottom: 0.75em;
}

.markdown-content pre code {
  background: none;
  border: none;
  padding: 0;
}

.markdown-content blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 12px;
  margin: 0.75em 0;
  color: var(--text-secondary);
}

.markdown-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1em 0;
}

.markdown-content a {
  color: var(--accent);
  text-decoration: underline;
}

.markdown-content a:hover {
  color: var(--accent-light);
}

.markdown-content table {
  border-collapse: collapse;
  width: auto;
  margin-bottom: 0.75em;
  font-size: 14px;
}

.markdown-content th,
.markdown-content td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
}

.markdown-content th {
  background: var(--bg-input);
  font-weight: 700;
}

.markdown-content tr:nth-child(even) {
  background: var(--bg-input);
}

.markdown-table-scroll {
  overflow-x: auto;
  overflow-y: auto;
  max-width: 100%;
  max-height: 400px;
  margin-bottom: 0.75em;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  position: relative;
}

.markdown-table-scroll table {
  margin-bottom: 0;
  border: none;
  width: auto;
  min-width: max-content;
}

.markdown-table-scroll th:first-child,
.markdown-table-scroll td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--bg-card);
}

.markdown-table-scroll th:first-child {
  background: var(--bg-input);
  z-index: 2;
}

.markdown-table-scroll th,
.markdown-table-scroll td {
  border-left: none;
  border-right: none;
  white-space: nowrap;
}

.markdown-table-scroll::-webkit-scrollbar {
  height: 6px;
  width: 6px;
}

.markdown-table-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.markdown-table-scroll::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 3px;
}

.markdown-table-scroll::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Markdown inside user message (white text on accent bg) */
.ai-msg-user .markdown-content,
.ai-msg-user .markdown-content h1,
.ai-msg-user .markdown-content h2,
.ai-msg-user .markdown-content h3,
.ai-msg-user .markdown-content p,
.ai-msg-user .markdown-content li,
.ai-msg-user .markdown-content a {
  color: #ffffff;
}

.ai-msg-user .markdown-content code {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

.ai-msg-user .markdown-content pre {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.ai-msg-user .markdown-content blockquote {
  border-left-color: rgba(255, 255, 255, 0.4);
  color: rgba(255, 255, 255, 0.8);
}

/* --- Landscape / Wide Screen Layout --- */
@media (min-width: 1024px), (min-width: 768px) and (orientation: landscape) {
  #app-screen.active {
    display: grid;
    grid-template-rows: auto 1fr;
    grid-template-columns: 1fr 1fr;
    min-height: 100dvh;
  }

  #app-screen .app-header {
    grid-column: 1 / -1;
  }

  /* Disable header hide-on-scroll in landscape */
  #app-screen .app-header.header-hidden {
    transform: none;
    opacity: 1;
    pointer-events: auto;
  }

  #app-screen .recording-panel {
    grid-column: 1;
    grid-row: 2;
    border-right: 1px solid var(--border);
    border-bottom: none;
    position: sticky;
    top: var(--header-height);
    height: calc(100dvh - var(--header-height));
    overflow-y: auto;
    padding: 32px 24px;
  }

  #app-screen .entries-section {
    grid-column: 2;
    grid-row: 2;
    overflow-y: auto;
    height: calc(100dvh - var(--header-height));
    max-width: none;
    padding: 24px;
  }
}

/* --- Comment System --- */
.entry-comments-section {
  margin-top: 8px;
}

.entry-comment-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  color: var(--text-secondary);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition);
}

.entry-comment-btn:hover {
  border-color: var(--warning);
  color: var(--text);
  background: var(--warning-bg);
}

.entry-comment-btn svg {
  width: 14px;
  height: 14px;
}

.comments-panel {
  margin-top: 8px;
  padding: 10px 12px;
  background: var(--warning-bg);
  border: 1px solid rgba(233, 196, 106, 0.3);
  border-radius: var(--radius-xs);
}

.comment-item {
  display: flex;
  gap: 8px;
  padding: 6px 0;
}

.comment-item + .comment-item {
  border-top: 1px solid rgba(233, 196, 106, 0.2);
}

.comment-avatar {
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  margin-top: 2px;
}

.comment-body {
  flex: 1;
  min-width: 0;
}

.comment-header-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 2px;
}

.comment-author {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.comment-time {
  font-size: 11px;
  color: var(--text-muted);
}

.comment-delete-btn {
  margin-left: auto;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease;
}

.comment-item:hover .comment-delete-btn {
  opacity: 1;
}

.comment-delete-btn:hover {
  color: var(--danger);
}

.comment-text {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  word-break: break-word;
}

.comment-mention {
  background: var(--accent-bg);
  color: var(--accent);
  padding: 1px 4px;
  border-radius: 3px;
  font-weight: 600;
  font-size: 12px;
}

.comment-hashtag {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
  font-size: 13px;
}

.comment-hashtag:hover {
  text-decoration: underline;
}

.comment-input-area {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(233, 196, 106, 0.25);
}

.comment-input-wrap {
  flex: 1;
  position: relative;
}

.comment-textarea {
  width: 100%;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  outline: none;
  resize: none;
  min-height: 36px;
  max-height: 80px;
  transition: border-color var(--transition);
}

.comment-textarea:focus {
  border-color: var(--accent);
}

.comment-send-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-xs);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease;
}

.comment-send-btn:hover {
  background: var(--accent-light);
}

.comment-send-btn:active {
  transform: scale(0.92);
}

/* @mention dropdown */
.mention-dropdown {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  margin-bottom: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  box-shadow: var(--shadow-lg);
  z-index: 100;
  max-height: 160px;
  overflow-y: auto;
}

.mention-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.1s ease;
}

.mention-option:hover {
  background: var(--accent-bg);
}

/* --- Hashtag System --- */
.hashtag-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-bottom: 12px;
  flex-shrink: 0;
}

.hashtag-pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  color: var(--text-secondary);
  background: var(--bg-input);
  border: 2px solid var(--border);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition);
}

.hashtag-pill:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.hashtag-pill.active {
  background: var(--accent-bg);
  border-color: var(--accent);
  color: var(--accent);
}

.hashtag-entries {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hashtag-entry-item {
  padding: 10px 12px;
  background: var(--bg-input);
  border-radius: var(--radius-xs);
  border-left: 3px solid var(--accent);
}

.hashtag-entry-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 13px;
}

.hashtag-entry-text {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  margin-bottom: 6px;
  word-break: break-word;
}

.hashtag-entry-source {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.hashtag-goto-entry {
  border: none;
  background: transparent;
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  padding: 2px 4px;
}

.hashtag-goto-entry:hover {
  text-decoration: underline;
}

/* --- Utility --- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Focus visible for keyboard nav */
*:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* Remove focus outline for mouse/touch */
*:focus:not(:focus-visible) {
  outline: none;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Selection color */
::selection {
  background: var(--accent);
  color: #ffffff;
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
