:root {
  color-scheme: light;
  --bg: #fbfbfd;
  --panel: #ffffff;
  --text: #1d1d1f;
  --muted: #86868b;
  --border: #d2d2d7;
  --primary: #0071e3;
  --primary-hover: #0077ed;
  --danger: #ff3b30;
  --success: #34c759;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  background: var(--bg);
  color: var(--text);
}

/* =========================================
   Apple Style Layout
   ========================================= */

.apple-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.apple-nav {
  height: 48px;
  background: rgba(29, 29, 31, 1);
  display: flex;
  justify-content: center;
  align-items: center;
}

.nav-content {
  width: 100%;
  max-width: 980px;
  padding: 0 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.nav-brand {
  color: #fff;
  font-weight: 600;
  font-size: 20px;
  letter-spacing: -0.01em;
}

.nav-links a {
  color: #d6d6d6;
  text-decoration: none;
  font-size: 12px;
  margin-left: 24px;
  transition: color 0.3s ease;
}

.nav-links a:hover {
  color: #fff;
}

.hero-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center; /* Center vertically like a product hero */
  text-align: center;
  background: #fbfbfd;
  padding: 80px 20px;
}

.hero-content {
  max-width: 600px;
  margin: 0 auto;
}

.hero-title {
  font-size: 56px;
  line-height: 1.07143;
  font-weight: 700;
  letter-spacing: -0.005em;
  margin: 0 0 16px 0;
  color: #1d1d1f;
}

.hero-subtitle {
  font-size: 24px;
  line-height: 1.33333; /* 32px */
  font-weight: 400;
  letter-spacing: 0.009em;
  color: #1d1d1f;
  margin: 0 auto 40px auto;
  max-width: 500px;
}

.hero-actions {
  margin-top: 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  width: 100%;
}

.action-card {
  background: #fff;
  border-radius: 20px;
  padding: 40px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.06);
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Primary Button (Pill shaped) */
.apple-btn-primary {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  background: var(--primary);
  color: #fff;
  border-radius: 980px;
  padding: 12px 26px; /* slightly smaller padding */
  font-size: 17px;
  line-height: 1.17648;
  font-weight: 400;
  min-width: 28px;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%; /* Full width in card */
}

.apple-btn-primary:hover {
  background: var(--primary-hover);
  transform: scale(1.02);
}

.divider-text {
  font-size: 13px;
  color: var(--muted);
  margin: 16px 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.7;
}

/* Input Wrapper */
.input-wrapper {
  position: relative;
  width: 100%;
}

.input-wrapper input {
  width: 100%;
  border-radius: 12px;
  border: 1px solid #d2d2d7;
  padding: 12px 44px 12px 16px; /* space for arrow icon */
  font-size: 16px;
  background: rgba(0, 0, 0, 0.02);
  color: #1d1d1f;
  transition: all 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
  outline: none; /* manage focus manually */
}

.input-wrapper input:focus {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.15);
}

.input-arrow-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  transition: background 0.2s;
}

.input-arrow-btn:hover {
  background: rgba(0, 113, 227, 0.1);
}

.apple-feedback {
  margin-top: 12px;
  font-size: 12px;
  min-height: 16px;
  color: var(--danger);
  text-align: center;
}

/* Footer (Apple Style) */
.apple-footer {
  background: #f5f5f7;
  font-size: 12px;
  color: #6e6e73;
  padding: 20px 0;
  border-top: 1px solid #d2d2d7;
}

