:root {
  color-scheme: light;
  --bg:#eeece6; --surface:rgba(255,255,255,.78); --surface-solid:#fff;
  --text:#171715; --muted:#7d7970; --line:rgba(20,20,18,.10);
  --shadow:0 26px 80px rgba(44,38,28,.10); --radius:26px;
}
:root[data-ui-theme="dark"] {
  color-scheme:dark; --bg:#11110f; --surface:rgba(28,28,25,.84); --surface-solid:#1d1d1a;
  --text:#f1efe8; --muted:#9f9a90; --line:rgba(255,255,255,.10); --shadow:0 28px 80px rgba(0,0,0,.32);
}
*{box-sizing:border-box} html,body{margin:0;min-height:100%}
body{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Hiragino Kaku Gothic ProN","Yu Gothic",sans-serif;background:radial-gradient(circle at 5% 0%,rgba(255,255,255,.5),transparent 28%),var(--bg);color:var(--text)}
button,input,textarea{font:inherit;color:inherit}.app-shell{max-width:1460px;margin:auto;padding:28px}.topbar{display:flex;align-items:center;justify-content:space-between;margin-bottom:22px;padding:0 4px}.eyebrow{margin:0 0 5px;font-size:10px;font-weight:750;letter-spacing:.2em;color:var(--muted)}h1,h2{margin:0;letter-spacing:-.04em}h1{font-size:clamp(30px,4vw,44px);font-weight:680}h2{font-size:23px}.round-button{width:44px;height:44px;border-radius:50%;border:1px solid var(--line);background:var(--surface);cursor:pointer;backdrop-filter:blur(14px)}
.workspace{display:grid;grid-template-columns:minmax(0,1fr) minmax(420px,.95fr);gap:22px;align-items:start}.panel{border:1px solid var(--line);background:var(--surface);box-shadow:var(--shadow);border-radius:var(--radius);backdrop-filter:blur(22px)}.editor-panel{padding:24px;display:flex;flex-direction:column;gap:20px}.meta-row{display:flex;align-items:center;justify-content:space-between;gap:12px}.date-button{border:0;background:none;padding:0;font-size:18px;font-weight:670;letter-spacing:-.025em;cursor:pointer}.emoji-button{width:46px;height:46px;border:1px solid var(--line);border-radius:15px;background:var(--surface-solid);font-size:26px;cursor:pointer}
.editor-wrap{border:1px solid var(--line);background:color-mix(in srgb,var(--surface-solid) 68%,transparent);border-radius:20px;padding:3px 16px 10px}#editor{width:100%;min-height:356px;resize:vertical;border:0;outline:0;background:transparent;padding:15px 0 10px;font-size:19px;line-height:1.8}#editor::placeholder{color:color-mix(in srgb,var(--muted) 55%,transparent)}.editor-foot{display:flex;align-items:center;justify-content:space-between;gap:12px;padding-top:9px;border-top:1px solid var(--line)}.markdown-hint{font-size:11px;color:var(--muted)}.char-count{font-size:12px;font-variant-numeric:tabular-nums;color:var(--muted)}.char-count.warn{color:#b16b21}.char-count.limit{color:#b43a33}
.section-head,.preview-head{display:flex;align-items:center;justify-content:space-between;margin-bottom:11px;font-size:10px;font-weight:750;letter-spacing:.18em;color:var(--muted)}.template-strip{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:9px}.template-option{border:0;background:none;padding:0;cursor:pointer;text-align:left}.template-thumb{aspect-ratio:3/4;border-radius:13px;border:1px solid rgba(0,0,0,.08);padding:9px;display:flex;flex-direction:column;justify-content:space-between;transition:transform .17s ease,box-shadow .17s ease}.template-option:hover .template-thumb{transform:translateY(-2px)}.template-option[aria-pressed="true"] .template-thumb{box-shadow:0 0 0 2px var(--text),0 8px 25px rgba(0,0,0,.10)}.template-name{display:block;margin-top:7px;font-size:11px;color:var(--muted)}.t-journal{background:#f4efe4;color:#302d28}.t-minimal{color:#284d68;background:
repeating-linear-gradient(to bottom,#fbfcfd 0,#fbfcfd 12px,#c9dce8 12px,#c9dce8 13px)}.t-editorial{background:#202126;color:#8177ff}.t-midnight{background:#fffdf7;color:#242424}.t-mono{background:#17324d;color:#72c7e8}.thumb-lines{display:grid;gap:3px}.thumb-lines i{height:2px;border-radius:3px;background:currentColor;opacity:.75}.thumb-lines i:nth-child(2){width:74%;opacity:.4}.thumb-lines i:nth-child(3){width:56%;opacity:.4}
.control-surface{display:grid;grid-template-columns:1fr 1fr;gap:1px;background:var(--line);border:1px solid var(--line);border-radius:18px;overflow:hidden}.control-block{background:var(--surface-solid);padding:15px}.control-label{display:block;font-size:9px;font-weight:750;letter-spacing:.17em;color:var(--muted);margin-bottom:9px}.segment-control{display:grid;grid-template-columns:1fr 1fr;border:1px solid var(--line);padding:3px;border-radius:12px;background:var(--bg)}.segment-control button{border:0;background:transparent;border-radius:9px;padding:8px 9px;font-size:12px;cursor:pointer;color:var(--muted)}.segment-control button[aria-pressed="true"]{background:var(--surface-solid);color:var(--text);box-shadow:0 2px 8px rgba(0,0,0,.08)}.switch-block{display:flex;align-items:center;justify-content:space-between;gap:14px}.control-description{display:block;font-size:13px}.switch{cursor:pointer}.switch input{position:absolute;opacity:0;pointer-events:none}.switch-track{width:48px;height:28px;padding:3px;border-radius:999px;background:#c9c6bf;display:block;transition:.2s}.switch-thumb{display:block;width:22px;height:22px;border-radius:50%;background:white;box-shadow:0 2px 6px rgba(0,0,0,.22);transition:.2s}.switch input:checked+.switch-track{background:#222}.switch input:checked+.switch-track .switch-thumb{transform:translateX(20px)}:root[data-ui-theme="dark"] .switch input:checked+.switch-track{background:#f1efe8}:root[data-ui-theme="dark"] .switch input:checked+.switch-track .switch-thumb{background:#111}
.settings{border-top:1px solid var(--line);padding-top:15px}.settings summary{font-size:13px;color:var(--muted);cursor:pointer}.settings label{display:grid;gap:7px;margin-top:13px;font-size:12px;color:var(--muted)}.settings input{border:1px solid var(--line);background:var(--surface-solid);border-radius:12px;padding:10px 12px;outline:0}
.preview-panel{padding:18px;display:flex;flex-direction:column}.preview-head{padding:4px 4px 0;margin-bottom:13px}.preview-head #saveState{letter-spacing:0;font-weight:500}.preview-stage{min-height:0;border-radius:20px;background:color-mix(in srgb,var(--bg) 76%,transparent);display:grid;place-items:center;padding:24px;overflow:hidden}.preview-stage img{display:block;width:350px;max-width:100%;height:auto;box-shadow:0 20px 60px rgba(0,0,0,.17)}.actions{display:grid;grid-template-columns:1fr auto;gap:10px;padding-top:16px}.actions button{border-radius:14px;padding:13px 18px;font-weight:660;cursor:pointer}.primary-button{border:1px solid var(--text);background:var(--text);color:var(--surface-solid)}:root[data-ui-theme="dark"] .primary-button{color:#111}.secondary-button{border:1px solid var(--line);background:var(--surface-solid)}
.emoji-dialog{width:min(520px,calc(100vw - 32px));border:1px solid var(--line);border-radius:24px;background:var(--surface-solid);color:var(--text);padding:20px;box-shadow:var(--shadow)}.emoji-dialog::backdrop{background:rgba(0,0,0,.42);backdrop-filter:blur(5px)}.dialog-head{display:flex;align-items:center;justify-content:space-between;margin-bottom:18px}.emoji-grid{display:grid;grid-template-columns:repeat(8,1fr);gap:7px}.emoji-choice{aspect-ratio:1;border:1px solid var(--line);border-radius:12px;background:var(--surface);font-size:23px;cursor:pointer}.custom-emoji-row{display:grid;grid-template-columns:1fr auto auto;gap:8px;margin-top:15px}.custom-emoji-row input,.custom-emoji-row button{border:1px solid var(--line);background:var(--surface);border-radius:11px;padding:9px 11px}.custom-emoji-row button{cursor:pointer}

@media(max-width:940px){
  html,body{min-height:100dvh}
  body{overflow-x:hidden}
  .app-shell{width:100%;max-width:none;padding:12px;min-height:100dvh}
  .topbar{margin-bottom:10px;padding:2px 2px 0}
  .topbar .eyebrow{display:none}
  .topbar h1{font-size:24px;letter-spacing:-.045em}
  .round-button{width:38px;height:38px}
  .workspace{display:block}
  .editor-panel{padding:14px;gap:13px;border-radius:20px;box-shadow:none}
  .meta-row{min-height:40px}
  .date-button{font-size:16px}
  .emoji-button{width:40px;height:40px;border-radius:13px;font-size:23px}
  .editor-wrap{border-radius:16px;padding:2px 12px 8px}
  #editor{min-height:190px;max-height:32dvh;resize:vertical;padding:11px 0 8px;font-size:17px;line-height:1.7}
  .editor-foot{padding-top:7px}
  .template-strip{display:flex;overflow-x:auto;gap:8px;padding:2px 2px 7px;scrollbar-width:none}
  .template-strip::-webkit-scrollbar{display:none}
  .template-option{min-width:68px}
  .template-thumb{width:68px;padding:7px;border-radius:11px}
  .template-name{font-size:10px;margin-top:5px}
  .control-surface{grid-template-columns:1fr 1fr;border-radius:15px}
  .control-block{padding:11px}
  .segment-control button{padding:7px 5px}
  .control-description{font-size:12px}
  .username-field{padding-top:11px}
  .username-field input{padding:9px 11px}
  .preview-panel{margin-top:12px;padding:12px;border-radius:20px;box-shadow:none}
  .preview-head{margin-bottom:9px}
  .preview-stage{min-height:0;padding:10px;border-radius:15px;overflow:visible}
  .preview-stage img{width:350px;max-width:100%;height:auto;box-shadow:0 12px 34px rgba(0,0,0,.14)}
  .actions{position:sticky;bottom:max(8px,env(safe-area-inset-bottom));z-index:4;grid-template-columns:1fr auto;padding:8px;margin-top:8px;background:var(--surface);border:1px solid var(--line);border-radius:16px;backdrop-filter:blur(18px)}
  .actions button{padding:11px 15px}
}
@media(max-width:540px){
  .app-shell{padding:8px;padding-bottom:max(8px,env(safe-area-inset-bottom))}
  .topbar{padding:1px 3px}
  .topbar h1{font-size:22px}
  .editor-panel{padding:12px;gap:11px}
  #editor{min-height:170px;max-height:29dvh;font-size:16px}
  .markdown-hint{display:none}
  .section-head{margin-bottom:8px}
  .template-option{min-width:62px}
  .template-thumb{width:62px}
  .control-surface{grid-template-columns:1fr}
  .preview-panel{padding:9px}
  .preview-stage{padding:7px}
  .emoji-grid{grid-template-columns:repeat(6,1fr)}
}

/* ===== Image Note unified UI tone ===== */
:root{
  --ui-radius-lg:20px;
  --ui-radius-md:15px;
  --ui-radius-sm:11px;
  --ui-border:1px solid var(--line);
  --ui-pad:14px;
}

/* panels */
.panel{
  border:var(--ui-border);
  border-radius:var(--ui-radius-lg);
  background:var(--surface);
  box-shadow:0 18px 55px rgba(30,28,24,.08);
}
.editor-panel,.preview-panel{gap:14px}

/* section language */
.section-head,.preview-head,.control-label,.eyebrow{
  font-size:10px;
  font-weight:750;
  letter-spacing:.16em;
  color:var(--muted);
}
.section-head{margin-bottom:9px}

/* editor */
.editor-wrap{
  border:var(--ui-border);
  border-radius:var(--ui-radius-md);
  background:var(--surface-solid);
  padding:3px 14px 9px;
  box-shadow:none;
}
#editor{
  font-size:17px;
  line-height:1.72;
}

/* templates */
.template-strip{gap:8px}
.template-option{border-radius:var(--ui-radius-md)}
.template-thumb{
  border:var(--ui-border);
  border-radius:13px;
  box-shadow:none;
}
.template-option[aria-pressed="true"] .template-thumb{
  box-shadow:0 0 0 2px color-mix(in srgb,var(--text) 82%,transparent);
}
.template-name{
  font-size:10px;
  font-weight:650;
  letter-spacing:.01em;
}

/* settings card */
.control-surface{
  grid-template-columns:1fr 1fr;
  border:var(--ui-border);
  border-radius:var(--ui-radius-lg);
  overflow:hidden;
  background:var(--line);
}
.control-block{
  min-height:92px;
  padding:16px 18px;
  background:var(--surface-solid);
}
.control-label{margin-bottom:10px}
.control-description{
  font-size:14px;
  font-weight:560;
}

/* typeface segmented control */
.segment-control{
  border:var(--ui-border);
  border-radius:13px;
  padding:3px;
  background:color-mix(in srgb,var(--bg) 78%,var(--surface-solid));
}
.segment-control button{
  min-height:38px;
  border-radius:10px;
  font-size:13px;
  font-weight:600;
}
.segment-control button[aria-pressed="true"]{
  background:var(--surface-solid);
  box-shadow:0 2px 8px rgba(0,0,0,.07);
}

/* switches */
.switch-track{
  width:46px;
  height:27px;
  padding:3px;
}
.switch-thumb{width:21px;height:21px}
.switch input:checked+.switch-track .switch-thumb{transform:translateX(19px)}

/* username belongs to the same visual system */
.username-field{
  border:var(--ui-border);
  border-radius:var(--ui-radius-lg);
  background:var(--surface-solid);
  padding:15px 18px 16px;
}
.username-field label{gap:8px}
.username-field .control-label{margin:0}
.username-field input{
  width:100%;
  border:0;
  border-radius:0;
  background:transparent;
  padding:2px 0;
  font-size:15px;
  font-weight:560;
  line-height:1.5;
  outline:none;
  box-shadow:none;
}
.username-field input::placeholder{color:var(--muted)}
.username-field input:focus{
  border:0;
  box-shadow:none;
}

/* meta/date/emoji */
.meta-row{
  border:var(--ui-border);
  border-radius:var(--ui-radius-md);
  background:var(--surface-solid);
  padding:9px 10px 9px 14px;
}
.date-button{
  font-size:15px;
  font-weight:650;
}
.emoji-button{
  width:40px;
  height:40px;
  border:var(--ui-border);
  border-radius:12px;
  background:color-mix(in srgb,var(--surface-solid) 88%,var(--bg));
}

/* buttons */
.actions button,.round-button,.emoji-choice,.custom-emoji-row button{
  transition:transform .14s ease,opacity .14s ease,background .14s ease;
}
.actions button{
  border-radius:13px;
  min-height:44px;
  font-size:14px;
}
.actions button:active,.round-button:active,.emoji-choice:active{transform:scale(.98)}
.primary-button{
  box-shadow:none;
}
.secondary-button{
  border:var(--ui-border);
}

/* preview */
.preview-stage{
  border:var(--ui-border);
  background:color-mix(in srgb,var(--bg) 68%,var(--surface-solid));
  border-radius:var(--ui-radius-md);
}
.preview-stage img{
  border-radius:2px;
}

/* dialog */
.emoji-dialog{
  border:var(--ui-border);
  border-radius:var(--ui-radius-lg);
  box-shadow:0 24px 70px rgba(0,0,0,.18);
}
.emoji-choice{
  border:var(--ui-border);
  border-radius:11px;
  background:var(--surface-solid);
}
.custom-emoji-row input,
.custom-emoji-row button{
  border:var(--ui-border);
  border-radius:11px;
  background:var(--surface-solid);
}

/* mobile: same tone, not a different UI */
@media(max-width:940px){
  .editor-panel,.preview-panel{border-radius:18px}
  .control-surface{border-radius:16px}
  .control-block{min-height:84px;padding:13px 14px}
  .username-field{border-radius:16px;padding:13px 14px}
  .meta-row{border-radius:14px}
}
@media(max-width:540px){
  .control-surface{grid-template-columns:1fr 1fr}
  .control-block{min-height:80px;padding:12px}
  .segment-control button{font-size:12px;padding-inline:4px}
  .username-field{padding:12px}
}

/* Mobile editor: give writing space priority */
@media(max-width:940px){
  #editor{
    min-height:280px;
    height:38dvh;
    max-height:460px;
    resize:vertical;
  }
}
@media(max-width:540px){
  #editor{
    min-height:300px;
    height:42dvh;
    max-height:480px;
  }
}
@media(max-height:700px) and (max-width:540px){
  #editor{
    min-height:240px;
    height:36dvh;
  }
}

