* { box-sizing: border-box; }

html {
  background: #eee6db;
  color: #1c1c1c;
  font-family: var(--font-body);
  font-size: 16px;
}

body {
  min-height: 100vh;
  margin: 0;
  background: #f5efe7;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

button,
input,
textarea { font: inherit; }

.notes-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: calc(58px + env(safe-area-inset-top));
  padding: calc(7px + env(safe-area-inset-top)) 12px 7px;
  border-bottom: 1px solid rgba(28, 28, 28, .09);
  background: rgba(250, 246, 240, .92);
  backdrop-filter: blur(18px) saturate(150%);
}

.notes-header > strong {
  overflow: hidden;
  font-size: 16px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.back-link {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: #1c1c1c;
  text-decoration: none;
  font-size: 22px;
}

.header-save {
  min-height: 38px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: #e82203;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

.header-reset {
  min-height: 38px;
  padding: 0 9px;
  border: 0;
  background: transparent;
  color: #77706a;
  font-size: 12px;
  font-weight: 600;
}

.notes-main {
  width: min(680px, 100%);
  margin: auto;
  padding: 16px 12px 48px;
}

.notes-intro {
  margin: 2px 4px 14px;
}

.notes-intro h1 {
  margin: 0;
  font: 600 italic clamp(29px, 8vw, 38px)/1.05 var(--font-heading);
  letter-spacing: -.02em;
}

.notes-intro p {
  margin: 5px 0 0;
  color: #69635d;
  font-size: 13px;
  line-height: 1.4;
}

#sermon-notes {
  overflow: hidden;
  border: 1px solid rgba(28, 28, 28, .1);
  border-radius: 15px;
  background: rgba(255, 255, 255, .74);
  box-shadow: 0 10px 28px rgba(44, 35, 26, .05);
}

.note-card {
  margin: 0;
  padding: 15px 16px 17px;
  border-top: 1px solid rgba(28, 28, 28, .09);
}

.note-card:first-child { border-top: 0; }
.note-card--application { background: rgba(255, 240, 238, .55); }

.note-card > h2 {
  margin: 0 0 11px;
  font: 600 italic 20px/1.1 var(--font-heading);
}

.field-grid {
  display: grid;
  grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr);
  gap: 10px 13px;
}

