/* ==========================================================================
   CLANKER — Skeuomorphic Notebook RAG Assistant
   Design Tokens & CSS Variables
   ========================================================================== */

:root {
  /* Color Palette - Warm Paper & Earthy Leather */
  --bg-desk: #2b2622;
  --bg-desk-gradient: radial-gradient(circle at 50% 30%, #3e3732 0%, #1e1b18 100%);
  
  --cover-leather: #5a3825;
  --cover-leather-dark: #3f2517;
  --cover-leather-accent: #784b33;
  --cover-gold: #d4af37;
  --cover-gold-glow: rgba(212, 175, 55, 0.35);

  --paper-cream: #fdfbf7;
  --paper-edge: #e8e3d5;
  --paper-ruled: #dce5ef;
  --paper-margin: #e8989e;
  --paper-shadow: rgba(0, 0, 0, 0.22);
  
  --text-ui: #23272e;
  --text-ui-muted: #57606a;
  --text-ink-blue: #1c3d5a;
  --text-ink-dark: #1f2328;
  --text-clanker: #1e3a5f;
  
  --accent-blue: #2563eb;
  --accent-blue-hover: #1d4ed8;
  --accent-blue-light: #eff6ff;
  
  --memo-bg: #fef9c3;
  --memo-border: #facc15;
  --memo-tag: #854d0e;
  
  --tag-green-bg: #dcfce7;
  --tag-green-text: #166534;
  --tag-red-bg: #fee2e2;
  --tag-red-text: #991b1b;
  
  /* Typography */
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-handwriting: 'Caveat', 'Patrick Hand', cursive, sans-serif;
  
  /* Radii & Shadows */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 18px;
  --shadow-tactile: 0 4px 0 rgba(0, 0, 0, 0.2), 0 6px 12px rgba(0, 0, 0, 0.15);
  --shadow-notebook: 0 15px 35px rgba(0, 0, 0, 0.35), 0 5px 15px rgba(0, 0, 0, 0.2);
  --shadow-paper: 0 3px 10px rgba(0, 0, 0, 0.08);
}

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

body {
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text-ui);
  background-color: var(--bg-desk);
  background-image: var(--bg-desk-gradient);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  overflow-x: hidden;
}

/* Accessibility Focus Ring */
:focus-visible {
  outline: 3px solid var(--accent-blue);
  outline-offset: 2px;
}

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

.hidden {
  display: none !important;
}

/* Ambient Desk Backdrop */
.desk-background {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: 
    radial-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 0),
    radial-gradient(rgba(0, 0, 0, 0.12) 1px, transparent 0);
  background-size: 24px 24px;
  background-position: 0 0, 12px 12px;
  z-index: -1;
}

/* App Main Container */
.app-container {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  position: relative;
  perspective: 1200px;
}

/* ==========================================================================
   VIEW 1: NOTEBOOK COVER / "LET'S CHAT" STARTING PAGE
   ========================================================================== */

.notebook-cover-view {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  padding: 20px 0;
}

.closed-book {
  position: relative;
  width: 100%;
  max-width: 580px;
  background: var(--cover-leather);
  background: linear-gradient(135deg, var(--cover-leather) 0%, var(--cover-leather-dark) 100%);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-notebook), inset 0 1px 1px rgba(255, 255, 255, 0.2);
  border: 3px solid var(--cover-leather-dark);
  padding: 18px 22px;
  display: flex;
  overflow: hidden;
}

/* Spine details on cover */
.notebook-spine-outer {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 32px;
  background: linear-gradient(90deg, rgba(0,0,0,0.5) 0%, rgba(0,0,0,0.1) 80%, rgba(255,255,255,0.05) 100%);
  border-right: 1px solid rgba(0, 0, 0, 0.3);
  z-index: 2;
}

.cover-card {
  width: 100%;
  padding-left: 20px;
  position: relative;
  z-index: 3;
}

/* Binder Rings on Cover */
.binder-rings {
  position: absolute;
  left: -4px;
  top: 30px;
  bottom: 30px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none;
}