.date-button-hidden{display:none!important}
.meta-row-compact{
  justify-content:flex-end;
  gap:9px;
}
.meta-label{
  margin-right:auto;
  font-size:10px;
  font-weight:750;
  letter-spacing:.16em;
  color:var(--muted);
}
.snippet-bar{
  display:flex;
  gap:7px;
  overflow-x:auto;
  padding:1px 1px 2px;
  scrollbar-width:none;
}
.snippet-bar::-webkit-scrollbar{display:none}
.snippet-bar button{
  flex:0 0 auto;
  min-height:34px;
  padding:7px 10px;
  border:1px solid var(--line);
  border-radius:10px;
  background:var(--surface-solid);
  color:var(--text);
  font-size:11px;
  font-weight:650;
  cursor:pointer;
}
.snippet-bar button:active{transform:scale(.98)}
@media(max-width:540px){
  .snippet-bar{margin-inline:-1px}
  .snippet-bar button{min-height:36px;padding:8px 11px}
}

.template-thumb{justify-content:center}
.template-thumb .thumb-lines{width:100%}

.date-button-hidden{display:initial!important}
.meta-row-compact{justify-content:space-between}
.meta-label{display:none}

/* Date toggle now lives beside the date */
.date-inline{
  display:flex;
  align-items:center;
  gap:10px;
  min-width:0;
}
.date-switch{
  flex:0 0 auto;
}
.date-switch .switch-track{
  width:40px;
  height:24px;
  padding:3px;
}
.date-switch .switch-thumb{
  width:18px;
  height:18px;
}
.date-switch input:checked+.switch-track .switch-thumb{
  transform:translateX(16px);
}

/* TYPEFACE becomes a full-width settings card */
.control-surface{
  grid-template-columns:1fr;
}
.control-block{
  min-height:auto;
}

/* Hidden on desktop; mobile gets an always-visible live preview */
.mobile-live-preview{
  display:none;
}

