:root {
  --brand: #c2410c;
  --brand-2: #f59e0b;
  --radius: 16px;
}

[data-bs-theme="light"] {
  --app-bg: #f8f5f0;
  --card-bg: #ffffff;
  --soft-border: #e8e1d6;
  --muted-bg: #f1ebe2;
  --brand-text: #9a3412;
  --shadow: 0 1px 2px rgba(30, 20, 10, .04), 0 4px 14px rgba(30, 20, 10, .05);
  --bs-secondary-bg: #efe8dd;
  --bs-tertiary-bg: #f6f1ea;
  --bs-border-color: #e3dbcf;
  --bs-link-color: #9a3412;
  --bs-link-color-rgb: 154, 52, 18;
  --bs-link-hover-color: #7c2d12;
  --bs-link-hover-color-rgb: 124, 45, 18;
}

[data-bs-theme="dark"] {
  --app-bg: #12100e;
  --card-bg: #1a1714;
  --soft-border: #2e2924;
  --muted-bg: #221e1a;
  --brand-text: #fbbf6a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .25);
  --bs-body-bg: #1a1714;
  --bs-body-bg-rgb: 26, 23, 20;
  --bs-secondary-bg: #2e2924;
  --bs-tertiary-bg: #221e1a;
  --bs-border-color: #332d27;
  --bs-link-color: #fbbf6a;
  --bs-link-color-rgb: 251, 191, 106;
  --bs-link-hover-color: #fcd9a4;
  --bs-link-hover-color-rgb: 252, 217, 164;
}

html,
body {
  background: var(--app-bg);
}

.btn {
  border-radius: 12px;
}

.btn-brand {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  border: 0;
  color: #fff;
  font-weight: 600;
}

.btn-brand:hover,
.btn-brand:focus-visible,
.btn-brand:active {
  color: #fff !important;
  filter: brightness(1.08);
}

.btn-brand:disabled {
  color: #fff;
  opacity: .55;
}

.form-control:focus,
.form-select:focus {
  border-color: color-mix(in srgb, var(--brand-2) 70%, transparent);
  box-shadow: 0 0 0 .25rem color-mix(in srgb, var(--brand-2) 25%, transparent);
}

.list-group {
  --bs-list-group-bg: transparent;
}

.modal-content {
  --bs-modal-bg: var(--card-bg);
}

.offcanvas {
  --bs-offcanvas-bg: var(--card-bg);
}

.b-card {
  background: var(--card-bg);
  border: 1px solid var(--soft-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.badge-soft {
  background: var(--muted-bg);
  color: var(--bs-body-color);
  border: 1px solid var(--soft-border);
  font-weight: 500;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.2rem;
  letter-spacing: -.02em;
}

.transcription-text {
  white-space: pre-wrap;
}

/* O iOS dá zoom na página ao focar input com fonte menor que 16px. Mantém o
   resto do estilo "sm" (padding, altura) e só sobe a fonte pra evitar isso. */
.form-control-sm,
.input-group-sm > .form-control {
  font-size: 1rem;
}

.row-actions {
  flex-shrink: 0;
  margin-left: auto;
}

.transcription-row.htmx-swapping {
  opacity: 0;
  transform: translateX(2.5rem);
  transition: opacity .25s ease, transform .25s ease;
}

.page-width,
.page-wide {
  max-width: 840px;
  margin: 0 auto;
}

.min-w-0 {
  min-width: 0;
}

.journal-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 1.5rem;
}

.entry-aside {
  display: grid;
  gap: 16px;
}

.aside-actions .btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 12px;
  text-align: left;
  font-weight: 500;
}

.aside-actions .btn:not(.btn-brand):hover {
  background: var(--muted-bg);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--app-bg) 86%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--soft-border);
}

.record-wrap {
  max-width: 420px;
  margin: 0 auto;
}

.record-square {
  width: 100%;
  aspect-ratio: 1.9 / 1;
  border: none;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 10px 28px color-mix(in srgb, var(--brand) 35%, transparent);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  font-size: 1rem;
  transition: background-color .15s ease, filter .15s ease;
}

.record-square:hover:not(:disabled) {
  filter: brightness(1.06);
}

@media (min-width: 768px) {
  .record-square {
    aspect-ratio: 2.4 / 1;
  }
}

.record-square.recording {
  background: #b91c1c;
  box-shadow: 0 10px 28px rgba(185, 28, 28, .35);
}

