:root {
  --ink: #10231f;
  --ink-soft: #445852;
  --paper: #edf3f0;
  --foam: #d9ebe4;
  --sea: #1b7a64;
  --sea-deep: #0c3f35;
  --accent: #2a8f9e;
  --accent-soft: #7ec8d2;
  --line: rgba(16, 35, 31, 0.12);
  --danger: #a33b2d;
  --radius: 14px;
  --font-display: "Fraunces", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-body: "Source Sans 3", "Segoe UI", sans-serif;
  --shadow: 0 18px 50px rgba(12, 63, 53, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.05rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
  word-break: break-word;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(27, 122, 100, 0.2), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(42, 143, 158, 0.18), transparent 50%),
    linear-gradient(165deg, #e8f2ef 0%, var(--paper) 48%, #e2ebe7 100%);
}

a {
  color: var(--sea-deep);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

a:hover {
  color: var(--sea);
}

.site-header {
  --header-control-h: 2.4rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem clamp(1rem, 4vw, 2.5rem);
  position: relative;
  background: rgba(237, 243, 240, 0.92);
  border-bottom: 1px solid var(--line);
  min-height: 3.75rem;
}

.brand {
  font-family: var(--font-display);
  font-weight: 650;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--sea-deep);
  text-decoration: none;
  min-width: 0;
  max-width: min(48vw, 22rem);
  overflow-wrap: anywhere;
  display: inline-flex;
  align-items: center;
  align-self: center;
}

.header-end {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: wrap;
  justify-content: flex-end;
  min-width: 0;
  align-self: center;
}

.header-book-tools {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: nowrap;
  min-width: 0;
  align-self: center;
}

/* Forms have UA margin and baseline quirks — reset for header alignment. */
.site-header form.header-search {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
  align-self: center;
  vertical-align: middle;
}

.header-search input[type="search"] {
  box-sizing: border-box;
  width: min(16rem, 42vw);
  min-width: 8rem;
  height: var(--header-control-h);
  margin: 0;
  padding: 0 0.85rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  font: inherit;
  font-size: 0.95rem;
  line-height: var(--header-control-h);
  background: #fffcf7;
  color: var(--ink);
  -webkit-appearance: none;
  appearance: none;
}

.header-search input[type="search"]::-webkit-search-decoration,
.header-search input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

.header-search .header-search-btn {
  box-sizing: border-box;
  height: var(--header-control-h);
  min-height: var(--header-control-h);
  padding: 0 0.95rem;
  margin: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transform: none;
}

.header-search .header-search-btn:hover {
  transform: none;
}

.book-calendar {
  position: relative;
  display: inline-flex;
  align-items: center;
  align-self: center;
}

.cal-toggle {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--header-control-h);
  height: var(--header-control-h);
  padding: 0;
  margin: 0;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fffcf7;
  color: var(--sea-deep);
  cursor: pointer;
  line-height: 1;
}

.cal-toggle:hover,
.cal-toggle[aria-expanded="true"] {
  border-color: rgba(27, 122, 100, 0.4);
  background: var(--foam);
}

.cal-pop {
  position: absolute;
  top: calc(100% + 0.45rem);
  right: 0;
  z-index: 40;
  width: min(19.5rem, calc(100vw - 2rem));
  padding: 0.85rem;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fffcf7;
  box-shadow: var(--shadow);
}

.cal-pop[hidden] {
  display: none;
}

.cal-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  margin-bottom: 0.55rem;
}

.cal-heading {
  font-family: var(--font-display);
  font-weight: 650;
  font-size: 1rem;
}

.cal-nav {
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}

.cal-nav:hover {
  background: var(--foam);
}

.cal-jump {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 0.4rem;
  margin-bottom: 0.65rem;
}

.cal-jump select {
  width: 100%;
  padding: 0.35rem 0.45rem;
  border-radius: 8px;
  font-size: 0.9rem;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.2rem;
}

.cal-dow {
  text-align: center;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-soft);
  padding: 0.2rem 0;
}

.cal-day {
  aspect-ratio: 1;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-size: 0.88rem;
  cursor: default;
}

.cal-day-empty {
  visibility: hidden;
}

.cal-day-has {
  background: var(--foam);
  color: var(--sea-deep);
  font-weight: 700;
  cursor: pointer;
}

.cal-day-has:hover {
  background: #cfe4db;
}