@media(max-width:940px){
  .mobile-live-preview{
    display:block;
    position:sticky;
    top:8px;
    z-index:3;
    margin:0;
    padding:8px;
    border:1px solid var(--line);
    border-radius:16px;
    background:color-mix(in srgb,var(--surface-solid) 92%,transparent);
    box-shadow:0 10px 30px rgba(0,0,0,.10);
    backdrop-filter:blur(18px);
  }
  .mobile-live-head{
    display:flex;
    align-items:center;
    justify-content:space-between;
    margin-bottom:6px;
    font-size:9px;
    font-weight:750;
    letter-spacing:.15em;
    color:var(--muted);
  }
  .mobile-live-stage{
    display:flex;
    justify-content:center;
    max-height:26dvh;
    overflow:hidden;
    border-radius:10px;
    background:color-mix(in srgb,var(--bg) 72%,var(--surface-solid));
  }
  .mobile-live-stage img{
    display:block;
    width:100%;
    max-width:280px;
    height:auto;
    object-fit:contain;
    object-position:top center;
  }

  /* Keep the large final preview below for export confirmation */
  .preview-panel{
    margin-top:12px;
  }
}

@media(max-width:540px){
  .meta-row{
    padding:8px 9px 8px 12px;
  }
  .date-inline{
    gap:8px;
  }
  .date-button{
    font-size:14px;
  }
  .mobile-live-preview{
    top:max(6px,env(safe-area-inset-top));
    padding:7px;
  }
  .mobile-live-stage{
    max-height:24dvh;
  }
  .mobile-live-stage img{
    max-width:250px;
  }
}

/* Realtime preview uses the normal preview only; no secondary preview UI. */
.mobile-live-preview{display:none!important}

/* ===== True realtime WYSIWYG editor ===== */
.workspace{
  display:block!important;
  max-width:760px;
  margin:0 auto;
}
.editor-panel{
  width:100%;
}
.preview-panel{display:none!important}

.wysiwyg-editor{
  display:grid;
  gap:8px;
}
.wysiwyg-stage{
  position:relative;
  width:350px;
  max-width:100%;
  margin:0 auto;
  border:1px solid var(--line);
  border-radius:16px;
  overflow:hidden;
  background:var(--surface-solid);
  box-shadow:0 16px 42px rgba(0,0,0,.10);
}
.wysiwyg-stage #previewImage{
  display:block;
  width:100%;
  height:auto;
  min-height:180px;
  pointer-events:none;
  user-select:none;
}
.wysiwyg-stage #editor{
  position:absolute;
  inset:0;
  width:100%;
  height:100%!important;
  min-height:0!important;
  max-height:none!important;
  resize:none;
  margin:0;
  border:0;
  outline:0;
  padding:0;
  overflow:hidden;
  background:transparent;
  color:transparent;
  -webkit-text-fill-color:transparent;
  caret-color:#6d63ff;
  font:inherit;
  line-height:1;
  z-index:2;
}
/* selection should still be visible while editing */
.wysiwyg-stage #editor::selection{
  background:rgba(109,99,255,.20);
}
.wysiwyg-stage #editor::placeholder{
  color:transparent;
  -webkit-text-fill-color:transparent;
}
.editor-foot{
  width:350px;
  max-width:100%;
  margin:0 auto;
}

/* Integrated action buttons */
.integrated-actions{
  margin-top:14px;
  position:sticky;
  bottom:max(8px,env(safe-area-inset-bottom));
  z-index:5;
  background:var(--surface);
  border:1px solid var(--line);
  border-radius:16px;
  padding:8px;
  backdrop-filter:blur(18px);
}

/* Desktop can be a little larger while preserving 350px design canvas */
@media(min-width:941px){
  .workspace{max-width:820px}
  .wysiwyg-stage,.editor-foot{width:350px}
}

/* Mobile: keep the live canvas visible and usable */
@media(max-width:540px){
  .app-shell{padding:8px}
  .editor-panel{padding:12px}
  .wysiwyg-stage{
    width:min(350px,calc(100vw - 40px));
    border-radius:14px;
  }
  .editor-foot{
    width:min(350px,calc(100vw - 40px));
  }
}

/* ===== Image Note refined unified tone ===== */
:root{
  --ink:#1d1e20;
  --ui-bg:#f3f2ee;
  --ui-card:rgba(255,255,255,.88);
  --ui-border:rgba(24,24,22,.09);
  --ui-muted:#77756f;
  --accent:#6f68ee;
  --radius-xl:22px;
  --radius-lg:16px;
  --radius-md:12px;
  --soft-shadow:0 18px 50px rgba(32,29,24,.08);
}
:root[data-ui-theme="dark"]{
  --ui-bg:#111210;
  --ui-card:rgba(29,30,28,.92);
  --ui-border:rgba(255,255,255,.09);
  --ui-muted:#aaa69d;
  --soft-shadow:0 20px 55px rgba(0,0,0,.26);
}

body{
  background:
    radial-gradient(circle at 18% -10%,rgba(255,255,255,.72),transparent 28%),
    var(--bg);
}
.app-shell{max-width:900px;padding:22px}
.topbar{
  margin-bottom:16px;
  padding:0 3px;
}
.topbar h1{
  font-size:clamp(28px,5vw,38px);
  font-weight:690;
  letter-spacing:-.045em;
}
.panel{
  border:1px solid var(--ui-border);
  border-radius:var(--radius-xl);
  background:var(--ui-card);
  box-shadow:var(--soft-shadow);
}
.editor-panel{
  padding:18px;
  gap:14px;
}

/* Meta row, snippets, controls: one language */
.meta-row,
.control-surface,
.username-field{
  border:1px solid var(--ui-border);
  background:var(--surface-solid);
  border-radius:var(--radius-lg);
}
.meta-row{
  padding:9px 10px 9px 14px;
}
.date-button{
  font-size:15px;
  font-weight:650;
  letter-spacing:-.02em;
}
.emoji-button{
  border:1px solid var(--ui-border);
  background:color-mix(in srgb,var(--surface-solid) 90%,var(--bg));
  border-radius:12px;
}
.snippet-bar{
  gap:6px;
  padding:0;
}
.snippet-bar button{
  min-height:34px;
  padding:7px 10px;
  border:1px solid var(--ui-border);
  border-radius:10px;
  background:var(--surface-solid);
  font-size:11px;
  font-weight:650;
  color:var(--muted);
}
.snippet-bar button:hover{
  color:var(--text);
  border-color:color-mix(in srgb,var(--text) 20%,var(--ui-border));
}
.snippet-bar button:active{transform:translateY(1px)}

/* True editing canvas */
.wysiwyg-editor{gap:8px}
.wysiwyg-stage{
  --note-bg:#f4efe4;
  --note-fg:#302d28;
  width:350px;
  max-width:100%;
  margin:0 auto;
  border:1px solid rgba(0,0,0,.08);
  border-radius:14px;
  background:var(--note-bg);
  box-shadow:0 14px 36px rgba(0,0,0,.11);
  transition:background .16s ease,box-shadow .16s ease;
}
.wysiwyg-stage:focus-within{
  box-shadow:0 0 0 3px color-mix(in srgb,var(--accent) 17%,transparent),0 14px 36px rgba(0,0,0,.11);
}
.wysiwyg-stage #previewImage{
  width:100%;
  min-height:180px;
  background:var(--note-bg);
}
.wysiwyg-stage #editor{
  caret-color:var(--accent);
}
.editor-foot{
  width:350px;
  max-width:100%;
  padding:0 2px;
  border:0;
}
.markdown-hint{font-size:10px}
.char-count{font-size:11px}

/* Template strip */
.section-head{
  margin-bottom:8px;
  padding-inline:1px;
}
.template-strip{gap:9px}
.template-option{
  text-align:center;
  border-radius:12px;
}
.template-thumb{
  border:1px solid rgba(0,0,0,.08);
  border-radius:12px;
  transition:transform .15s ease,box-shadow .15s ease,outline-color .15s ease;
}
.template-option:hover .template-thumb{transform:translateY(-1px)}
.template-option[aria-pressed="true"] .template-thumb{
  box-shadow:0 0 0 2px var(--text),0 7px 18px rgba(0,0,0,.10);
}
.template-name{
  text-align:center;
  font-size:10px;
  font-weight:650;
  margin-top:6px;
}

/* Controls */
.control-surface{
  grid-template-columns:1fr;
  overflow:hidden;
}
.control-block{
  min-height:auto;
  padding:13px 14px;
}
.control-label{
  margin-bottom:8px;
  font-size:9px;
  letter-spacing:.17em;
}
.segment-control{
  border:1px solid var(--ui-border);
  background:color-mix(in srgb,var(--bg) 75%,var(--surface-solid));
  border-radius:12px;
}
.segment-control button{
  min-height:36px;
  border-radius:9px;
  font-weight:620;
}
.username-field{
  padding:13px 14px;
  border-top:1px solid var(--ui-border)!important;
}
.username-field input{
  border:0!important;
  background:transparent!important;
  padding:1px 0!important;
  font-size:14px;
}

/* Actions */
.integrated-actions{
  margin-top:12px;
  border:1px solid var(--ui-border);
  background:color-mix(in srgb,var(--surface) 92%,transparent);
  border-radius:16px;
  padding:7px;
  box-shadow:0 10px 28px rgba(0,0,0,.08);
}
.actions button{
  min-height:44px;
  border-radius:11px;
  font-size:13px;
}
.primary-button{
  background:var(--text);
  border-color:var(--text);
}

