/* Penneth — story editor */
@font-face { font-family: "PE Head"; src: url(../fonts/bricolage-grotesque-var.woff2) format("woff2"); font-weight: 200 800; font-display: swap; }
@font-face { font-family: "PE UI"; src: url(../fonts/inter-var.woff2) format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Source Serif 4"; src: url(../fonts/source-serif-4-latin-normal.woff2) format("woff2"); font-weight: 400 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Source Serif 4"; src: url(../fonts/source-serif-4-latin-italic.woff2) format("woff2"); font-weight: 400 700; font-style: italic; font-display: swap; }
:root { --ink: #16181d; --text: #26292f; --mute: #6b7079; --line: #ebecef; --soft: #f7f7f8; --violet: #7c5cff; --mint: #13b38b; --coral: #ff5a5f; --sun: #ffb81c; --ease: cubic-bezier(.2, .7, .2, 1); --serif: "Source Serif 4", "Iowan Old Style", Georgia, serif; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body.pe { font: 15px/1.55 "PE UI", Inter, system-ui, sans-serif; color: var(--text); background: #fff; -webkit-font-smoothing: antialiased; }
button { font: inherit; }

/* Top bar */
.pe-top { position: sticky; top: 0; z-index: 30; display: flex; justify-content: space-between; align-items: center; height: 68px; padding: 0 clamp(16px, 4vw, 48px); background: rgba(255, 255, 255, .92); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.pe-top-l, .pe-top-r { display: flex; align-items: center; gap: 18px; }
.pe-logo { font: 800 24px/1 "PE Head", sans-serif; letter-spacing: -.045em; color: var(--ink); text-decoration: none; display: inline-flex; align-items: baseline; }
.pe-logo span { width: 8px; height: 8px; border-radius: 50%; background: var(--coral); margin: 0 22px 0 3px; box-shadow: 11px 0 0 var(--sun), 22px 0 0 var(--mint); }
.pe-state { font-size: 13.5px; color: var(--mute); display: flex; align-items: center; gap: 8px; }
.pe-dot { width: 3px; height: 3px; border-radius: 50%; background: #b8bcc4; }
.pe-saved.is-error { color: #d8343a; }
.pe-btn { border: 0; border-radius: 999px; background: var(--mint); color: #fff; font-weight: 600; font-size: 14px; padding: 9px 18px; cursor: pointer; transition: background .25s var(--ease), opacity .25s; }
.pe-btn:hover { background: #0e9a77; }
.pe-btn:disabled { opacity: .4; cursor: default; }
.pe-icon { width: 38px; height: 38px; border: 0; border-radius: 50%; background: none; color: var(--mute); cursor: pointer; display: grid; place-items: center; }
.pe-icon svg { width: 22px; height: 22px; fill: currentColor; }
.pe-icon:hover { background: var(--soft); color: var(--ink); }
.pe-more { position: relative; }
.pe-menu { position: absolute; right: 0; top: calc(100% + 8px); width: 200px; background: #fff; border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 20px 40px -18px rgba(22, 24, 29, .25); padding: 6px; }
.pe-menu a, .pe-menu button { display: block; width: 100%; text-align: left; padding: 9px 12px; border-radius: 10px; color: var(--text); text-decoration: none; font-size: 14px; border: 0; background: none; cursor: pointer; }
.pe-menu a:hover, .pe-menu button:hover { background: var(--soft); }
.pe-menu .pe-del { color: #d8343a; }
.pe-me { border-radius: 50%; }

/* Document */
.pe-doc { max-width: 740px; margin: 0 auto; padding: clamp(28px, 6vh, 72px) 20px 40vh; }
[contenteditable] { outline: 0; }
[contenteditable]:empty::before, .pe-body.is-empty::before { content: attr(data-ph); color: #b6bac2; pointer-events: none; }
.pe-body.is-empty::before { position: absolute; }
.pe-title { font: 800 clamp(34px, 4.6vw, 46px)/1.1 "PE Head", sans-serif; letter-spacing: -.035em; color: var(--ink); margin: 0 0 12px; }
.pe-sub { font: 400 22px/1.45 var(--serif); color: var(--mute); margin: 0 0 28px; }
.pe-body { position: relative; font: 400 21px/1.75 var(--serif); color: var(--text); min-height: 40vh; caret-color: var(--violet); }
.pe-body p { margin: 0 0 22px; }
.pe-body h2 { font: 700 30px/1.2 "PE Head", sans-serif; letter-spacing: -.025em; color: var(--ink); margin: 40px 0 12px; }
.pe-body h3 { font: 700 23px/1.25 "PE Head", sans-serif; letter-spacing: -.02em; color: var(--ink); margin: 32px 0 10px; }
.pe-body blockquote { margin: 28px 0; padding: 2px 0 2px 24px; border-left: 4px solid var(--violet); font-style: italic; font-size: 24px; line-height: 1.5; color: var(--ink); }
.pe-body blockquote p { margin: 0; }
.pe-body ul, .pe-body ol { margin: 0 0 22px; padding-left: 28px; }
.pe-body li { margin: 6px 0; }
.pe-body a { color: #0b8566; text-decoration: underline; text-underline-offset: 3px; }
.pe-body mark { background: linear-gradient(transparent 12%, #c9f2e3 12%, #c9f2e3 92%, transparent 92%); color: inherit; padding: 0 2px; }
.pe-body code { font: 15px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--soft); padding: 2px 6px; border-radius: 6px; }
.pe-body pre { font: 14.5px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; background: #16181d; color: #e9eaee; padding: 20px 22px; border-radius: 14px; overflow-x: auto; margin: 0 0 24px; white-space: pre-wrap; }
.pe-body pre code { background: none; padding: 0; color: inherit; }
.pe-body hr { border: 0; height: 30px; margin: 32px 0; text-align: center; }
.pe-body hr::before { content: "• • •"; letter-spacing: 1em; color: var(--mute); font-size: 18px; }
.pe-body figure { margin: 36px 0; position: relative; }
.pe-body figure img { display: block; width: 100%; height: auto; border-radius: 14px; }
.pe-body figure.is-selected img { box-shadow: 0 0 0 3px var(--violet); }
.pe-body figure.is-loading img { opacity: .5; }
.pe-body figcaption { font: 14px/1.5 "PE UI", sans-serif; color: var(--mute); text-align: center; margin-top: 10px; min-height: 1.5em; }
.pe-body figcaption:empty::before { content: attr(data-ph); color: #c2c5cc; }

/* Floating format bar */
.pe-bar { position: absolute; z-index: 40; display: flex; align-items: center; gap: 2px; background: var(--ink); color: #fff; border-radius: 12px; padding: 5px; box-shadow: 0 14px 30px -12px rgba(22, 24, 29, .5); transform: translateX(-50%); }
.pe-bar::after { content: ""; position: absolute; left: 50%; bottom: -5px; width: 10px; height: 10px; background: var(--ink); transform: translateX(-50%) rotate(45deg); border-radius: 2px; }
.pe-bar button { width: 36px; height: 34px; border: 0; background: none; color: #fff; border-radius: 8px; cursor: pointer; display: grid; place-items: center; font-size: 16px; }
.pe-bar button:hover, .pe-bar button.is-on { background: rgba(255, 255, 255, .14); color: #c9f2e3; }
.pe-bar svg { width: 19px; height: 19px; }
.pe-bar .pe-t1 { font: 700 19px "PE Head", sans-serif; }
.pe-bar .pe-t2 { font: 700 14px "PE Head", sans-serif; }
.pe-bar .pe-hl { font: 700 14px "PE Head", sans-serif; background: #c9f2e3; color: var(--ink); border-radius: 4px; padding: 0 5px; }
.pe-sep { width: 1px; height: 20px; background: rgba(255, 255, 255, .2); margin: 0 4px; }
.pe-linkbox { display: flex; align-items: center; gap: 4px; padding-left: 4px; }
.pe-linkbox input { width: 230px; height: 32px; border: 0; border-radius: 8px; padding: 0 10px; font: 14px "PE UI", sans-serif; background: rgba(255, 255, 255, .12); color: #fff; outline: 0; }
.pe-linkbox input::placeholder { color: rgba(255, 255, 255, .55); }

/* "+" insert */
.pe-plus { position: absolute; z-index: 35; display: flex; align-items: center; gap: 10px; }
.pe-plus-btn { width: 34px; height: 34px; border-radius: 50%; border: 1px solid #c9ccd2; background: #fff; color: var(--mute); font-size: 22px; line-height: 1; cursor: pointer; display: grid; place-items: center; transition: transform .25s var(--ease), border-color .2s, color .2s; }
.pe-plus-btn:hover { border-color: var(--ink); color: var(--ink); }
.pe-plus-btn[aria-expanded="true"] { transform: rotate(45deg); border-color: var(--ink); color: var(--ink); }
.pe-plus-menu { display: flex; gap: 8px; animation: pe-in .2s var(--ease); }
.pe-plus-menu button { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--mint); background: #fff; color: var(--mint); cursor: pointer; display: grid; place-items: center; }
.pe-plus-menu button:hover { background: #e5f8f2; }
.pe-plus-menu svg { width: 19px; height: 19px; }
@keyframes pe-in { from { opacity: 0; transform: translateX(-6px); } to { opacity: 1; transform: none; } }

/* Publish overlay */
.pe-pub { position: fixed; inset: 0; z-index: 60; background: #fff; overflow-y: auto; animation: pe-fade .25s var(--ease); }
@keyframes pe-fade { from { opacity: 0; } to { opacity: 1; } }
.pe-pub-x { position: absolute; right: 24px; top: 18px; width: 42px; height: 42px; border: 0; background: none; font-size: 30px; color: var(--mute); cursor: pointer; border-radius: 50%; }
.pe-pub-x:hover { background: var(--soft); color: var(--ink); }
.pe-pub-in { max-width: 1040px; margin: 0 auto; padding: clamp(48px, 10vh, 110px) 24px 60px; display: grid; grid-template-columns: 1fr 1fr; gap: clamp(32px, 6vw, 80px); }
.pe-k { font-size: 13px; color: var(--mute); margin: 0 0 14px; }
.pe-k b { color: var(--ink); }
.pe-cover { aspect-ratio: 16 / 9; border-radius: 16px; background: var(--soft); overflow: hidden; display: grid; place-items: center; }
.pe-cover img { width: 100%; height: 100%; object-fit: cover; }
.pe-cover-empty { color: var(--mute); font-size: 14px; text-align: center; max-width: 260px; padding: 20px; }
.pe-cover-pick { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.pe-cover-pick button { width: 62px; height: 44px; padding: 0; border: 2px solid transparent; border-radius: 9px; overflow: hidden; cursor: pointer; background: var(--soft); }
.pe-cover-pick button.is-on { border-color: var(--violet); }
.pe-cover-pick img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pe-cover-acts { display: flex; gap: 16px; margin: 12px 0 22px; }
.pe-link { border: 0; background: none; padding: 0; color: var(--violet); font-weight: 600; font-size: 14px; cursor: pointer; }
.pe-link-mute { color: var(--mute); font-weight: 500; }
.pe-prev-t { font: 700 22px/1.25 "PE Head", sans-serif; letter-spacing: -.02em; color: var(--ink); margin: 0 0 6px; border-bottom: 1px solid var(--line); padding-bottom: 10px; }
.pe-prev-s { font: 16px/1.5 var(--serif); color: var(--mute); margin: 8px 0 0; }
.pe-pub-r h2 { font: 800 34px/1.1 "PE Head", sans-serif; letter-spacing: -.035em; color: var(--ink); margin: 0 0 8px; }
.pe-help { color: var(--mute); font-size: 14.5px; margin: 0 0 18px; }
.pe-review { background: #fff7e0; color: #7a5200; border-radius: 12px; padding: 10px 14px; margin-top: 18px; }
.pe-topics { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 26px; }
.pe-topic { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 999px; padding: 8px 16px; font-weight: 600; font-size: 14px; color: var(--ink); background: #fff; cursor: pointer; transition: border-color .2s, background .2s; }
.pe-topic i { width: 9px; height: 9px; border-radius: 50%; background: var(--c); }
.pe-topic:hover { border-color: var(--c); }
.pe-topic[aria-checked="true"] { background: var(--c); border-color: var(--c); color: #fff; }
.pe-topic[aria-checked="true"] i { background: #fff; }
.pe-tags-l { display: block; font-weight: 600; font-size: 14px; color: var(--ink); margin-bottom: 8px; }
.pe-tags-l small { color: var(--mute); font-weight: 500; }
.pe-tags { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; border: 1px solid var(--line); border-radius: 14px; padding: 8px 10px; min-height: 50px; }
.pe-tags:focus-within { border-color: var(--violet); box-shadow: 0 0 0 4px rgba(124, 92, 255, .14); }
.pe-tag { display: inline-flex; align-items: center; gap: 6px; background: var(--soft); border-radius: 999px; padding: 5px 8px 5px 12px; font-size: 13.5px; color: var(--ink); }
.pe-tag button { border: 0; background: none; color: var(--mute); cursor: pointer; font-size: 16px; line-height: 1; padding: 0 2px; }
.pe-tags input { flex: 1; min-width: 140px; border: 0; outline: 0; font: 15px "PE UI", sans-serif; padding: 6px 4px; }
.pe-err { color: #d8343a; font-size: 14px; min-height: 20px; margin: 16px 0 8px; }
.pe-btn-go { padding: 14px 28px; font-size: 15px; }

.pe-toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); background: var(--ink); color: #fff; border-radius: 999px; padding: 10px 20px; font-size: 14px; z-index: 80; box-shadow: 0 12px 30px -12px rgba(0, 0, 0, .4); }

@media (max-width: 760px) {
	.pe-state { display: none; }
	.pe-pub-in { grid-template-columns: 1fr; }
	.pe-pub-l { order: 2; }
	.pe-body { font-size: 19px; }
	.pe-linkbox input { width: 160px; }
}
