/* Web editor. Builds on site.css tokens. */
.app-wrap { width: min(1040px, 100% - 32px); padding-bottom: 64px; }
.app-top { display: flex; align-items: center; justify-content: space-between; padding: 14px 0 10px; }
.icon-btn { width: 48px; height: 48px; display: grid; place-items: center; border: 0; border-radius: 24px; background: transparent; color: var(--ink); cursor: pointer; }
.icon-btn:hover { background: var(--sand-deep); }
.icon-btn svg { width: 24px; height: 24px; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.panel + .panel { margin-top: 16px; }
.panel h1 { font-size: 34px; margin-bottom: 10px; }
.panel h2 { font-size: 21px; margin-bottom: 14px; }
.muted { color: var(--ink-2); }
.small { font-size: 14px; }
.hint { margin-top: 6px; font-size: 13px; line-height: 1.45; color: var(--ink-2); }
.error { margin-top: 12px; padding: 10px 14px; border-radius: 10px; background: #f6e3df; color: var(--error); font-size: 14px; font-weight: 500; }
.error[hidden], [hidden] { display: none !important; }

.import { max-width: 560px; margin: 32px auto 0; text-align: left; }
.drop { margin-top: 22px; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 44px 20px; border: 2px dashed var(--outline); border-radius: 18px; background: var(--paper); cursor: pointer; text-align: center; transition: background-color .15s, border-color .15s; }
.drop:hover, .drop.over, .drop:focus-within { background: var(--sand-deep); border-color: var(--oxblood); }
.drop svg { width: 40px; height: 40px; color: var(--oxblood); margin-bottom: 8px; }
.drop-title { font-family: var(--serif); font-weight: 600; font-size: 22px; }

.work { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); gap: 24px; align-items: start; margin-top: 8px; }
.col-side { position: sticky; top: 16px; }

.file-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.file-name { font-weight: 600; overflow-wrap: anywhere; }
.lock-note { margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: var(--sand-deep); font-size: 14px; line-height: 1.45; }

.field { margin-top: 16px; }
.field label:not(.switch), .seg legend, .radios legend { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; padding: 0; }
.field input[type="text"], .field input[type="email"], .locked-field input {
  width: 100%; height: 52px; padding: 0 14px; border: 1.5px solid var(--outline); border-radius: 12px; background: var(--surface); font-size: 16px; font-weight: 500;
}
.field input:focus-visible, .locked-field input:focus-visible { outline: 3px solid var(--forest); outline-offset: 1px; border-color: var(--forest); }
.field input[readonly] { background: var(--sand-deep); border-color: var(--line); color: var(--ink-2); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.row-between label:not(.switch) { margin-bottom: 0 !important; }
.row-gap { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }

/* Switch */
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; color: var(--ink); cursor: pointer; min-height: 44px; }
.switch input { position: absolute; opacity: 0; width: 44px; height: 44px; margin: 0; cursor: pointer; }
.switch .track { position: relative; width: 44px; height: 26px; border-radius: 13px; background: var(--outline); transition: background-color .15s; flex-shrink: 0; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.switch input:checked + .track { background: var(--oxblood); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 3px solid var(--forest); outline-offset: 2px; }
.switch { position: relative; }

/* Segmented + radios */
fieldset { border: 0; margin: 18px 0 0; padding: 0; min-width: 0; }
.seg { display: inline-flex; flex-wrap: wrap; }
.seg legend { width: 100%; }
.seg label { position: relative; }
.seg input, .radios input { position: absolute; opacity: 0; }
.seg span { display: grid; place-items: center; min-width: 96px; min-height: 48px; padding: 0 20px; border: 1.5px solid var(--outline); font-weight: 600; cursor: pointer; background: var(--surface); }
.seg label:first-of-type span { border-radius: 24px 0 0 24px; }
.seg label:last-of-type span { border-radius: 0 24px 24px 0; margin-left: -1.5px; }
.seg input:checked + span { background: var(--oxblood); border-color: var(--oxblood); color: var(--on-oxblood); position: relative; }
.seg input:focus-visible + span { outline: 3px solid var(--forest); outline-offset: 2px; }
.radios label { position: relative; display: flex; align-items: center; gap: 12px; min-height: 48px; cursor: pointer; }
.radios span::before { content: ""; display: inline-block; vertical-align: -5px; width: 22px; height: 22px; margin-right: 12px; border: 2px solid var(--outline); border-radius: 50%; background: var(--surface); }
.radios input:checked + span::before { border-color: var(--oxblood); background: radial-gradient(circle, var(--oxblood) 0 5px, var(--surface) 6px); }
.radios input:focus-visible + span::before { outline: 3px solid var(--forest); outline-offset: 2px; }

/* Preview */
.preview { display: grid; justify-items: center; gap: 8px; background: var(--sand); border-radius: 12px; padding: 20px; min-height: 240px; align-content: center; }
.preview canvas { width: auto; max-width: 100%; max-height: 460px; background: #fff; border-radius: 4px; box-shadow: 0 1px 0 rgba(0,0,0,.05), 0 14px 28px -14px rgba(31,27,22,.45); }
.preview canvas.empty { display: none; }
#pages-line { margin-top: 12px; }

/* Send */
.send-summary { margin-bottom: 14px; font-size: 14px; color: var(--ink-2); line-height: 1.5; }
.send-summary b { color: var(--ink); font-weight: 600; overflow-wrap: anywhere; }
.send .btn-primary { width: 100%; }
.after { margin-top: 18px; padding: 16px 18px; background: var(--sand-deep); border-radius: 12px; }
.after h3 { font-size: 18px; margin-bottom: 8px; }
.after ol { margin: 0; padding-left: 20px; display: grid; gap: 8px; }
.linkish { padding: 0; border: 0; background: none; color: var(--oxblood); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; text-align: left; }

/* Dialog */
dialog { width: min(520px, calc(100% - 24px)); max-height: calc(100dvh - 24px); padding: 0; border: 0; border-radius: 20px; background: var(--paper); color: var(--ink); box-shadow: 0 24px 60px -12px rgba(31,27,22,.45); }
dialog::backdrop { background: rgba(31,27,22,.45); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 4px 24px; }
.dlg-head h2 { font-size: 24px; }
.dlg-body { padding: 8px 24px 28px; }
.label-caps { font-family: var(--sans); font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); margin: 18px 0 0; }
.locked-field { position: relative; }
.locked-field input { padding-right: 56px; }
.locked-field .icon-btn { position: absolute; top: 4px; right: 4px; width: 44px; height: 44px; border-radius: 10px; }
.locked-field .icon-btn svg { width: 20px; height: 20px; }
.locked-field input:not([readonly]) { background: var(--surface); color: var(--ink); border-color: var(--outline); }
.note { margin-top: 16px; background: var(--sand-deep); border-radius: 14px; padding: 14px 16px; }
.note h4 { margin: 0 0 6px; font-size: 15px; }
.note p { font-size: 14px; line-height: 1.5; }
.author-list { list-style: none; margin: 8px 0 0; padding: 0; }
.author-list li { display: flex; align-items: center; min-height: 48px; border-bottom: 1px solid var(--line); }
.author-list li span { flex: 1; overflow-wrap: anywhere; }
.author-list .icon-btn { width: 44px; height: 44px; }
.author-list .icon-btn svg { width: 20px; height: 20px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 12px 18px; border-radius: 12px; font-size: 15px; z-index: 50; max-width: calc(100% - 32px); box-shadow: 0 8px 24px rgba(0,0,0,.25); }

@media (max-width: 800px) {
  .work { grid-template-columns: 1fr; }
  .col-side { position: static; }
  .panel h1 { font-size: 30px; }
  .app-wrap .btn { width: auto; }
  .send .btn-primary { width: 100%; }
}