/* Dialog */
.emoji-dialog{
  border:1px solid var(--ui-border);
  border-radius:20px;
}
.emoji-choice,.custom-emoji-row input,.custom-emoji-row button{
  border:1px solid var(--ui-border);
  background:var(--surface-solid);
}

/* Mobile refinement */
@media(max-width:540px){
  .app-shell{padding:8px 8px max(8px,env(safe-area-inset-bottom))}
  .topbar{margin-bottom:9px}
  .topbar .eyebrow{display:none}
  .topbar h1{font-size:23px}
  .editor-panel{padding:11px;gap:11px;border-radius:18px}
  .wysiwyg-stage{
    width:min(350px,calc(100vw - 38px));
    border-radius:13px;
  }
  .editor-foot{width:min(350px,calc(100vw - 38px))}
  .template-strip{
    overflow-x:auto;
    display:flex;
    gap:7px;
    padding:2px 1px 7px;
    scrollbar-width:none;
  }
  .template-strip::-webkit-scrollbar{display:none}
  .template-option{min-width:62px}
  .template-thumb{width:62px}
  .snippet-bar{overflow-x:auto;scrollbar-width:none}
  .snippet-bar::-webkit-scrollbar{display:none}
}

/* ===== Narrow single-column layout / cursor-correct editor ===== */
.app-shell{
  width:100%;
  max-width:390px!important;
  margin:0 auto;
  padding:14px!important;
}
.workspace{
  width:100%;
  max-width:350px!important;
  margin:0 auto!important;
  display:block!important;
}
.editor-panel{
  width:100%;
  padding:12px!important;
}
.topbar{
  width:100%;
  max-width:350px;
  margin:0 auto 10px!important;
}

.editor-stack{
  display:grid;
  gap:10px;
}
.editor-wrap-live{
  width:100%;
  border:1px solid var(--ui-border,var(--line));
  border-radius:14px;
  background:var(--surface-solid);
  padding:3px 12px 8px;
}
.editor-wrap-live #editor{
  position:static!important;
  inset:auto!important;
  display:block;
  width:100%;
  height:auto!important;
  min-height:220px!important;
  max-height:42dvh!important;
  resize:vertical!important;
  margin:0;
  padding:12px 0 10px!important;
  border:0!important;
  outline:0;
  overflow:auto!important;
  background:transparent!important;
  color:var(--text)!important;
  -webkit-text-fill-color:currentColor!important;
  caret-color:var(--accent,#6f68ee)!important;
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Hiragino Kaku Gothic ProN","Yu Gothic",sans-serif!important;
  font-size:16px!important;
  line-height:1.72!important;
  letter-spacing:0!important;
}
.editor-wrap-live #editor::placeholder{
  color:color-mix(in srgb,var(--muted) 60%,transparent)!important;
  -webkit-text-fill-color:currentColor!important;
}
.editor-wrap-live .editor-foot{
  width:100%!important;
  margin:0!important;
  padding-top:7px!important;
  border-top:1px solid var(--line)!important;
}

.live-preview-wrap{
  width:350px;
  max-width:100%;
  margin:0 auto;
  overflow:hidden;
  border:1px solid rgba(0,0,0,.08);
  border-radius:13px;
  box-shadow:0 12px 30px rgba(0,0,0,.10);
  background:#f4efe4;
}
.live-preview-wrap img{
  display:block;
  width:100%;
  height:auto;
}

/* old overlay WYSIWYG must never participate */
.wysiwyg-editor,
.wysiwyg-stage{display:none!important}

/* compact templates */
.template-strip{
  display:flex!important;
  gap:6px!important;
  overflow-x:auto;
  padding:1px 0 5px!important;
  scrollbar-width:none;
}
.template-strip::-webkit-scrollbar{display:none}
.template-option{
  min-width:48px!important;
  width:48px!important;
}
.template-thumb{
  width:48px!important;
  height:62px!important;
  aspect-ratio:auto!important;
  padding:6px!important;
  border-radius:9px!important;
}
.template-name{
  margin-top:4px!important;
  font-size:9px!important;
  line-height:1.1!important;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

/* controls/actions align with same 350px column */
.control-surface,
.username-field,
.integrated-actions,
.meta-row,
.snippet-bar{
  width:100%;
}
.integrated-actions{
  max-width:350px;
  margin:10px auto 0!important;
}

@media(max-width:540px){
  .app-shell{padding:8px!important}
  .workspace{max-width:350px!important}
  .editor-panel{padding:10px!important}
  .editor-wrap-live #editor{
    min-height:250px!important;
    max-height:46dvh!important;
  }
  .template-option{
    min-width:44px!important;
    width:44px!important;
  }
  .template-thumb{
    width:44px!important;
    height:58px!important;
  }
}

/* ===== Canonical Image Note UI ===== */
:root{
  --app-width:350px;
  --ui-gap:10px;
  --ui-radius:14px;
  --ui-border:1px solid var(--line);
  --accent:#6f68ee;
}

html,body{
  width:100%;
  overflow-x:hidden;
}
body{
  display:block;
}
.app-shell{
  width:100%!important;
  max-width:390px!important;
  margin:0 auto!important;
  padding:12px!important;
}
.topbar{
  width:var(--app-width)!important;
  max-width:100%!important;
  margin:0 auto 10px!important;
  padding:0 2px!important;
}
.workspace{
  display:block!important;
  width:var(--app-width)!important;
  max-width:100%!important;
  margin:0 auto!important;
}
.panel{
  width:100%!important;
  margin:0!important;
}
.editor-panel{
  display:flex!important;
  flex-direction:column!important;
  gap:var(--ui-gap)!important;
  padding:12px!important;
  border-radius:18px!important;
}

/* top row */
.meta-row{
  width:100%!important;
  min-height:44px!important;
  padding:8px 9px 8px 12px!important;
  border-radius:13px!important;
}
.date-inline{min-width:0!important;gap:8px!important}
.date-button{
  white-space:nowrap!important;
  overflow:hidden!important;
  text-overflow:ellipsis!important;
  font-size:14px!important;
}
.emoji-button{
  flex:0 0 40px!important;
  width:40px!important;
  height:40px!important;
}

/* markdown toolbar */
.snippet-bar{
  width:100%!important;
  display:flex!important;
  gap:6px!important;
  overflow-x:auto!important;
  padding:0 0 2px!important;
  scrollbar-width:none!important;
}
.snippet-bar::-webkit-scrollbar{display:none!important}
.snippet-bar button{
  flex:0 0 auto!important;
  min-height:34px!important;
  padding:7px 9px!important;
  border-radius:9px!important;
  font-size:10px!important;
  line-height:1!important;
}

/* WYSIWYG */
.editor-stack,.editor-wrap-live,.live-preview-wrap{display:none!important}
.wysiwyg-editor{
  display:grid!important;
  gap:7px!important;
  width:100%!important;
}
.wysiwyg-stage{
  --note-bg:#f4efe4;
  position:relative!important;
  display:block!important;
  width:100%!important;
  min-height:180px!important;
  margin:0!important;
  overflow:hidden!important;
  border:1px solid rgba(0,0,0,.08)!important;
  border-radius:12px!important;
  background:var(--note-bg)!important;
  box-shadow:0 10px 28px rgba(0,0,0,.10)!important;
}
.wysiwyg-stage #previewImage{
  display:block!important;
  width:100%!important;
  height:auto!important;
  min-height:180px!important;
  margin:0!important;
  pointer-events:none!important;
  user-select:none!important;
  background:var(--note-bg)!important;
}
.wysiwyg-stage #editor{
  position:absolute!important;
  inset:0!important;
  z-index:2!important;
  width:100%!important;
  height:100%!important;
  min-height:0!important;
  max-height:none!important;
  margin:0!important;
  padding:0!important;
  border:0!important;
  outline:0!important;
  resize:none!important;
  overflow:hidden!important;
  background:transparent!important;
  color:transparent!important;
  -webkit-text-fill-color:transparent!important;
  caret-color:var(--accent)!important;
}
.wysiwyg-stage #editor::selection{
  background:rgba(111,104,238,.18)!important;
}
.editor-foot{
  width:100%!important;
  margin:0!important;
  padding:0 2px!important;
  border:0!important;
}

/* templates */
.section-head{
  margin:1px 0 6px!important;
}
.template-strip{
  display:flex!important;
  gap:6px!important;
  overflow-x:auto!important;
  padding:1px 1px 5px!important;
  scrollbar-width:none!important;
}
.template-strip::-webkit-scrollbar{display:none!important}
.template-option{
  flex:0 0 44px!important;
  width:44px!important;
  min-width:44px!important;
}
.template-thumb{
  width:44px!important;
  height:56px!important;
  aspect-ratio:auto!important;
  padding:5px!important;
  border-radius:8px!important;
}
.template-name{
  margin-top:4px!important;
  font-size:8px!important;
  line-height:1.05!important;
  text-align:center!important;
  white-space:nowrap!important;
}

/* settings */
.control-surface{
  width:100%!important;
  grid-template-columns:1fr!important;
  border-radius:13px!important;
}
.control-block{
  min-height:0!important;
  padding:11px 12px!important;
}
.segment-control button{
  min-height:34px!important;
  padding:6px 8px!important;
  font-size:12px!important;
}
.username-field{
  width:100%!important;
  padding:11px 12px!important;
  border-radius:13px!important;
}
.username-field input{
  width:100%!important;
}

