:root {
  --bg-primary: #f5f4f0;        /* Soft warm paper white */
  --bg-secondary: #eaddd3;      /* Muted light clay/linen */
  --bg-gradient: linear-gradient(135deg, #f7f6f2 0%, #eaddd3 100%);
  --glass-bg: rgba(255, 255, 255, 0.65);
  --glass-border: rgba(0, 0, 0, 0.08);
  --glass-shadow: 0 8px 32px rgba(112, 105, 95, 0.12);
  --blur: blur(20px);
  --text-primary: #2a2c2e;      /* Deep slate gray */
  --text-secondary: #5c5e62;    /* Muted steel gray */
  --text-muted: #9aa0a6;        /* Light stone gray */
  --accent-coral: #b88d8d;      /* Muted dusty rose */
  --accent-mint: #78907c;       /* Muted sage green */
  --accent-purple: #8e7f94;     /* Muted dusty lavender */
  --accent-blue: #728494;       /* Muted slate blue */
  --accent-orange: #a89984;     /* Muted warm sand */
  --recording-red: #c98a8a;
  --recording-glow: 0 0 20px rgba(201, 138, 138, 0.25);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
  --safe-area-top: env(safe-area-inset-top, 0px);
  --transition-fast: 0.15s ease;
  --transition-normal: 0.3s ease;
  --transition-slow: 0.5s ease;
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-family);
  background: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden; /* Prevent body scroll, handle in #main-content */
}

::selection {
  background: var(--accent-purple);
  color: #fff;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

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

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

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

h1, h2, h3, h4, h5, h6 {
  margin-top: 0;
  color: var(--text-primary);
  font-weight: 600;
}

a {
  color: var(--accent-blue);
  text-decoration: none;
}

p {
  margin: 0 0 1rem 0;
  line-height: 1.6;
}

/* Base App Layout */
#app-container {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  width: 100vw;
}

/* Top Navigation (iPad/Desktop) */
#nav-top {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  padding: calc(1rem + var(--safe-area-top)) 2rem 1rem 2rem;
  background: var(--glass-bg);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-bottom: 1px solid var(--glass-border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

.nav-tabs {
  display: flex;
  gap: 1rem;
}

.nav-tab {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 500;
  padding: 0.5rem 1rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
}

.nav-tab:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.nav-tab.active {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.1);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.nav-actions {
  display: flex;
  align-items: center;
}

.sync-badge {
  font-size: 1.2rem;
}

/* Bottom Tab Bar (iPhone) */
#nav-bottom {
  display: none;
  flex-direction: row;
  justify-content: space-around;
  padding: 0.75rem 0 calc(0.75rem + var(--safe-area-bottom)) 0;
  background: var(--glass-bg);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-top: 1px solid var(--glass-border);
  position: sticky;
  bottom: 0;
  z-index: 100;
}

.bottom-tab {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  font-size: 1.5rem;
  cursor: pointer;
  transition: var(--transition-fast);
}

.bottom-tab span {
  font-size: 0.7rem;
  font-weight: 500;
}

.bottom-tab.active {
  color: var(--accent-purple);
}

/* Main Content Area */
#main-content {
  flex-grow: 1;
  overflow-y: auto;
  padding: 1.5rem 2rem;
  position: relative;
}

.view {
  display: none;
  animation: fade-in var(--transition-normal);
}

.view.active {
  display: block;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slide-up {
  from { opacity: 0; transform: translateY(100%); }
  to { opacity: 1; transform: translateY(0); }
}

/* Glass Card */
.glass-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--glass-shadow);
  margin-bottom: 1.5rem;
}

/* Buttons */
.btn {
  background: transparent;
  border: none;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 500;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: var(--transition-normal);
  color: var(--text-primary);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-blue));
  color: #fff;
  box-shadow: 0 4px 15px rgba(151, 117, 250, 0.4);
}

.btn-primary:hover {
  box-shadow: 0 6px 20px rgba(151, 117, 250, 0.6);
  transform: translateY(-1px);
}

.btn-danger-ghost {
  color: var(--recording-red);
  padding: 0.5rem;
}

.btn-danger-ghost:hover {
  background: rgba(255, 71, 87, 0.1);
  border-radius: var(--radius-sm);
}

.btn-ghost {
  color: var(--text-primary);
}

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

.btn-sm {
  padding: 0.4rem 0.8rem;
  font-size: 0.875rem;
  border-radius: var(--radius-sm);
}

.btn-record {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--recording-red);
  font-size: 1.5rem;
  padding: 0;
  box-shadow: var(--recording-glow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-record:hover {
  transform: scale(1.05);
}

.btn-pause, .btn-stop {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  font-size: 1.25rem;
  padding: 0;
}

.btn-pause:hover, .btn-stop:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* Inputs */
.input-glass {
  width: 100%;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 1rem;
  transition: var(--transition-fast);
}

.input-glass:focus {
  outline: none;
  border-color: var(--accent-purple);
  box-shadow: 0 0 0 2px rgba(151, 117, 250, 0.2);
}

.title-input {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 2rem;
  font-weight: 700;
  padding: 0.5rem 0;
  font-family: inherit;
  margin-bottom: 1rem;
}

.title-input:focus {
  outline: none;
}

.file-input {
  display: none;
}

/* Notes List View */
.view-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.view-header h1 {
  margin: 0;
  font-size: 2rem;
}

.search-bar {
  margin-bottom: 1.5rem;
}

.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
}

.note-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.note-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--glass-shadow);
  border-color: rgba(255, 255, 255, 0.2);
}

.note-card h3 {
  margin: 0;
  font-size: 1.2rem;
}

.note-card p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.9rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.note-card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: auto;
}

.note-card-meta small {
  color: var(--text-muted);
}

