/*
  GemNotes Web App Stylesheet
  ──────────────────────────────────────────
  Shared design identity with GemNotes Chrome Extension.
  Color tokens (--paper, --ink, --accent, etc.) are defined in themes.css.
*/

:root {
  /* Typography */
  --serif: 'Fraunces', Georgia, serif;
  --sans:  'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --mono:  'JetBrains Mono', monospace;

  /* Source badge soft variants */
  --src-web-soft:       #E3EEEC;
  --src-curso-soft:     #F3EAD4;
  --src-x-soft:         #E9E9E7;
  --src-youtube-soft:   #F5E4E1;
  --src-instagram-soft: #F3E2EC;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a {
  color: inherit;
  text-decoration: none;
}

::selection {
  background: var(--accent-soft);
  color: var(--accent);
}

.hidden {
  display: none !important;
}

/* ─── App Shell & Header ───────────────────────────────────────────────────── */
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--paper);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  background: var(--paper-raised);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  text-decoration: none;
}

.brand-mark {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  position: relative;
  flex-shrink: 0;
}

.brand-mark::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
}

.brand-title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 18px;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.header-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 7px 12px;
  color: var(--ink-faint);
  font-size: 13px;
  flex: 1;
  max-width: 480px;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.header-search:focus-within {
  border-color: var(--accent);
  background: var(--paper-raised);
}

.header-search svg {
  flex-shrink: 0;
}

.header-search input {
  border: none;
  background: transparent;
  outline: none;
  width: 100%;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--ink);
}

.header-search input::placeholder {
  color: var(--ink-faint);
}

.header-search kbd {
  font-family: var(--mono);
  font-size: 10px;
  padding: 2px 5px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--paper-raised);
  color: var(--ink-faint);
  margin-left: auto;
  flex-shrink: 0;
}

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

.user-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 500;
  padding: 6px 10px;
  background: var(--paper);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  color: var(--ink-soft);
}

.user-badge svg {
  color: var(--accent);
}

/* ─── Buttons ──────────────────────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--ink);
  color: var(--paper);
  border: none;
  border-radius: var(--radius);
  padding: 7px 14px;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.btn-primary:hover {
  opacity: 0.88;
}

.btn-primary.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 7px 12px;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-ghost:hover {
  background: var(--paper);
  color: var(--ink);
  border-color: var(--line-strong);
}

.btn-ghost.btn-sm {
  padding: 4px 8px;
  font-size: 12px;
}

.btn-icon {
  padding: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ─── Main Layout ──────────────────────────────────────────────────────────── */
.main-layout {
  display: flex;
  flex: 1;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 24px;
  gap: 32px;
}

/* ─── Left Sidebar Navigation ──────────────────────────────────────────────── */
.sidebar-nav {
  width: 240px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.nav-section {
  display: flex;
  flex-direction: column;
}

.nav-heading {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding: 0 6px;
  margin-bottom: 6px;
  font-weight: 600;
}

.nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 9px;
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-item:hover {
  background: var(--paper-raised);
  color: var(--ink);
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.nav-item.active .count {
  color: var(--accent);
}

.nav-item.active .square {
  background: var(--accent);
}

.nav-item .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.nav-item .square {
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: var(--ink-faint);
  flex-shrink: 0;
}

.nav-item .count {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-faint);
}

.dot.src-web, .nav-item.src-web .dot { background: var(--src-web); }
.dot.src-curso, .nav-item.src-curso .dot { background: var(--src-curso); }
.dot.src-x, .nav-item.src-x .dot { background: var(--src-x); }
.dot.src-youtube, .nav-item.src-youtube .dot { background: var(--src-youtube); }
.dot.src-instagram, .nav-item.src-instagram .dot { background: var(--src-instagram); }

.tag-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 4px;
}

.tag-pill {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 3px 7px;
  background: var(--paper-raised);
  cursor: pointer;
  transition: all 0.15s ease;
}

.tag-pill:hover, .tag-pill.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

/* ─── Main Feed & Strand (Timeline) ────────────────────────────────────────── */
.feed-column {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.feed-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding-bottom: 12px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.feed-header h1 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 22px;
  color: var(--ink);
  margin: 0;
}

.feed-header .feed-count {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--ink-faint);
}

.strand {
  padding: 4px 0 32px;
}