/* actions */
.integrated-actions{
  width:var(--app-width)!important;
  max-width:100%!important;
  margin:10px auto 0!important;
  grid-template-columns:1fr auto!important;
  padding:7px!important;
  border-radius:14px!important;
}
.integrated-actions button{
  min-height:42px!important;
  padding:10px 14px!important;
}

/* mobile */
@media(max-width:390px){
  .app-shell{padding:7px!important}
  .topbar,.workspace,.integrated-actions{
    width:calc(100vw - 14px)!important;
  }
  .editor-panel{padding:10px!important}
  .template-option{
    flex-basis:42px!important;
    width:42px!important;
    min-width:42px!important;
  }
  .template-thumb{
    width:42px!important;
    height:54px!important;
  }
}

/* ===== caret-correct direct visual editor ===== */
.wysiwyg-stage,.editor-stack,.editor-wrap-live,.live-preview-wrap{display:none!important}
.visual-editor{
  --note-bg:#f4efe4;
  --note-fg:#302d28;
  --note-muted:#777066;
  --note-heading:#302d28;
  --note-font:"Yu Gothic","Hiragino Sans",sans-serif;
  position:relative;
  width:100%;
  min-height:180px;
  padding:70px 30px 30px;
  border:1px solid rgba(0,0,0,.08);
  border-radius:12px;
  outline:none;
  overflow-wrap:anywhere;
  background:var(--note-bg);
  color:var(--note-fg);
  font-family:var(--note-font);
  font-size:17px;
  line-height:1.68;
  box-shadow:0 10px 28px rgba(0,0,0,.10);
  caret-color:#6f68ee;
}
.visual-editor:focus{
  box-shadow:0 0 0 3px rgba(111,104,238,.16),0 10px 28px rgba(0,0,0,.10);
}
.visual-editor::before{
  content:attr(data-date);
  position:absolute;
  left:30px;top:30px;
  font-size:12px;line-height:1;
  font-weight:500;
  color:var(--note-fg);
  pointer-events:none;
}
.visual-editor:not(.show-date)::before{content:""}
.visual-editor::after{
  content:attr(data-emoji);
  position:absolute;
  right:30px;top:24px;
  font:28px/1 sans-serif;
  pointer-events:none;
}
.ve-line{
  position:relative;
  min-height:1.68em;
  white-space:pre-wrap;
}
.ve-content{outline:none}
.ve-line[data-type="h1"]{
  margin:4px 0 4px;
  font-size:22px;
  line-height:1.45;
  font-weight:700;
  color:var(--note-heading);
}
.ve-line[data-type="h2"]{
  margin:3px 0 3px;
  font-size:19px;
  line-height:1.52;
  font-weight:700;
  color:var(--note-heading);
}
.ve-line[data-type="bullet"],
.ve-line[data-type="ordered"],
.ve-line[data-type="check"],
.ve-line[data-type="checked"]{
  padding-left:20px;
}
.ve-line[data-type="bullet"]::before{
  content:"";
  position:absolute;
  left:4px;top:.69em;
  width:6px;height:6px;border-radius:50%;
  background:var(--note-fg);
}
.ve-line[data-type="ordered"]{counter-increment:ol}
.visual-editor{counter-reset:ol}
.ve-line[data-type="ordered"]::before{
  content:counter(ol) ".";
  position:absolute;left:0;top:0;
}
.ve-check{
  position:absolute;
  left:0;top:.43em;
  width:12px;height:12px;
  border:1.25px solid var(--note-fg);
  border-radius:50%;
}
.ve-line[data-type="checked"] .ve-check{
  background:var(--note-fg);
}
.ve-line[data-type="checked"] .ve-check::after{
  content:"";
  position:absolute;
  left:3px;top:1.5px;
  width:4px;height:6px;
  border:solid var(--note-bg);
  border-width:0 1.5px 1.5px 0;
  transform:rotate(45deg);
}
.visual-editor.is-memo .ve-line[data-type="check"] .ve-check,
.visual-editor.is-memo .ve-line[data-type="checked"] .ve-check{
  border-color:#f2b90c;
}
.visual-editor.is-memo .ve-line[data-type="checked"] .ve-check{background:#f2b90c}
.visual-editor.is-notebook{
  background-color:var(--note-bg);
  background-image:repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 28px,
    #c9dce8 28px,
    #c9dce8 29px
  );
}
.visual-editor[data-username]:not([data-username=""]){
  padding-bottom:58px;
}
.visual-editor[data-username]:not([data-username=""]) + .editor-foot::before{
  content:"";
}
@media(max-width:540px){
  .visual-editor{
    padding:64px 24px 26px;
    font-size:17px;
    border-radius:11px;
  }
  .visual-editor::before{left:24px;top:26px}
  .visual-editor::after{right:24px;top:20px}
}

/* Footer metadata: date left, emoji right, same row and size */
.visual-editor{
  padding-top:30px!important;
  padding-bottom:62px!important;
}
.visual-editor::before{
  content:attr(data-date)!important;
  position:absolute!important;
  left:30px!important;
  top:auto!important;
  bottom:24px!important;
  font-family:var(--note-font)!important;
  font-size:12px!important;
  line-height:1!important;
  font-weight:500!important;
  color:var(--note-muted)!important;
}
.visual-editor:not(.show-date)::before{content:""!important}
.visual-editor::after{
  content:attr(data-emoji)!important;
  position:absolute!important;
  right:30px!important;
  top:auto!important;
  bottom:24px!important;
  font-family:sans-serif!important;
  font-size:12px!important;
  line-height:1!important;
  color:var(--note-fg)!important;
}
.visual-editor[data-username]:not([data-username=""]){
  padding-bottom:86px!important;
}
@media(max-width:540px){
  .visual-editor{
    padding-top:26px!important;
    padding-bottom:58px!important;
  }
  .visual-editor::before{
    left:24px!important;
    bottom:22px!important;
    font-size:12px!important;
  }
  .visual-editor::after{
    right:24px!important;
    bottom:22px!important;
    font-size:12px!important;
  }
  .visual-editor[data-username]:not([data-username=""]){
    padding-bottom:82px!important;
  }
}

/* ===== Notebook exact grid alignment ===== */
.visual-editor.is-notebook{
  /* One CSS row equals one exported ruled row. */
  line-height:var(--notebook-gap)!important;
  background-color:var(--note-bg)!important;
  background-image:repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent calc(var(--notebook-gap) - 1px),
    #c9dce8 calc(var(--notebook-gap) - 1px),
    #c9dce8 var(--notebook-gap)
  )!important;
  /*
    Exported SVG starts rules at top + 18px.
    The editor's content box starts after its padding, so shift the paper grid
    to the same visual origin instead of letting it begin at element y=0.
  */
  background-position:0 18px!important;
  background-size:100% var(--notebook-gap)!important;
}

/* Body/list/check/ordered rows occupy exactly one notebook grid row. */
.visual-editor.is-notebook .ve-line{
  min-height:var(--notebook-gap)!important;
  line-height:var(--notebook-gap)!important;
  margin-top:0!important;
  margin-bottom:0!important;
}

/* Put text slightly above the blue rule, matching SVG export. */
.visual-editor.is-notebook .ve-line[data-type="body"] .ve-content,
.visual-editor.is-notebook .ve-line[data-type="bullet"] .ve-content,
.visual-editor.is-notebook .ve-line[data-type="ordered"] .ve-content,
.visual-editor.is-notebook .ve-line[data-type="check"] .ve-content,
.visual-editor.is-notebook .ve-line[data-type="checked"] .ve-content{
  position:relative;
  top:calc(-1 * var(--notebook-text-offset));
}

/* Keep bullets / numbering / checks on the same baseline as their text. */
.visual-editor.is-notebook .ve-line[data-type="bullet"]::before{
  top:calc((var(--notebook-gap) / 2) - 3px - var(--notebook-text-offset))!important;
}
.visual-editor.is-notebook .ve-line[data-type="ordered"]::before{
  top:calc(-1 * var(--notebook-text-offset))!important;
  line-height:var(--notebook-gap)!important;
}
.visual-editor.is-notebook .ve-check{
  top:calc((var(--notebook-gap) / 2) - 6px - var(--notebook-text-offset))!important;
}

/* Headings are freeform blocks; suppress paper lines through their own area visually. */
.visual-editor.is-notebook .ve-line[data-type="h1"],
.visual-editor.is-notebook .ve-line[data-type="h2"]{
  position:relative;
  z-index:1;
  background:var(--note-bg);
  padding-top:2px;
  padding-bottom:2px;
}

/* Resume body rows on the next exact notebook grid row after a heading. */
.visual-editor.is-notebook .ve-line[data-type="h1"] + .ve-line,
.visual-editor.is-notebook .ve-line[data-type="h2"] + .ve-line{
  margin-top:0!important;
}

/* ===== Notebook uses the same typography spacing as every other template ===== */
.visual-editor.is-notebook{
  line-height:1.68!important;
  background-color:var(--note-bg)!important;
  background-image:repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent calc(var(--notebook-gap) - 1px),
    #c9dce8 calc(var(--notebook-gap) - 1px),
    #c9dce8 var(--notebook-gap)
  )!important;
  /* First rule sits just below the first normal body baseline. */
  background-position:0 20px!important;
  background-size:100% var(--notebook-gap)!important;
}

