:root {
  color-scheme: light;
  --ink: #41252b;
  --muted: #77565d;
  --accent: #a43f5b;
  --accent-dark: #8c304b;
  --border: #e9d3d3;
  --paper: #fffbf6;
  --blush: #f8e9e8;
  font-family: "Geeza Pro", "Segoe UI", Tahoma, Arial, sans-serif;
  background: #f5e7e5;
  color: var(--ink);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100svh; padding: clamp(14px, 3vw, 50px); display: grid; place-items: center; }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .52; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
svg { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; width: 1em; height: 1em; flex: none; }
.symbols { position: absolute; overflow: hidden; width: 0; height: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.layout {
  width: min(100%, 1280px);
  min-height: min(735px, calc(100svh - 2 * clamp(14px, 3vw, 50px)));
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.12fr);
  background: var(--paper);
  border: 1px solid #ecd5d4;
  border-radius: 32px;
  padding: 12px;
  box-shadow: 0 32px 90px -54px #72394d8c;
}

.cover {
  position: relative;
  grid-column: 2;
  grid-row: 1;
  min-height: 650px;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
  isolation: isolate;
  border-radius: 23px;
  background: radial-gradient(ellipse at 75% 20%, #d9818b 0, #9a4559 47%, #381e2a 100%);
  color: #fff8f1;
}
.cover::before, .cover::after { content: ""; position: absolute; inset: 0; z-index: -1; }
.cover::before { background-image: linear-gradient(180deg, transparent 30%, #180d1740 53%, #211019dc 100%); }
.is-open .cover::before {
  background-image: linear-gradient(180deg, #1f12191a 13%, #21141d00 36%, #24152145 55%, #211019e6 100%), url("/aya.webp");
  background-size: cover;
  background-position: center, 58% 42%;
}
.cover::after { inset: 13px; border: 1px solid #fff8ef53; border-radius: 15px; pointer-events: none; }
.cover-content { width: 100%; padding: clamp(28px, 4.5vw, 64px); }
.love-mark { display: grid; place-items: center; width: 42px; height: 42px; border: 1px solid #fff6ea9c; border-radius: 50%; margin-bottom: 20px; font-size: 17px; }
.dedication { font-family: "Iowan Old Style", "Baskerville", Georgia, serif; font-size: clamp(53px, 7.7vw, 113px); line-height: .88; letter-spacing: -.052em; }
.dedication span, .dedication em { display: block; }
.dedication em { color: #ffd2d4; font-weight: 400; }
.cover-note { margin-top: 29px; display: flex; align-items: center; gap: 10px; font-family: Georgia, serif; font-size: 13px; letter-spacing: .13em; }
.cover-note span { width: 20px; height: 1px; background: #ffe0df99; }
.cover-note span:last-child { display: none; }

.letter { min-width: 0; padding: 24px clamp(20px, 4.2vw, 66px) 22px; display: flex; flex-direction: column; }
.letter-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.private { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: .875rem; }
.private svg { color: var(--accent); }
.letter-content { margin-block: auto; padding-block: 40px 32px; }
.salutation { color: var(--accent-dark); margin: 0 0 6px; display: flex; gap: 8px; align-items: center; font-size: .95rem; font-weight: 650; }
.salutation svg { fill: #f3ccd1; height: 15px; width: 15px; }
h1 { margin: 0; font-size: clamp(2.45rem, 4.3vw, 4.55rem); line-height: 1.2; letter-spacing: -.045em; }
h1 span { color: var(--accent); font-weight: 400; }
.intro { margin: 10px 0 0; color: var(--muted); max-width: 36ch; line-height: 1.75; font-size: 1rem; }

.details { margin-top: 28px; }
.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
h2, h3 { font-size: 1.02rem; margin: 0; font-weight: 720; }
.details h2, .links h2 { margin-bottom: 8px; }
.credential { display: flex; justify-content: space-between; gap: 10px; align-items: center; background: #fffdfa; border: 1px solid var(--border); border-radius: 13px; padding: 10px 13px 10px 10px; margin-top: 8px; }
.credential-text { display: grid; gap: 3px; min-width: 0; }
.field-label { color: var(--muted); font-size: .875rem; }
.credential bdi { display: block; min-width: 0; font-size: .95rem; font-family: ui-monospace, Menlo, monospace; overflow-wrap: anywhere; white-space: pre-wrap; }
.controls { display: flex; align-items: center; gap: 6px; flex: none; }
.soft-button, .icon-button, .text-button { border: 0; font-size: .875rem; font-weight: 650; color: var(--accent-dark); display: inline-flex; align-items: center; justify-content: center; gap: 6px; flex: none; }
.soft-button, .icon-button { background: var(--blush); border-radius: 9px; min-height: 36px; padding: 5px 11px; }
.icon-button { min-width: 36px; padding-inline: 6px; }
.icon-button[aria-pressed="true"] { background: #eed0d4; color: var(--ink); }
.text-button { background: transparent; padding: 5px 0; }
.text-button:hover { text-decoration: underline; }
.soft-button:not(:disabled):hover, .icon-button:not(:disabled):hover { background: #f1d6d6; }

.links { margin-top: 24px; }
.link-list { display: grid; gap: 7px; }
.link-row { display: flex; align-items: center; gap: 9px; border: 1px solid var(--border); border-radius: 13px; padding: 9px; background: #fffdfa; }
.link-icon { width: 35px; height: 35px; display: grid; place-items: center; flex: none; border-radius: 8px; background: var(--blush); color: var(--accent-dark); }
.link-info { min-width: 0; flex: 1; display: grid; gap: 3px; }
.link-info strong, .link-info bdi { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-info strong { font-size: .9rem; }
.link-info bdi { font-size: .81rem; color: var(--muted); }
.open-link { color: var(--accent-dark); text-decoration: none; font-weight: 700; font-size: .875rem; padding: 8px 4px; }
.open-link:hover { text-decoration: underline; }
.empty { font-size: .9rem; color: var(--muted); margin: 5px 0 0; }
.letter-footer { border-top: 1px solid var(--border); padding-top: 13px; font-size: .875rem; display: flex; gap: 6px; align-items: center; color: var(--muted); }
.letter-footer svg { color: var(--accent-dark); }
.unlock-form { margin-top: 26px; max-width: 350px; }
label { display: block; font-weight: 650; font-size: .925rem; }
input { display: block; width: 100%; color: var(--ink); background: #fffdfa; border: 1px solid #dcbfc3; border-radius: 10px; min-height: 46px; padding: 10px 12px; margin: 6px 0 14px; }
.primary { color: #fff; width: 100%; background: var(--accent-dark); border: 0; border-radius: 10px; padding: 13px 16px; font-weight: 700; }
.primary:not(:disabled):hover { background: #742740; }
.primary span { margin-inline-start: 5px; }
.feedback { color: #932d43; line-height: 1.55; margin-block: 8px 0; font-size: .9rem; }
.feedback:empty { display: none; }

dialog { color: var(--ink); background: var(--paper); border: 1px solid var(--border); border-radius: 22px; padding: 22px; width: min(540px, calc(100% - 28px)); max-height: calc(100svh - 32px); box-shadow: 0 20px 80px #38162545; }
dialog::backdrop { background: #361b2b83; }
dialog .section-heading { margin-bottom: 17px; }
dialog .link-heading { margin-block: 20px 6px; }
dialog .icon-button { font-size: 1.25rem; }
.edit-link { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px 9px; margin-bottom: 10px; background: var(--blush); border-radius: 10px; padding: 9px; }
.edit-link input { margin: 0; min-width: 0; font-size: .9rem; }
.edit-link input[type="url"] { grid-column: 1 / -1; }
#edit-feedback:not(:empty) { margin: 0 0 10px; }

@media (max-width: 850px) {
  .letter { padding-inline: 21px; }
  .cover { min-height: 610px; }
}
@media (max-width: 680px) {
  body { padding: 10px; }
  .layout { display: flex; flex-direction: column; padding: 7px; border-radius: 23px; width: min(100%, 480px); }
  .cover { min-height: 330px; border-radius: 17px; }
  .cover::after { inset: 9px; border-radius: 11px; }
  .cover-content { padding: 24px; }
  .dedication { font-size: clamp(52px, 13vw, 76px); }
  .cover-note { margin-top: 16px; }
  .love-mark { width: 32px; height: 32px; font-size: 14px; margin-bottom: 14px; }
  .letter { padding: 15px 15px 12px; }
  .letter-content { padding-block: 27px 25px; }
  .intro { max-width: 100%; }
}