.gem-row {
  display: grid;
  grid-template-columns: 20px 1fr;
  column-gap: 14px;
  position: relative;
}

.thread-col {
  position: relative;
  display: flex;
  justify-content: center;
}

.thread-col::before {
  content: '';
  position: absolute;
  top: 8px;
  bottom: -8px;
  width: 1px;
  background: var(--line-strong);
}

.gem-row:last-child .thread-col::before {
  bottom: 50%;
}

.pearl-dot {
  position: relative;
  z-index: 1;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 18px;
  border: 2px solid var(--paper);
  box-shadow: 0 0 0 1px var(--line);
}

.pearl-dot.src-web { background: var(--src-web); }
.pearl-dot.src-curso { background: var(--src-curso); }
.pearl-dot.src-x { background: var(--src-x); }
.pearl-dot.src-youtube { background: var(--src-youtube); }
.pearl-dot.src-instagram { background: var(--src-instagram); }

.gem-card {
  padding: 14px 16px 18px;
  border-bottom: 1px solid var(--line);
  border-radius: var(--radius);
  transition: background 0.15s ease;
  cursor: pointer;
}

.gem-card:hover {
  background: var(--paper-raised);
}

.gem-meta-top {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}

.source-tag {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-weight: 500;
}

.source-tag.src-web { background: var(--src-web-soft); color: var(--src-web); }
.source-tag.src-curso { background: var(--src-curso-soft); color: var(--src-curso); }
.source-tag.src-x { background: var(--src-x-soft); color: var(--src-x); }
.source-tag.src-youtube { background: var(--src-youtube-soft); color: var(--src-youtube); }
.source-tag.src-instagram { background: var(--src-instagram-soft); color: var(--src-instagram); }

.cat-badge {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 2px 6px;
  background: var(--paper);
}

.gem-domain {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-faint);
}

.gem-date {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-faint);
}

.gem-header-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.gem-header-row .gem-title {
  margin-bottom: 0;
  flex: 1;
}

.gem-header-row .gem-date {
  margin-left: auto;
  flex-shrink: 0;
}

.gem-source-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.gem-title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.005em;
  color: var(--ink);
  line-height: 1.35;
  word-break: break-word;
  overflow-wrap: break-word;
}

.gem-content {
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
  overflow-wrap: break-word;
}

.gem-note {
  display: flex;
  gap: 8px;
  background: var(--paper);
  border-left: 2px solid var(--accent);
  padding: 8px 12px;
  margin-bottom: 8px;
  border-radius: 0 var(--radius) var(--radius) 0;
  word-break: break-word;
  overflow-wrap: break-word;
}

.gem-note .label {
  font-family: var(--mono);
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  flex-shrink: 0;
  padding-top: 1px;
  font-weight: 600;
}

.gem-note p {
  font-size: 12.5px;
  color: var(--ink);
  font-style: italic;
  margin: 0;
  line-height: 1.4;
  word-break: break-word;
  overflow-wrap: break-word;
}

.gem-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.gem-category-tag {
  display: flex;
  margin-top: 6px;
  margin-bottom: 2px;
}

.gem-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.gem-tags .tag-pill {
  font-size: 9.5px;
  padding: 1px 5px;
}

.gem-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  flex-shrink: 0;
}

.gem-actions .action-btn,
.gem-actions span, 
.gem-actions a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-faint);
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}

.gem-actions .action-btn:hover,
.gem-actions span:hover, 
.gem-actions a:hover {
  background: var(--paper-raised);
  color: var(--ink);
  border-color: var(--line);
}

.gem-actions .action-delete:hover {
  background: #FDF2F1 !important;
  color: #B23A2E !important;
  border-color: rgba(178, 58, 46, 0.2) !important;
}

.empty-state {
  text-align: center;
  color: var(--ink-faint);
  font-style: italic;
  padding: 48px 16px;
  font-size: 14px;
  background: var(--paper-raised);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  margin-top: 12px;
}

/* ─── Modals & Dialogs ─────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(18, 18, 16, 0.45);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-card {
  background: var(--paper-raised);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  width: 100%;
  max-width: 520px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  overflow: hidden;
  animation: scaleUp 0.15s ease;
}

@keyframes scaleUp {
  from { transform: scale(0.97); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--paper-raised);
}

.modal-head h3 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 18px;
  color: var(--ink);
  margin: 0;
}

.btn-close {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--ink-faint);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: color 0.15s ease;
}

.btn-close:hover {
  color: var(--ink);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  background: var(--paper);
}

/* ─── Form Elements ────────────────────────────────────────────────────────── */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  display: block;
  font-family: var(--mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  font-weight: 600;
}

