:root {
  --bg: #f7f1e7;
  --bg-soft: #fbf8f2;
  --bg-deep: #efe4d4;
  --surface: rgba(255, 251, 245, 0.9);
  --surface-strong: #fffdf9;
  --surface-muted: rgba(247, 242, 233, 0.76);
  --text: #2b1d15;
  --text-soft: #6d5a4c;
  --text-faint: #978372;
  --line: rgba(96, 71, 47, 0.15);
  --line-strong: rgba(87, 63, 41, 0.2);
  --accent: #355f4d;
  --accent-strong: #284b3d;
  --accent-soft: #e6eee7;
  --accent-ghost: rgba(53, 95, 77, 0.08);
  --danger: #8f4338;
  --danger-soft: rgba(143, 67, 56, 0.08);
  --shadow-soft: 0 18px 40px rgba(63, 42, 27, 0.08);
  --shadow-card: 0 28px 60px rgba(63, 42, 27, 0.1);
  --radius-xs: 12px;
  --radius-sm: 18px;
  --radius-md: 22px;
  --radius-lg: 28px;
  --radius-xl: 34px;
  --sidebar-width: 292px;
  --font-ui: "Aptos", "Segoe UI", sans-serif;
  --font-display: "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --brand-filter: brightness(0) saturate(100%) invert(30%) sepia(10%) saturate(1330%) hue-rotate(104deg) brightness(89%) contrast(86%);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.96), transparent 30%),
    radial-gradient(circle at top right, rgba(229, 239, 230, 0.55), transparent 26%),
    linear-gradient(180deg, var(--bg-soft) 0%, var(--bg) 58%, var(--bg-deep) 100%);
  font-family: var(--font-ui);
  text-rendering: optimizeLegibility;
}

img {
  display: block;
  max-width: 100%;
}

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

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
}

.auth-shell {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: clamp(32px, 8vh, 72px) 20px 40px;
}

.page {
  position: relative;
}

.page-app {
  padding: 40px clamp(20px, 4vw, 56px) 56px;
}

.page-auth {
  width: min(760px, 100%);
  display: grid;
  gap: 18px;
}