.binder-rings .ring {
  width: 22px;
  height: 9px;
  background: linear-gradient(180deg, #e5e7eb 0%, #9ca3af 50%, #4b5563 100%);
  border-radius: 6px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

.cover-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 10px;
}

/* Embossed Notebook Label Plate */
.notebook-label-plate {
  background: #fdfaf3;
  background: linear-gradient(180deg, #fdfbf7 0%, #f4ede1 100%);
  border: 2px solid var(--cover-gold);
  border-radius: var(--radius-md);
  padding: 24px;
  text-align: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25), inset 0 1px 2px rgba(255, 255, 255, 0.9);
  position: relative;
}

.app-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--cover-leather);
  background: rgba(212, 175, 55, 0.18);
  border: 1px solid rgba(212, 175, 55, 0.4);
  padding: 4px 10px;
  border-radius: 20px;
  margin-bottom: 12px;
}

.robot-icon {
  width: 14px;
  height: 14px;
}

.brand-title {
  font-size: 38px;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--cover-leather-dark);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
  margin-bottom: 4px;
  font-family: var(--font-ui);
}

/* Clanker Robot Mascot Container on Landing Page */
.mascot-container {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 12px 0 10px 0;
}

.mascot-img {
  width: 140px;
  height: 155px;
  object-fit: cover;
  border-radius: var(--radius-md);
  border: 2px solid var(--cover-gold);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4), inset 0 1px 2px rgba(255, 255, 255, 0.2);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.mascot-img:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.5), 0 0 12px rgba(239, 68, 68, 0.4);
}

.brand-tagline {
  font-size: 14px;
  color: var(--text-ui-muted);
  font-weight: 500;
  font-family: var(--font-ui);
}

/* Mascot in Chat Header */
.header-mascot-badge {
  display: flex;
  align-items: center;
  justify-content: center;
}

.header-mascot-img {
  width: 28px;
  height: 28px;
  object-fit: cover;
  border-radius: 50%;
  border: 1.5px solid var(--cover-gold);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
}

/* Mascot in Speaker Avatar */
.speaker-avatar-img {
  width: 18px;
  height: 18px;
  object-fit: cover;
  border-radius: 50%;
  border: 1px solid var(--cover-leather);
  vertical-align: middle;
  display: inline-block;
}

/* Mascot in Loading State */
.mascot-loading-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading-mascot-img {
  width: 26px;
  height: 26px;
  object-fit: cover;
  border-radius: 50%;
  border: 1.5px solid var(--cover-gold);
  animation: pulseMascot 1.2s ease-in-out infinite alternate;
}

@keyframes pulseMascot {
  from {
    transform: scale(0.95);
    opacity: 0.85;
  }
  to {
    transform: scale(1.1);
    opacity: 1;
    filter: drop-shadow(0 0 8px rgba(239, 68, 68, 0.7));
  }
}

/* Paper Inset Note on Cover */
.cover-paper-note {
  background: var(--paper-cream);
  border-radius: var(--radius-sm);
  padding: 20px;
  border: 1px solid var(--paper-edge);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.08), var(--shadow-paper);
}

.welcome-heading {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-ui);
  margin-bottom: 8px;
  font-family: var(--font-ui);
}

.welcome-text {
  font-size: 14px;
  color: var(--text-ui-muted);
  line-height: 1.6;
  margin-bottom: 14px;
  font-family: var(--font-ui);
}

.grounding-disclaimer {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-ink-blue);
  background: var(--accent-blue-light);
  border: 1px solid rgba(37, 99, 235, 0.2);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
}

.shield-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--accent-blue);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 15px;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
  text-decoration: none;
}

.btn-tactile {
  box-shadow: var(--shadow-tactile);
}

.btn-tactile:hover {
  transform: translateY(-1px);
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.22), 0 8px 16px rgba(0, 0, 0, 0.2);
}

.btn-tactile:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2), 0 2px 4px rgba(0, 0, 0, 0.15);
}

