:root {
  --bg: #F3F1E8; --panel: #FBF9F3; --line: #E2DDCC; --text: #3F4D39; --muted: #6B7563;
  --accent: #56664D; --accent-soft: #E6EBDD; --danger: #9A4F43; --warn: #8A6A28;
  --sans: "Montserrat", "Helvetica Neue", Arial, sans-serif; --serif: "Cormorant Garamond", Georgia, serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--sans); font-size: 14px; line-height: 1.5; display: flex; flex-direction: column; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 8px 16px; border-radius: 999px; border: 1px solid transparent; cursor: pointer; font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; }
.btn--solid { background: var(--accent); color: #fff; }
.btn--solid:hover { filter: brightness(.92); }
.btn--outline { background: #fff; border-color: #CFC9B5; }
.btn--outline:hover { border-color: var(--accent); }
.btn--ghost { background: none; }
.btn--ghost:hover { background: rgba(86, 102, 77, .08); }
.btn--small { min-height: 34px; padding: 5px 12px; font-size: 11px; }
.btn[disabled] { opacity: .55; cursor: progress; }

/* top bar */
/* EMD Digital Templates brand bar (black & gold). The customer's wedding
   website keeps its own design; EMD branding appears only in the Customizer. */
.bar { --emd-black: #111111; --emd-gold: #C9A54C; --emd-gold-soft: #E6D3A3; display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--emd-black); color: #F4EFE4; border-bottom: 2px solid var(--emd-gold); flex-wrap: wrap; }
.bar__brand { display: flex; align-items: center; gap: 12px; }
.bar__brand div { display: flex; flex-direction: column; line-height: 1.2; }
.bar__brand strong { color: #FFFFFF; font-weight: 600; }
.bar__brand span { font-size: 11px; color: var(--emd-gold-soft); letter-spacing: .12em; text-transform: uppercase; }
.emd-mark { display: inline-flex; flex-direction: column; align-items: center; padding: 3px 10px 4px; border: 1px solid var(--emd-gold); border-radius: 4px; line-height: 1; }
.emd-mark b { font-family: Georgia, "Times New Roman", serif; font-weight: 400; font-size: 18px; letter-spacing: .14em; color: var(--emd-gold); }
.emd-mark i { font-style: normal; font-size: 7.5px; letter-spacing: .18em; text-transform: uppercase; color: var(--emd-gold-soft); margin-top: 2px; }
.bar__status { flex: 1; font-size: 12.5px; color: #CFC8B8; min-width: 140px; }
.bar .btn--ghost { color: #F4EFE4; border-color: rgba(201, 165, 76, .55); }
.bar .btn--ghost:hover { background: rgba(201, 165, 76, .14); }
.bar .btn--ghost:disabled { color: #8D8778; }
.bar .btn--solid { background: var(--emd-gold); color: #111; }
.bar .menu { color: var(--text); }
.ws-bar { display: flex; align-items: center; gap: 8px; }
.ws-bar__label { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--emd-gold-soft); }
.ws-bar select { min-height: 36px; max-width: 220px; padding: 4px 10px; border: 1px solid #CFC9B5; border-radius: 999px; background: #fff; font-size: 13px; }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 6px; }
.btn--icon { padding: 8px 12px; font-size: 13px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.btn--icon[disabled] { opacity: .35; cursor: default; }

/* design: presets, fonts, toggles */
.presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; margin-top: 8px; }
.preset { display: grid; gap: 6px; padding: 8px; border: 1px solid #DDD7C4; border-radius: 10px; background: #fff; cursor: pointer; text-align: left; font-size: 12.5px; font-weight: 600; }
.preset[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.preset__chips { display: flex; height: 26px; border-radius: 6px; overflow: hidden; border: 1px solid rgba(0,0,0,.06); }
.preset__chips span { flex: 1; }
.fonts { display: grid; gap: 8px; margin-top: 8px; }
.font-card { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; align-items: center; padding: 10px 12px; border: 1px solid #DDD7C4; border-radius: 10px; background: #fff; cursor: pointer; }
.font-card:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.font-card input { grid-row: span 3; accent-color: var(--accent); width: 18px; height: 18px; }
.font-card__name { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.font-card__script { font-size: 30px; line-height: 1.1; }
.font-card__serif { font-size: 18px; }
.font-card__sans { font-size: 12.5px; color: var(--muted); }
.toggles { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.toggles .check { margin-top: 10px; }

/* crop dialog */
.dialog--crop { width: min(560px, calc(100% - 24px)); }
.crop { display: grid; place-items: center; background: repeating-conic-gradient(#eee 0 25%, #f8f8f8 0 50%) 0 0 / 20px 20px; border-radius: 10px; padding: 10px; }
.crop canvas { width: min(100%, 420px); aspect-ratio: 1; border-radius: 4px; box-shadow: 0 0 0 9px #FFFDF8, 0 10px 30px -12px rgba(0,0,0,.4); cursor: grab; touch-action: none; }
.crop canvas:active { cursor: grabbing; }
.crop__zoom { display: grid; gap: 4px; font-size: 12px; font-weight: 600; }
.crop__nudge { display: flex; flex-wrap: wrap; gap: 4px; }
@media (max-width: 900px) { .hide-sm { display: none; } .toggles { grid-template-columns: 1fr; } }
.row--featured { grid-template-columns: 1fr 1fr auto; }
.row--featured textarea { width: 100%; min-height: 70px; padding: 8px 11px; border: 1px solid #D6D0BC; border-radius: 9px; background: #FFFEFB; font-size: 16px; resize: vertical; }
.bar__status.is-saved::before { content: "✓ "; color: var(--emd-gold); font-weight: 700; }
.bar__actions { position: relative; display: flex; gap: 8px; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 10; min-width: 260px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 6px; box-shadow: 0 16px 36px -18px rgba(40, 48, 36, .5); display: grid; }
.menu button, .menu__file { text-align: left; background: none; border: 0; padding: 10px 12px; border-radius: 8px; cursor: pointer; font-size: 13.5px; }
.menu button:hover, .menu__file:hover { background: var(--accent-soft); }
.menu .danger { color: var(--danger); }
.menu a { padding: 8px 12px; border-radius: 8px; font-size: 13px; color: var(--text); text-decoration: none; }
.menu a:hover { background: var(--accent-soft); }
.menu__head { padding: 6px 12px 2px; font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }

/* mobile switch */
.switch { display: none; gap: 4px; padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--line); }
.switch button { flex: 1; min-height: 38px; border: 1px solid #CFC9B5; background: #fff; border-radius: 999px; font-weight: 600; font-size: 13px; cursor: pointer; }
.switch button[aria-pressed="true"] { background: var(--accent); color: #fff; border-color: var(--accent); }

/* layout */
.layout { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(340px, 460px) 1fr; }
.editor { overflow-y: auto; padding: 16px 18px 60px; border-right: 1px solid var(--line); background: var(--panel); }
.intro { margin: 0 0 14px; color: var(--muted); }
.foot { color: var(--muted); font-size: 12.5px; margin-top: 18px; }

.sec { border: 1px solid var(--line); border-radius: 12px; background: #fff; margin-bottom: 10px; }
.sec > summary { cursor: pointer; padding: 14px 16px; font-family: var(--serif); font-size: 21px; font-weight: 600; list-style: none; display: flex; justify-content: space-between; align-items: center; }
.sec > summary::-webkit-details-marker { display: none; }
.sec > summary::after { content: "+"; font-family: var(--sans); font-size: 18px; color: var(--muted); }
.sec[open] > summary::after { content: "–"; }
.sec[open] > summary { border-bottom: 1px solid #EFEBDD; }
.sec > :not(summary) { margin-left: 16px; margin-right: 16px; }
.sec > :last-child { margin-bottom: 16px; }
.sec label { display: grid; gap: 4px; margin-top: 12px; font-size: 12px; font-weight: 600; color: var(--text); }
.sec label small, .sub small { font-weight: 400; color: var(--muted); }
.sec input:not([type="checkbox"]):not([type="color"]):not([type="range"]), .sec select, .sec textarea {
  width: 100%; min-height: 42px; padding: 8px 11px; border: 1px solid #D6D0BC; border-radius: 9px; background: #FFFEFB; font-size: 16px; font-weight: 400;
}
.sec textarea { resize: vertical; }
.sec [aria-invalid="true"] { border-color: #C47A6D !important; background: #FFF8F6 !important; }
.sec .check { display: flex; align-items: flex-start; gap: 8px; font-weight: 500; }
.sec .check input { width: 18px; height: 18px; margin-top: 1px; accent-color: var(--accent); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.grid2 .span2 { grid-column: 1 / -1; }
.sub { margin: 18px 16px 0; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; }
.note { color: var(--muted); font-size: 12.5px; margin-top: 10px; }
.sec > .btn { margin-top: 12px; }

.photos, .rows { list-style: none; padding: 0; display: grid; gap: 10px; margin-top: 12px; }
.photo { display: grid; grid-template-columns: 84px 1fr; gap: 10px; padding: 10px; border: 1px solid #EFEBDD; border-radius: 10px; background: #FFFEFB; }
.photo__thumb { width: 84px; height: 84px; object-fit: cover; border-radius: 6px; background: var(--accent-soft); }
.photo label { margin-top: 0; }
.photo__fields { display: grid; gap: 6px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.row-actions .btn { margin: 0; }
.row { display: grid; gap: 6px 8px; padding: 10px; border: 1px solid #EFEBDD; border-radius: 10px; background: #FFFEFB; grid-template-columns: 96px 1fr auto; align-items: end; }
.row label { margin-top: 0; }
.row .span-all { grid-column: 1 / -1; }
.row--tradition { grid-template-columns: 56px 1fr; }
.row--tradition img { width: 56px; }
.row--swatch { grid-template-columns: 56px 1fr auto; }
.row--swatch input[type="color"], .colors input[type="color"] { width: 48px; height: 40px; padding: 2px; border: 1px solid #D6D0BC; border-radius: 8px; background: #fff; }
.icon-btn { border: 0; background: none; color: var(--danger); cursor: pointer; padding: 6px 8px; border-radius: 8px; font-size: 12px; }
.icon-btn:hover { background: #F7E9E5; }
.colors { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.colors label { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.music-box { margin-top: 10px; padding: 10px; border: 1px solid #EFEBDD; border-radius: 10px; background: #FFFEFB; }
.music-box p { margin: 0 0 8px; }
.music-box audio { width: 100%; }

.problems { border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; background: #FFF7E8; border: 1px solid #EBD7AE; }
.problems h2 { margin: 0 0 6px; font-size: 14px; }
.problems ul { margin: 0; padding: 0; list-style: none; }
.problems li { margin: 4px 0; padding-left: 14px; position: relative; }
.problems li::before { content: "•"; position: absolute; left: 0; }
.problems li.error { color: var(--danger); }
.problems li.warning { color: var(--warn); }
.problems button { display: inline; background: none; border: 0; padding: 0; color: inherit; text-decoration: underline; cursor: pointer; text-align: left; font-size: inherit; }

/* preview */
.preview { display: flex; flex-direction: column; min-height: 0; }
.preview__bar { display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-bottom: 1px solid var(--line); background: #F7F5EE; font-size: 12.5px; color: var(--muted); }
.preview__bar > span { flex: 1; }
.seg { display: inline-flex; border: 1px solid #CFC9B5; border-radius: 999px; overflow: hidden; background: #fff; }
.seg button { border: 0; background: none; padding: 6px 12px; font-size: 12px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--accent); color: #fff; }
.preview__stage { flex: 1; min-height: 0; display: grid; place-items: center; padding: 16px; overflow: auto; background: repeating-linear-gradient(45deg, #EEEBE0 0 12px, #F1EEE4 12px 24px); }
.preview__stage iframe { border: 0; background: #F5F3E9; box-shadow: 0 20px 50px -25px rgba(40, 48, 36, .55); }
.preview__stage[data-device="phone"] iframe { width: 390px; height: min(820px, 100%); border-radius: 28px; border: 10px solid #2D3329; }
.preview__stage[data-device="desktop"] iframe { width: 100%; height: 100%; border-radius: 8px; }

/* dialog */
.dialog { width: min(520px, calc(100% - 24px)); border: 1px solid var(--line); border-radius: 14px; padding: 0; color: var(--text); background: var(--panel); }
.dialog::backdrop { background: rgba(40, 48, 36, .45); }
.dialog__body { padding: 20px; display: grid; gap: 10px; }
.dialog h2 { margin: 0; font-family: var(--serif); font-size: 28px; font-weight: 600; }
.dialog .check { display: flex; gap: 8px; align-items: flex-start; font-size: 13.5px; }
.dialog .check input { margin-top: 3px; accent-color: var(--accent); }
.dialog progress { width: 100%; height: 10px; accent-color: var(--accent); }
.dialog__msg { min-height: 1.4em; margin: 0; font-size: 13.5px; }
.dialog__actions { display: flex; justify-content: flex-end; gap: 8px; }

/* phones and small tablets */
@media (max-width: 900px) {
  body { height: auto; min-height: 100%; }
  .switch { display: flex; position: sticky; top: 0; z-index: 5; }
  .layout { display: block; }
  .layout[data-view="edit"] .preview { display: none; }
  .layout[data-view="preview"] .editor { display: none; }
  .editor { border-right: 0; padding: 12px 12px 60px; }
  .preview { height: calc(100vh - 110px); }
  .preview__stage { padding: 0; }
  .preview__stage[data-device] iframe { width: 100%; height: 100%; border: 0; border-radius: 0; }
  .preview__bar .seg { display: none; }
  .bar__status { order: 3; flex-basis: 100%; }
  .bar__actions { flex-wrap: wrap; flex: 1 1 100%; }
  .bar__actions #btn-export { flex: 1 1 auto; }
  .ws-bar { flex: 1 1 auto; }
  .ws-bar select { flex: 1; max-width: none; }
  .grid2 { grid-template-columns: 1fr; }
  .row { grid-template-columns: 1fr 1fr; }
  .row--tradition { grid-template-columns: 48px 1fr; }
}
