/*
 * Pages（lib/pages.php）の見た目: 公開ページ (.pgv-*)、一覧 (.pgl-*)、エディタ (.pg-*。assets/js/pages.js)。
 * folita.me と amanetoki.com（/tweets/pages.css として配る）で同じ。色は folita の site.css の変数があればそれに、無ければここの既定に
 * （公開ページとエディタは単体の文書なので既定が効く。folita の dashboard の一覧は site.css の中）。
 */
:root {
  color-scheme: light dark;
  --pg-bg: var(--bg, #f7f7f5); --pg-fg: var(--fg, #171717); --pg-muted: var(--muted, #6b6b6b); --pg-line: var(--border, #e5e5e2); --pg-card: var(--card, #fff);
  --pg-accent: var(--accent, #3b82f6); --pg-accent-bg: var(--accent-bg, #eff6ff); --pg-code: #f1f1ee; --pg-hover: rgba(0,0,0,.05); --pg-shadow: 0 8px 28px rgba(0,0,0,.14);
  --pg-font: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Noto Sans JP", sans-serif;
  --pg-mono: ui-monospace, "SF Mono", Menlo, Consolas, "Noto Sans Mono CJK JP", monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --pg-bg: var(--bg, #141414); --pg-fg: var(--fg, #ededed); --pg-muted: var(--muted, #a1a1a1); --pg-line: var(--border, #2e2e2e); --pg-card: var(--card, #1c1c1c); --pg-accent: var(--accent, #60a5fa); --pg-accent-bg: var(--accent-bg, rgba(59,130,246,.15)); --pg-code: #232323; --pg-hover: rgba(255,255,255,.08); --pg-shadow: 0 8px 28px rgba(0,0,0,.5); }
}
:root[data-theme="dark"] { --pg-bg: var(--bg, #141414); --pg-fg: var(--fg, #ededed); --pg-muted: var(--muted, #a1a1a1); --pg-line: var(--border, #2e2e2e); --pg-card: var(--card, #1c1c1c); --pg-accent: var(--accent, #60a5fa); --pg-accent-bg: var(--accent-bg, rgba(59,130,246,.15)); --pg-code: #232323; --pg-hover: rgba(255,255,255,.08); --pg-shadow: 0 8px 28px rgba(0,0,0,.5); }

body.pg-editing, body:has(> .pgv-wrap) { margin: 0; background: var(--pg-bg); color: var(--pg-fg); font-family: var(--pg-font); -webkit-font-smoothing: antialiased; }

/* ---------- 公開ページ ---------- */
.pgv-wrap { max-width: 720px; margin: 0 auto; padding: 48px 20px 80px; }
.pgv__notice { margin: 0 0 20px; padding: 10px 14px; border-radius: 10px; background: #fff6d6; color: #6b4e00; font-size: 13px; }
:root[data-theme="dark"] .pgv__notice { background: rgba(255,200,0,.14); color: #ffd666; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .pgv__notice { background: rgba(255,200,0,.14); color: #ffd666; } }
.pgv__head { margin-bottom: 28px; }
.pgv__title { margin: 0 0 12px; font-size: 34px; line-height: 1.25; font-weight: 800; letter-spacing: -.02em; overflow-wrap: anywhere; }
.pgv__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; color: var(--pg-muted); font-size: 13.5px; }
.pgv__author { display: inline-flex; align-items: center; gap: 8px; color: inherit; text-decoration: none; font-weight: 600; }
.pgv__author:hover { color: var(--pg-fg); }
.pgv__avatar { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; }
.pgv__edit { margin-left: auto; color: var(--pg-accent); text-decoration: none; font-weight: 600; }
.pgv__body { font-size: 16.5px; line-height: 1.8; overflow-wrap: anywhere; }
.pgv__body > * + * { margin-top: .9em; }
.pgv__body h1, .pgv__body h2, .pgv__body h3, .pgv__body h4 { line-height: 1.35; letter-spacing: -.01em; margin-top: 1.6em; }
.pgv__body h1 { font-size: 28px; } .pgv__body h2 { font-size: 23px; } .pgv__body h3 { font-size: 19px; } .pgv__body h4 { font-size: 17px; }
.pgv__body p { margin-bottom: 0; }
.pgv__body a { color: var(--pg-accent); text-underline-offset: 3px; }
.pgv__body code { font-family: var(--pg-mono); font-size: .88em; background: var(--pg-code); padding: 2px 5px; border-radius: 5px; }
.pgv__body pre { background: var(--pg-code); border-radius: 10px; padding: 14px 16px; overflow: auto; font-size: 13.5px; line-height: 1.6; }
.pgv__body pre code { background: none; padding: 0; font-size: inherit; }
.pgv__body blockquote { margin: 0; padding: 2px 0 2px 16px; border-left: 3px solid var(--pg-line); color: var(--pg-muted); }
.pgv__body ul, .pgv__body ol { padding-left: 1.5em; }
.pgv__body li + li { margin-top: .25em; }
.pgv__body ul.pgv-todo { list-style: none; padding-left: .2em; }
.pgv__body ul.pgv-todo li { display: flex; align-items: flex-start; gap: 8px; }
.pgv__body ul.pgv-todo input { margin: .45em 0 0; accent-color: var(--pg-accent); }
.pgv__body ul.pgv-todo li.is-done > span { color: var(--pg-muted); text-decoration: line-through; }
.pgv__body hr { border: 0; border-top: 1px solid var(--pg-line); margin: 1.8em 0; }
.pgv__body figure { margin: 1.2em 0; }
.pgv__body img { max-width: 100%; height: auto; border-radius: 10px; }
.pgv__body figcaption { margin-top: 6px; text-align: center; color: var(--pg-muted); font-size: 13px; }
.pgv__empty, .pgl__empty { color: var(--pg-muted); }
.pgv__foot { margin-top: 56px; padding-top: 18px; border-top: 1px solid var(--pg-line); font-size: 14px; }
.pgv__foot a { color: var(--pg-muted); text-decoration: none; } .pgv__foot a:hover { color: var(--pg-fg); }
.pgv__locked { max-width: 420px; margin: 80px auto; padding: 28px 22px; border: 1px solid var(--pg-line); border-radius: 14px; background: var(--pg-card); text-align: center; }
.pgv__locked svg { width: 28px; height: 28px; color: var(--pg-muted); }
.pgv__locked-title { margin: 10px 0 6px; font-weight: 700; } .pgv__locked-desc { margin: 0; color: var(--pg-muted); font-size: 13.5px; line-height: 1.7; }

/* ---------- 一覧 ---------- */
.pgl-wrap .pgl__head { margin-top: 24px; }
.pgl__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.pgl__h1 { margin: 0; font-size: 24px; font-weight: 800; letter-spacing: -.02em; }
.pgl__head .pgv__author { font-size: 14px; color: var(--pg-muted); width: 100%; }
.pgl { list-style: none; margin: 18px 0 0; padding: 0; display: grid; gap: 10px; }
.pgl__link { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "title badge" "excerpt excerpt" "date date"; gap: 4px 10px; padding: 14px 16px; border: 1px solid var(--pg-line); border-radius: 12px; background: var(--pg-card); color: inherit; text-decoration: none; }
.pgl__link:hover { border-color: var(--pg-muted); }
.pgl__title { grid-area: title; font-weight: 700; font-size: 16px; overflow-wrap: anywhere; }
.pgl__badge { grid-area: badge; align-self: start; font-size: 11.5px; padding: 2px 8px; border-radius: 999px; background: #fff0c2; color: #6b4e00; font-weight: 600; }
:root[data-theme="dark"] .pgl__badge { background: rgba(255,200,0,.18); color: #ffd666; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .pgl__badge { background: rgba(255,200,0,.18); color: #ffd666; } }
.pgl__excerpt { grid-area: excerpt; color: var(--pg-muted); font-size: 13.5px; line-height: 1.6; }
.pgl__date { grid-area: date; color: var(--pg-muted); font-size: 12.5px; }
.pgl__new { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 10px; background: var(--pg-fg); color: var(--pg-bg); font-weight: 600; font-size: 14px; text-decoration: none; border: 0; cursor: pointer; font-family: inherit; }

/* ---------- エディタ ---------- */
.pg-root { min-height: 100vh; }
.pg-loading { padding: 40px; text-align: center; color: var(--pg-muted); }
.pg-top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px; padding: 10px 16px; overflow-x: auto; scrollbar-width: none; background: color-mix(in srgb, var(--pg-bg) 86%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--pg-line); }
.pg-top__back { flex: none; white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; color: var(--pg-muted); text-decoration: none; font-size: 14px; padding: 6px 8px; border-radius: 8px; }
.pg-top__back:hover { background: var(--pg-hover); color: var(--pg-fg); }
.pg-top__crumb { font-size: 14px; color: var(--pg-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.pg-top__spacer { flex: 1; }
.pg-top__status { font-size: 12.5px; color: var(--pg-muted); white-space: nowrap; }
.pg-top__status.is-error { color: #d33; }
.pg-btn { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 8px; border: 1px solid var(--pg-line); background: var(--pg-card); color: var(--pg-fg); font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.pg-btn:hover { background: var(--pg-hover); }
.pg-btn--primary { background: var(--pg-fg); color: var(--pg-bg); border-color: var(--pg-fg); }
.pg-btn--primary:hover { opacity: .88; background: var(--pg-fg); }
.pg-btn--ghost { border-color: transparent; background: transparent; }
.pg-btn--danger { color: #d33; }
.pg-btn svg { width: 16px; height: 16px; }
.pg-pill { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; font-size: 12.5px; padding: 3px 10px; border-radius: 999px; font-weight: 600; }
.pg-pill--draft { background: #fff0c2; color: #6b4e00; } .pg-pill--published { background: #dcf5e3; color: #0b5d2a; }
:root[data-theme="dark"] .pg-pill--draft { background: rgba(255,200,0,.18); color: #ffd666; } :root[data-theme="dark"] .pg-pill--published { background: rgba(40,200,100,.18); color: #7ee2a0; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .pg-pill--draft { background: rgba(255,200,0,.18); color: #ffd666; } :root:not([data-theme="light"]) .pg-pill--published { background: rgba(40,200,100,.18); color: #7ee2a0; } }

.pg-paper { max-width: 760px; margin: 0 auto; padding: 48px 56px 50vh; }
.pg-title { width: 100%; border: 0; background: none; color: inherit; font: inherit; font-size: 38px; font-weight: 800; letter-spacing: -.02em; line-height: 1.2; padding: 0; margin: 0 0 18px; outline: none; resize: none; overflow: hidden; }
.pg-title::placeholder { color: var(--pg-muted); opacity: .5; }
.pg-blocks { font-size: 16.5px; line-height: 1.75; }
.pg-block { position: relative; display: flex; align-items: flex-start; gap: 4px; margin: 1px 0; border-radius: 6px; }
.pg-block.sortable-ghost { opacity: .35; }
.pg-block.sortable-chosen { background: var(--pg-accent-bg); }
.pg-handle { flex: none; width: 22px; height: 24px; margin: 4px 0 0 -30px; border: 0; border-radius: 6px; background: none; color: var(--pg-muted); cursor: grab; opacity: 0; display: flex; align-items: center; justify-content: center; padding: 0; }
.pg-handle svg { width: 16px; height: 16px; }
.pg-block:hover .pg-handle, .pg-block.is-menu .pg-handle { opacity: .7; }
.pg-handle:hover { background: var(--pg-hover); opacity: 1 !important; }
.pg-content { flex: 1; min-width: 0; padding: 3px 6px; outline: none; overflow-wrap: anywhere; white-space: pre-wrap; }
.pg-content:empty::before, .pg-content.is-empty::before { content: attr(data-placeholder); color: var(--pg-muted); opacity: .55; pointer-events: none; }
.pg-content:focus:empty::before { opacity: .55; }
.pg-content a { color: var(--pg-accent); } .pg-content code { font-family: var(--pg-mono); font-size: .88em; background: var(--pg-code); padding: 1px 4px; border-radius: 4px; }
.pg-block[data-type="h1"] .pg-content { font-size: 28px; font-weight: 800; line-height: 1.35; margin-top: 18px; }
.pg-block[data-type="h2"] .pg-content { font-size: 23px; font-weight: 800; line-height: 1.35; margin-top: 14px; }
.pg-block[data-type="h3"] .pg-content { font-size: 19px; font-weight: 700; line-height: 1.4; margin-top: 8px; }
.pg-block[data-type="ul"], .pg-block[data-type="ol"], .pg-block[data-type="todo"] { padding-left: 4px; }
.pg-bullet { flex: none; width: 22px; text-align: center; margin-top: 3px; color: var(--pg-fg); user-select: none; }
.pg-block[data-type="ol"] .pg-bullet { font-variant-numeric: tabular-nums; font-size: .95em; }
.pg-block[data-type="todo"] .pg-bullet input { margin: 0; width: 16px; height: 16px; accent-color: var(--pg-accent); vertical-align: -2px; cursor: pointer; }
.pg-block[data-type="todo"].is-done .pg-content { color: var(--pg-muted); text-decoration: line-through; }
.pg-block[data-type="quote"] .pg-content { border-left: 3px solid var(--pg-line); padding-left: 14px; color: var(--pg-muted); }
.pg-block[data-type="code"] { margin: 6px 0; }
.pg-block[data-type="code"] .pg-content { font-family: var(--pg-mono); font-size: 13.5px; line-height: 1.6; background: var(--pg-code); border-radius: 10px; padding: 12px 14px; tab-size: 2; }
.pg-block[data-type="code"] .pg-lang { position: absolute; right: 10px; top: 6px; font-size: 11px; color: var(--pg-muted); background: none; border: 0; font-family: var(--pg-mono); width: 80px; text-align: right; outline: none; }
.pg-block[data-type="hr"] .pg-content { padding: 0; height: 1px; background: var(--pg-line); margin: 16px 0; cursor: default; caret-color: transparent; }
.pg-block[data-type="hr"] { cursor: pointer; }
.pg-block[data-type="hr"].is-selected .pg-content { background: var(--pg-accent); }
.pg-block[data-type="img"] .pg-content { padding: 0; }
.pg-block[data-type="img"] img { max-width: 100%; height: auto; border-radius: 10px; display: block; }
.pg-block[data-type="img"].is-selected img { outline: 3px solid var(--pg-accent); outline-offset: 2px; }
.pg-block[data-type="img"] .pg-img-cap { font-size: 13px; color: var(--pg-muted); text-align: center; padding: 6px; outline: none; }
.pg-block[data-type="img"] .pg-img-cap:empty::before { content: "キャプション（任意）"; opacity: .55; }
.pgv-tweet { margin: 1.2em 0; } .pgv-tweet .twitter-tweet { margin: 0 auto !important; }
.pgv-tweet blockquote.twitter-tweet { border: 1px solid var(--pg-line); border-radius: 12px; padding: 14px 16px; }
.pg-block[data-type="tweet"] .pg-content { padding: 0; }
.pg-block[data-type="tweet"].is-selected .pg-tweet { outline: 3px solid var(--pg-accent); outline-offset: 2px; border-radius: 12px; }
.pg-tweet { min-height: 40px; } .pg-tweet .twitter-tweet { margin: 0 auto !important; }
.pg-tweet__link { display: block; padding: 12px 16px; border: 1px solid var(--pg-line); border-radius: 12px; color: var(--pg-muted); font-size: 13.5px; text-decoration: none; overflow-wrap: anywhere; }
.pg-img-ph { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border: 1px dashed var(--pg-line); border-radius: 10px; color: var(--pg-muted); font-size: 14px; }
.pg-img-ph input { flex: 1; font: inherit; border: 0; background: none; color: inherit; outline: none; }
.pg-add { display: block; width: 100%; text-align: left; border: 0; background: none; color: var(--pg-muted); opacity: 0; font: inherit; font-size: 14px; padding: 6px; cursor: text; }
.pg-blocks:hover + .pg-add, .pg-add:hover, .pg-add:focus { opacity: .7; }

/* スラッシュメニュー・ブロックメニュー */
.pg-menu { position: absolute; z-index: 30; min-width: 230px; max-height: 320px; overflow: auto; background: var(--pg-card); border: 1px solid var(--pg-line); border-radius: 12px; box-shadow: var(--pg-shadow); padding: 6px; }
.pg-menu__label { font-size: 11px; color: var(--pg-muted); padding: 6px 10px 2px; text-transform: uppercase; letter-spacing: .04em; }
.pg-menu__item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 10px; border: 0; border-radius: 8px; background: none; color: var(--pg-fg); font: inherit; font-size: 14px; text-align: left; cursor: pointer; }
.pg-menu__item.is-active, .pg-menu__item:hover { background: var(--pg-hover); }
.pg-menu__item.is-danger { color: #d33; }
.pg-menu__icon { flex: none; width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; border: 1px solid var(--pg-line); border-radius: 7px; font-size: 13px; font-weight: 700; background: var(--pg-bg); }
.pg-menu__icon svg { width: 16px; height: 16px; }
.pg-menu__text small { display: block; font-size: 11.5px; color: var(--pg-muted); }
.pg-menu__empty { padding: 10px; color: var(--pg-muted); font-size: 13px; }

/* 選択中の文字の書式バー */
.pg-fmt { position: absolute; z-index: 30; display: flex; gap: 2px; padding: 4px; background: var(--pg-card); border: 1px solid var(--pg-line); border-radius: 10px; box-shadow: var(--pg-shadow); }
.pg-fmt button { width: 30px; height: 28px; border: 0; border-radius: 6px; background: none; color: var(--pg-fg); font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
.pg-fmt button:hover, .pg-fmt button.is-on { background: var(--pg-hover); }
.pg-fmt button svg { width: 15px; height: 15px; vertical-align: -3px; }

/* 共有パネル */
.pg-share { position: absolute; z-index: 30; right: 16px; top: 54px; width: min(420px, calc(100vw - 32px)); box-sizing: border-box; background: var(--pg-card); border: 1px solid var(--pg-line); border-radius: 14px; box-shadow: var(--pg-shadow); padding: 16px; }
.pg-share h3 { margin: 0 0 4px; font-size: 14px; }
.pg-share p { margin: 0 0 10px; font-size: 12.5px; color: var(--pg-muted); line-height: 1.6; }
.pg-share__row { display: flex; gap: 6px; margin-bottom: 12px; }
.pg-share__row input { flex: 1; min-width: 0; font: inherit; font-size: 12.5px; padding: 7px 9px; border: 1px solid var(--pg-line); border-radius: 8px; background: var(--pg-bg); color: inherit; }
.pg-share__sw { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-top: 1px solid var(--pg-line); margin-top: 4px; font-size: 14px; font-weight: 600; }
.pg-share__sw small { display: block; font-weight: 400; color: var(--pg-muted); font-size: 12px; }

/* Markdown タブ */
.pg-md { width: 100%; min-height: 60vh; font-family: var(--pg-mono); font-size: 13.5px; line-height: 1.6; border: 1px solid var(--pg-line); border-radius: 10px; background: var(--pg-card); color: inherit; padding: 14px; resize: vertical; outline: none; tab-size: 2; }
.pg-tabs { display: inline-flex; gap: 2px; padding: 3px; border: 1px solid var(--pg-line); border-radius: 9px; }
.pg-tabs button { white-space: nowrap; padding: 4px 10px; border: 0; border-radius: 6px; background: none; color: var(--pg-muted); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.pg-tabs button.is-on { background: var(--pg-fg); color: var(--pg-bg); }

.pg-toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50; padding: 9px 14px; border-radius: 10px; background: var(--pg-fg); color: var(--pg-bg); font-size: 13.5px; box-shadow: var(--pg-shadow); }

@media (max-width: 720px) {
  .pg-paper { padding: 24px 16px 40vh; }
  .pg-title { font-size: 30px; }
  .pg-handle { margin-left: -2px; opacity: .4; width: 18px; }
  .pg-top__crumb, .pg-top__status { display: none; }
  .pg-top { padding: 8px 12px; gap: 6px; }
  .pg-top__spacer { flex: 1 0 4px; }
  .pg-share { left: 12px; right: 12px; width: auto; }
  .pgv__title { font-size: 28px; }
}