.record-square:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.record-square .icon {
  font-size: 2.5rem;
}

.record-timer {
  font-variant-numeric: tabular-nums;
  font-size: 1.1rem;
}

.record-error {
  font-size: .85rem;
  color: #ffd7d7;
  max-width: 240px;
  text-align: center;
}

.record-bars {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 40px;
}

.record-bars span {
  width: 4px;
  border-radius: 2px;
  background: #fff;
  opacity: .9;
  height: 15%;
  transition: height .06s linear;
}

.waveform-card {
  border: 1px solid var(--soft-border);
  border-radius: var(--radius);
  background: var(--card-bg);
  padding: .85rem 1rem;
}

.waveform-card__title {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: .75rem;
  font-weight: 600;
}

.waveform-player {
  display: flex;
  align-items: center;
  gap: .75rem;
}

.waveform-player__toggle {
  width: 2.5rem;
  height: 2.5rem;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.waveform-player__toggle:disabled {
  opacity: .55;
}

.waveform-player__wave {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 44px;
}

.waveform-player__time {
  min-width: 2.6rem;
  text-align: center;
  color: var(--bs-secondary-color);
  font-size: .82rem;
  font-variant-numeric: tabular-nums;
}

.waveform-player__fallback {
  width: 100%;
}

.waveform-player__rates {
  display: flex;
  justify-content: flex-end;
  gap: .4rem;
  margin-top: .75rem;
}

.waveform-player__rate {
  min-width: 3rem;
  border: 1px solid var(--bs-border-color);
  border-radius: 999px;
  background: var(--bs-body-bg);
  color: var(--bs-body-color);
  font-size: .78rem;
  font-variant-numeric: tabular-nums;
  padding: .22rem .55rem;
}

.waveform-player__rate.is-active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.waveform-player__rate:disabled {
  opacity: .55;
}

.waveform-player--busy {
  opacity: .65;
}

.row-confirm {
  background: var(--bs-danger-bg-subtle);
  padding-left: .75rem !important;
  padding-right: .75rem !important;
  border-radius: 8px;
}

.badge-queued {
  background: var(--bs-secondary-bg-subtle);
  color: var(--bs-secondary-text-emphasis);
  font-weight: 500;
}

.badge-processing {
  background: var(--bs-warning-bg-subtle);
  color: var(--bs-warning-text-emphasis);
  font-weight: 500;
}

.badge-uploading {
  background: var(--bs-primary-bg-subtle);
  color: var(--bs-primary-text-emphasis);
  font-weight: 500;
}

.badge-error {
  background: var(--bs-danger-bg-subtle);
  color: var(--bs-danger-text-emphasis);
  font-weight: 500;
}

.clock-chip {
  font-variant-numeric: tabular-nums;
}

.diff-add {
  background: var(--bs-success-bg-subtle);
  color: var(--bs-success-text-emphasis);
  text-decoration: none;
  padding: 0 1px;
  border-radius: 2px;
}

.diff-del {
  background: var(--bs-danger-bg-subtle);
  color: var(--bs-danger-text-emphasis);
  text-decoration: line-through;
  padding: 0 1px;
  border-radius: 2px;
}

.day-heading {
  color: var(--bs-secondary-color);
  text-transform: uppercase;
  font-size: .7rem;
  letter-spacing: .05em;
}

.timeline-rail {
  position: relative;
  padding-left: 1.6rem;
}

.timeline-item {
  position: relative;
  padding: .65rem 0;
}

.timeline-item::before {
  content: "";
  position: absolute;
  z-index: 1;
  left: -1.6rem;
  top: calc(50% - 4.5px);
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--j, var(--brand));
}

.timeline-item:not(:last-child)::after {
  content: "";
  position: absolute;
  z-index: 0;
  left: calc(-1.6rem + 4px);
  top: calc(50% - .5px);
  bottom: calc(-50% + .5px);
  width: 1px;
  background: var(--bs-border-color);
}

.timeline-item .t-time {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: .85rem;
  color: var(--j, var(--brand-text));
}