.footer-content {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 22px;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.footer-links a {
  margin-left: 20px;
  color: #424245;
  text-decoration: none;
}
.footer-links a:hover {
  text-decoration: underline;
}

/* Responsive typography adjustments */
@media only screen and (max-width: 734px) {
  .hero-title {
    font-size: 40px;
    line-height: 1.1;
  }
  .hero-subtitle {
    font-size: 19px;
    line-height: 1.36;
  }
  
  .nav-links {
    display: none; /* Hide on mobile for simplicity */
  }
  
  .footer-content {
    flex-direction: column;
    text-align: center;
  }
  
  .footer-links a {
    margin: 0 10px;
  }
}

/* =========================================
   PRESERVED EDITOR STYLES
   ========================================= */

.editor-shell {
  max-width: 1200px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 18px 18px 22px;
  display: grid;
  grid-template-rows: auto auto auto auto 1fr;
  gap: 12px;
}

.editor-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.header-menu {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.editor-header .subtitle {
  margin: 4px 0 0;
  color: var(--muted);
}

.menu-open-form input {
  min-width: 220px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
}

.toolbar {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  gap: 10px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.share-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.86rem;
  color: var(--muted);
}

.inline-group {
  display: flex;
  gap: 8px;
  align-items: center;
}

.status-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.84rem;
  background: #fff;
}

.status-pill.connected {
  border-color: transparent;
  color: #137333;
  background: #e6f4ea;
}

.status-pill.reconnecting {
  border-color: transparent;
  color: #b06000;
  background: #fef7e0;
}

.status-pill.locked {
  border-color: transparent;
  color: #c5221f;
  background: #fce8e6;
}

.lock-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.editor-textarea {
  width: 100%;
  min-height: min(70vh, 860px);
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  padding: 16px;
  line-height: 1.6;
  font-family: 'Roboto Mono', monospace;
  resize: vertical;
}

.editor-textarea:disabled {
  background: #f1f3f4;
  color: var(--muted);
}

/* Legacy buttons used in editor */
.btn {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 4px;
  padding: 8px 16px;
  cursor: pointer;
  font-weight: 500;
  font-size: 14px;
}

.btn:hover {
  background: #f1f3f4;
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.btn-primary:hover {
  background: #1967d2;
  box-shadow: 0 1px 2px rgba(60,64,67,0.3);
}

.btn-danger {
  background: #fce8e6;
  border-color: transparent;
  color: #c5221f;
}

@media (max-width: 900px) {
  .editor-shell {
    grid-template-rows: auto auto auto auto minmax(420px, 1fr);
    padding: 12px;
  }
  .inline-group {
    flex-wrap: wrap;
  }
  .menu-open-form input {
    min-width: 100%;
  }
}


/* Recent Docs Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(2px);
  z-index: 9999;
  display: flex;
  justify-content: center;
  align-items: center;
}

.modal-content {
  background: #fff;
  border-radius: 12px;
  width: 90%;
  max-width: 400px;
  max-height: 80vh;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
  display: flex;
  flex-direction: column;
}

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

.modal-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.close-btn {
  background: none;
  border: none;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
}

.recent-list {
  list-style: none;
  padding: 0;
  margin: 0;
  overflow-y: auto;
}

.recent-list li {
  border-bottom: 1px solid var(--border);
}

.recent-list li:last-child {
  border-bottom: none;
}

.recent-link {
  display: block;
  padding: 12px 16px;
  text-decoration: none;
  color: var(--text);
  font-size: 14px;
  transition: background 0.2s;
}

.recent-link:hover {
  background: #f5f5f7;
}

.recent-timestamp {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

/* =========================================
   Apple-Like Editor Layout
   ========================================= */

.app-layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: #fff;
}

.app-toolbar {
  height: 52px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 16px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(0,0,0,0.1);
  flex-shrink: 0;
  z-index: 100;
}

.toolbar-left, .toolbar-center, .toolbar-right {
  display: flex;
  align-items: center;
}

.toolbar-left {
  gap: 12px;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: #1d1d1f;
  font-weight: 600;
}

.brand-icon {
  background: linear-gradient(135deg, #0071e3, #42a5f5);
  color: #fff;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
}

.divider-vertical {
  width: 1px;
  height: 16px;
  background: #d2d2d7;
}

.doc-info {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.doc-label {
  font-size: 10px;
  color: #86868b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.doc-id {
  font-family: 'SF Mono', 'Roboto Mono', monospace;
  font-size: 12px;
  color: #1d1d1f;
}

/* Status Indicator */
.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #d2d2d7; /* connecting/default */
  transition: background-color 0.3s ease;
}

/* These classes are toggled by JS on .status-pill (reused ID) */
#connectionStatus.connected {
  background-color: #34c759;
}
#connectionStatus.reconnecting {
  background-color: #ff9500;
}
#connectionStatus.locked {
  background-color: #ff3b30;
}
/* Hide text content of the div since we just want the dot */
#connectionStatus {
  font-size: 0;
  color: transparent;
}

.collaborator-badge {
    margin-left: 8px;
    font-size: 11px;
    color: #86868b;
    background: rgba(0,0,0,0.05);
    padding: 2px 8px;
    border-radius: 99px;
    font-weight: 500;
    cursor: default;
    display: none;
}

.collaborator-badge.visible {
    display: flex;
    align-items: center;
    gap: 4px;
}

.collaborator-badge::before {
    content: '';
    display: none;
    width: 6px;
    height: 6px;
    background-color: #34c759;
    border-radius: 50%;
}


.toolbar-right {
  gap: 4px;
}

.tool-btn {
  background: transparent;
  border: none;
  border-radius: 6px;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  color: #1d1d1f;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.2s;
  text-decoration: none; /* Ensure links look like buttons */
}

.tool-btn:hover, .settings-trigger:hover {
  background: rgba(0,0,0,0.05);
}