.cal-day-selected {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.cal-day-today:not(.cal-day-has) {
  box-shadow: inset 0 0 0 1px var(--line);
}

.cal-day:disabled {
  opacity: 0.45;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.nav {
  display: inline-flex;
  gap: 0.85rem;
  align-items: center;
  flex-wrap: wrap;
  line-height: 1;
  align-self: center;
  margin: 0;
  padding: 0;
}

.nav a,
.nav button.linkish,
.nav .muted {
  font-size: 0.95rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  margin: 0;
}

.nav form {
  display: inline-flex;
  align-items: center;
  margin: 0;
  padding: 0;
}

.profile-menu {
  position: relative;
  display: inline-flex;
  align-items: center;
  align-self: center;
  margin-left: 0.15rem;
}

.profile-toggle {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--header-control-h, 2.4rem);
  height: var(--header-control-h, 2.4rem);
  padding: 0;
  margin: 0;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fffcf7;
  color: var(--sea-deep);
  cursor: pointer;
  line-height: 1;
}

.profile-toggle:hover,
.profile-toggle[aria-expanded="true"] {
  border-color: rgba(27, 122, 100, 0.4);
  background: var(--foam);
}

.profile-pop {
  position: absolute;
  top: calc(100% + 0.45rem);
  right: 0;
  z-index: 50;
  min-width: 12.5rem;
  max-width: min(20rem, calc(100vw - 2rem));
  padding: 0.45rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fffcf7;
  box-shadow: var(--shadow);
  display: grid;
  gap: 0.15rem;
}

.profile-pop[hidden] {
  display: none;
}

.profile-email {
  padding: 0.55rem 0.7rem 0.45rem;
  font-size: 0.82rem;
  color: var(--ink-soft);
  overflow-wrap: anywhere;
  border-bottom: 1px solid var(--line);
  margin-bottom: 0.2rem;
}

.profile-item {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  text-decoration: none;
  color: var(--ink);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  text-align: left;
  border: none;
  background: transparent;
  cursor: pointer;
}

.profile-item:hover {
  background: var(--foam);
  color: var(--sea-deep);
}

.profile-logout {
  display: block;
  margin: 0;
  padding: 0;
}

.profile-item-btn {
  color: var(--danger);
}

.profile-item-btn:hover {
  background: rgba(163, 59, 45, 0.08);
  color: var(--danger);
}

button.linkish {
  background: none;
  border: none;
  padding: 0;
  color: var(--sea-deep);
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

.wrap {
  width: min(920px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0 4rem;
}

.wrap-wide {
  width: min(1100px, calc(100% - 2rem));
}

.hero {
  min-height: calc(100vh - 4.5rem);
  display: grid;
  align-items: end;
  padding: clamp(1.5rem, 5vw, 4rem);
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(120deg, rgba(12, 63, 53, 0.92), rgba(27, 122, 100, 0.62) 48%, rgba(42, 143, 158, 0.42)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160'%3E%3Cpath fill='none' stroke='rgba(255,255,255,0.08)' stroke-width='1' d='M0 80h160M80 0v160'/%3E%3C/svg%3E");
  background-size: cover, 120px 120px;
  animation: wash 14s ease-in-out infinite alternate;
}

@keyframes wash {
  from { filter: saturate(1) brightness(1); }
  to { filter: saturate(1.15) brightness(1.05); }
}

.hero-inner {
  position: relative;
  z-index: 1;
  color: #f7f3ea;
  max-width: 28rem;
  animation: rise 0.9s ease-out both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}

.hero-brand {
  font-family: var(--font-display);
  font-size: clamp(3.4rem, 10vw, 6.2rem);
  line-height: 0.92;
  letter-spacing: -0.04em;
  margin: 0 0 1rem;
}

.hero p {
  margin: 0 0 1.5rem;
  font-size: 1.15rem;
  max-width: 24rem;
  opacity: 0.92;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: none;
  border-radius: 999px;
  padding: 0.7rem 1.25rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--accent);
  color: #f4fcfd;
  box-shadow: 0 10px 24px rgba(42, 143, 158, 0.28);
}

.btn-primary:hover {
  background: #217987;
  color: #fff;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.35);
}

.btn-ghost {
  background: transparent;
  color: var(--sea-deep);
  border: 1px solid var(--line);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.cta-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.panel {
  background: rgba(255, 252, 246, 0.78);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem 1.35rem;
  box-shadow: var(--shadow);
}

.stack {
  display: grid;
  gap: 1rem;
}

.stack-lg {
  gap: 1.5rem;
}

.page-toolbar {
  margin-bottom: 0.35rem;
}

.manage-page {
  gap: 2.25rem;
}

.manage-toc {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1.1rem;
  padding: 0.85rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 252, 246, 0.55);
}

.manage-toc a {
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
}

.manage-toc a:hover {
  text-decoration: underline;
}

.manage-toc a.is-active {
  color: var(--sea);
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

.manage-card-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

a.manage-card {
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

a.manage-card:hover {
  border-color: rgba(31, 111, 91, 0.35);
  transform: translateY(-1px);
}

a.manage-card h2 {
  margin: 0;
  color: var(--sea-deep);
}

a.manage-card-danger h2 {
  color: var(--danger);
}

.manage-section-head {
  display: grid;
  gap: 0.35rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 0.25rem;
}

.manage-section-head h2 {
  margin: 0;
}

.manage-section-head .muted {
  margin: 0;
}

.manage-subsection {
  padding-top: 0.35rem;
}

.manage-subsection h3 {
  margin: 0;
  font-size: 1.05rem;
}

h1, h2, h3 {
  font-family: var(--font-display);
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin: 0 0 0.6rem;
}

.muted {
  color: var(--ink-soft);
}

time.local-datetime {
  display: inline-block;
  font-size: 0.9rem;
}

.flash {
  padding: 0.75rem 1rem;
  border-radius: 10px;
  background: #f8e6df;
  color: var(--danger);
  border: 1px solid rgba(163, 59, 45, 0.2);
}

.flash-ok {
  background: #e3f2eb;
  color: var(--sea-deep);
  border-color: rgba(31, 111, 91, 0.25);
}

label {
  display: grid;
  gap: 0.35rem;
  font-weight: 600;
  font-size: 0.92rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
  font: inherit;
  background: #fffcf7;
  color: var(--ink);
}

textarea {
  min-height: 180px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.95rem;
  line-height: 1.45;
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
}

.book-list {
  display: grid;
  gap: 0.85rem;
}

.book-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding: 1rem 1.1rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 252, 246, 0.7);
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.book-row:hover {
  border-color: rgba(31, 111, 91, 0.35);
  transform: translateY(-1px);
}

.book-row a.title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  text-decoration: none;
  color: var(--ink);
}

.pill {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: var(--foam);
  color: var(--sea-deep);
}

.pill-lock {
  background: #d9e8f0;
  color: #1f5a6b;
}

.post-list {
  display: grid;
  gap: 0.75rem;
}

.post-item {
  padding: 0.95rem 0;
  border-bottom: 1px solid var(--line);
}

.post-item:last-child {
  border-bottom: none;
}

.post-item a {
  font-family: var(--font-display);
  font-size: 1.2rem;
  text-decoration: none;
  color: var(--ink);
}

.prose {
  font-size: 1.08rem;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.prose a,
.post-title,
.book-title,
.post-body {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.css-class-hints {
  margin: 0.35rem 0 0;
  padding-left: 1.15rem;
  font-size: 0.88rem;
  font-weight: 400;
  color: var(--ink-soft);
  display: grid;
  gap: 0.2rem;
}

.css-class-hints code {
  font-size: 0.86em;
}

.prose :where(h1, h2, h3) {
  margin-top: 1.4em;
}

.prose :where(pre) {
  overflow-x: auto;
  padding: 0.9rem 1rem;
  border-radius: 10px;
  background: #13241f;
  color: #e8f2ee;
}

.prose :where(code) {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
}

.prose :where(p code) {
  background: rgba(15, 61, 51, 0.08);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

.prose :where(blockquote) {
  margin-left: 0;
  padding-left: 1rem;
  border-left: 3px solid var(--accent-soft);
  color: var(--ink-soft);
}

.attachments {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.attachments img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--line);
}

.attachments-thumbs {
  grid-template-columns: repeat(auto-fill, minmax(72px, 72px));
  gap: 0.5rem;
  margin-top: 0.35rem;
}

.attachments-thumbs img {
  width: 72px;
  height: 72px;
  border-radius: 8px;
}

.image-manage {
  display: grid;
  gap: 0.75rem;
}

.image-manage-row {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.image-manage-row img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
}

.book-shell {
  min-height: 60vh;
  border-radius: calc(var(--radius) + 4px);
  padding: clamp(1.2rem, 3vw, 2rem);
  border: 1px solid var(--line);
  background: rgba(255, 252, 246, 0.82);
}

.field-error {
  display: block;
  margin-top: 0.35rem;
  color: var(--danger);
  font-size: 0.88rem;
  font-weight: 500;
}

input.input-invalid,
textarea.input-invalid {
  border-color: var(--danger);
}

.hint {
  font-size: 0.88rem;
  font-weight: 400;
  color: var(--ink-soft);
}

.empty {
  padding: 2rem 0;
  color: var(--ink-soft);
}

.danger-zone {
  border-color: rgba(163, 59, 45, 0.28);
  background: rgba(163, 59, 45, 0.05);
}

.post-item-manage {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
}

.post-check {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  font-weight: 400;
  flex: 1;
  min-width: 0;
}

.post-check-body {
  min-width: 0;
}

.delete-preview-list {
  margin: 0;
  padding-left: 1.2rem;
  display: grid;
  gap: 0.35rem;
}

.danger-zone h1,
.danger-zone h2 {
  color: var(--danger);
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
  background: rgba(16, 35, 31, 0.08);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

@media (max-width: 640px) {
  .book-row {
    flex-direction: column;
    align-items: flex-start;
  }
}