.field {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.field--wide { grid-column: 1 / -1; }

.field > span {
  overflow: hidden;
  color: #77706a;
  font: 700 9px/1.2 var(--font-condensed);
  letter-spacing: .09em;
  text-transform: uppercase;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.field input,
.field textarea {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 8px 0;
  border: 0;
  border-bottom: 1px solid rgba(28, 28, 28, .19);
  border-radius: 0;
  background: transparent;
  color: #1c1c1c;
  font-size: 16px;
  line-height: 1.4;
  outline: none;
  resize: none;
}

.field input:focus,
.field textarea:focus,
.point-row textarea:focus { border-color: #e82203; }

.field input::placeholder,
.field textarea::placeholder,
.point-row textarea::placeholder { color: #aaa39b; }

.field--notes textarea {
  min-height: 112px;
  padding: 11px 12px;
  border: 1px solid rgba(28, 28, 28, .12);
  border-radius: 9px;
  background: rgba(255, 255, 255, .63);
  line-height: 1.5;
}

.field textarea[name="application"] { min-height: 86px; }

.point-row {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) 30px;
  align-items: start;
  gap: 7px;
}

.point-row + .point-row { margin-top: 4px; }

.point-index {
  display: grid;
  place-items: center;
  width: 23px;
  height: 23px;
  margin-top: 9px;
  border-radius: 50%;
  background: #f1c491;
  font: 700 10px/1 var(--font-condensed);
}

.point-row textarea {
  width: 100%;
  min-height: 42px;
  padding: 8px 0;
  border: 0;
  border-bottom: 1px solid rgba(28, 28, 28, .16);
  background: transparent;
  font-size: 16px;
  line-height: 1.4;
  resize: none;
  outline: none;
}

.point-remove {
  width: 30px;
  height: 38px;
  border: 0;
  background: transparent;
  color: #918b84;
  font-size: 20px;
}

.add-point {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  margin-top: 5px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #c41b02;
  font: 700 10px/1 var(--font-condensed);
  letter-spacing: .07em;
  text-transform: uppercase;
}

.add-point span {
  display: grid;
  place-items: center;
  width: 23px;
  height: 23px;
  border: 1px solid rgba(232, 34, 3, .24);
  border-radius: 50%;
  font-size: 16px;
}

button:active { transform: scale(.97); }

dialog {
  width: min(480px, calc(100vw - 24px));
  padding: 22px;
  border: 0;
  border-radius: 18px;
  background: #f7efe4;
  color: #1c1c1c;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .28);
}

dialog::backdrop {
  background: rgba(20, 20, 20, .58);
  backdrop-filter: blur(4px);
}

.dialog-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
}

.eyebrow {
  color: #e82203;
  font-family: var(--font-condensed);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.dialog-head h2,
.reset-dialog h2 {
  margin: 5px 0 8px;
  font: 600 italic 28px/1 var(--font-heading);
}

.dialog-head button {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(28, 28, 28, .13);
  border-radius: 50%;
  background: transparent;
  font-size: 22px;
}

.reset-dialog > p {
  margin: 6px 0 0;
  color: #5f5953;
  font-size: 14px;
  line-height: 1.45;
}

.export-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-top: 18px;
}

.export-actions button {
  display: grid;
  align-content: center;
  gap: 4px;
  min-height: 78px;
  padding: 12px;
  border: 1px solid rgba(28, 28, 28, .13);
  border-radius: 11px;
  background: white;
  text-align: left;
}

.export-actions strong { font-size: 14px; }
.export-actions span { color: #6d6761; font-size: 11px; line-height: 1.3; }

.export-status {
  display: block;
  min-height: 16px;
  margin-top: 10px;
  color: #c41b02;
  font-size: 12px;
}

.reset-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 20px;
}

.reset-actions button {
  min-height: 46px;
  border: 1px solid rgba(28, 28, 28, .14);
  border-radius: 999px;
  background: white;
  font-size: 13px;
  font-weight: 700;
}

.reset-actions .danger {
  border: 0;
  background: #c41b02;
  color: white;
}

.export-sheet {
  position: fixed;
  left: -9999px;
  top: 0;
  width: 900px;
  padding: 72px;
  background: #f7efe4;
  color: #1c1c1c;
  font-family: Arial, sans-serif;
}

.export-sheet header { padding-bottom: 34px; border-bottom: 5px solid #e82203; }
.export-sheet header > span,
.export-sheet small { color: #e82203; font-weight: 800; letter-spacing: .14em; }
.export-sheet h1 { margin: 16px 0; font-family: Georgia, serif; font-size: 58px; font-style: italic; }
.export-sheet header p { display: flex; justify-content: space-between; }
.export-sheet section { padding: 30px 0; border-bottom: 1px solid #c9bfb3; }
.export-sheet section h2 { font-family: Georgia, serif; font-size: 30px; }
.export-sheet ol { padding-left: 28px; font-size: 22px; line-height: 1.6; }
.export-copy { white-space: pre-wrap; font-size: 21px; line-height: 1.65; }
.export-application { padding: 30px !important; background: #fff0ee; }
.export-sheet footer { padding-top: 30px; color: #666; font-size: 14px; text-align: center; }

@media (max-width: 679px) {
  dialog {
    width: 100%;
    max-width: none;
    margin: auto 0 0;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
    border-radius: 20px 20px 0 0;
  }
}

@media (min-width: 680px) {
  .notes-main { padding-top: 26px; }
  .notes-intro { margin-bottom: 18px; }
  .note-card { padding: 20px 22px 22px; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