.tool-btn svg {
  color: #515154;
}

.settings-menu-wrapper {
  position: relative;
}

.settings-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  width: 260px;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  border: 1px solid rgba(0,0,0,0.1);
  padding: 12px;
  display: none; /* hidden by default */
  flex-direction: column;
  gap: 8px;
  z-index: 200;
}

.settings-dropdown.active {
  display: flex;
}

.dropdown-header {
  font-size: 11px;
  font-weight: 600;
  color: #86868b;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.settings-form {
  display: flex;
  gap: 4px;
}

.settings-input {
  flex: 1;
  border: 1px solid #d2d2d7;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 12px;
}

.btn-micro {
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid #d2d2d7;
  background: #fff;
  cursor: pointer;
}

.btn-danger-text {
  color: #ff3b30;
  border-color: #ff3b30;
  width: 100%;
  margin-top: 4px;
}

.dropdown-divider {
  height: 1px;
  background: #e5e5e5;
  margin: 4px 0;
}

.info-row {
  display: flex;
  justify-content: space-between;
}

.info-text {
  font-size: 11px;
  color: #86868b;
}

/* Editor Area */
.editor-main {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  max-width: 900px !important; /* Overriding previous max-width */
  margin: 0 auto;
  width: 100%;
  padding: 24px 24px 0 !important;
  overflow-y: auto; /* Enable scrolling */
  min-height: 0; /* Override .editor-shell min-height to allow flex container to handle height */
}

.editor-textarea {
  flex: 1;
  width: 100%;
  border: none !important;
  box-shadow: none !important;
  background: transparent !important;
  resize: none !important;
  outline: none !important;
  font-family: 'SF Mono', 'Menlo', 'Monaco', 'Courier New', monospace !important;
  font-size: 15px;
  line-height: 1.6;
  padding: 0;
  margin-bottom: 24px;
}

.editor-feedback-container {
  min-height: 24px;
  margin-bottom: 12px;
}

.feedback-toast {
  font-size: 12px;
  color: #86868b;
  transition: opacity 0.3s;
}
.feedback-toast.error {
  color: #ff3b30;
}



/* WYSIWYG Editor Styles */
.editor-toolbar {
  position: sticky;
  top: 0; /* Stick to top of scrollable .editor-main */
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 8px;
  z-index: 90;
}

.toolbar-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  font-weight: 600;
  font-family: inherit;
  font-size: 14px;
  transition: all 0.2s ease;
}

.toolbar-btn:hover {
  background: rgba(0,0,0,0.05);
}

.toolbar-btn svg {
  width: 16px;
  height: 16px;
  stroke-width: 2px;
}

.editor-content {
  flex: 1;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 40px 20px;
  outline: none;
  font-size: 18px;
  line-height: 1.6;
  min-height: 60vh;
}

.editor-content:empty:before {
  content: attr(placeholder);
  color: var(--muted);
}

/* Mobile Menu Implementation */
.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.mobile-menu-toggle {
  display: none;
  background: transparent;
  border: none;
  padding: 8px;
  cursor: pointer;
  color: #1d1d1f;
  margin-left: auto;
}

@media (max-width: 768px) {
  .app-toolbar {
    position: relative;
    padding-right: 12px; /* Ensure space for hamburger */
  }

  .toolbar-right {
    position: static; /* Allows absolute children to reference .app-toolbar */
  }

  .mobile-menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .nav-links {
    display: none;
  }

  /* Make sure toolbar actions stack vertically on mobile */
  .toolbar-actions {
    display: none;
    position: absolute;
    top: 100%; 
    left: 0;
    right: 0;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(0,0,0,0.1);
    padding: 16px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.12);
    align-items: stretch; /* Full width items */
    gap: 8px;
    z-index: 1000;
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: none; /* Prevent clicks when hidden */
  }

  .toolbar-actions.active {
    display: flex;
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
  }

  .tool-btn {
    width: 100%;
    justify-content: flex-start;
    padding: 12px;
    border-radius: 8px;
    background: rgba(0,0,0,0.02);
  }

  .tool-btn:hover {
    background: rgba(0,0,0,0.05);
  }

  /* Settings specifically */
  .settings-menu-wrapper {
    width: 100%;
  }

  .settings-trigger {
    width: 100%;
    justify-content: space-between;
    background: rgba(0,0,0,0.02);
    padding: 12px;
    border-radius: 8px;
  }

  .settings-dropdown {
    position: static;
    width: 100%;
    margin-top: 8px;
    background: transparent;
    box-shadow: none;
    border: 1px solid rgba(0,0,0,0.1);
    padding: 12px;
  }
}