[data-bs-theme="dark"] .timeline-item .t-time {
  color: color-mix(in srgb, var(--j, var(--brand-2)) 60%, #fff);
}

.ai-badge {
  background: #f1e9ff;
  color: #6f3ff5;
}

[data-bs-theme="dark"] .ai-badge {
  background: #2c1f47;
  color: #c299fc;
}

.icon-rail {
  display: flex;
  justify-content: space-between;
  border-top: 1px solid var(--bs-border-color);
  border-bottom: 1px solid var(--bs-border-color);
  padding: .6rem .25rem;
}

.icon-rail button,
.icon-rail a {
  font-size: .64rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .25rem;
  flex: 1;
  padding: .25rem;
}

.icon-rail i {
  font-size: 1.1rem;
}

.ref-panel {
  background: var(--bs-secondary-bg);
  border-radius: 10px;
  padding: .75rem;
}

.section-label {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--bs-secondary-color);
}

.icon-circle-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  transition: transform .1s ease, opacity .15s ease;
}

.icon-circle-btn:active {
  transform: scale(.9);
}

.icon-circle-btn:disabled {
  opacity: .5;
  transform: none;
}

.edit-textarea:read-only {
  background: var(--bs-secondary-bg);
  opacity: .7;
  transition: background-color .15s ease, opacity .15s ease;
}

.pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--bs-warning-text-emphasis);
  display: inline-block;
  animation: pulse-dot 1.4s ease-in-out infinite;
}

.sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--bs-border-color);
  border-radius: 2px;
}

.icon-circle-btn--subtle {
  background: var(--bs-secondary-bg);
  color: var(--bs-body-color);
}

@keyframes pulse-dot {
  0%, 100% { opacity: .35; }
  50% { opacity: 1; }
}

.shell {
  display: flex;
  min-height: 100dvh;
  transition: opacity .2s ease;
}

.shell-main {
  flex: 1;
  min-width: 0;
}

.sidebar {
  display: none;
}

.first-upper::first-letter {
  text-transform: uppercase;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.stat-tile {
  padding: 10px 14px;
  background: var(--card-bg);
  border: 1px solid var(--soft-border);
  border-left: 4px solid var(--j);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1.1;
}

.top-search {
  position: relative;
  flex: 1;
  max-width: 420px;
}

.top-search > i {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--bs-secondary-color);
}

.top-search input {
  padding-left: 40px;
  background: var(--card-bg);
  border-color: var(--soft-border);
}

.search-page-form {
  max-width: none;
}

.search-result {
  display: block;
  padding: 14px 16px;
  transition: border-color .15s ease;
}

.search-result:hover {
  border-color: var(--j);
}

mark {
  padding: 0 2px;
  border-radius: 3px;
  background: color-mix(in srgb, var(--brand-2) 35%, transparent);
  color: inherit;
}

.journal-week {
  display: flex;
  gap: 4px;
  flex-basis: 100%;
  margin-top: 10px;
}

.journal-week__day {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.journal-week__bar {
  width: 100%;
  height: 22px;
  border-radius: 6px;
  background: var(--muted-bg);
}

.journal-week__bar--1 {
  background: color-mix(in srgb, var(--j) 35%, transparent);
}

.journal-week__bar--2 {
  background: color-mix(in srgb, var(--j) 75%, transparent);
}

.journal-week__label {
  font-size: .68rem;
  color: var(--bs-tertiary-color);
  text-transform: uppercase;
}

.swatch-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.swatch {
  display: flex;
  justify-content: center;
  cursor: pointer;
}

.swatch__dot {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--j);
  color: transparent;
  transition: transform .1s ease;
}

.swatch input:checked + .swatch__dot {
  color: #fff;
  box-shadow: 0 0 0 3px var(--card-bg), 0 0 0 5px var(--j);
}

.swatch input:focus-visible + .swatch__dot {
  outline: 2px solid var(--bs-body-color);
  outline-offset: 4px;
}

.icon-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 6px;
}

.icon-choice {
  cursor: pointer;
}

.icon-choice__box {
  aspect-ratio: 1;
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-size: 1.1rem;
  color: var(--bs-secondary-color);
  background: var(--muted-bg);
}

.icon-choice input:checked + .icon-choice__box {
  color: #fff;
  background: var(--j);
}

.icon-choice input:focus-visible + .icon-choice__box {
  outline: 2px solid var(--bs-body-color);
  outline-offset: 2px;
}

.page-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2000;
  height: 3px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}

.page-progress::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 40%;
  border-radius: 0 3px 3px 0;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
  box-shadow: 0 0 8px color-mix(in srgb, var(--brand-2) 60%, transparent);
  animation: page-progress-slide 1.1s ease-in-out infinite;
}

.page-progress.is-active {
  opacity: 1;
}

