:root { color-scheme: light; color: #111; background: #fff; font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Hiragino Sans", "Yu Gothic", sans-serif; font-size: 14px; line-height: 1.7; }
* { box-sizing: border-box; }
body { margin: 0; }
button, textarea, input { font: inherit; }
button { min-height: 40px; border: 1px solid #d6d6d6; border-radius: 4px; padding: 8px 16px; color: #111; background: #fff; cursor: pointer; }
button:disabled { opacity: .4; cursor: default; }
button:focus-visible, textarea:focus-visible, input:focus-visible, summary:focus-visible { outline: 2px solid #111; outline-offset: 3px; }
[hidden] { display: none !important; }
.editor-bar { min-height: 72px; padding: 12px 28px; display: flex; align-items: center; gap: 20px; border-bottom: 1px solid #e5e5e5; }
.editor-bar h1 { margin: 0; font-size: 20px; font-weight: 600; white-space: nowrap; }
#status { margin-left: auto; color: #666; font-size: 12px; }
#save { color: #fff; background: #111; border-color: #111; min-width: 80px; }
.editor-layout { display: grid; grid-template-columns: minmax(320px, 44%) minmax(0, 1fr); height: calc(100svh - 72px - var(--editor-feedback-height, 0px)); }
.writing-pane { padding: 24px 28px 60px; overflow-y: auto; }
.help { margin: 0 0 28px; color: #666; font-size: 12px; line-height: 1.8; }
.article-character-count { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; margin-bottom: 20px; font-size: 13px; }
.article-character-count output { font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.article-character-count small { flex-basis: 100%; color: #666; font-size: 11px; }
.pairing p { color: #666; }
.pairing label { display: block; margin: 16px 0 6px; }
.pairing input { display: block; width: 100%; padding: 10px 12px; min-height: 44px; border: 1px solid #d6d6d6; border-radius: 4px; color: #111; background: #fff; font-size: 16px; }
.pairing button { margin-top: 12px; min-height: 44px; }
.pairing { margin-bottom: 28px; padding-bottom: 20px; border-bottom: 1px solid #e5e5e5; font-size: 12px; }
.pairing summary { cursor: pointer; font-size: 14px; }
.editor-section + .editor-section { margin-top: 32px; padding-top: 24px; border-top: 1px solid #e5e5e5; }
.editor-section h2 { margin: 0 0 16px; font-size: 15px; font-weight: 700; }
.editor-field { margin-bottom: 20px; }
.editor-field label { display: block; margin-bottom: 6px; color: #666; font-size: 12px; }
textarea { font-size: 16px; display: block; width: 100%; min-height: 104px; padding: 10px 12px; color: #111; background: #fff; border: 1px solid #d6d6d6; border-radius: 4px; line-height: 1.9; resize: vertical; }
.slot-note { margin: -10px 0 20px; color: #888; font-size: 12px; }
.preview-pane { position: relative; display: flex; flex-direction: column; align-items: center; overflow: hidden; padding: 18px 16px 0; background: #f1f1f1; border-left: 1px solid #e5e5e5; }
.preview-label { flex: none; margin-bottom: 12px; color: #666; font-size: 12px; }
#preview { display: block; flex: 1; min-height: 0; width: min(390px, 100%); border: 0; background: #fff; }
.conflict { padding: 14px 28px; background: #f5f5f5; border-bottom: 1px solid #ddd; }
.conflict p { margin: 0 0 10px; }
.conflict button { margin: 0 8px 4px 0; }
body.has-conflict .editor-layout { height: calc(100svh - 210px); }
@media (max-width: 1024px) {
  .editor-bar { padding: 12px 16px; gap: 12px; position: sticky; top: 0; z-index: 2; background: #fff; }
  .editor-bar h1 { font-size: 17px; }
  #status { line-height: 1.5; }
  .editor-layout, body.has-conflict .editor-layout { display: block; height: auto; }
  .writing-pane { padding: 20px 20px 60px; max-height: none; min-height: 0; overflow: visible; }
  html { scroll-padding-top: 88px; }
  .editor-bar { gap: 8px; z-index: 3; }
  .preview-pane { display: none; height: auto; min-height: 0; padding: 0; overflow: visible; border: 0; background: #fff; }
  .editor-preview-mode .writing-pane { display: none; }
  .editor-preview-mode .preview-pane { display: block; }
  .preview-label { display: none; }
  #preview { width: 100%; flex: none; }
  textarea { resize: none; scroll-margin-top: 88px; }
  .editor-field textarea { max-height: 320px; overflow-y: auto; }
  .paragraph-cut input { scroll-margin-top: 88px; }
  .conflict, .editor-feedback { position: sticky; top: 72px; z-index: 2; }
  #preview-toggle { display: inline-flex; }

  button { min-height: 44px; }
}

/* Stable paragraph actions, with touch-size controls on mobile. */
#status { min-width: 0; }
.field-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.field-heading label { min-width: 0; margin-bottom: 0; }
.paragraph-actions { display: flex; flex: none; gap: 8px; }
.paragraph-action { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; min-height: 32px; padding: 0; font-size: 20px; line-height: 1; }
.paragraph-action:hover { border-color: #888; }
.chapter-add { margin: 0 0 20px; }
.undo-panel { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; padding: 8px 12px; background: #f5f5f5; border: 1px solid #ddd; border-radius: 4px; font-size: 12px; }
.undo-panel button { flex: none; padding: 6px 10px; }
@media (max-width: 1024px) { .paragraph-action { width: 44px; height: 44px; min-height: 44px; } }




/* Compact shared save state; only a confirmed save receives the check. */
#status { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 18px; min-width: 18px; height: 18px; }
.editor-state-icon { display: block; width: 18px; height: 18px; color: #666; }
.editor-a11y { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); clip-path: inset(50%); white-space: nowrap; border: 0; }
.editor-feedback { margin: 0; padding: 10px 20px; border-bottom: 1px solid #e5e5e5; background: #fff; color: #111; font-size: 12px; }
#preview-toggle { display: none; align-items: center; justify-content: center; flex: none; width: 44px; height: 44px; min-height: 44px; padding: 0; border: 0; background: transparent; color: #666; }
#preview-toggle svg { display: block; width: 20px; height: 20px; }
@media (max-width: 1024px) { #preview-toggle { display: inline-flex; } }

@media (max-width: 1024px) { .undo-panel { top: 72px; } }

.editor-block-tools{display:flex;gap:4px;flex:none;}.editor-block-tools button{min-height:44px;padding:0 8px;font-size:12px;}.editor-block-tools .remove-block{min-width:44px;font-size:20px;}
.editor-add-row{display:flex;gap:8px;flex-wrap:wrap;margin:0 0 20px;}.editor-image-box{width:100%;aspect-ratio:16/9;background:#f2f2f2;margin:0 0 10px;}
.editor-block{padding-top:16px;border-top:1px solid #eee;margin-top:20px;}
.editor-field textarea{font-size:16px!important;line-height:1.7;min-height:80px;}
@media(max-width:1024px){.field-heading{gap:4px;}.field-heading label{font-size:12px;}.editor-block-tools button{padding-inline:6px;}#status{margin-left:auto;}.editor-bar h1{font-size:17px;}}

.article-editor-section{margin-bottom:36px;}.article-editor-section>h2{font-size:16px;font-weight:600;margin:0 0 16px;}.editor-field{margin-bottom:20px;}.article-editor-section textarea{display:block;width:100%;padding:10px 12px;border:1px solid #d5d5d5;border-radius:4px;background:#fff;color:#111;}#article-metadata{margin-bottom:28px;}#article-metadata>summary{min-height:44px;cursor:pointer;padding-block:10px;}#article-metadata[open]>.article-editor-section{padding-top:16px;}

html{-webkit-text-size-adjust:100%;text-size-adjust:100%;}

button{min-height:44px;}

/* Shared line icons; touch targets remain 44px. */
.editor-add-icon,.editor-block-tools button.editor-add-icon{display:inline-flex;align-items:center;justify-content:center;flex:0 0 44px;width:44px;height:44px;min-height:44px;padding:0;}
.editor-add-icon svg{display:block;width:20px;height:20px;}

.image-ratio-open,.image-ratio-open body{overflow:hidden;overscroll-behavior:none;}
.image-ratio-dialog{width:calc(100% - 32px);max-width:360px;max-height:calc(100svh - 32px);margin:auto;padding:20px;border:0;border-radius:8px;background:#fff;color:#111;box-shadow:0 12px 48px #0003;}
.image-ratio-dialog::backdrop{background:#0006;}
.image-ratio-heading{display:flex;align-items:center;justify-content:space-between;gap:12px;margin:-8px -8px 0 0;}
.image-ratio-heading h2{margin:0;font-size:18px;line-height:1.5;font-weight:600;}
.image-ratio-close{display:inline-flex;align-items:center;justify-content:center;flex:none;width:44px;height:44px;padding:0;border:0;background:transparent;}
.image-ratio-close svg{width:20px;height:20px;}
.image-ratio-dialog p{margin:4px 0 20px;color:#666;font-size:13px;}
.image-ratio-options{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;}
.image-ratio-choice{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;min-height:124px;padding:12px;color:#111;background:#fff;border:1px solid #d6d6d6;font-size:14px;line-height:1.5;}
.image-ratio-choice:hover,.image-ratio-choice:active{background:#f5f5f5;border-color:#888;}
.image-ratio-canvas{display:grid;place-items:center;width:72px;height:72px;}
.image-ratio-shape{display:block;border:1.5px solid #888;border-radius:2px;background:#f2f2f2;}
.image-ratio-shape[data-ratio="1:1"]{width:52px;aspect-ratio:1;}
.image-ratio-shape[data-ratio="4:3"]{width:64px;aspect-ratio:4/3;}
.image-ratio-shape[data-ratio="16:9"]{width:64px;aspect-ratio:16/9;}
.image-ratio-shape[data-ratio="9:16"]{width:36px;aspect-ratio:9/16;}