/* Undo all previous notebook-only row positioning. */
.visual-editor.is-notebook .ve-line{
  min-height:1.68em!important;
  line-height:1.68!important;
  margin-top:0!important;
  margin-bottom:0!important;
}
.visual-editor.is-notebook .ve-line .ve-content{
  position:static!important;
  top:auto!important;
}
.visual-editor.is-notebook .ve-line[data-type="bullet"]::before{
  top:.69em!important;
}
.visual-editor.is-notebook .ve-line[data-type="ordered"]::before{
  top:0!important;
  line-height:inherit!important;
}
.visual-editor.is-notebook .ve-check{
  top:.43em!important;
}

/* Headings keep normal app spacing; just mask rules directly behind the heading. */
.visual-editor.is-notebook .ve-line[data-type="h1"],
.visual-editor.is-notebook .ve-line[data-type="h2"]{
  background:var(--note-bg)!important;
}

/* Preview checkbox vertical alignment */
.visual-editor .ve-line[data-type="check"] .ve-check,
.visual-editor .ve-line[data-type="checked"] .ve-check{
  top:calc(.43em - 2px)!important;
}

/* Notebook uses the same visual correction without changing line spacing. */
.visual-editor.is-notebook .ve-line[data-type="check"] .ve-check,
.visual-editor.is-notebook .ve-line[data-type="checked"] .ve-check{
  top:calc(.43em - 2px)!important;
}

/* ===== Final Notebook line alignment ===== */
.visual-editor{
  --note-line:28.56px;
}
.visual-editor.is-notebook{
  line-height:1.68!important;
  background-color:var(--note-bg)!important;
  background-image:repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent calc(var(--note-line) - 1px),
    #c9dce8 calc(var(--note-line) - 1px),
    #c9dce8 var(--note-line)
  )!important;
  /*
    Editor content starts after 30px top padding.
    Normal body baseline is 17px below that.
    Put the blue rule 3px below baseline: 30 + 17 + 3 = 50px.
  */
  background-position:0 50px!important;
  background-size:100% var(--note-line)!important;
}
.visual-editor.is-notebook .ve-line{
  min-height:1.68em!important;
  line-height:1.68!important;
  margin:0!important;
}
.visual-editor.is-notebook .ve-line .ve-content{
  position:static!important;
  top:auto!important;
}
.visual-editor.is-notebook .ve-line[data-type="bullet"]::before{
  top:.69em!important;
}
.visual-editor.is-notebook .ve-line[data-type="ordered"]::before{
  top:0!important;
  line-height:inherit!important;
}
.visual-editor.is-notebook .ve-check{
  top:calc(.43em - 2px)!important;
}
/* headings keep normal spacing and simply cover rules behind them */
.visual-editor.is-notebook .ve-line[data-type="h1"],
.visual-editor.is-notebook .ve-line[data-type="h2"]{
  background:var(--note-bg)!important;
}

/* Temporary: template 2 intentionally matches template 1 exactly */
.t-minimal{
  background:#f4efe4!important;
  color:#302d28!important;
  background-image:none!important;
}

/* Notebook: white paper / black text */
.t-minimal{
  background:#ffffff!important;
  color:#111111!important;
  background-image:none!important;
}

/* Checkbox: move only the inner check mark slightly upward */
.visual-editor .ve-line[data-type="checked"] .ve-check::after{
  top:0px!important;
}

/* Heading Markdown markers stay visible in the WYSIWYG editor. */
.visual-editor .ve-line[data-type="h1"] .ve-content,
.visual-editor .ve-line[data-type="h2"] .ve-content{
  white-space:pre-wrap;
}

/* Show Markdown heading marker only on the heading line currently being edited. */
.visual-editor .ve-line[data-type="h1"]:focus-within .ve-content::before{
  content:"# ";
  opacity:.55;
}
.visual-editor .ve-line[data-type="h2"]:focus-within .ve-content::before{
  content:"## ";
  opacity:.55;
}

/* Heading marker: show only on the line containing the caret. */
.visual-editor .ve-line[data-type="h1"]:focus-within .ve-content::before,
.visual-editor .ve-line[data-type="h2"]:focus-within .ve-content::before{
  content:none!important;
}
.visual-editor .ve-line[data-type="h1"].is-active-line .ve-content::before{
  content:"# ";
  opacity:.55;
}
.visual-editor .ve-line[data-type="h2"].is-active-line .ve-content::before{
  content:"## ";
  opacity:.55;
}

/* Export/share confirmation */
.confirm-dialog{
  width:min(340px,calc(100vw - 28px));
  padding:0;
  border:1px solid var(--line);
  border-radius:20px;
  background:var(--surface-solid);
  color:var(--text);
  box-shadow:0 24px 80px rgba(0,0,0,.22);
}
.confirm-dialog::backdrop{
  background:rgba(18,18,18,.42);
  backdrop-filter:blur(6px);
}
.confirm-card{padding:20px}
.confirm-copy h2{
  margin:2px 0 8px;
  font-size:20px;
  letter-spacing:-.03em;
}
.confirm-message{
  margin:0;
  color:var(--muted);
  font-size:13px;
  line-height:1.7;
}
.confirm-actions{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:8px;
  margin-top:20px;
}
.confirm-actions button{
  min-height:42px;
  border-radius:12px;
  cursor:pointer;
}
.confirm-actions button:disabled{
  opacity:.55;
  cursor:default;
}

/* ===== Modern controls / color system ===== */
:root{
  --accent:#6f68ee;
  --accent-strong:#5d56e8;
  --accent-soft:color-mix(in srgb,var(--accent) 12%,transparent);
  --accent-softer:color-mix(in srgb,var(--accent) 7%,transparent);
  --control-bg:color-mix(in srgb,var(--surface-solid) 94%,var(--bg));
  --control-hover:color-mix(in srgb,var(--surface-solid) 84%,var(--accent-soft));
  --control-border:color-mix(in srgb,var(--text) 10%,transparent);
  --control-border-strong:color-mix(in srgb,var(--accent) 34%,var(--control-border));
  --control-shadow:0 6px 18px rgba(25,24,30,.08);
}

:root[data-ui-theme="dark"]{
  --accent:#8b84ff;
  --accent-strong:#9a94ff;
  --accent-soft:rgba(139,132,255,.16);
  --accent-softer:rgba(139,132,255,.10);
  --control-bg:rgba(255,255,255,.045);
  --control-hover:rgba(255,255,255,.075);
  --control-border:rgba(255,255,255,.10);
  --control-border-strong:rgba(139,132,255,.34);
  --control-shadow:0 8px 20px rgba(0,0,0,.18);
}

/* generic buttons */
button{
  -webkit-tap-highlight-color:transparent;
}
.round-button,
.emoji-button,
.snippet-bar button,
.segment-control button,
.actions button,
.confirm-actions button,
.custom-emoji-row button,
.emoji-choice{
  transition:
    background-color .16s ease,
    border-color .16s ease,
    color .16s ease,
    box-shadow .16s ease,
    transform .12s ease,
    opacity .16s ease;
}
.round-button:active,
.emoji-button:active,
.snippet-bar button:active,
.segment-control button:active,
.actions button:active,
.confirm-actions button:active,
.custom-emoji-row button:active,
.emoji-choice:active{
  transform:translateY(1px) scale(.985);
}

/* top icon buttons */
.round-button,
.emoji-button{
  border:1px solid var(--control-border)!important;
  background:var(--control-bg)!important;
  box-shadow:var(--control-shadow);
}
.round-button:hover,
.emoji-button:hover{
  border-color:var(--control-border-strong)!important;
  background:var(--control-hover)!important;
}

/* markdown chips */
.snippet-bar button{
  color:var(--muted)!important;
  background:var(--control-bg)!important;
  border:1px solid var(--control-border)!important;
  box-shadow:none!important;
}
.snippet-bar button:hover{
  color:var(--text)!important;
  border-color:var(--control-border-strong)!important;
  background:var(--control-hover)!important;
}

/* segmented control */
.segment-control{
  padding:3px!important;
  border:1px solid var(--control-border)!important;
  background:color-mix(in srgb,var(--bg) 80%,transparent)!important;
  border-radius:13px!important;
}
.segment-control button{
  color:var(--muted)!important;
  background:transparent!important;
  border:0!important;
  box-shadow:none!important;
}
.segment-control button[aria-pressed="true"]{
  color:#fff!important;
  background:linear-gradient(180deg,var(--accent),var(--accent-strong))!important;
  box-shadow:0 5px 14px color-mix(in srgb,var(--accent) 28%,transparent)!important;
}

/* modern switch */
.switch-track{
  width:44px!important;
  height:26px!important;
  padding:3px!important;
  background:color-mix(in srgb,var(--muted) 28%,var(--bg))!important;
  border:1px solid var(--control-border)!important;
  box-shadow:inset 0 1px 2px rgba(0,0,0,.06);
}
.switch-thumb{
  width:20px!important;
  height:20px!important;
  background:#fff!important;
  box-shadow:0 2px 7px rgba(0,0,0,.20)!important;
}
.switch input:checked + .switch-track{
  background:linear-gradient(180deg,var(--accent),var(--accent-strong))!important;
  border-color:transparent!important;
  box-shadow:0 4px 12px color-mix(in srgb,var(--accent) 22%,transparent)!important;
}
.switch input:checked + .switch-track .switch-thumb{
  transform:translateX(18px)!important;
}

/* primary / secondary actions */
.primary-button{
  color:#fff!important;
  background:linear-gradient(180deg,var(--accent),var(--accent-strong))!important;
  border:1px solid transparent!important;
  box-shadow:0 8px 20px color-mix(in srgb,var(--accent) 22%,transparent)!important;
}
.primary-button:hover{
  filter:brightness(1.03);
}
.secondary-button{
  color:var(--text)!important;
  background:var(--control-bg)!important;
  border:1px solid var(--control-border)!important;
  box-shadow:none!important;
}
.secondary-button:hover{
  background:var(--control-hover)!important;
  border-color:var(--control-border-strong)!important;
}