.field-input {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 11px;
  font-family: var(--sans);
  font-size: 13.5px;
  color: var(--ink);
  background: var(--paper);
  width: 100%;
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.field-input:focus {
  border-color: var(--accent);
  background: var(--paper-raised);
}

.field-input.title-input {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 17px;
  padding: 10px 12px;
}

.field-input.mono {
  font-family: var(--mono);
  font-size: 12.5px;
}

textarea.field-input {
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
}

.cat-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.cat-pill {
  font-size: 12px;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 4px 10px;
  background: var(--paper);
  cursor: pointer;
  transition: all 0.15s ease;
}

.cat-pill:hover {
  border-color: var(--ink-soft);
  color: var(--ink);
}

.cat-pill.active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
  font-weight: 600;
}

.cat-pill.cat-add {
  color: var(--accent);
  border-style: dashed;
  border-color: var(--line-strong);
  background: transparent;
}

.tag-input-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.selected-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 24px;
}

.selected-tag {
  font-family: var(--mono);
  font-size: 11px;
  background: var(--accent);
  color: var(--paper);
  border-radius: var(--radius);
  padding: 3px 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
}

.selected-tag .remove-tag {
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  font-weight: bold;
  opacity: 0.8;
  transition: opacity 0.1s ease;
}

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

.existing-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.existing-tags .tag-pill {
  font-size: 10px;
  padding: 2px 6px;
  background: var(--paper);
}

/* ─── Auth Modal Tabs ──────────────────────────────────────────────────────── */
.auth-tabs {
  display: flex;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
}

.tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  padding: 10px;
  font-weight: 600;
  font-size: 13px;
  color: var(--ink-soft);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s ease;
}

.tab-btn.active {
  color: var(--ink);
  border-bottom-color: var(--ink);
}

/* ─── Settings & Themes ────────────────────────────────────────────────────── */
.settings-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
}

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

.theme-options-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.theme-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: all 0.15s ease;
}

.theme-card:hover {
  border-color: var(--accent);
}

.theme-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
  background: var(--paper-raised);
}

.theme-card-name {
  font-weight: 600;
  font-size: 12.5px;
  color: var(--ink);
}

.theme-card-desc {
  font-size: 10.5px;
  color: var(--ink-soft);
  line-height: 1.3;
}

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

.shortcut-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  color: var(--ink-soft);
}

kbd {
  font-family: var(--mono);
  font-size: 11px;
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 2px 7px;
  border-radius: 4px;
  color: var(--ink);
}

.settings-msg {
  font-size: 12px;
  margin-top: 8px;
  padding: 7px 10px;
  border-radius: var(--radius);
}

.settings-msg.success {
  background: var(--accent-soft);
  color: var(--accent);
}

.settings-msg.error {
  background: #FDF2F1;
  color: #B23A2E;
}

.form-error {
  font-size: 12px;
  color: #B23A2E;
  background: #FDF2F1;
  padding: 8px 12px;
  border-radius: var(--radius);
  border: 1px solid rgba(178, 58, 46, 0.2);
}

/* ─── Detail View Modal ────────────────────────────────────────────────────── */
.detail-head-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.detail-head-meta .detail-title {
  margin-bottom: 0;
  flex: 1;
}

.detail-head-meta .gem-date {
  margin-left: auto;
  flex-shrink: 0;
}

.detail-source-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  margin-bottom: 4px;
}

.detail-title {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.35;
}

.detail-url-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-soft);
  word-break: break-all;
}

.detail-url-box a {
  color: var(--accent);
  text-decoration: underline;
  margin-left: auto;
  white-space: nowrap;
}

.detail-note-block {
  background: var(--paper);
  border-left: 3px solid var(--accent);
  padding: 12px 16px;
  border-radius: 0 var(--radius) var(--radius) 0;
}

.detail-note-block .label {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  font-weight: 600;
  display: block;
  margin-bottom: 4px;
}

.detail-note-block p {
  font-size: 13.5px;
  color: var(--ink);
  font-style: italic;
  line-height: 1.5;
  white-space: pre-wrap;
}