.sidebar,
.panel,
.detail-card,
.editor-card,
.auth-card,
.sidebar-footer-panel,
.collection-list,
.empty-panel,
.entry-card {
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.sidebar,
.panel,
.detail-card,
.editor-card,
.auth-card,
.sidebar-footer-panel,
.collection-list,
.empty-panel,
.entry-card,
.reminder-panel {
  border-radius: var(--radius-lg);
}

.sidebar {
  position: sticky;
  top: 0;
  min-height: 100vh;
  padding: 28px 28px 32px;
  display: flex;
  flex-direction: column;
  gap: 30px;
  background:
    linear-gradient(180deg, rgba(255, 253, 249, 0.92), rgba(248, 242, 233, 0.9)),
    radial-gradient(circle at top left, rgba(229, 239, 230, 0.45), transparent 32%);
  border-radius: 0;
  border-top: none;
  border-left: none;
  border-bottom: none;
  box-shadow: 1px 0 0 rgba(93, 69, 47, 0.08);
}

.brand,
.auth-brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-copy strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.brand-copy p {
  margin: 4px 0 0;
  color: var(--text-soft);
}

.brand-mark {
  width: 58px;
  height: 58px;
  flex: 0 0 58px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255, 252, 247, 0.95);
  border: 1px solid rgba(90, 69, 46, 0.12);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.brand-mark img {
  width: 26px;
  height: 26px;
  filter: var(--brand-filter);
}

.nav-group {
  display: grid;
  gap: 8px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 18px;
  color: var(--text-soft);
  font-size: 1.02rem;
  transition: background-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.nav-link:hover {
  transform: translateX(1px);
}

.nav-link.active,
.nav-link:hover {
  background: rgba(238, 235, 224, 0.95);
  color: var(--text);
}

.nav-icon {
  width: 20px;
  height: 20px;
  opacity: 0.8;
}

.sidebar-footer {
  margin-top: auto;
}

.sidebar-footer-panel {
  padding: 18px;
  display: grid;
  gap: 18px;
  background:
    linear-gradient(180deg, rgba(255, 251, 246, 0.94), rgba(248, 243, 235, 0.94));
}

.sidebar-status {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.sidebar-status-icon {
  width: 20px;
  height: 20px;
  margin-top: 3px;
}

.sidebar-status strong {
  display: block;
  margin-bottom: 4px;
  font-weight: 600;
}

.sidebar-status p {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.92rem;
  line-height: 1.55;
}

.sidebar-actions,
.sidebar-actions form {
  display: grid;
  gap: 10px;
}

.sidebar-button {
  width: 100%;
  justify-content: center;
}

.page-header {
  display: grid;
  gap: 10px;
  margin-bottom: 26px;
}

.page-header-copy {
  display: grid;
  gap: 6px;
}

.eyebrow {
  margin: 0;
  color: var(--text-faint);
  font-size: 0.78rem;
  line-height: 1;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 0.98;
  letter-spacing: -0.03em;
}

h1 {
  font-size: clamp(3rem, 4vw, 4.15rem);
}

h2 {
  font-size: clamp(2rem, 3vw, 3rem);
}

h3 {
  font-size: clamp(1.32rem, 2vw, 1.7rem);
}

.lede {
  margin: 0;
  color: var(--text-soft);
  line-height: 1.7;
}

.flash {
  margin-bottom: 18px;
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(255, 252, 247, 0.8);
  box-shadow: var(--shadow-soft);
}

.flash-notice {
  background: rgba(231, 238, 229, 0.92);
}

.flash-error {
  background: rgba(246, 226, 220, 0.94);
}

.panel {
  padding: 28px;
}

.page-actions,
.panel-header,
.entry-card-header,
.form-actions,
.inline-actions,
.split-actions,
.reminder-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.page-actions,
.panel-header,
.entry-card-header,
.form-actions,
.split-actions {
  justify-content: space-between;
}

.page-actions {
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 253, 249, 0.86);
  color: var(--text-soft);
  font-size: 0.95rem;
  transition: background-color 160ms ease, border-color 160ms ease;
}

.filter-chip.active {
  background: var(--accent-soft);
  color: var(--accent-strong);
  border-color: rgba(53, 95, 77, 0.08);
}

.dashboard-grid {
  display: grid;
  gap: 22px;
}

.reminder-host {
  padding: 0;
  border: none;
  background: transparent;
  box-shadow: none;
}

.reminder-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(320px, 0.92fr);
  padding: 0;
  overflow: hidden;
  min-height: 520px;
  background:
    linear-gradient(180deg, rgba(255, 253, 248, 0.97), rgba(250, 245, 237, 0.94));
  box-shadow: var(--shadow-card);
}

.reminder-copy {
  padding: 34px 34px 30px;
  display: grid;
  align-content: start;
  gap: 16px;
}

.meta-badge {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.95rem;
  font-weight: 600;
}

.meta-badge img {
  width: 16px;
  height: 16px;
}

.reminder-body {
  color: var(--text);
  font-size: 1.06rem;
  line-height: 1.68;
  max-height: 18rem;
  overflow: auto;
  padding-right: 6px;
}

.reminder-body::-webkit-scrollbar {
  width: 8px;
}

.reminder-body::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(109, 90, 76, 0.28);
}

.markdown,
.prose-block {
  color: var(--text);
  line-height: 1.76;
}

.markdown p,
.markdown ul,
.markdown ol,
.markdown blockquote,
.prose-block p,
.prose-block ul,
.prose-block ol,
.prose-block blockquote {
  margin: 0 0 14px;
}

.markdown p:last-child,
.markdown ul:last-child,
.markdown ol:last-child,
.markdown blockquote:last-child,
.prose-block p:last-child,
.prose-block ul:last-child,
.prose-block ol:last-child,
.prose-block blockquote:last-child {
  margin-bottom: 0;
}

.markdown ul,
.markdown ol,
.prose-block ul,
.prose-block ol {
  padding-left: 24px;
}

.markdown a,
.prose-block a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 0.16em;
}

.reminder-actions {
  flex-wrap: wrap;
  margin-top: 4px;
}

.reminder-visual {
  min-height: 100%;
  background: linear-gradient(180deg, rgba(240, 236, 226, 0.42), rgba(236, 231, 223, 0.28));
}

.reminder-visual img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.section-directory {
  padding: 0;
  overflow: hidden;
}

.section-directory-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.directory-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 24px 28px;
  transition: background-color 160ms ease;
}

.directory-row:hover {
  background: rgba(255, 255, 255, 0.45);
}

.directory-row:nth-child(n + 3) {
  border-top: 1px solid var(--line);
}

.directory-row:nth-child(odd) {
  border-right: 1px solid var(--line);
}

.directory-row-main {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 16px;
}

.directory-icon {
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(239, 235, 223, 0.72);
}

.directory-icon img {
  width: 22px;
  height: 22px;
}