.tag-remove {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: 0 2px;
  font-size: 1em;
  opacity: 0.6;
  transition: opacity var(--transition-fast);
}

.tag-remove:hover {
  opacity: 1;
}

.empty-state {
  text-align: center;
  padding: 4rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.empty-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

/* Tags */
.tags-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.tags-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tag-badge {
  background: rgba(77, 171, 247, 0.15);
  color: var(--accent-blue);
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-xl);
  font-size: 0.8rem;
  font-weight: 500;
  border: 1px solid rgba(77, 171, 247, 0.3);
}

/* Sections */
.section-card {
  margin-bottom: 1.5rem;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.section-header h3 {
  margin: 0;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.transcript-content, .summary-content {
  max-height: 300px;
  overflow-y: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--text-secondary);
  padding-right: 0.5rem;
}

.transcript-placeholder {
  font-style: italic;
  color: var(--text-muted);
}

/* Todo List */
.todo-list, .decisions-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem 0;
}

.todo-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
  padding: 0.5rem;
  background: rgba(0, 0, 0, 0.1);
  border-radius: var(--radius-sm);
}

.todo-item input[type="checkbox"] {
  margin-top: 0.25rem;
  accent-color: var(--accent-purple);
}

.todo-item.done span {
  text-decoration: line-through;
  color: var(--text-muted);
}

/* Editor */
.editor-section {
  background: var(--glass-bg);
  border-radius: var(--radius-md);
  border: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  padding: 0.5rem;
  border-bottom: 1px solid var(--glass-border);
  gap: 0.25rem;
  flex-wrap: wrap;
}

.toolbar-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
}

.toolbar-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.toolbar-spacer {
  flex-grow: 1;
}

.editor-container {
  display: flex;
  flex-direction: column;
}

.editor-textarea, .editor-preview {
  width: 100%;
  min-height: 400px;
  padding: 1rem;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text-primary);
  background: transparent;
  border: none;
  resize: none;
}

.editor-textarea:focus {
  outline: none;
}

.editor-preview {
  display: none;
  overflow-y: auto;
}

/* Recording View */
.record-header {
  text-align: center;
  margin-bottom: 2rem;
}

.record-status-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  text-align: center;
}

.recording-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.record-indicator {
  width: 12px;
  height: 12px;
  background-color: var(--recording-red);
  border-radius: 50%;
  display: none;
}

.record-indicator.active {
  display: block;
  animation: pulse 1.5s infinite ease-in-out;
}

@keyframes pulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(255, 71, 87, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 10px rgba(255, 71, 87, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(255, 71, 87, 0); }
}

.waveform {
  width: 100%;
  max-width: 600px;
  height: 80px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius-sm);
}

.recording-timer {
  font-size: 3rem;
  font-weight: 700;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  letter-spacing: 2px;
}

.record-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
}

.drop-zone {
  border: 2px dashed var(--glass-border);
  border-radius: var(--radius-md);
  padding: 2rem;
  text-align: center;
  transition: var(--transition-fast);
  background: var(--glass-bg);
}

.drop-zone:hover {
  border-color: var(--accent-purple);
  background: rgba(151, 117, 250, 0.05);
}

.drop-label {
  cursor: pointer;
  display: block;
  color: var(--accent-blue);
  font-weight: 500;
}

.live-transcript-section {
  margin-top: 1.5rem;
}

.manual-notes-section {
  margin-top: 1.5rem;
}

/* Settings View */
.settings-group {
  margin-bottom: 1.5rem;
}

.settings-group h3 {
  margin-top: 0;
  margin-bottom: 0.5rem;
  font-size: 1.2rem;
}

.settings-group p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.input-group label {
  font-size: 0.9rem;
  font-weight: 500;
}

.status-text {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

select.input-glass {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a0a0b0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  background-size: 1em;
}

select.input-glass option {
  background: var(--bg-primary);
  color: var(--text-primary);
}

/* Components */
.toast {
  position: fixed;
  bottom: calc(2rem + var(--safe-area-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: rgba(30, 30, 30, 0.9);
  color: #fff;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-xl);
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  z-index: 1000;
  transition: transform var(--transition-normal);
  opacity: 0;
  pointer-events: none;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 12, 41, 0.8);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 2000;
}

.loading-spinner {
  width: 50px;
  height: 50px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  border-top-color: var(--accent-purple);
  animation: spin 1s ease-in-out infinite;
  margin-bottom: 1rem;
}

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

/* Responsive Layouts */

/* Mobile (iPhone) */
@media (max-width: 768px) {
  #nav-top {
    display: none;
  }
  
  #nav-bottom {
    display: flex;
  }
  
  #main-content {
    padding: 1rem;
  }
  
  .view-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }
  
  .header-actions {
    width: 100%;
    display: flex;
    justify-content: flex-end;
  }
  
  .title-input {
    font-size: 1.5rem;
  }
  
  .recording-timer {
    font-size: 2.5rem;
  }
}

/* Tablet / Desktop (iPad) */
@media (min-width: 769px) {
  #nav-bottom {
    display: none;
  }
  
  .input-group {
    flex-direction: row;
    align-items: center;
  }
  
  .input-group label {
    width: 80px;
  }
}

/* iPad Pro / Large Desktop */
@media (min-width: 1024px) {
  .editor-container {
    flex-direction: row;
    gap: 1rem;
  }
  
  .editor-textarea, .editor-preview {
    flex: 1;
    min-height: 600px;
  }
  
  .editor-preview {
    display: block !important; /* Always show preview on large screens */
    border-left: 1px solid var(--glass-border);
    padding-left: 1rem;
  }
  
  #btn-toggle-preview {
    display: none; /* Hide toggle button on large screens */
  }
}