.detail-category-row {
  display: flex;
  margin-top: 10px;
  margin-bottom: 6px;
}

.detail-tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* ─── Toast Notifications ──────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background: var(--ink);
  color: var(--paper);
  font-size: 13px;
  font-weight: 500;
  padding: 10px 16px;
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: slideToast 0.2s ease;
}

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

.toast.toast-error {
  background: #B23A2E;
  color: #fff;
}

/* ─── Responsive Media Queries (Mobile & iPad / Tablet) ────────────────────── */

/* Tablets / iPads (Portrait & Landscape <= 960px) */
@media (max-width: 960px) {
  .main-layout {
    flex-direction: column;
    padding: 16px;
    gap: 16px;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .sidebar-nav {
    width: 100%;
    border-bottom: 1px solid var(--line);
    padding-bottom: 12px;
    gap: 12px;
  }

  .nav-section {
    gap: 4px;
  }

  .nav-heading {
    padding: 0 2px;
    margin-bottom: 4px;
    font-size: 9.5px;
  }

  /* Make list filters scroll horizontally as smooth chips on tablets */
  .nav-list {
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 6px;
    padding-bottom: 4px;
    scrollbar-width: none;
  }

  .nav-list::-webkit-scrollbar {
    display: none;
  }

  .nav-item {
    white-space: nowrap;
    flex-shrink: 0;
    padding: 5px 10px;
    font-size: 12px;
    background: var(--paper);
    border: 1px solid var(--line);
  }

  .nav-item.active {
    border-color: var(--accent);
  }

  .tag-pills {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 6px;
    padding: 2px 0 4px;
    scrollbar-width: none;
  }

  .tag-pills::-webkit-scrollbar {
    display: none;
  }

  .tag-pill {
    flex-shrink: 0;
    white-space: nowrap;
  }

  .theme-options-grid {
    grid-template-columns: 1fr;
  }
}

/* Mobile Phones (<= 768px) */
@media (max-width: 768px) {
  .app-header {
    padding: 10px 14px;
    gap: 8px;
  }

  /* Hide app title on mobile to maximize available space */
  .brand-title {
    display: none;
  }

  .brand {
    gap: 0;
    padding: 4px 0;
  }

  .brand-mark {
    width: 22px;
    height: 22px;
  }

  .brand-mark::after {
    width: 6px;
    height: 6px;
    top: 3px;
    left: 3px;
  }

  .header-search {
    padding: 6px 10px;
    font-size: 13px;
    max-width: none;
  }

  .header-search kbd {
    display: none;
  }

  /* Hide username string on mobile header badge to conserve space */
  .user-badge span {
    display: none;
  }

  .user-badge {
    padding: 6px 8px;
  }

  .header-actions {
    gap: 6px;
  }

  #btn-logout {
    display: none;
  }

  .btn-primary {
    padding: 6px 10px;
    font-size: 12.5px;
  }

  .feed-header h1 {
    font-size: 18px;
  }

  .gem-row {
    grid-template-columns: 14px 1fr;
    column-gap: 10px;
  }

  .pearl-dot {
    width: 8px;
    height: 8px;
    margin-top: 14px;
  }

  .thread-col::before {
    left: 50%;
  }

  .gem-card {
    padding: 12px 14px;
    min-width: 0;
  }

  .gem-meta-top {
    flex-wrap: wrap;
    gap: 4px 6px;
    font-size: 11px;
  }

  .gem-domain {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .gem-title {
    font-size: 15px;
  }

  .gem-note {
    font-size: 12.5px;
    padding: 8px 10px;
    margin: 8px 0;
  }

  .gem-actions {
    gap: 10px;
  }

  /* Modal on Mobile (Bottom-Sheet / Safe Area) */
  .modal-overlay {
    padding: 12px 8px;
    align-items: flex-end;
  }

  .modal-card {
    padding: 16px 14px;
    border-radius: var(--radius) var(--radius) 0 0;
    max-height: 90vh;
    width: 100%;
    margin-bottom: env(safe-area-inset-bottom, 0px);
  }

  .modal-header h2 {
    font-size: 17px;
  }

  /* Ensure inputs have 16px font size to prevent iOS Safari auto-zoom */
  .field-input,
  .title-input,
  input[type="text"],
  input[type="search"],
  input[type="email"],
  input[type="password"],
  textarea {
    font-size: 16px !important;
  }
}