.btn-primary {
  background: linear-gradient(180deg, #2563eb 0%, #1d4ed8 100%);
  color: #ffffff;
  border: 1px solid #1e40af;
  width: 100%;
  font-size: 16px;
  padding: 14px 20px;
}

.btn-primary:hover {
  background: linear-gradient(180deg, #3b82f6 0%, #1d4ed8 100%);
}

.btn-arrow {
  width: 18px;
  height: 18px;
  transition: transform 0.2s ease;
}

.btn-primary:hover .btn-arrow {
  transform: translateX(4px);
}

.cover-actions {
  display: flex;
  justify-content: center;
}

.cover-footer {
  text-align: center;
}

.footer-meta {
  font-size: 12px;
  color: #d1c5b8;
  font-weight: 500;
  font-family: var(--font-ui);
}

/* ==========================================================================
   VIEW 2: OPEN NOTEBOOK CHAT SPREAD
   ========================================================================== */

.notebook-chat-view {
  width: 100%;
}

.notebook-spread {
  position: relative;
  width: 100%;
  background: var(--cover-leather);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-notebook);
  border: 3px solid var(--cover-leather-dark);
  display: flex;
  overflow: hidden;
  min-height: 86vh;
}

/* Spiral Wire Binding (Left Strip) */
.notebook-binding-spine {
  width: 38px;
  background: linear-gradient(90deg, var(--cover-leather-dark) 0%, #4a2d1d 80%, rgba(0,0,0,0.3) 100%);
  border-right: 1px solid rgba(0, 0, 0, 0.35);
  display: flex;
  justify-content: center;
  padding: 30px 0;
  flex-shrink: 0;
}

.spiral-holes {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
  width: 100%;
  align-items: center;
}

.hole-pair {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 28px;
  height: 12px;
}

.hole {
  width: 7px;
  height: 12px;
  background: #1e1713;
  border-radius: 4px;
  box-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.8);
}

.wire {
  width: 18px;
  height: 5px;
  background: linear-gradient(180deg, #f3f4f6 0%, #9ca3af 50%, #4b5563 100%);
  position: absolute;
  border-radius: 3px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

/* Open Ruled Notebook Paper Page */
.notebook-page-paper {
  flex: 1;
  background-color: var(--paper-cream);
  /* Skeuomorphic Ruled Lines (every 28px) */
  background-image: repeating-linear-gradient(
    transparent,
    transparent 27px,
    var(--paper-ruled) 27px,
    var(--paper-ruled) 28px
  );
  background-attachment: local;
  position: relative;
  display: flex;
  flex-direction: column;
  box-shadow: inset 5px 0 15px rgba(0, 0, 0, 0.06);
  min-width: 0;
}

/* Soft Pink Margin Line on the left */
.paper-margin-line {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 64px;
  width: 2px;
  background-color: var(--paper-margin);
  opacity: 0.65;
  pointer-events: none;
  z-index: 1;
}

/* Notebook Top Header */
.notebook-header {
  padding: 14px 20px 14px 74px;
  border-bottom: 2px solid var(--paper-edge);
  background: rgba(253, 251, 247, 0.95);
  backdrop-filter: blur(4px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  z-index: 2;
}

.header-branding {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-icon {
  background: #f1ede3;
  border: 1px solid var(--paper-edge);
  border-radius: var(--radius-sm);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-ui);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-icon:hover {
  background: #e8e2d4;
}

.btn-icon svg {
  width: 18px;
  height: 18px;
}

.header-titles {
  display: flex;
  flex-direction: column;
}

.app-title-nav {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--cover-leather-dark);
  font-family: var(--font-ui);
}

.notebook-subtitle {
  font-size: 12px;
  color: var(--text-ui-muted);
  font-family: var(--font-ui);
}

.header-badges {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--tag-green-text);
  background: var(--tag-green-bg);
  border: 1px solid rgba(22, 101, 52, 0.2);
  padding: 4px 8px;
  border-radius: 12px;
  font-family: var(--font-ui);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #16a34a;
}

.btn-sm {
  font-size: 12px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
}

.btn-secondary {
  background: #f4ede1;
  color: var(--text-ui);
  border: 1px solid #dfd5c5;
}

.btn-secondary:hover {
  background: #eae0cf;
}

/* Notebook Scroll Conversation Area */
.notebook-scroll-area {
  flex: 1;
  overflow-y: auto;
  padding: 24px 24px 24px 74px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: relative;
  z-index: 2;
}

/* ==========================================================================
   HANDWRITING FONT SCOPING — CRITICAL
   ========================================================================== */

/* Strict scope: ONLY message text and notebook input use handwriting font */
.handwriting-text,
.chat-message .message-body,
.user-message .message-body p,
.assistant-message .message-body p,
.notepad-textarea {
  font-family: var(--font-handwriting);
  font-size: 21px;
  line-height: 28px; /* Perfectly aligned with 28px notebook ruled lines */
  letter-spacing: 0.3px;
  font-weight: 600;
}

/* ALL other UI elements use clean UI Sans font */
.speaker-tag,
.prompt-chips-wrapper,
.chips-label,
.prompt-chip,
.chip-tag,
.retrieval-box,
.retrieval-header,
.doc-badge,
.section-badge,
.score-badge,
.passage-quote,
.citation-footer,
.citation-tag,
.shortcut-hint,
.grounding-note,
.loading-main,
.loading-sub,
.error-box,
.notepad-line-guide,
.btn {
  font-family: var(--font-ui) !important;
}

/* Chat Message Items */
.chat-message {
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: fadeInNote 0.25s ease-out;
}

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

.speaker-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-ui-muted);
}

.speaker-icon {
  width: 14px;
  height: 14px;
}

/* User Note Style */
.user-message {
  padding-left: 12px;
  border-left: 3px solid var(--accent-blue);
}

.user-message .speaker-tag {
  color: var(--accent-blue);
}

.user-message .message-body {
  color: var(--text-ink-blue);
}

/* Assistant (Clanker) Note Style */
.assistant-message {
  padding-left: 12px;
  border-left: 3px solid var(--cover-gold);
}

.assistant-message .speaker-tag {
  color: var(--cover-leather);
}

.assistant-message .message-body {
  color: var(--text-ink-dark);
}

/* Prompt Chips on Welcome Note */
.prompt-chips-wrapper {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chips-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-ui-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.chips-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.prompt-chip {
  text-align: left;
  background: #fdfbf7;
  border: 1px solid var(--paper-edge);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-ui);
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.prompt-chip:hover {
  background: #f4ede1;
  border-color: var(--cover-gold);
  transform: translateX(3px);
}

.chip-tag {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--tag-green-bg);
  color: var(--tag-green-text);
}

.chip-tag.alert-tag {
  background: var(--tag-red-bg);
  color: var(--tag-red-text);
}

/* ==========================================================================
   RAG RETRIEVAL DISPLAY (VISIBLE CITATION BOX)
   ========================================================================== */

.retrieval-box {
  background: var(--memo-bg);
  border: 1px solid var(--memo-border);
  border-left: 4px solid var(--memo-border);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin: 6px 0 10px 0;
  box-shadow: var(--shadow-paper);
}

.retrieval-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
  border-bottom: 1px dashed rgba(133, 77, 14, 0.25);
  padding-bottom: 6px;
}

