:root {
  --bg: #f7f5f0;
  --surface: #fffdfa;
  --surface-2: #efebe2;
  --text: #1d1d1b;
  --muted: #6a675f;
  --line: #d8d2c7;
  --accent: #213a32;
  --accent-2: #bc8e55;
  --danger: #a83232;
  --private: #5a4770;
  --radius: 18px;
  --shadow: 0 18px 50px rgba(30, 28, 23, .08);
  --container: 1180px;
  --font-sans: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI Variable", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --font-serif: ui-serif, "New York", "Iowan Old Style", Baskerville, Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; min-height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.65;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}
main {
  width: 100%;
  min-width: 0;
  flex: 1 0 auto;
  display: block;
}
.site-header, .page-header, .page-section, .site-footer { width: 100%; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: #0d1f18; }
img { display: block; max-width: 100%; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; }

.container {
  width: min(calc(100% - 40px), var(--container));
  max-width: var(--container);
  margin-left: auto;
  margin-right: auto;
}
.narrow, .container.narrow {
  width: min(calc(100% - 40px), 820px);
  max-width: 820px;
  margin-left: auto;
  margin-right: auto;
}
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; top: 8px; left: 8px; z-index: 999; background: #fff; padding: 8px 12px; transform: translateY(-200%); }
.skip-link:focus { transform: translateY(0); }

.site-header { position: sticky; top: 0; z-index: 50; backdrop-filter: blur(16px); background: color-mix(in srgb, var(--bg) 88%, transparent); border-bottom: 1px solid rgba(120,110,90,.15); }
.nav-wrap { min-height: 74px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 800; letter-spacing: -.02em; }
.brand-mark { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; background: var(--accent); color: white; font-size: 13px; letter-spacing: .05em; }
.main-nav { display: flex; align-items: center; flex-wrap: wrap; gap: 18px; }
.main-nav a { position: relative; text-decoration: none; font-size: 14px; color: var(--muted); font-weight: 700; transition: color .18s ease; }
.main-nav a:hover { color: var(--text); }
.main-nav a.is-active { color: var(--text); font-weight: 800; }
.main-nav a.is-active::after { content: ""; position: absolute; left: 0; right: 0; bottom: -8px; height: 2px; border-radius: 999px; background: var(--accent); }
.nav-toggle { display: none; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); padding: 8px 11px; }

.hero { padding: 90px 0 70px; border-bottom: 1px solid var(--line); background: radial-gradient(circle at 85% 15%, rgba(188,142,85,.16), transparent 28%), linear-gradient(135deg, #f7f5f0 0%, #f0ede5 100%); }
.hero-grid { display: grid; grid-template-columns: 1.4fr .8fr; gap: 60px; align-items: center; }
.hero h1, .page-header h1 { font-family: var(--font-serif); font-weight: 500; letter-spacing: -.035em; line-height: 1.03; }
.hero h1 { font-size: clamp(3.25rem, 6.6vw, 6.4rem); margin: .2em 0 .2em; max-width: 950px; }
.hero-tagline { max-width: 760px; margin: 0 0 12px; font-family: var(--font-serif); font-size: clamp(1.45rem, 2.4vw, 2.25rem); font-weight: 600; line-height: 1.2; letter-spacing: -.02em; color: var(--accent); }
.hero-lead { max-width: 720px; margin-top: 0; font-size: clamp(1.08rem, 2vw, 1.45rem); color: var(--muted); }
.philosophy-card { background: var(--accent); color: white; padding: 32px; border-radius: var(--radius); box-shadow: var(--shadow); }
.philosophy-card .eyebrow { color: rgba(255,255,255,.65); }
.philosophy-card blockquote { margin: 18px 0 0; font-family: var(--font-serif); font-size: 1.55rem; line-height: 1.35; }

.eyebrow { margin: 0 0 8px; color: var(--accent-2); font-size: .75rem; font-weight: 850; text-transform: uppercase; letter-spacing: .12em; }
.page-header { padding: 64px 0 48px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.page-header h1 { font-size: clamp(2.6rem, 6vw, 5.2rem); margin: 0 0 16px; }
.page-header p:last-child, .page-header .page-description { color: var(--muted); max-width: 760px; }
.admin-header { padding: 38px 0 30px; }
.admin-header h1 { font-size: clamp(2.35rem, 4vw, 3.9rem); margin-bottom: 0; }
.admin-shell .page-header .section-heading {
  align-items: center;
  margin-bottom: 0;
}
.admin-shell .page-section { padding: 44px 0 64px; }
.admin-shell .page-header > .container,
.admin-shell .page-section > .container {
  width: min(calc(100% - 40px), var(--container));
  max-width: var(--container);
  margin-left: auto;
  margin-right: auto;
}
.admin-shell .page-header > .container.narrow,
.admin-shell .page-section > .container.narrow {
  width: min(calc(100% - 40px), 820px);
  max-width: 820px;
}
.admin-shell .site-footer { margin-top: auto; }
.private-header { background: #efeaf4; border-color: #d7ccdf; }

.page-section { padding: 68px 0; }
.section-muted { background: var(--surface-2); border-block: 1px solid var(--line); }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin-bottom: 28px; }
.section-heading h2 { margin: 0; font-family: var(--font-serif); font-size: clamp(2rem, 4vw, 3.2rem); font-weight: 500; letter-spacing: -.03em; }
.section-heading > h2 { font-family: inherit; font-size: 1.35rem; font-weight: 800; letter-spacing: -.02em; }

.card-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 24px; }
.project-card { overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 28px rgba(35,30,20,.04); }
.card-image { display: block; width: 100%; aspect-ratio: 5 / 4; object-fit: cover; background: #ddd; }
.card-body { padding: 22px; }
.card-body h2, .card-body h3 { margin: 12px 0 8px; line-height: 1.2; }
.card-body h2 a, .card-body h3 a { color: var(--text); text-decoration: none; }
.card-body p { margin-bottom: 0; color: var(--muted); }
.project-card-description {
  display: block;
  overflow: visible;
}

.meta-row, .record-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 16px; color: var(--muted); font-size: .88rem; }
.status, .privacy-badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 3px 9px; font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }
.status-completed { background: #dfeee3; color: #245a35; }
.status-active { background: #e2e9ef; color: #294d68; }
.status-paused { background: #f1e8d8; color: #765727; }
.status-archived { background: #e9e7e2; color: #5f5a50; }
.privacy-badge { background: #e8dff0; color: var(--private); }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline > li { position: relative; display: grid; grid-template-columns: 130px 1fr; gap: 30px; padding: 24px 0 24px 30px; border-left: 1px solid var(--line); }
.timeline > li:not(.timeline-year)::before { content: ""; position: absolute; left: -6px; top: 31px; width: 11px; height: 11px; border-radius: 50%; background: var(--accent-2); box-shadow: 0 0 0 5px var(--bg); }
.section-muted .timeline > li:not(.timeline-year)::before { box-shadow: 0 0 0 5px var(--surface-2); }
.timeline time { color: var(--muted); font-size: .87rem; }
.timeline h2, .timeline h3 { margin: 0 0 6px; line-height: 1.25; }
.timeline h2 a, .timeline h3 a { color: var(--text); text-decoration: none; }
.timeline p { margin: 0 0 7px; color: var(--muted); }
.timeline-year { padding-top: 42px !important; padding-bottom: 8px !important; grid-template-columns: 1fr !important; font-family: var(--font-serif); font-size: 2.3rem; font-weight: 600; color: var(--accent); }
.linked-project { font-size: .82rem; color: var(--muted); }

.button-row, .form-actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 26px; }
.button { display: inline-flex; justify-content: center; align-items: center; gap: 8px; border: 1px solid var(--accent); border-radius: 10px; background: var(--accent); color: #fff; text-decoration: none; font-weight: 800; padding: 11px 16px; line-height: 1.2; }
.button:hover { background: #132b23; color: white; }
.button-ghost { background: transparent; color: var(--accent); }
.button-danger { border-color: var(--danger); background: var(--danger); }
.button-danger:hover { background: #7d2222; }
.button-small { padding: 8px 11px; font-size: .85rem; }
.button-full { width: 100%; }

.record-image { width: 100%; max-height: 620px; object-fit: cover; margin: 30px 0; border-radius: var(--radius); border: 1px solid var(--line); }
.lead { font-size: 1.22rem; color: #43413c; }
.prose { font-family: var(--font-serif); font-size: 1.08rem; }
.prose h2, .prose h3 { font-family: var(--font-sans); }
.prose p { margin: 0 0 1.2em; }
.legal-page h2 { margin-top: 2.2em; }
.legal-note { margin-top: 40px; padding: 15px; background: var(--surface-2); border-radius: 10px; font-family: var(--font-sans); font-size: .9rem; color: var(--muted); }

.search-form, .filter-bar { display: flex; gap: 10px; margin-top: 24px; }
.search-form input, .filter-bar input { flex: 1; }
.result-list article { padding: 20px 0; border-bottom: 1px solid var(--line); }
.result-list h3 { margin: 3px 0; }
.result-list p { color: var(--muted); }

.empty-state { padding: 30px; border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); background: rgba(255,255,255,.35); }
.muted { color: var(--muted); }
.help-text { margin: -4px 0 4px; color: var(--muted); font-size: .84rem; }
.required { color: var(--danger); font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; }
.top-gap { margin-top: 22px; }
.top-gap-lg { margin-top: 38px; }

.site-footer { padding: 44px 0; border-top: 1px solid var(--line); background: #ece8df; }
.footer-grid { display: flex; justify-content: space-between; gap: 30px; }
.footer-grid p { max-width: 680px; margin: 4px 0 0; color: var(--muted); }
.footer-grid nav { display: flex; flex-direction: column; gap: 7px; min-width: 130px; }
.footer-grid nav a { color: var(--muted); }

.flash {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  padding: 10px 14px;
  border: 1px solid;
  border-radius: 10px;
  font-size: .94rem;
  font-weight: 650;
  line-height: 1.35;
}
.flash::before {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: .78rem;
  font-weight: 900;
}
.flash-success { background: #e7f4e8; border-color: #a6d4aa; color: #245a35; }
.flash-success::before { content: "✓"; background: #cce7d0; color: #245a35; }
.flash-warning { background: #fff1d8; border-color: #e8c881; color: #75551c; }
.flash-warning::before { content: "!"; background: #f6dfae; color: #75551c; }
.flash-error { background: #f9e2e2; border-color: #dfa0a0; color: #7f2424; }
.flash-error::before { content: "×"; background: #efc7c7; color: #7f2424; }

.auth-section { min-height: calc(100vh - 150px); display: grid; place-items: center; padding: 55px 20px; }
.auth-card { width: min(100%, 520px); padding: 34px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.auth-card-wide { width: min(100%, 720px); }
.auth-card h1 { margin-top: 0; font-family: var(--font-serif); font-size: 2.6rem; line-height: 1.1; }
.setup-steps { padding-left: 22px; }
.secret-box { padding: 16px; border-radius: 12px; background: var(--surface-2); display: grid; gap: 8px; }
.secret-box code { font-size: 1.1rem; font-weight: 800; letter-spacing: .07em; }
.totp-setup-grid { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); gap: 22px; margin-top: 24px; align-items: start; }
.totp-setup-grid h2 { margin: 0 0 14px; font-family: inherit; font-size: 1.05rem; letter-spacing: -.01em; }
.totp-qr-panel, .totp-manual-panel { min-width: 0; }
.totp-qr-wrap { display: inline-flex; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: #fff; box-shadow: 0 8px 24px rgba(35,30,20,.05); }
.totp-qr { width: 220px; height: 220px; display: grid; place-items: center; }
.totp-qr img, .totp-qr canvas { display: block; width: 220px !important; height: 220px !important; max-width: 100%; }
.uri-code { display: block; margin-top: 12px; padding: 12px; background: var(--surface-2); border-radius: 8px; }
.code-input { letter-spacing: .18em; font-size: 1.3rem; }

.form-stack { display: grid; gap: 18px; }
.form-stack label, .editor-form label { display: grid; gap: 7px; font-weight: 750; }
input, textarea, select { width: 100%; border: 1px solid #bcb5a8; border-radius: 10px; padding: 11px 12px; background: var(--surface); color: var(--text); outline: none; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(33,58,50,.12); }
textarea { resize: vertical; line-height: 1.55; }

/* Keep date fields compact and consistent across Projects, Progress Logs, and Private Goals. */
input[type="date"] {
  box-sizing: border-box;
  height: 52px;
  min-height: 52px;
  padding-top: 0;
  padding-bottom: 0;
  font-size: 1rem;
}
label small { font-weight: 500; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.check-row { display: flex !important; align-items: flex-start; gap: 9px !important; font-weight: 650 !important; }
.check-row input { width: auto; margin-top: 5px; }
.check-stack { display: grid; gap: 10px; }
.private-check { padding: 15px; background: #eee7f3; border: 1px solid #d8c8e4; border-radius: 12px; }
.field-with-action { display: grid; gap: 8px; }
.field-with-action > .button { justify-self: start; }
.character-counter {
  justify-self: end;
  margin-top: 1px;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 650;
  line-height: 1.3;
  text-align: right;
  transition: color .16s ease;
}
.character-counter.is-near-limit { color: #9a651c; }
.character-counter.is-at-limit { color: var(--danger); font-weight: 800; }
.current-upload { display: grid; grid-template-columns: 180px 1fr; align-items: center; gap: 16px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; }
.current-upload img { width: 180px; max-height: 120px; object-fit: cover; border-radius: 8px; }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.stat-card { display: grid; padding: 22px; text-decoration: none; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); }
.stat-card strong { font-family: var(--font-serif); font-size: 2.5rem; color: var(--text); }
.stat-card span { color: var(--muted); font-weight: 700; }
.private-stat { border-color: #d7ccdf; background: #f4eff7; }
.admin-grid, .security-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.security-grid { grid-template-columns: 1fr; }
.panel { padding: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.panel h2 { margin-top: 0; }
.danger-panel { border-color: #dfb4b4; }
.action-list { display: grid; }
.action-list a { display: flex; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--line); text-decoration: none; font-weight: 750; }
.compact-list { display: grid; }
.compact-list > div { display: grid; padding: 9px 0; border-bottom: 1px solid var(--line); }
.compact-list span { color: var(--muted); font-size: .82rem; }
.definition-list { display: grid; gap: 10px; }
.definition-list > div { display: grid; grid-template-columns: 180px 1fr; gap: 10px; padding-bottom: 9px; border-bottom: 1px solid var(--line); }
.definition-list dt { color: var(--muted); }
.definition-list dd { margin: 0; font-weight: 750; }

.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  border-radius: 12px;
  -webkit-overflow-scrolling: touch;
}
table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--line);
}
.admin-shell .table-wrap table { min-width: 820px; }
th, td { padding: 13px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
th { background: var(--surface-2); font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; }
td small { display: block; margin-top: 4px; color: var(--muted); }
.project-admin-primary {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  min-width: 0;
}
.project-admin-thumbnail {
  display: block;
  width: 80px;
  aspect-ratio: 5 / 4;
  flex: 0 0 80px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #ddd;
}
.project-admin-copy {
  min-width: 0;
  flex: 1 1 auto;
}
.actions { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.actions form { display: inline; margin: 0; }
/* Keep table action cells as true table cells so row borders and heights stay aligned. */
.table-wrap td.actions { display: table-cell; white-space: nowrap; }
.table-wrap td.actions > a, .table-wrap td.actions > form { display: inline-block; vertical-align: middle; margin-right: 12px; }
.table-wrap td.actions > :last-child { margin-right: 0; }
.actions a, .link-danger { border: 0; padding: 0; background: none; text-decoration: underline; font-weight: 700; font-size: .88rem; }
.link-danger { color: var(--danger); }

.private-notice { margin: 18px 0 24px; padding: 14px 16px; background: #efe8f4; border: 1px solid #d6c8e0; border-radius: 12px; color: #4f3f61; }
.goal-list { display: grid; gap: 14px; }
.goal-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 24px; align-items: start; padding: 22px; background: var(--surface); border: 1px solid #d6c8e0; border-radius: var(--radius); }
.goal-card > div:first-child { min-width: 0; }
.goal-card > .actions { align-self: start; justify-content: flex-end; flex-wrap: nowrap; white-space: nowrap; }
.goal-card > .actions form { display: inline-flex; }
.goal-card h2 { margin: 8px 0; }
.goal-card p { color: var(--muted); overflow-wrap: anywhere; }
.goal-completed { opacity: .82; }

.recovery-box { padding: 26px; border-radius: var(--radius); border: 2px solid var(--accent); background: var(--surface); }
.recovery-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 18px 0; }
.recovery-grid code { display: block; padding: 10px; background: var(--surface-2); border-radius: 8px; font-weight: 800; letter-spacing: .05em; }

.print-document { background: white; color: black; }
.print-actions { max-width: 820px; margin: 24px auto; padding: 0 20px; }
.print-record { max-width: 820px; margin: 40px auto; padding: 40px; background: white; border: 1px solid #ccc; }


.nav-logout-form { margin: 0; display: inline-flex; }
.nav-logout {
  appearance: none;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  line-height: inherit;
  text-decoration: none;
}
.nav-logout:hover { color: var(--text); }

.filter-bar { align-items: center; width: 100%; }
.filter-bar input[type="search"] { flex: 1 1 420px; min-width: 220px; width: auto; }
.filter-bar select { flex: 0 0 220px; width: 220px; }
.filter-bar > input[type="search"],
.filter-bar > select,
.filter-bar > .button {
  box-sizing: border-box;
  height: 52px;
  min-height: 52px;
}
.filter-bar > select {
  padding: 0 44px 0 16px;
  font-size: 1.05rem;
  line-height: 1.2;
}
.filter-bar > .button {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding-top: 0;
  padding-bottom: 0;
  white-space: nowrap;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
}
.pagination-status { color: var(--muted); font-size: .9rem; font-weight: 700; text-align: center; }
.button.is-disabled { opacity: .45; pointer-events: none; cursor: not-allowed; }

.tag-list { display: flex; flex-wrap: wrap; gap: 7px; margin: 10px 0; }
.tag-list-compact { margin: 8px 0 0; gap: 5px; }
.tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border: 1px solid #cfc6b8;
  border-radius: 999px;
  background: #f2eee6;
  color: #5d5549;
  font-size: .74rem;
  font-weight: 750;
  line-height: 1.35;
}
.tag-list-compact .tag { padding: 2px 7px; font-size: .7rem; }
.record-tags { margin: 14px 0 0; }
.search-result-section + .search-result-section { margin-top: 48px; padding-top: 38px; border-top: 1px solid var(--line); }

@media (max-width: 900px) {
  .hero-grid, .card-grid, .stats-grid, .admin-grid { grid-template-columns: 1fr 1fr; }
  .hero-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 680px) {
  .totp-setup-grid { grid-template-columns: 1fr; }
  .totp-qr-wrap { display: flex; justify-content: center; width: 100%; }
  .container,
  .narrow,
  .container.narrow,
  .admin-shell .page-header > .container,
  .admin-shell .page-section > .container,
  .admin-shell .page-header > .container.narrow,
  .admin-shell .page-section > .container.narrow {
    width: min(calc(100% - 28px), var(--container));
  }
  .nav-toggle { display: inline-flex; }
  .main-nav { display: none; position: absolute; top: 68px; left: 14px; right: 14px; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); flex-direction: column; align-items: stretch; }
  .main-nav.is-open { display: flex; }
  .main-nav a.is-active { padding-left: 12px; }
  .main-nav a.is-active::after { top: 2px; bottom: 2px; right: auto; width: 3px; height: auto; }
  .hero { padding: 60px 0 50px; }
  .hero h1 { font-size: clamp(2.7rem, 13vw, 4.25rem); line-height: .94; }
  .card-grid, .stats-grid, .admin-grid, .form-grid, .recovery-grid { grid-template-columns: 1fr; }
  .section-heading, .footer-grid { align-items: flex-start; flex-direction: column; }
  .goal-card { grid-template-columns: 1fr; }
  .goal-card > .actions { justify-content: flex-start; flex-wrap: wrap; white-space: normal; }
  .admin-shell .page-header .section-heading { align-items: flex-start; }
  .admin-header { padding: 30px 0 24px; }
  .admin-shell .page-section { padding: 34px 0 48px; }
  table, .admin-shell .table-wrap table { min-width: 680px; }
  .timeline > li { grid-template-columns: 1fr; gap: 5px; padding-left: 24px; }
  .search-form, .filter-bar { flex-direction: column; }
  .current-upload { grid-template-columns: 1fr; }
  .definition-list > div { grid-template-columns: 1fr; }
}


@media (max-width: 680px) {
  .main-nav .nav-logout-form { width: 100%; }
  .main-nav .nav-logout { width: 100%; text-align: left; padding: 4px 0; }
  .filter-bar input[type="search"], .filter-bar select { width: 100%; min-width: 0; flex: 1 1 auto; }
  .pagination { justify-content: space-between; }
  .pagination-status { width: 100%; order: -1; }
}

@media print {
  body { background: white; color: black; font-size: 11pt; }
  .no-print, .site-header, .site-footer { display: none !important; }
  .page-section, .page-header { padding: 0; background: white; border: 0; }
  .container, .narrow { width: 100%; max-width: none; }
  a { color: black; text-decoration: none; }
  .record-image { max-height: 420px; break-inside: avoid; }
  .timeline > li { break-inside: avoid; }
  .print-record { margin: 0; padding: 0; border: 0; max-width: none; }
}

/* v2.0: Keep analytics cards fully inside the admin container. */
.analytics-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
}
.analytics-panel {
  min-width: 0;
  overflow: hidden;
}
.analytics-panel .table-wrap {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
}
.analytics-panel .table-wrap table {
  width: 100%;
  min-width: 0 !important;
  max-width: 100%;
  table-layout: fixed;
}
.analytics-summary-panel th:nth-child(1),
.analytics-summary-panel td:nth-child(1) { width: 28%; }
.analytics-summary-panel th:nth-child(2),
.analytics-summary-panel td:nth-child(2) { width: 24%; }
.analytics-summary-panel th:nth-child(3),
.analytics-summary-panel td:nth-child(3) { width: 48%; }
.analytics-routes-panel th:nth-child(1),
.analytics-routes-panel td:nth-child(1) { width: 60%; }
.analytics-routes-panel th:nth-child(2),
.analytics-routes-panel td:nth-child(2),
.analytics-routes-panel th:nth-child(3),
.analytics-routes-panel td:nth-child(3) { width: 20%; }
.analytics-routes-panel code {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* v2.0: Reduce the excessive gap between the Private Goals header and filters. */
.admin-shell .private-goals-list-section {
  padding-top: 32px;
}
.private-goals-list-section .filter-bar {
  margin-top: 0;
}

@media (max-width: 1000px) {
  .analytics-grid {
    grid-template-columns: 1fr;
  }
}

/* v2.1: Standardize the vertical gap between admin page headers and their main content. */
.admin-shell .page-section,
.admin-shell .private-goals-list-section {
  padding-top: 48px;
}

@media (max-width: 680px) {
  .admin-shell .page-section,
  .admin-shell .private-goals-list-section {
    padding-top: 34px;
  }
}


/* v2.3: Modern typography pairing and destructive portfolio-reset controls. */
.button:disabled {
  opacity: .5;
  cursor: not-allowed;
  filter: saturate(.7);
}
.portfolio-reset-panel {
  border-width: 2px;
}
.danger-eyebrow {
  color: var(--danger);
}
.reset-preservation-note {
  display: grid;
  gap: 4px;
  margin: 18px 0 24px;
  padding: 15px 16px;
  border: 1px solid #d9c9aa;
  border-radius: 12px;
  background: #f6efe2;
  color: #5b4a2f;
}
.reset-preservation-note strong {
  color: var(--text);
}
.reset-acknowledgement {
  padding: 14px 15px;
  border: 1px solid #dfb4b4;
  border-radius: 12px;
  background: #fbefef;
}
.portfolio-reset-panel code {
  font-size: .92em;
  font-weight: 800;
}

/* v2.4: Keep the destructive portfolio reset collapsed until the owner intentionally expands it. */
.danger-zone-disclosure {
  margin: 0;
}

.danger-zone-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.danger-zone-summary::-webkit-details-marker {
  display: none;
}

.danger-zone-summary::marker {
  content: "";
}

.danger-zone-summary-copy {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.danger-zone-summary .eyebrow {
  margin: 0;
}

.danger-zone-title {
  display: block;
  color: var(--text);
  font-family: var(--font-serif);
  font-size: clamp(1.6rem, 2vw, 2rem);
  font-weight: 700;
  line-height: 1.08;
}

.danger-zone-summary-text {
  color: var(--muted);
  font-size: .95rem;
  line-height: 1.5;
}

.danger-zone-chevron {
  width: 13px;
  height: 13px;
  flex: 0 0 13px;
  border-right: 2px solid var(--danger);
  border-bottom: 2px solid var(--danger);
  transform: rotate(45deg);
  transition: transform .18s ease;
}

.danger-zone-disclosure[open] .danger-zone-chevron {
  transform: rotate(225deg);
}

.danger-zone-summary:focus-visible {
  outline: 3px solid rgba(168, 50, 50, .24);
  outline-offset: 6px;
  border-radius: 8px;
}

.danger-zone-content {
  margin-top: 22px;
  padding-top: 22px;
  border-top: 1px solid #dfb4b4;
}

.danger-zone-content > :first-child {
  margin-top: 0;
}

@media (max-width: 680px) {
  .danger-zone-summary {
    gap: 16px;
  }

  .danger-zone-title {
    font-size: 1.55rem;
  }
}

/* v2.6: Context-aware Improve Writing review modal, refined print view, and unified notifications. */
body.modal-open {
  overflow: hidden;
}

.writing-review-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(18, 21, 19, .62);
  backdrop-filter: blur(5px);
}

.writing-review-backdrop[hidden] {
  display: none !important;
}

.writing-review-modal {
  width: min(100%, 920px);
  max-height: min(88vh, 860px);
  overflow: auto;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 30px 90px rgba(20, 20, 18, .28);
}

.writing-review-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.writing-review-header h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: clamp(1.8rem, 3vw, 2.5rem);
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: -.025em;
}

.writing-review-close {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 1.5rem;
  line-height: 1;
}

.writing-review-close:hover,
.writing-review-close:focus-visible {
  color: var(--text);
  border-color: var(--accent);
}

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

.writing-review-block {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg);
}

.writing-review-improved {
  border-color: #9dbcae;
  background: #eef6f1;
}

.writing-review-block h3 {
  margin: 0 0 10px;
  font-size: .76rem;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.writing-review-text {
  min-height: 96px;
  max-height: 360px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--text);
  line-height: 1.6;
}

.writing-review-notice {
  margin: 16px 0 0;
  padding: 12px 14px;
  border: 1px solid #d8c8a7;
  border-radius: 12px;
  background: #f6efe1;
  color: #655337;
  font-weight: 700;
}

.writing-review-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 20px;
}

.print-document {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

.print-page-shell {
  width: min(calc(100% - 40px), 920px);
  margin: 0 auto 48px;
}

.print-actions {
  width: min(calc(100% - 40px), 920px);
  max-width: 920px;
  margin: 24px auto 0;
  padding: 0;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
}

.print-back-link {
  font-weight: 750;
}

.print-record,
.goal-print-record {
  max-width: 920px;
  margin: 24px auto 0;
  padding: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.goal-detail-title {
  margin: 8px 0 18px;
  max-width: 100%;
  font-family: var(--font-serif);
  font-size: clamp(2.4rem, 6vw, 5rem);
  font-weight: 600;
  line-height: .98;
  letter-spacing: -.035em;
  overflow-wrap: anywhere;
}

.goal-print-meta {
  gap: 8px 0;
}

.goal-print-meta span {
  display: inline-flex;
  align-items: center;
}

.goal-print-meta span + span::before {
  content: "·";
  margin: 0 10px;
  color: var(--accent-2);
  font-weight: 900;
}

.goal-print-description {
  margin-top: 24px;
  font-size: 1.04rem;
}

.goal-privacy-note {
  display: grid;
  gap: 4px;
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  color: var(--muted);
}

.goal-privacy-note strong {
  color: var(--text);
}

@media (max-width: 680px) {
  .writing-review-backdrop {
    padding: 12px;
    align-items: end;
  }

  .writing-review-modal {
    width: 100%;
    max-height: 92vh;
    padding: 20px;
    border-radius: 18px 18px 10px 10px;
  }

  .writing-review-grid {
    grid-template-columns: 1fr;
  }

  .writing-review-text {
    min-height: 72px;
    max-height: 220px;
  }

  .writing-review-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .print-page-shell,
  .print-actions {
    width: min(calc(100% - 28px), 920px);
  }

  .print-record,
  .goal-print-record {
    padding: 22px;
  }

  .goal-detail-title {
    font-size: clamp(2.2rem, 13vw, 4rem);
  }

  .goal-print-meta {
    display: grid;
    gap: 4px;
  }

  .goal-print-meta span + span::before {
    content: none;
  }
}

@media print {
  @page {
    margin: 16mm;
  }

  .print-document {
    background: white;
  }

  .print-page-shell {
    width: 100%;
    margin: 0;
  }

  .print-record,
  .goal-print-record {
    max-width: none;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: white;
  }

  .goal-detail-title {
    font-size: 30pt;
    line-height: 1.04;
    page-break-after: avoid;
  }

  .goal-privacy-note {
    break-inside: avoid;
  }
}

/* v2.7: Improve the Private Goals mobile filter button proportions. */
@media (max-width: 680px) {
  .private-goals-list-section .filter-bar > .button {
    min-width: 150px;
    align-self: center;
  }
}