/* sticky action bar */
.integrated-actions{
  background:color-mix(in srgb,var(--surface-solid) 86%,transparent)!important;
  border:1px solid var(--control-border)!important;
  box-shadow:0 10px 28px rgba(0,0,0,.10)!important;
}

/* modal buttons */
.confirm-actions .primary-button{
  min-height:44px;
}
.confirm-actions .secondary-button{
  min-height:44px;
}

/* dialog surface */
.confirm-dialog,
.emoji-dialog{
  background:color-mix(in srgb,var(--surface-solid) 96%,var(--bg))!important;
  border:1px solid var(--control-border)!important;
  box-shadow:0 28px 90px rgba(0,0,0,.24)!important;
}

/* inputs */
.username-field,
.meta-row,
.control-surface{
  border-color:var(--control-border)!important;
}
.username-field input,
.custom-emoji-row input{
  color:var(--text)!important;
}
.username-field input:focus,
.custom-emoji-row input:focus{
  outline:none!important;
  box-shadow:0 0 0 3px var(--accent-softer)!important;
}

/* template selection */
.template-option[aria-pressed="true"] .template-thumb{
  box-shadow:
    0 0 0 2px var(--accent),
    0 8px 18px color-mix(in srgb,var(--accent) 16%,transparent)!important;
}
.template-option[aria-pressed="true"] .template-name{
  color:var(--accent)!important;
}

/* focus visibility */
button:focus-visible,
input:focus-visible,
.visual-editor:focus-visible{
  outline:2px solid var(--accent)!important;
  outline-offset:2px!important;
}

/* Softer, more rounded button language */
.round-button,
.emoji-button,
.snippet-bar button,
.segment-control button,
.actions button,
.integrated-actions button,
.confirm-actions button,
.custom-emoji-row button,
.emoji-choice{
  border-radius:999px!important;
}

/* Segmented container remains a soft capsule */
.segment-control{
  border-radius:999px!important;
}

/* ===== Notebook template: pale blue ruled paper ===== */
.visual-editor.is-notebook{
  --notebook-rule:#c9ddea;
  /*
    Keep the same typography as other templates.
    Rules are placed just below each normal text row.
  */
  background-color:#fff!important;
  background-image:repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent calc(1.68em - 1px),
    var(--notebook-rule) calc(1.68em - 1px),
    var(--notebook-rule) 1.68em
  )!important;
  background-position:0 0!important;
  background-size:100% 1.68em!important;
}

/* Headings have no ruled line behind them. */
.visual-editor.is-notebook .ve-line[data-type="h1"],
.visual-editor.is-notebook .ve-line[data-type="h2"]{
  position:relative;
  z-index:1;
  background:#fff!important;
}

/* Body/list/check/numbered text sits slightly above its rule,
   leaving a small gap under the glyphs like notebook paper. */
.visual-editor.is-notebook .ve-line[data-type="body"] .ve-content,
.visual-editor.is-notebook .ve-line[data-type="bullet"] .ve-content,
.visual-editor.is-notebook .ve-line[data-type="ordered"] .ve-content,
.visual-editor.is-notebook .ve-line[data-type="check"] .ve-content,
.visual-editor.is-notebook .ve-line[data-type="checked"] .ve-content{
  position:relative!important;
  top:-2px!important;
}

/* Keep list/check markers aligned with the slightly raised text. */
.visual-editor.is-notebook .ve-line[data-type="bullet"]::before{
  transform:translateY(-2px)!important;
}
.visual-editor.is-notebook .ve-line[data-type="ordered"]::before{
  transform:translateY(-2px)!important;
}
.visual-editor.is-notebook .ve-line[data-type="check"] .ve-check,
.visual-editor.is-notebook .ve-line[data-type="checked"] .ve-check{
  transform:translateY(-2px)!important;
}

/* Heading conversion must not create visual blank space before the active line. */
.visual-editor .ve-line[data-type="h1"],
.visual-editor .ve-line[data-type="h2"]{
  margin-top:0!important;
}

/* Hand-typed Markdown heading markers are shown only on the active heading line. */
.visual-editor .ve-line[data-type="h1"].is-active-line .ve-content::before{
  content:"# ";
  opacity:.55;
}
.visual-editor .ve-line[data-type="h2"].is-active-line .ve-content::before{
  content:"## ";
  opacity:.55;
}

/* ===== Notebook ruled-paper template ===== */
.visual-editor.is-notebook{
  --notebook-rule:#c9ddea;
  background-color:#fff!important;
  background-image:repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent calc(1.68em - 1px),
    var(--notebook-rule) calc(1.68em - 1px),
    var(--notebook-rule) 1.68em
  )!important;
  background-size:100% 1.68em!important;
  background-position:0 0!important;
}

/* No ruled line behind headings. */
.visual-editor.is-notebook .ve-line[data-type="h1"],
.visual-editor.is-notebook .ve-line[data-type="h2"]{
  position:relative;
  z-index:1;
  background:#fff!important;
}

/* ===== Notebook final: rules belong to rows, not the paper background ===== */
.visual-editor.is-notebook{
  background:#fff!important;
  background-image:none!important;
}

/* Never show a rule on headings. */
.visual-editor.is-notebook .ve-line[data-type="h1"],
.visual-editor.is-notebook .ve-line[data-type="h2"]{
  background:transparent!important;
  border-bottom:0!important;
}

/* Only normal text-like rows get the pale blue notebook rule. */
.visual-editor.is-notebook .ve-line[data-type="body"],
.visual-editor.is-notebook .ve-line[data-type="bullet"],
.visual-editor.is-notebook .ve-line[data-type="ordered"],
.visual-editor.is-notebook .ve-line[data-type="check"],
.visual-editor.is-notebook .ve-line[data-type="checked"]{
  border-bottom:1px solid #c9ddea!important;
  box-sizing:border-box!important;
  padding-bottom:3px!important;
}

/* Use the same typography/line-height as every other template. */
.visual-editor.is-notebook .ve-line{
  line-height:1.68!important;
  min-height:1.68em!important;
  margin-top:0!important;
  margin-bottom:0!important;
}

/* Do not vertically offset Notebook text anymore. */
.visual-editor.is-notebook .ve-content,
.visual-editor.is-notebook .ve-line[data-type="bullet"]::before,
.visual-editor.is-notebook .ve-line[data-type="ordered"]::before,
.visual-editor.is-notebook .ve-check{
  transform:none!important;
  top:auto;
}

/* Hard 140-character limit */
.char-count.limit{
  color:#e05252!important;
  font-weight:750!important;
}

/* ===== Notebook: continuous ruled paper ===== */
.visual-editor.is-notebook{
  --notebook-gap:28.56px; /* 17px × 1.68, same as normal body line-height */
  --notebook-rule:#c9ddea;
  background-color:#fff!important;
  background-image:repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent calc(var(--notebook-gap) - 1px),
    var(--notebook-rule) calc(var(--notebook-gap) - 1px),
    var(--notebook-rule) var(--notebook-gap)
  )!important;

  /*
    Content begins at the editor padding top. Shift the paper so a rule sits
    a few pixels below the normal body baseline rather than through glyphs.
  */
  background-position:0 5px!important;
  background-size:100% var(--notebook-gap)!important;
}

/* Use exactly the same text rhythm as the other templates. */
.visual-editor.is-notebook .ve-line{
  line-height:1.68!important;
  min-height:1.68em!important;
  margin-top:0!important;
  margin-bottom:0!important;
}

/* Heading areas must contain no ruled line at all. */
.visual-editor.is-notebook .ve-line[data-type="h1"],
.visual-editor.is-notebook .ve-line[data-type="h2"]{
  position:relative!important;
  z-index:1!important;
  background:#fff!important;
  border:0!important;
  box-shadow:0 0 0 3px #fff!important;
}

/* Cancel older per-row Notebook rules/offsets. */
.visual-editor.is-notebook .ve-line[data-type="body"],
.visual-editor.is-notebook .ve-line[data-type="bullet"],
.visual-editor.is-notebook .ve-line[data-type="ordered"],
.visual-editor.is-notebook .ve-line[data-type="check"],
.visual-editor.is-notebook .ve-line[data-type="checked"]{
  border-bottom:0!important;
  padding-bottom:0!important;
}

.visual-editor.is-notebook .ve-content,
.visual-editor.is-notebook .ve-line[data-type="bullet"]::before,
.visual-editor.is-notebook .ve-line[data-type="ordered"]::before,
.visual-editor.is-notebook .ve-check{
  transform:none!important;
}

/* Larger footer emoji in live preview */
.visual-editor::after{
  font-size:22px!important;
  line-height:1!important;
}