.retrieval-title-group {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--memo-tag);
}

.retrieval-icon {
  width: 14px;
  height: 14px;
}

.retrieval-meta-badges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.doc-badge, .section-badge, .score-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
}

.doc-badge {
  background: #fef08a;
  color: #713f12;
  border: 1px solid #fde047;
}

.section-badge {
  background: #e0e7ff;
  color: #3730a3;
  border: 1px solid #c7d2fe;
}

.score-badge {
  background: var(--tag-green-bg);
  color: var(--tag-green-text);
  border: 1px solid rgba(22, 101, 52, 0.2);
}

.passage-quote-container {
  margin-top: 6px;
}

.passage-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--memo-tag);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
  display: block;
}

.passage-quote {
  font-size: 13px;
  line-height: 1.5;
  color: #451a03;
  background: rgba(255, 255, 255, 0.65);
  border-radius: 4px;
  padding: 8px 10px;
  border-left: 2px solid var(--memo-border);
  font-style: italic;
}

/* Citations Tag Strip under answer */
.citation-footer {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.citation-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  background: #f4ede1;
  color: var(--text-ui-muted);
  border: 1px solid #e0d7c7;
  padding: 2px 8px;
  border-radius: 4px;
}

.citation-tag strong {
  color: var(--text-ui);
}