.directory-copy {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.directory-copy strong {
  font-family: var(--font-display);
  font-size: 1.12rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.directory-meta {
  color: var(--text-soft);
  font-size: 0.95rem;
}

.directory-chevron img {
  width: 18px;
  height: 18px;
  opacity: 0.7;
}

.stack-list {
  display: grid;
  gap: 16px;
}

.entry-card {
  padding: 22px 24px;
  display: grid;
  gap: 16px;
}

.entry-card h2,
.entry-card h3 {
  font-size: clamp(1.35rem, 2vw, 1.7rem);
}

.entry-card p,
.panel p,
.empty-panel p {
  margin: 0;
  color: var(--text-soft);
  line-height: 1.68;
}

.collection-list {
  gap: 0;
  padding: 0;
  overflow: hidden;
}

.collection-list .collection-row {
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding: 20px 24px;
}

.collection-list .collection-row + .collection-row {
  border-top: 1px solid var(--line);
}

.inline-actions {
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 600;
}

.empty-panel {
  padding: 34px 28px;
  text-align: center;
}

.detail-card,
.editor-card {
  width: min(980px, 100%);
  margin: 0 auto;
  padding: 30px 32px;
}

.content-reading {
  display: grid;
  gap: 22px;
}

.prose-block {
  max-width: 72ch;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  font-size: 1.03rem;
}

.entry-drawer {
  display: grid;
  gap: 16px;
  animation: drawer-reveal 180ms ease;
}

.entry-drawer-content {
  padding-top: 18px;
  width: 100%;
  max-width: none;
  color: var(--text);
}

.entry-drawer-content p,
.entry-drawer-content li,
.entry-drawer-content blockquote {
  color: var(--text);
}

.entry-toggle {
  min-width: 0;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0;
  border: none;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.entry-toggle:hover h2 {
  color: var(--accent);
}

.entry-toggle:focus-visible {
  outline: 2px solid rgba(53, 95, 77, 0.32);
  outline-offset: 8px;
  border-radius: 14px;
}

.entry-toggle-copy {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.entry-toggle-copy h2 {
  transition: color 160ms ease;
}

.entry-toggle-chevron {
  width: 12px;
  height: 12px;
  flex: 0 0 12px;
  border-right: 2px solid var(--text-faint);
  border-bottom: 2px solid var(--text-faint);
  transform: rotate(-45deg);
  transition: transform 160ms ease, border-color 160ms ease;
}

.entry-toggle:hover .entry-toggle-chevron {
  border-color: var(--accent);
}

.entry-toggle-chevron.is-expanded {
  transform: rotate(45deg);
}

@keyframes drawer-reveal {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.editor-form {
  display: grid;
  gap: 20px;
}

.dictation-toolbar,
.dictation-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.dictation-toolbar {
  margin-top: -6px;
}

.dictation-toolbar-hint {
  flex: 1 1 320px;
}

.editor-form label {
  display: grid;
  gap: 8px;
}

.editor-form span,
.stack-form span {
  font-weight: 600;
  color: var(--text);
}

.split-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
}

.introspection-template-section {
  margin-bottom: 30px;
}

.template-pill {
  height: 100%;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(255, 252, 247, 0.82);
  display: grid;
  gap: 6px;
}

.template-pill span {
  display: block;
  color: var(--text-faint);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.stack-form {
  display: grid;
  gap: 16px;
}

.form-hint {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.94rem;
  line-height: 1.65;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid rgba(91, 69, 46, 0.16);
  border-radius: 18px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.88);
  color: var(--text);
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(53, 95, 77, 0.38);
  box-shadow: 0 0 0 4px rgba(53, 95, 77, 0.08);
  background: rgba(255, 255, 255, 0.96);
}

textarea {
  min-height: 220px;
  resize: vertical;
  line-height: 1.7;
}

.primary-button,
.ghost-button,
.danger-button {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border-radius: 18px;
  padding: 13px 18px;
  font-weight: 600;
  transition: transform 160ms ease, box-shadow 160ms ease, background-color 160ms ease, border-color 160ms ease;
}

.primary-button:hover,
.ghost-button:hover,
.danger-button:hover {
  transform: translateY(-1px);
}

.primary-button {
  border: 1px solid rgba(28, 56, 44, 0.16);
  background: linear-gradient(180deg, #3f7159, #2f5948);
  color: #fffaf6;
  box-shadow: 0 12px 24px rgba(47, 89, 72, 0.18);
}

.ghost-button {
  border: 1px solid var(--line);
  background: rgba(255, 253, 249, 0.82);
  color: var(--text);
}

.danger-button {
  border: 1px solid rgba(143, 67, 56, 0.14);
  background: var(--danger-soft);
  color: var(--danger);
}

.primary-button img,
.ghost-button img,
.danger-button img {
  width: 16px;
  height: 16px;
}

.auth-card {
  width: 100%;
  max-width: 700px;
  padding: 34px 34px 32px;
  display: grid;
  gap: 22px;
  background:
    linear-gradient(180deg, rgba(255, 253, 248, 0.97), rgba(249, 244, 236, 0.95)),
    radial-gradient(circle at top right, rgba(230, 239, 231, 0.4), transparent 36%);
  box-shadow: var(--shadow-card);
}

.auth-copy {
  display: grid;
  gap: 6px;
}

.auth-copy h2 {
  font-size: clamp(2.6rem, 4vw, 3.8rem);
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--text-faint);
  font-size: 0.9rem;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.secondary-auth-block {
  display: grid;
  gap: 12px;
}

.security-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
  align-items: start;
}

.security-panel {
  display: grid;
  gap: 22px;
}

.security-form {
  gap: 18px;
}

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

.security-form-actions {
  display: flex;
  justify-content: flex-start;
}

.compact-list {
  gap: 12px;
}

.compact-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.security-row-copy,
.qa-item {
  display: grid;
  gap: 6px;
}

.meta-copy {
  color: var(--text-soft);
  font-size: 0.94rem;
}

.security-inline-form,
.inline-form {
  display: grid;
  grid-template-columns: minmax(0, 220px) auto;
  gap: 12px;
  align-items: center;
}

.qa-stack {
  display: grid;
  gap: 22px;
}

.qa-item strong {
  font-size: 1.05rem;
}

.question-list {
  margin: 0;
  padding-left: 24px;
  display: grid;
  gap: 12px;
}

.question-list li {
  color: var(--text);
  line-height: 1.72;
}

.dictation-overlay {
  position: fixed;
  inset: 0;
  z-index: 1900;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(28, 20, 16, 0.46);
  backdrop-filter: blur(10px);
}

.dictation-overlay-open {
  overflow: hidden;
}

.dictation-modal {
  width: min(760px, 100%);
  max-height: min(92vh, 960px);
  overflow: auto;
  padding: 28px;
  display: grid;
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(180deg, rgba(255, 253, 248, 0.98), rgba(250, 245, 237, 0.98));
  box-shadow: var(--shadow-card);
}

.dictation-status-panel,
.dictation-privacy-note,
.dictation-prompt-fallback {
  display: grid;
  gap: 8px;
  padding: 16px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(255, 253, 249, 0.78);
}

.dictation-status-panel .badge {
  background: rgba(239, 235, 223, 0.82);
  color: var(--text-soft);
}

.dictation-draft-field {
  display: grid;
  gap: 8px;
}

.dictation-draft-field textarea,
.dictation-prompt-fallback textarea {
  min-height: 220px;
}

[data-dictation-draft-editor][readonly] {
  background: rgba(247, 242, 233, 0.94);
}

details {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 600;
}

@media (max-width: 1180px) {
  .reminder-panel {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .reminder-visual {
    min-height: 280px;
  }
}

@media (max-width: 1040px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    min-height: auto;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .security-grid,
  .split-panel,
  .section-directory-grid {
    grid-template-columns: 1fr;
  }

  .directory-row:nth-child(odd) {
    border-right: none;
  }

  .directory-row:nth-child(n + 2) {
    border-top: 1px solid var(--line);
  }

  .security-fields {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 780px) {
  .page-app {
    padding: 26px 16px 36px;
  }

  .page-auth {
    gap: 14px;
  }

  .auth-card,
  .detail-card,
  .editor-card,
  .panel,
  .dictation-modal {
    padding: 22px 20px;
  }

  .page-actions,
  .panel-header,
  .entry-card-header,
  .form-actions,
  .split-actions,
  .reminder-actions,
  .dictation-actions,
  .compact-card,
  .security-inline-form,
  .inline-form {
    flex-direction: column;
    align-items: stretch;
  }

  .security-inline-form,
  .inline-form {
    grid-template-columns: 1fr;
  }

  .entry-card-header .inline-actions {
    width: 100%;
  }
}

@media (max-width: 640px) {
  h1 {
    font-size: clamp(2.5rem, 12vw, 3.4rem);
  }

  .auth-shell {
    padding-top: 28px;
  }

  .brand,
  .auth-brand {
    align-items: flex-start;
  }

  .directory-row,
  .collection-list .collection-row {
    padding: 18px 18px;
  }

  .reminder-copy {
    padding: 24px 20px 22px;
  }

  .reminder-body {
    max-height: none;
  }

  .reminder-visual {
    min-height: 220px;
  }
}