/* Clear action */
.integrated-actions{
  grid-template-columns:1fr 1fr auto!important;
}
.clear-button{
  color:#c44f4f!important;
  border-color:color-mix(in srgb,#c44f4f 26%,var(--control-border))!important;
  background:color-mix(in srgb,#c44f4f 6%,var(--control-bg))!important;
}
.clear-button:hover{
  background:color-mix(in srgb,#c44f4f 10%,var(--control-bg))!important;
  border-color:color-mix(in srgb,#c44f4f 42%,var(--control-border))!important;
}
@media(max-width:390px){
  .integrated-actions{
    grid-template-columns:1fr 1fr!important;
  }
  .clear-button{
    grid-column:1 / -1;
  }
}

/* Taller writing area */
.visual-editor{
  min-height:620px!important;
}

@media(max-width:600px){
  .visual-editor{
    min-height:68svh!important;
  }
}

/* Writing area height */
.visual-editor{
  min-height:420px!important;
}

@media(max-width:600px){
  .visual-editor{
    min-height:420px!important;
  }
}

/* Username in live preview */
.visual-editor{
  position:relative;
}

/* Use a dedicated pseudo element through a nested helper layer:
   ::before is already used by date, ::after by emoji, so inject via CSS-generated box on editor foot area
   using a real overlay element created by JS. */
.visual-editor .preview-username{
  display:none;
}

.preview-username{
  position:absolute;
  right:30px;
  bottom:50px;
  z-index:3;
  display:block!important;
  max-width:70%;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  pointer-events:none;
  user-select:none;
  color:var(--note-muted);
  font-family:var(--note-font);
  font-size:11px;
  line-height:1;
  font-weight:400;
}
.preview-username:empty{
  display:none!important;
}
@media(max-width:540px){
  .preview-username{
    right:24px;
    bottom:48px;
  }
}

/* Username overlay must live outside contenteditable, otherwise editor rerender deletes it. */
.visual-editor-wrap{
  position:relative;
  width:100%;
}
.visual-editor-wrap .visual-editor{
  width:100%;
}
.visual-editor-wrap .preview-username{
  position:absolute;
  right:30px;
  bottom:50px;
  z-index:5;
  display:block!important;
  max-width:70%;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  pointer-events:none;
  user-select:none;
  color:var(--note-muted,#777066);
  font-family:var(--note-font,"Yu Gothic","Hiragino Sans",sans-serif);
  font-size:11px;
  line-height:1;
}
.visual-editor-wrap .preview-username:empty{
  display:none!important;
}
@media(max-width:540px){
  .visual-editor-wrap .preview-username{
    right:24px;
    bottom:48px;
  }
}

/* Disable save/share until there are at least 3 visible characters */
.actions button:disabled,
.integrated-actions button:disabled{
  opacity:.38!important;
  cursor:not-allowed!important;
  box-shadow:none!important;
  filter:saturate(.45)!important;
  transform:none!important;
}
.actions button:disabled:hover,
.integrated-actions button:disabled:hover{
  transform:none!important;
}

/* Username footer alignment:
   with emoji -> directly to its left; without emoji -> right aligned. */
.visual-editor-wrap .preview-username{
  right:30px!important;
  text-align:right!important;
}
.visual-editor-wrap.has-emoji .preview-username{
  right:62px!important;
}

/* Username + emoji share the same footer row */
.visual-editor-wrap .preview-username{
  bottom:24px!important;
  right:30px!important;
}
.visual-editor-wrap.has-emoji .preview-username{
  bottom:24px!important;
  right:64px!important;
}
@media(max-width:540px){
  .visual-editor-wrap .preview-username{
    bottom:22px!important;
    right:24px!important;
  }
  .visual-editor-wrap.has-emoji .preview-username{
    bottom:22px!important;
    right:58px!important;
  }
}

/* ===== Footer metadata: date / username / emoji on one horizontal row ===== */
/* Date */
.visual-editor::before{
  top:auto!important;
  bottom:24px!important;
  line-height:1!important;
}

/* Emoji */
.visual-editor::after{
  top:auto!important;
  bottom:24px!important;
  line-height:1!important;
}

/* Username uses exactly the same footer row. */
.visual-editor-wrap .preview-username,
.visual-editor-wrap.has-emoji .preview-username{
  bottom:24px!important;
  line-height:1!important;
}

/* Keep username immediately left of emoji when emoji exists. */
.visual-editor-wrap.has-emoji .preview-username{
  right:64px!important;
}
.visual-editor-wrap:not(.has-emoji) .preview-username{
  right:30px!important;
}

@media(max-width:540px){
  .visual-editor::before,
  .visual-editor::after{
    bottom:22px!important;
  }
  .visual-editor-wrap .preview-username,
  .visual-editor-wrap.has-emoji .preview-username{
    bottom:22px!important;
  }
  .visual-editor-wrap.has-emoji .preview-username{
    right:58px!important;
  }
  .visual-editor-wrap:not(.has-emoji) .preview-username{
    right:24px!important;
  }
}

/* Export clone: preview appearance only, never editing chrome */
#exportPreviewClone .visual-editor{
  box-shadow:none!important;
  outline:none!important;
}
#exportPreviewClone .ve-line.is-active-line .ve-content::before{
  content:none!important;
}

/* ===== Notebook rules synced to actual DOM line positions ===== */
.visual-editor-wrap{
  position:relative;
}

.notebook-rule-layer{
  position:absolute;
  inset:0;
  z-index:0;
  pointer-events:none;
  overflow:hidden;
  border-radius:inherit;
}

.notebook-rule-line{
  position:absolute;
  left:0;
  right:0;
  height:1px;
  background:#c9ddea;
}

/* Notebook paper itself has no repeating background anymore. */
.visual-editor.is-notebook{
  position:relative;
  z-index:1;
  background-color:#fff!important;
  background-image:none!important;
}

/* Keep the note transparent enough for the separate rule layer to show,
   while headings mask their own rule bands. */
.visual-editor.is-notebook{
  background:transparent!important;
}
.visual-editor.is-notebook .ve-line{
  position:relative;
  z-index:2;
}
.visual-editor.is-notebook .ve-line[data-type="h1"],
.visual-editor.is-notebook .ve-line[data-type="h2"]{
  background:#fff!important;
  box-shadow:0 0 0 3px #fff!important;
}

/* Wrapper supplies the white paper background. */
.visual-editor-wrap:has(.visual-editor.is-notebook){
  background:#fff;
  border-radius:12px;
}

/* Fine tuning: checkbox marker slightly lower */
.visual-editor .ve-line[data-type="check"] .ve-check,
.visual-editor .ve-line[data-type="checked"] .ve-check{
  transform:translateY(1px)!important;
}

/* Fine tuning v2: checkbox marker 2px lower than the previous position */
.visual-editor .ve-line[data-type="check"] .ve-check,
.visual-editor .ve-line[data-type="checked"] .ve-check{
  transform:translateY(3px)!important;
}

/* Mobile: align bullet marker with text baseline */
@media(max-width:600px){
  .visual-editor .ve-line[data-type="bullet"]::before{
    transform:translateY(-2px)!important;
  }
}

/* Inline Markdown: * text * */


/* ===== Gradient template: modern cool-tone outer margin ===== */
.t-insta{
  position:relative;
  overflow:hidden;
  background:linear-gradient(135deg,#123a5a 0%,#176b87 34%,#2a9d8f 68%,#8fc7a5 100%)!important;
  color:#242124!important;
}
.t-insta::after{
  content:"";
  position:absolute;
  inset:7px;
  border-radius:8px;
  background:#fff;
  box-shadow:0 2px 8px rgba(16,58,72,.12);
}
.t-insta .thumb-lines{position:relative;z-index:1;width:58%!important}

.visual-editor.is-gradient{
  isolation:isolate;
  background:linear-gradient(135deg,#123a5a 0%,#176b87 34%,#2a9d8f 68%,#8fc7a5 100%)!important;
  border-color:rgba(32,112,126,.20)!important;
}
.visual-editor.is-gradient .gradient-inner-panel{
  position:absolute;
  inset:14px;
  z-index:0;
  display:block;
  border-radius:14px;
  background:#fff;
  box-shadow:0 5px 18px rgba(18,67,78,.13);
  pointer-events:none;
}
.visual-editor.is-gradient .ve-line{
  position:relative;
  z-index:1;
}
.visual-editor.is-gradient::before,
.visual-editor.is-gradient::after{
  z-index:2;
}
.visual-editor.is-gradient + .preview-username,
.visual-editor-wrap:has(.visual-editor.is-gradient) .preview-username{
  z-index:6;
}


/* ===== Violet template: purple-red gradient variant ===== */
.t-violet{
  position:relative;
  overflow:hidden;
  background:linear-gradient(135deg,#54206f 0%,#7b285f 34%,#a83255 68%,#d04a58 100%)!important;
  color:#242124!important;
}
.t-violet::after{
  content:"";
  position:absolute;
  inset:7px;
  border-radius:8px;
  background:#fff;
  box-shadow:0 2px 8px rgba(84,32,111,.13);
}
.t-violet .thumb-lines{position:relative;z-index:1;width:58%!important}
.visual-editor.is-gradient.is-gradient-violet{
  background:linear-gradient(135deg,#54206f 0%,#7b285f 34%,#a83255 68%,#d04a58 100%)!important;
  border-color:rgba(123,40,95,.20)!important;
}
.visual-editor.is-gradient.is-gradient-violet .gradient-inner-panel{
  box-shadow:0 5px 18px rgba(84,32,111,.14);
}

/* ===== Smaller template thumbnails ===== */
.template-option{
  flex:0 0 38px!important;
  width:38px!important;
  min-width:38px!important;
}
.template-thumb{
  width:38px!important;
  height:49px!important;
  padding:4px!important;
  border-radius:7px!important;
}
.template-name{
  margin-top:3px!important;
  font-size:7.5px!important;
}
@media(max-width:390px){
  .template-option{
    flex-basis:36px!important;
    width:36px!important;
    min-width:36px!important;
  }
  .template-thumb{
    width:36px!important;
    height:47px!important;
  }
}