/* Calm Out-of-Scope Presentation */
.calm-unsupported-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-left: 4px solid #94a3b8;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin: 6px 0 10px 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.calm-unsupported-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  color: #475569;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.calm-unsupported-desc {
  font-size: 12px;
  color: #64748b;
  line-height: 1.4;
}

/* Searching / Loading State */
.searching-indicator {
  display: flex;
  align-items: center;
  gap: 14px;
  background: #fdfaf3;
  border: 1px dashed var(--cover-gold);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin: 10px 0;
  box-shadow: var(--shadow-paper);
}

.pencil-loader {
  width: 24px;
  height: 24px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pencil-body {
  width: 14px;
  height: 14px;
  border: 2px solid var(--cover-leather);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loading-text-group {
  display: flex;
  flex-direction: column;
}

.loading-main {
  font-size: 14px;
  font-weight: 700;
  color: var(--cover-leather-dark);
}

.loading-sub {
  font-size: 12px;
  color: var(--text-ui-muted);
}

/* ==========================================================================
   NOTEBOOK INPUT SECTION (FIXED BOTTOM NOTEPAD)
   ========================================================================== */

.notebook-input-section {
  padding: 14px 20px 18px 74px;
  background: rgba(253, 251, 247, 0.96);
  border-top: 2px solid var(--paper-edge);
  backdrop-filter: blur(4px);
  z-index: 2;
}

.notepad-input-card {
  background: #ffffff;
  border: 1px solid #dfd7ca;
  border-radius: var(--radius-md);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.06), 0 2px 6px rgba(0, 0, 0, 0.04);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.input-header-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.notepad-line-guide {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #9ca3af;
}

.input-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
}

.notepad-textarea {
  flex: 1;
  border: none;
  background: transparent;
  resize: none;
  outline: none;
  color: var(--text-ink-blue);
  /* 28px line-height for handwriting */
  line-height: 28px;
  min-height: 56px;
  padding: 0;
}

.notepad-textarea::placeholder {
  color: #9ca3af;
  font-family: var(--font-handwriting);
  font-size: 20px;
}

.btn-ask {
  background: linear-gradient(180deg, #2563eb 0%, #1d4ed8 100%);
  color: #ffffff;
  border: 1px solid #1e40af;
  padding: 10px 20px;
  font-size: 15px;
  font-weight: 700;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

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

.ask-icon {
  width: 16px;
  height: 16px;
}

.input-footer-hints {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 11px;
  color: var(--text-ui-muted);
}

.grounding-note {
  font-size: 11px;
  color: #6b7280;
}

/* ==========================================================================
   RESPONSIVE DESIGN (320px, 375px, 390px, 768px, Desktop)
   ========================================================================== */

@media (max-width: 640px) {
  body {
    padding: 8px;
  }

  .closed-book {
    padding: 14px 10px;
    border-radius: var(--radius-md);
  }

  .cover-card {
    padding-left: 12px;
  }

  .notebook-label-plate {
    padding: 16px 12px;
  }

  .brand-title {
    font-size: 28px;
  }

  .notebook-spread {
    min-height: 94vh;
    border-radius: var(--radius-md);
  }

  .notebook-binding-spine {
    width: 24px;
    padding: 16px 0;
  }

  .spiral-holes .hole-pair {
    width: 18px;
  }

  .paper-margin-line {
    left: 36px;
  }

  .notebook-header {
    padding: 10px 12px 10px 42px;
  }

  .app-title-nav {
    font-size: 15px;
  }

  .notebook-scroll-area {
    padding: 16px 12px 16px 42px;
    gap: 16px;
  }

  .notebook-input-section {
    padding: 10px 12px 12px 42px;
  }

  .handwriting-text,
  .chat-message .message-body,
  .notepad-textarea {
    font-size: 19px;
    line-height: 26px;
  }

  .retrieval-box {
    padding: 10px;
  }
}

@media (max-width: 360px) {
  .paper-margin-line {
    display: none;
  }
  
  .notebook-header,
  .notebook-scroll-area,
  .notebook-input-section {
    padding-left: 12px;
  }
  
  .notebook-binding-spine {
    display: none;
  }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