.is-page-loading {
  cursor: progress;
}

.is-page-loading .shell {
  opacity: .6;
}

@keyframes page-progress-slide {
  from { left: -40%; }
  to { left: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .page-progress::before {
    left: 0;
    width: 100%;
    animation: none;
  }
}

@media (max-width: 991.98px) {
  .only-desktop {
    display: none !important;
  }
}

.j-icon {
  --size: 40px;
  width: var(--size);
  height: var(--size);
  border-radius: calc(var(--size) * .32);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: calc(var(--size) * .5);
  color: var(--j, var(--brand));
  background: color-mix(in srgb, var(--j, var(--brand)) 16%, var(--card-bg));
}

[data-bs-theme="dark"] .j-icon {
  color: color-mix(in srgb, var(--j, var(--brand-2)) 65%, #fff);
  background: color-mix(in srgb, var(--j, var(--brand)) 24%, var(--card-bg));
}

.side-link {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 7px 10px;
  border-radius: 12px;
  text-decoration: none;
  font-weight: 600;
  font-size: .92rem;
  color: var(--bs-body-color);
}

.side-link:hover {
  background: var(--muted-bg);
  color: var(--bs-body-color);
}

.side-link.active {
  background: color-mix(in srgb, var(--j, var(--brand)) 14%, transparent);
  color: var(--j, var(--brand-text));
}

[data-bs-theme="dark"] .side-link.active {
  color: color-mix(in srgb, var(--j, var(--brand-2)) 60%, #fff);
}

.side-count {
  margin-left: auto;
  font-size: .75rem;
  color: var(--bs-secondary-color);
}

#record-button {
  scroll-margin-top: 96px;
}

@media (min-width: 992px) {
  .only-mobile {
    display: none !important;
  }

  .sidebar {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 272px;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100dvh;
    padding: 20px 14px;
    background: var(--card-bg);
    border-right: 1px solid var(--soft-border);
    overflow-y: auto;
  }

  .sidebar-brand {
    padding: 4px 8px 18px;
  }

  .sidebar-footer {
    margin-top: auto;
    padding-top: 12px;
  }

  .offcanvas.offcanvas-bottom {
    top: 0;
    right: 0;
    bottom: 0;
    left: auto;
    width: 440px;
    height: 100% !important;
    max-height: none !important;
    border-top: 0;
    border-left: 1px solid var(--soft-border);
    border-radius: 22px 0 0 22px !important;
    transform: translateX(100%);
  }

  .app-header .page-width {
    max-width: none;
  }

  .page-wide {
    max-width: 1180px;
  }

  .desk-card {
    background: var(--card-bg);
    border: 1px solid var(--soft-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem;
  }

  .journal-layout {
    display: grid;
    grid-template-columns: 380px minmax(0, 1fr);
    gap: 28px;
    align-items: start;
  }

  .journal-layout--single {
    grid-template-columns: minmax(0, 1fr);
  }

  .journal-side {
    position: sticky;
    top: 88px;
  }

  .journal-side .record-wrap {
    max-width: none;
  }

  .record-square {
    aspect-ratio: 1.6 / 1;
  }

  .journal-search-group {
    max-width: 480px;
  }

  .journal-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
  }

  .journal-grid > .list-group-item {
    background: var(--card-bg);
    border: 1px solid var(--soft-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
    transition: border-color .15s ease, transform .15s ease;
  }

  .journal-grid > .journal-item {
    flex-wrap: wrap;
  }

  .stat-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .journal-grid > .list-group-item:hover {
    border-color: var(--j, var(--brand-2));
    transform: translateY(-2px);
  }

  .journal-grid > .list-group-item::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 4px;
    border-radius: var(--radius) var(--radius) 0 0;
    background: var(--j);
  }

  .journal-grid > :not(.list-group-item) {
    grid-column: 1 / -1;
  }

  .entry-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 32px;
    align-items: start;
  }

  .entry-article {
    background: var(--card-bg);
    border: 1px solid var(--soft-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2.5rem 3rem;
  }

  .entry-aside {
    position: sticky;
    top: 88px;
  }

  .reading {
    font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
    font-size: 1.12rem;
    line-height: 1.75;
  }

  .offcanvas-bottom .offcanvas-body {
    padding: 1.5rem !important;
  }

  .offcanvas-bottom .btn.border-top {
    border-radius: 0;
  }

  .offcanvas-bottom .sheet-handle {
    display: none;
  }
}
