:root {
  --navy: #09136C;
  --red: #C40606;
  --bg: #f6f4f0;
  --surface: #ffffff;
  --text: #1a1a1a;
  --text-muted: #666;
  --border: #ddd;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.brand-copywaste { color: var(--navy); }
.brand-notes { color: var(--red); }

a { color: var(--navy); text-decoration: none; }
a:hover { text-decoration: underline; }

.centered-page {
  max-width: 420px;
  margin: 15vh auto;
  padding: 2rem;
  text-align: center;
}

.button {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 1rem;
  border: none;
  cursor: pointer;
}
.button-primary {
  background: var(--navy);
  color: #fff;
}
.button-primary:hover { background: #0c1a8c; text-decoration: none; }
.button:disabled { opacity: 0.55; cursor: default; }

.button-secondary {
  background: var(--surface);
  color: var(--navy);
  border: 1px solid var(--navy);
}
.button-secondary:hover { background: #eef0fb; text-decoration: none; }

.button-secondary {
  background: var(--surface);
  color: var(--navy);
  border: 1px solid var(--navy);
}
.button-secondary:hover { background: #eef0fb; text-decoration: none; }

.link-button {
  background: none;
  border: none;
  color: var(--navy);
  cursor: pointer;
  font: inherit;
  padding: 0;
  text-decoration: underline;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 1.25rem; margin: 0; }
.account { display: flex; align-items: center; gap: 0.75rem; font-size: 0.9rem; color: var(--text-muted); }

/* Account menu: the signed-in name in the top-right, opening a small
   Settings / Sign out menu. */
.account-menu { position: relative; }

.account-trigger {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.6rem;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--navy);
  /* Drop the native disclosure triangle - we draw our own caret. */
  list-style: none;
}
.account-trigger::-webkit-details-marker { display: none; }
.account-trigger:hover { background: #eef0fb; }
.account-menu[open] .account-trigger { background: #eef0fb; }

.account-name { max-width: 14rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-caret { flex: 0 0 auto; transition: transform 0.15s ease; }
.account-menu[open] .account-caret { transform: rotate(180deg); }

/* Kept `display: none` by default and only shown via [open]: a <details>
   child with an unconditional `display` can render even while the element
   is closed, the same cascade trap that kept the folder picker on screen. */
.account-dropdown { display: none; }
.account-menu[open] .account-dropdown {
  display: flex;
  flex-direction: column;
  position: absolute;
  right: 0;
  top: calc(100% + 0.4rem);
  min-width: 13rem;
  padding: 0.35rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  z-index: 30;
}
.account-email {
  padding: 0.5rem 0.6rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.35rem;
  overflow-wrap: anywhere;
}
.account-dropdown a,
.account-signout {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.55rem 0.6rem;
  border: none;
  border-radius: 6px;
  background: none;
  font: inherit;
  font-size: 0.9rem;
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
}
.account-dropdown a:hover,
.account-signout:hover { background: #eef0fb; text-decoration: none; }
.account-signout { color: var(--red); }

.back-link { font-weight: 600; }

.title-form { flex: 1 1 auto; min-width: 0; }
.title-input {
  width: 100%;
  border: none;
  border-bottom: 1px solid transparent;
  background: transparent;
  font-size: 1.1rem;
  font-weight: 700;
  font-family: inherit;
  color: inherit;
  padding: 0.15rem 0;
}
.title-input::placeholder { color: var(--text-muted); font-weight: 400; }
.title-input:hover, .title-input:focus { border-bottom-color: var(--border); }
.title-input:focus { outline: none; }

.record-section {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem;
  flex-wrap: wrap;
}
.record-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.9rem 1.75rem;
  border-radius: 999px;
  border: none;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  background: var(--navy);
  cursor: pointer;
  min-width: 180px;
}
.record-btn[data-state="recording"] {
  background: var(--red);
}
.record-btn:disabled { opacity: 0.6; cursor: default; }
.record-btn .icon { flex: 0 0 auto; }
.record-btn .icon-stop { display: none; }
.record-btn[data-state="recording"] .icon-mic { display: none; }
.record-btn[data-state="recording"] .icon-stop { display: inline-block; }
.record-timer {
  font-variant-numeric: tabular-nums;
  color: var(--red);
  font-weight: 600;
}
.record-error { color: var(--red); font-size: 0.9rem; }

.new-note-form { margin: 0; }
.new-note-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  padding: 0.9rem 1.5rem;
  border-radius: 999px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1.25rem 1rem;
}
.filters-label { font-weight: 600; color: var(--text-muted); }
.filter-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.95rem;
}

#notes-table-wrap { padding: 0 1.25rem 2rem; overflow-x: auto; }
.notes-table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; }
.notes-table th, .notes-table td { padding: 0.75rem; text-align: left; border-bottom: 1px solid var(--border); font-size: 0.95rem; }
.notes-table th a { color: inherit; font-weight: 700; }
.empty-row { text-align: center; color: var(--text-muted); padding: 2rem !important; }

.status-select {
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 0.85rem;
  font-weight: 600;
  background: #eee;
}
.status-open { background: #dbe7fb; }
.status-in_progress { background: #fdecc8; }
.status-todo { background: #ecdcf7; }
.status-closed { background: #dcf0dc; }

.detail-meta { display: flex; gap: 1rem; padding: 0 1.25rem; color: var(--text-muted); font-size: 0.9rem; flex-wrap: wrap; }
.processing-note { padding: 0 1.25rem; color: var(--navy); }
.processing-error { padding: 0 1.25rem; color: var(--red); }

.status-form { padding: 1rem 1.25rem; }
.status-form select { padding: 0.4rem 0.6rem; border-radius: 8px; border: 1px solid var(--border); }

.audio-player { display: block; width: calc(100% - 2.5rem); margin: 0 1.25rem 1.5rem; }

.transcript-form { padding: 0 1.25rem 2rem; display: flex; flex-direction: column; gap: 0.75rem; }
.transcript-form textarea {
  width: 100%;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9rem;
  padding: 0.75rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  resize: vertical;
}
.transcript-actions { display: flex; align-items: center; gap: 0.75rem; }
.autosave-status { font-size: 0.85rem; color: var(--text-muted); }
.autosave-status-error { color: var(--red); }

@media (max-width: 600px) {
  .topbar { padding: 0.85rem 1rem; }
  .filters, #notes-table-wrap, .transcript-form, .detail-meta, .status-form { padding-left: 1rem; padding-right: 1rem; }
  .notes-table th, .notes-table td { padding: 0.5rem; font-size: 0.85rem; }

  /* Same round, icon-only record button as the Android app, pinned to the
     bottom of the screen instead of sitting inline with the page content. */
  body { padding-bottom: 96px; }
  .record-section {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    margin: 0;
    justify-content: center;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 0.75rem 1rem;
  }
  .record-btn {
    width: 64px;
    height: 64px;
    min-width: 0;
    flex: 0 0 auto;
    padding: 0;
    border-radius: 50%;
  }
  .record-btn .icon { width: 26px; height: 26px; }
  .record-label { display: none; }

  /* Same icon-only treatment as the record button, so it fits the fixed
     bottom bar alongside it instead of pushing it off-center. */
  .new-note-btn {
    width: 64px;
    height: 64px;
    min-width: 0;
    flex: 0 0 auto;
    padding: 0;
    border-radius: 50%;
    justify-content: center;
  }
  .new-note-btn span { display: none; }
}

/* --- Settings page (Phase 4: Save to Google Drive) --- */
.settings-section { padding: 1.25rem; max-width: 720px; }
.settings-heading { font-size: 1.05rem; margin: 0 0 0.35rem; }
.settings-help { color: var(--text-muted); font-size: 0.9rem; margin: 0 0 1rem; }
.settings-toggle { display: flex; align-items: center; gap: 0.5rem; font-weight: 600; margin-bottom: 1rem; }
.settings-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.85rem 0;
  border-top: 1px solid var(--border);
}
.settings-label { font-weight: 600; color: var(--text-muted); }
.chosen-folder { flex: 1 1 auto; min-width: 0; }
.settings-actions { display: flex; align-items: center; gap: 0.75rem; padding-top: 1rem; flex-wrap: wrap; }
.settings-status { font-size: 0.9rem; color: var(--text-muted); }
.settings-error { color: var(--red); font-size: 0.9rem; }

.folder-picker {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 20;
}
/* The `display: flex` above is an author rule, so it outranks the browser
   default stylesheet's `[hidden] { display: none }` - without this the
   overlay is permanently on screen and its backdrop eats every click. */
.folder-picker[hidden] { display: none; }
.folder-picker-panel {
  background: var(--surface);
  border-radius: var(--radius);
  width: min(460px, 100%);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  padding: 1rem;
  gap: 0.75rem;
}
.folder-picker-header { display: flex; align-items: center; gap: 0.75rem; }
.folder-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1 1 auto; min-height: 120px; }
.folder-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 0.6rem 0.25rem;
  font: inherit;
  cursor: pointer;
}
.folder-item:hover { background: #f2f4fb; }
.folder-item::before { content: "📁"; margin-right: 0.5rem; }
.folder-empty { color: var(--text-muted); font-size: 0.9rem; padding: 0.6rem 0.25rem; }
.folder-picker-new { display: flex; gap: 0.5rem; }
.folder-picker-new input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
}
.folder-picker-actions { display: flex; justify-content: flex-end; align-items: center; gap: 0.75rem; }
