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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  color: #222;
  background: #fafafa;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.layout { display: flex; flex-direction: column; height: 100vh; }

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  background: #fff;
  border-bottom: 1px solid #e5e5e5;
  flex-shrink: 0;
}
.topbar h1 { font-size: 16px; font-weight: 600; white-space: nowrap; }
.search-form { display: flex; gap: 6px; flex: 1; max-width: 360px; }
.search-form input {
  flex: 1; padding: 6px 10px; border: 1px solid #ddd;
  border-radius: 6px; font-size: 13px; outline: none;
}
.search-form input:focus { border-color: #888; }
.search-form button {
  padding: 6px 10px; border: 1px solid #ddd; background: #fff;
  border-radius: 6px; cursor: pointer;
}
.count { font-size: 12px; color: #888; white-space: nowrap; }

.panels { display: flex; flex: 1; overflow: hidden; }

.panel-left {
  width: 260px;
  flex-shrink: 0;
  border-right: 1px solid #e5e5e5;
  background: #fff;
  overflow-y: auto;
}

.panel-right {
  flex: 1;
  padding: 24px 32px;
  overflow-y: auto;
  background: #fafafa;
}

/* ── Note list items ── */
.note-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 16px;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  transition: background 0.1s;
}
.note-item:hover { background: #f5f5f5; }
.note-item.failed { opacity: 0.6; }

.note-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.note-title {
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.note-status { font-size: 13px; width: 16px; text-align: center; color: #666; flex-shrink: 0; }

.note-item-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}
.note-date { font-size: 11px; color: #999; }
.note-duration { font-size: 11px; color: #bbb; }

.user-badge {
  font-size: 10px;
  color: #888;
  background: #f0f0f0;
  border-radius: 4px;
  padding: 1px 5px;
  font-weight: 500;
}

.note-item-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 2px;
}
.tag-chip-sm {
  font-size: 10px;
  color: #666;
  background: #f0f4ff;
  border-radius: 10px;
  padding: 1px 6px;
}

.empty-list { padding: 20px 16px; color: #999; font-size: 13px; }

/* ── Detail panel ── */
.detail-header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.detail-header h2 { font-size: 15px; font-weight: 600; }

.badge {
  padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 500;
  flex-shrink: 0;
}
.badge-done { background: #d4edda; color: #155724; }
.badge-failed { background: #f8d7da; color: #721c24; }
.badge-pending, .badge-processing { background: #fff3cd; color: #856404; }

.note-summary {
  font-size: 13px;
  color: #555;
  line-height: 1.6;
  margin-bottom: 10px;
}

.note-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}
.tag-chip {
  font-size: 12px;
  color: #4a6fa5;
  background: #eef2fb;
  border-radius: 12px;
  padding: 3px 10px;
  text-decoration: none;
  cursor: pointer;
}
.tag-chip:hover { background: #dce6f7; }

.audio-player {
  display: flex; align-items: center; gap: 12px;
  background: #fff; border: 1px solid #e5e5e5;
  border-radius: 8px; padding: 12px 16px; margin-bottom: 16px;
}
.audio-player audio { flex: 1; height: 32px; }
.duration { font-size: 12px; color: #888; }

.transcript-actions { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.btn {
  padding: 6px 14px; border: 1px solid #ddd; background: #fff;
  border-radius: 6px; cursor: pointer; font-size: 13px;
  transition: background 0.1s;
}
.btn:hover { background: #f0f0f0; }
.btn-secondary { color: #555; }

.transcript-body {
  background: #fff; border: 1px solid #e5e5e5; border-radius: 8px;
  padding: 16px 20px; line-height: 1.7; white-space: pre-wrap;
  font-size: 14px; color: #333; margin-bottom: 10px;
  min-height: 120px;
}
.transcript-meta { font-size: 11px; color: #aaa; }
.no-transcript { padding: 20px 0; color: #888; }
.empty-state { padding: 40px 20px; color: #999; text-align: center; }

.similar-notes-section { margin-top: 28px; }
.similar-notes-section h4 { font-size: 13px; font-weight: 600; color: #888; margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.04em; }
.similar-notes-list { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.similar-notes-list li { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.similar-notes-list a { font-size: 13px; color: #4a6fa5; text-decoration: none; }
.similar-notes-list a:hover { text-decoration: underline; }
.similar-notes-list .note-date { font-size: 11px; color: #bbb; }

/* Back button — desktop: hidden; mobile: shown */
.mobile-back { display: none; }


/* ═══════════════════════════════════════════
   MOBILE  (iPhone 12 = 390 × 844)
   ═══════════════════════════════════════════ */
@media (max-width: 600px) {

  body { font-size: 15px; }

  /* Topbar: tighter, search takes all remaining space */
  .topbar {
    padding: 10px 14px;
    gap: 8px;
  }
  .topbar h1 { display: none; }
  .search-form { max-width: none; flex: 1; }
  .search-form input { font-size: 15px; padding: 8px 10px; }
  .search-form button { padding: 8px 10px; font-size: 15px; }
  .count { display: none; }

  /* Two-panel → single-panel slide */
  .panels { position: relative; overflow: hidden; }

  .panel-left {
    width: 100%;
    border-right: none;
    overflow-y: auto;
    /* full height of panels area */
    position: absolute;
    inset: 0;
    transition: transform 0.28s ease;
    z-index: 1;
  }

  .panel-right {
    padding: 16px;
    position: absolute;
    inset: 0;
    width: 100%;
    overflow-y: auto;
    background: #fafafa;
    transform: translateX(100%);
    transition: transform 0.28s ease;
    z-index: 2;
  }

  /* When a note is open, slide detail in and list out */
  .panels.mobile-detail-open .panel-left  { transform: translateX(-30%); }
  .panels.mobile-detail-open .panel-right { transform: translateX(0); }

  /* Back button */
  .mobile-back {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    color: #4a6fa5;
    font-size: 15px;
    font-weight: 500;
    padding: 0 0 16px 0;
    cursor: pointer;
  }

  /* Note list items: bigger tap targets */
  .note-item {
    padding: 14px 16px;
    gap: 5px;
  }
  .note-title { font-size: 14px; white-space: normal; }
  .note-date, .note-duration { font-size: 12px; }
  .note-status { font-size: 14px; }

  /* Detail: full-width audio player */
  .audio-player {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 12px;
  }
  .audio-player audio { width: 100%; height: 36px; }

  /* Bigger action buttons (easier to tap) */
  .transcript-actions { gap: 10px; }
  .btn { padding: 10px 16px; font-size: 15px; }

  /* Transcript text: comfortable reading size */
  .transcript-body {
    font-size: 15px;
    line-height: 1.75;
    padding: 14px;
  }

  /* Summary and tags */
  .note-summary { font-size: 14px; }
  .tag-chip { font-size: 13px; padding: 5px 12px; }

  /* Detail header: allow title to wrap */
  .detail-header h2 { font-size: 15px; white-space: normal; }

  .similar-notes-section { margin-top: 24px; }
}
