/* ═══════════════════════════════
   TOKENS — DARK
═══════════════════════════════ */
:root {
  --bg:          #18181c;
  --text:        rgba(255,255,255,0.88);
  --label:       rgba(255,255,255,0.60);
  --meta:        rgba(255,255,255,0.42);
  --faint:       rgba(255,255,255,0.22);

  /* dark card: flat + subtle glow border */
  --card:        #202026;
  --card-border: rgba(255,255,255,0.22);
  --card-shadow: 0 2px 12px rgba(0,0,0,0.45), 0 1px 3px rgba(0,0,0,0.3);
  --card-shadow-hover: 0 6px 24px rgba(0,0,0,0.55), 0 2px 6px rgba(0,0,0,0.3);
  --card-shadow-drag:  0 16px 40px rgba(0,0,0,0.7), 0 4px 10px rgba(0,0,0,0.4);

  /* neumorphic — for FAB/ico buttons only */
  --nm-bg:       #202026;
  --nm-out-a:    rgba(0,0,0,0.6);
  --nm-out-b:    rgba(255,255,255,0.03);
  --nm-in-a:     rgba(0,0,0,0.65);
  --nm-in-b:     rgba(255,255,255,0.03);

  --bar-bg:      rgba(16,16,20,0.92);
  --bar-border:  rgba(255,255,255,0.07);
  --ctx-bg:      #1c1c22;
  --ctx-border:  rgba(255,255,255,0.10);
  --hint-bg:     rgba(16,16,20,0.88);
  --grain-op:    0.032;
  --font-body: 'M PLUS 1p', sans-serif;
  --font-ui: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --font-jp: 'M PLUS 1p', sans-serif;
  --DIN: var(--font-ui);
}

/* ═══════════════════════════════
   TOKENS — LIGHT
   Card: frosted flat glass
   FAB/ico: neumorphic (light base)
═══════════════════════════════ */
body.light {
  /* background base — flat off-white default */
  --bg:          #F0EDEA;

  --text:        rgba(0,0,0,0.55);
  --label:       rgba(0,0,0,0.38);
  --meta:        rgba(0,0,0,0.28);
  --faint:       rgba(0,0,0,0.15);

  /* flat card — white-ish glass, no nm shadow */
  --card:        rgba(255,255,255,0.75);
  --card-border: rgba(255,255,255,0.80);
  --card-shadow: 0 1px 4px rgba(0,0,0,0.07), 0 4px 16px rgba(0,0,0,0.06);
  --card-shadow-hover: 0 4px 20px rgba(0,0,0,0.12), 0 1px 4px rgba(0,0,0,0.06);
  --card-shadow-drag:  0 12px 36px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.08);

  /* neumorphic — light surface: neutral */
  --nm-bg:       rgba(244,244,244,0.95);
  --nm-out-a:    rgba(0,0,0,0.14);
  --nm-out-b:    rgba(255,255,255,0.75);
  --nm-in-a:     rgba(0,0,0,0.12);
  --nm-in-b:     rgba(255,255,255,0.68);

  --bar-bg:      rgba(238,238,238,0.92);
  --bar-border:  rgba(0,0,0,0.08);
  --ctx-bg:      rgba(245,245,247,0.97);
  --ctx-border:  rgba(0,0,0,0.08);
  --hint-bg:     rgba(225,225,228,0.88);
  --grain-op:    0.014;
}

/* ── LIGHT mesh gradient — only when no custom bg selected ── */
body.light:not(.has-gradient)::before {
  content: '';
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(ellipse 85% 65% at 2%   5%,  rgba(0,163,175,0.42)  0%, transparent 62%),
    radial-gradient(ellipse 55% 75% at 98%  4%,  rgba(56,161,219,0.32) 0%, transparent 58%),
    radial-gradient(ellipse 65% 52% at 82%  96%, rgba(195,216,37,0.26) 0%, transparent 56%),
    radial-gradient(ellipse 52% 62% at 2%   97%, rgba(237,109,61,0.18) 0%, transparent 52%),
    radial-gradient(ellipse 48% 48% at 50%  50%, rgba(0,163,175,0.10)  0%, transparent 66%);
  animation: meshLight 24s ease-in-out infinite alternate;
}
@keyframes meshLight {
  0%   { opacity: 0.92; filter: blur(0px);  }
  50%  { opacity: 1.00; filter: blur(2px);  }
  100% { opacity: 0.92; filter: blur(0px);  }
}

/* ── DARK mesh gradient — 深い紺・インディゴ・ティール ── */
body:not(.light)::before {
  content: '';
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(ellipse 80% 60% at 0%   0%,  rgba(0,60,90,0.70)   0%, transparent 60%),
    radial-gradient(ellipse 55% 70% at 100% 5%,  rgba(20,10,60,0.65)  0%, transparent 58%),
    radial-gradient(ellipse 60% 50% at 88%  95%, rgba(0,80,80,0.55)   0%, transparent 56%),
    radial-gradient(ellipse 50% 60% at 2%   95%, rgba(30,0,60,0.50)   0%, transparent 52%),
    radial-gradient(ellipse 45% 45% at 50%  50%, rgba(0,40,60,0.30)   0%, transparent 65%);
  animation: meshDark 26s ease-in-out infinite alternate;
}
@keyframes meshDark {
  0%   { opacity: 0.85; filter: blur(0px);  }
  50%  { opacity: 1.00; filter: blur(3px);  }
  100% { opacity: 0.85; filter: blur(0px);  }
}

/* ═══ BASE ═══ */
html, body {
  width: 100%; height: 100%;
  background: var(--bg); color: var(--text);
  font-family: var(--font-body);
  overflow: hidden; cursor: crosshair;
  user-select: none; -webkit-tap-highlight-color: transparent;
  touch-action: none; transition: background .35s;
}
#grain { position:fixed;inset:0;pointer-events:none;z-index:9998;opacity:var(--grain-op); }

/* ═══ TOPBAR ═══ */
#topbar {
  position: fixed; top: 0; left: 0; right: 0; height: 44px;
  display: flex; align-items: center; gap: 10px; padding: 0 18px;
  background: var(--bar-bg); backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--bar-border); z-index: 1000;
}
.logo {
  font-family: var(--DIN);
  font-size: 16px; letter-spacing: .42em; font-weight: 500;
  color: var(--label); text-transform: uppercase;
  pointer-events: none; flex: 1;
}
/* top-btn: flat, hairline border */
.top-btn {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: 1px solid var(--bar-border);
  cursor: pointer; color: var(--label);
  transition: color .15s, border-color .15s; flex-shrink: 0;
}
.top-btn:hover { color: var(--text); border-color: var(--faint); }
.top-btn svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

/* ═══ HINT BAR ═══ */
#hint-bar {
  position: fixed; bottom: 0; left: 0; right: 0; height: 34px;
  display: flex; align-items: center; justify-content: center;
  gap: 16px; padding: 0 18px;
  background: var(--hint-bg); backdrop-filter: blur(14px);
  border-top: 1px solid var(--bar-border);
  z-index: 1000; pointer-events: none;
  flex-wrap: nowrap; overflow: hidden;
}
.hint-item {
  font-family: var(--DIN); font-size: 12px; letter-spacing: .14em;
  color: var(--meta); text-transform: uppercase; white-space: nowrap;
}
.hint-privacy {
  font-family: var(--DIN); font-size: 13px; letter-spacing: .10em;
  color: var(--meta); white-space: nowrap;
}
.hint-sep { color: var(--faint); font-size: 13px; flex-shrink: 0; }
.lang-btn {
  font-family: var(--DIN); font-size: 12px; letter-spacing: .18em;
  color: var(--label); text-transform: uppercase;
  background: none; border: 1px solid var(--bar-border);
  padding: 2px 8px; cursor: pointer;
  transition: color .15s, border-color .15s; white-space: nowrap;
  pointer-events: all; flex-shrink: 0; line-height: 1.6;
}
.lang-btn:hover { color: var(--text); border-color: var(--faint); }

/* テキストリンクボタン（FS・言語） */
.hint-txt-btn {
  font-family: var(--DIN); font-size: 12px; letter-spacing: .18em;
  color: var(--label); text-transform: uppercase;
  background: none; border: none; padding: 0;
  cursor: pointer; pointer-events: all; white-space: nowrap;
  transition: color .15s; line-height: 1;
}
.hint-txt-btn:hover { color: var(--text); }
.hint-sep-right { flex-shrink: 0; }
@media(max-width: 600px) {
  .hint-item:not(#hint-add), .hint-sep { display: none; }
  #hint-bar {
    min-height: 34px;
    height: auto;
    padding: 5px 18px;
    justify-content: center;
  }
  .hint-privacy {
    font-size: 10px;
    letter-spacing: .04em;
    line-height: 1.35;
    text-align: center;
    white-space: normal;
  }
}

/* ═══ CANVAS ═══ */
#canvas { position: fixed; inset: 0; z-index: 1; }

/* ═══ MEMO CARD — flat glass ═══ */
@keyframes memoIn {
  0%   { opacity: 0; transform: scale(0.55) rotate(-2deg); }
  55%  { opacity: 1; transform: scale(1.06) rotate(0.8deg); }
  75%  { transform: scale(0.97) rotate(-0.3deg); }
  90%  { transform: scale(1.01); }
  100% { opacity: 1; transform: scale(1) rotate(0deg); }
}
@keyframes memoOut {
  0%   { opacity: 1; transform: scale(1); }
  25%  { transform: scale(1.05) rotate(0.8deg); }
  100% { opacity: 0; transform: scale(0.45) rotate(-3deg); }
}

.memo {
  position: absolute;
  min-width: 180px; max-width: 300px;
  max-height: min(60dvh, 280px);
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 12px 14px 12px;
  cursor: move; touch-action: none;
  animation: memoIn .42s cubic-bezier(0.34,1.28,0.64,1) both;
  box-shadow: var(--card-shadow);
  /* glass blur in light mode */
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: box-shadow .2s, transform .15s;
  transform-origin: center center;
}
.memo:hover  { box-shadow: var(--card-shadow-hover); }
.memo.drag   { box-shadow: var(--card-shadow-drag); cursor: grabbing; transform: scale(1.02); }
.memo.long   { transform: scale(0.98); opacity: .9; }
.memo.removing { animation: memoOut .3s cubic-bezier(0.55,0,1,0.45) both; pointer-events: none; }

/* accent */
.memo.accent {
  border-color: var(--nc, transparent);
  box-shadow: var(--card-shadow), 0 0 22px -5px var(--ng, transparent);
}
.memo.accent:hover {
  box-shadow: var(--card-shadow-hover), 0 0 28px -4px var(--ng, transparent);
}
/* light mode: accent text always dark gray — neon only for border/glow */
body.light       .memo.accent textarea { color: var(--text); }
body.light       .memo.accent .num     { color: var(--meta); }
body:not(.light) .memo.accent textarea { color: var(--nc,  var(--text)); }
body:not(.light) .memo.accent .num     { color: var(--nc,  var(--meta)); }

/* memo header */
.memo-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 9px; gap: 8px;
}
.num {
  font-family: var(--DIN);
  font-size: 13px; letter-spacing: .20em;
  color: var(--meta); text-transform: uppercase;
  flex: 1; pointer-events: none; line-height: 1;
}
.acts { display: flex; gap: 8px; align-items: center; }

/* ── icon buttons: neumorphic circle ── */
.ico {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  background: var(--nm-bg); border: none; padding: 0; border-radius: 50%;
  box-shadow: 3px 3px 7px var(--nm-out-a), -2px -2px 6px var(--nm-out-b);
  transition: box-shadow .12s, color .12s; flex-shrink: 0;
}
.ico:hover  { box-shadow: 4px 4px 9px var(--nm-out-a), -3px -3px 7px var(--nm-out-b); }
.ico:active { box-shadow: inset 2px 2px 5px var(--nm-in-a), inset -2px -2px 4px var(--nm-in-b); }
.ico svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.ico.cp { color: var(--meta); }
.ico.cp:hover { color: var(--label); }
.ico.ok { color: #3ec87a; } .ico.ok svg { stroke: #3ec87a; }
.ico.dl { color: rgba(200,70,70,0.50); }
.ico.dl:hover { color: #e85454; box-shadow: 4px 4px 9px var(--nm-out-a), -3px -3px 7px var(--nm-out-b), 0 0 8px -2px rgba(232,84,84,0.35); }

.memo-divider {
  height: 1px;
  background: linear-gradient(90deg, var(--faint) 0%, transparent 100%);
  margin: 0 0 10px; opacity: .8;
}

textarea {
  width: 100%; background: transparent; border: none; outline: none;
  color: var(--text); font-family: var(--font-body);
  font-size: 15px; line-height: 1.48;
  resize: none; min-height: 24px; max-height: 190px; overflow-y: auto;
  cursor: text; user-select: text; font-weight: 400; letter-spacing: .02em;
  touch-action: auto;
}
textarea::placeholder { color: var(--faint); }

.empty-guide {
  position: fixed;
  left: clamp(22px, 8vw, 96px);
  top: clamp(96px, 24vh, 220px);
  z-index: 2;
  max-width: min(300px, calc(100vw - 44px));
  color: var(--meta);
  pointer-events: none;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity .2s ease, transform .2s ease;
}
.empty-guide.visible {
  opacity: 1;
  transform: translateY(0);
}
.empty-guide p {
  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 1.8;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.empty-guide p + p {
  margin-top: 10px;
  color: var(--faint);
}



/* ═══ HELP BUTTON + TOOLTIP ═══ */
.help-wrap {
  position: relative;
}
.help-btn {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: none;
  border: 1px solid var(--bar-border);
  color: var(--label);
  font-family: var(--DIN);
  font-size: 13px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: color .15s, border-color .15s;
  line-height: 1;
}
.help-btn:hover { color: var(--text); border-color: var(--faint); }

.help-tooltip {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 0;
  background: var(--ctx-bg);
  border: 1px solid var(--ctx-border);
  border-radius: 10px;
  padding: 10px 14px;
  display: flex; flex-direction: column; gap: 6px;
  min-width: 200px;
  backdrop-filter: blur(16px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.14), 0 2px 6px rgba(0,0,0,0.08);
  opacity: 0; pointer-events: none;
  transform: translateY(6px);
  transition: opacity .18s, transform .18s;
  z-index: 3000;
  white-space: nowrap;
}
.help-wrap:hover .help-tooltip,
.help-wrap:focus-within .help-tooltip {
  opacity: 1; pointer-events: all;
  transform: translateY(0);
}
/* arrow */
.help-tooltip::after {
  content: '';
  position: absolute;
  bottom: -5px; left: 14px;
  width: 8px; height: 8px;
  background: var(--ctx-bg);
  border-right: 1px solid var(--ctx-border);
  border-bottom: 1px solid var(--ctx-border);
  transform: rotate(45deg);
}
.help-tooltip span {
  font-family: var(--DIN);
  font-size: 13px; letter-spacing: .13em;
  color: var(--label); text-transform: uppercase;
  display: block;
}

/* ═══ TOAST ═══ */
#toast {
  position: fixed;
  bottom: 52px;
  left: 50%; transform: translateX(-50%) translateY(8px);
  background: var(--ctx-bg);
  border: 1px solid var(--ctx-border);
  border-radius: 24px;
  padding: 8px 20px;
  display: flex; align-items: center; gap: 12px;
  font-family: var(--DIN); font-size: 13px; letter-spacing: .14em;
  color: var(--label); text-transform: uppercase;
  backdrop-filter: blur(16px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.14);
  z-index: 4000;
  opacity: 0; pointer-events: none;
  transition: opacity .4s, transform .4s;
  white-space: nowrap;
}
#toast.show {
  opacity: 1; transform: translateX(-50%) translateY(0);
}
.toast-sep { color: var(--faint); }

/* ═══ BOTTOM-LEFT: fullscreen + lang ═══ */
#bottom-left {
  position: fixed; bottom: 46px; left: 22px;
  display: flex; flex-direction: column; align-items: flex-start;
  gap: 6px; z-index: 2000;
}
.text-btn {
  font-family: var(--DIN);
  font-size: 13px; letter-spacing: .22em;
  color: var(--label); text-transform: uppercase;
  background: none; border: none; padding: 0;
  cursor: pointer; text-align: left;
  transition: color .15s; pointer-events: all;
  line-height: 1.5;
}
.text-btn:hover { color: var(--text); }
/* hide fullscreen on touch devices */
@media (hover: none) and (pointer: coarse) {
  #fab-fs { display: none; }
}
/* ═══ FAB — neumorphic circle (both modes) ═══ */
#fab-row {
  position: fixed; bottom: 46px; right: 22px;
  display: flex; flex-direction: column; align-items: flex-end;
  gap: 12px; z-index: 2000;
}
.fab {
  width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--label);
  background: var(--nm-bg); border: none; border-radius: 50%;
  box-shadow: 5px 5px 13px var(--nm-out-a), -4px -4px 11px var(--nm-out-b);
  transition: box-shadow .15s, color .15s, opacity .2s, transform .15s;
}
.fab:hover {
  color: var(--text);
  box-shadow: 7px 7px 17px var(--nm-out-a), -5px -5px 14px var(--nm-out-b);
  transform: scale(1.07);
}
.fab:active {
  box-shadow: inset 3px 3px 8px var(--nm-in-a), inset -3px -3px 7px var(--nm-in-b);
  transform: scale(0.97);
}
.fab svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.55; stroke-linecap: round; stroke-linejoin: round; }
#fab-clear { opacity: 0; pointer-events: none; color: rgba(210,70,70,0.45); }
#fab-clear.visible { opacity: 1; pointer-events: all; }
#fab-clear:hover { color: #e85454; box-shadow: 7px 7px 17px var(--nm-out-a), -5px -5px 14px var(--nm-out-b), 0 0 14px -3px rgba(232,84,84,0.3); }

#count {
  position: fixed; bottom: 46px; right: 82px;
  font-family: var(--DIN); font-size: 13px; letter-spacing: .24em;
  color: var(--meta); text-transform: uppercase;
  z-index: 1000; pointer-events: none; line-height: 48px;
}

/* ═══ CONTEXT MENU ═══ */
#ctx {
  position: fixed; display: none;
  background: var(--ctx-bg); border: 1px solid var(--ctx-border);
  border-radius: 12px;
  padding: 5px 0; min-width: 184px;
  backdrop-filter: blur(16px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.14), 0 2px 6px rgba(0,0,0,0.08);
  z-index: 5000; overflow: hidden;
}
#ctx button {
  display: block; width: 100%; background: none; border: none;
  color: var(--text); font-family: var(--DIN);
  font-size: 13px; letter-spacing: .14em;
  text-align: left; padding: 9px 18px;
  cursor: pointer; text-transform: uppercase;
  transition: background .1s, color .1s;
}
#ctx button:hover  { background: var(--faint); color: var(--text); }
#ctx .danger:hover { color: #e85454; }
#ctx hr { border: none; border-top: 1px solid var(--faint); margin: 4px 0; }

/* ── palette ── */
#ctx-palette {
  display: none; padding: 10px 16px 13px;
  flex-direction: column; gap: 9px;
}
#ctx-palette.visible { display: flex; }
.palette-label {
  font-family: var(--DIN); font-size: 13px; letter-spacing: .20em;
  color: var(--meta); text-transform: uppercase;
}
.palette-swatches { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; }
.swatch {
  width: 22px; height: 22px; border-radius: 50%; cursor: pointer;
  border: 2px solid transparent;
  transition: transform .15s, border-color .15s; flex-shrink: 0;
}
.swatch:hover { transform: scale(1.28); }
.swatch.active { border-color: var(--text); outline: 2px solid var(--ctx-bg); outline-offset: 0px; transform: scale(1.18); }
.swatch-none {
  width: 22px; height: 22px; border-radius: 50%; cursor: pointer;
  border: 1.5px solid var(--faint);
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s, border-color .15s; flex-shrink: 0; background: transparent;
}
.swatch-none:hover { transform: scale(1.22); border-color: var(--label); }
.swatch-none svg { width: 10px; height: 10px; fill: none; stroke: var(--meta); stroke-width: 2; stroke-linecap: round; }
.swatch-none.active { border-color: var(--text); }

/* ═══ GLASS MODE — gradient背景のときニューモをガラスに差し替え ═══ */
/* ═══ HAS-GRADIENT overrides ═══
   Dark gradient: white text/glass
   Light gradient: keep dark tokens, just adjust card/button surfaces
═══════════════════════════════ */

/* ── Dark mode + gradient: glass surfaces ── */
body:not(.light).has-gradient .fab,
body:not(.light).has-gradient .lang-fab {
  background: rgba(255,255,255,0.10);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 4px 20px rgba(0,0,0,0.28), inset 0 1px 0 rgba(255,255,255,0.15);
  border: none;
}
body:not(.light).has-gradient .fab:hover,
body:not(.light).has-gradient .lang-fab:hover {
  background: rgba(255,255,255,0.17);
}
body:not(.light).has-gradient .fab:active,
body:not(.light).has-gradient .lang-fab:active {
  background: rgba(255,255,255,0.07);
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.18);
}
body:not(.light).has-gradient #fab-clear { color: rgba(255,120,120,0.65); }
body:not(.light).has-gradient #fab-clear:hover { color: #ff6b6b; }

body:not(.light).has-gradient .ico {
  background: rgba(255,255,255,0.10);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.22), inset 0 1px 0 rgba(255,255,255,0.14);
}
body:not(.light).has-gradient .ico:hover { background: rgba(255,255,255,0.17); }
body:not(.light).has-gradient .ico:active { background: rgba(255,255,255,0.06); box-shadow: inset 0 1px 4px rgba(0,0,0,0.16); }
body:not(.light).has-gradient .ico.cp { color: rgba(255,255,255,0.50); }
body:not(.light).has-gradient .ico.cp:hover { color: rgba(255,255,255,0.85); }
body:not(.light).has-gradient .ico.dl { color: rgba(255,100,100,0.50); }
body:not(.light).has-gradient .ico.dl:hover { color: #ff6b6b; }

body:not(.light).has-gradient .top-btn {
  background: rgba(255,255,255,0.08);
  backdrop-filter: blur(10px);
  border-color: rgba(255,255,255,0.18);
  color: rgba(255,255,255,0.55);
}
body:not(.light).has-gradient .top-btn:hover { color: rgba(255,255,255,0.90); border-color: rgba(255,255,255,0.30); }

body:not(.light).has-gradient .memo {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.16);
  box-shadow: 0 2px 16px rgba(0,0,0,0.22), inset 0 1px 0 rgba(255,255,255,0.12);
}
body:not(.light).has-gradient .memo:hover {
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.26);
}
body:not(.light).has-gradient .memo textarea { color: rgba(255,255,255,0.88); }
body:not(.light).has-gradient .memo textarea::placeholder { color: rgba(255,255,255,0.22); }
body:not(.light).has-gradient .num { color: rgba(255,255,255,0.28); }
body:not(.light).has-gradient .memo-divider { background: linear-gradient(90deg, rgba(255,255,255,0.12) 0%, transparent 100%); }
body:not(.light).has-gradient .memo.accent textarea { color: var(--nc, rgba(255,255,255,0.88)); }
body:not(.light).has-gradient .memo.accent .num { color: var(--nd, rgba(255,255,255,0.25)); }
body:not(.light).has-gradient .text-btn { color: rgba(255,255,255,0.50); }
body:not(.light).has-gradient .text-btn:hover { color: rgba(255,255,255,0.88); }
body:not(.light).has-gradient .logo { color: rgba(255,255,255,0.45); }
body:not(.light).has-gradient .hint-item,
body:not(.light).has-gradient .hint-privacy { color: rgba(255,255,255,0.30); }

/* ── Light mode + gradient: keep dark text, just soften surfaces ── */
body.light.has-gradient .fab,
body.light.has-gradient .lang-fab {
  background: rgba(255,255,255,0.45);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 2px 12px rgba(0,0,0,0.10), inset 0 1px 0 rgba(255,255,255,0.70);
  border: none;
}
body.light.has-gradient .fab:hover,
body.light.has-gradient .lang-fab:hover { background: rgba(255,255,255,0.60); }
body.light.has-gradient .ico {
  background: rgba(255,255,255,0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 1px 6px rgba(0,0,0,0.10), inset 0 1px 0 rgba(255,255,255,0.70);
}
body.light.has-gradient .ico:hover { background: rgba(255,255,255,0.62); }
body.light.has-gradient .top-btn {
  background: rgba(255,255,255,0.35);
  backdrop-filter: blur(10px);
  border-color: rgba(255,255,255,0.60);
  /* keep var(--label) dark text — no override */
}
body.light.has-gradient .memo {
  background: rgba(255,255,255,0.52);
  border-color: rgba(255,255,255,0.75);
  box-shadow: 0 1px 8px rgba(0,0,0,0.08), 0 4px 20px rgba(0,0,0,0.06);
}
body.light.has-gradient .memo:hover {
  background: rgba(255,255,255,0.65);
}
/* Light gradient: text stays dark — no color override */

/* ═══ GRADIENT BACKGROUND ═══ */
#bg-layer {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  transition: opacity .6s ease;
  opacity: 0;
}
body.has-gradient #bg-layer { opacity: 1; }
/* has-gradient: bg handled by #bg-layer, no token override needed */

/* BG picker panel */
#bg-picker {
  position: fixed; top: 54px; right: 18px;
  display: none;
  flex-direction: column; gap: 6px;
  background: var(--ctx-bg);
  border: 1px solid var(--ctx-border);
  border-radius: 12px;
  padding: 12px 14px 14px;
  z-index: 3000;
  backdrop-filter: blur(16px);
  box-shadow: 0 8px 28px rgba(0,0,0,0.22);
  min-width: 168px;
}
#bg-picker.open { display: flex; }
.bg-picker-label {
  font-family: var(--DIN); font-size: 13px; letter-spacing: .22em;
  color: var(--meta); text-transform: uppercase; margin-bottom: 2px;
}
.bg-swatches {
  display: flex; gap: 7px; align-items: center; flex-wrap: nowrap;
}
.bg-swatch {
  width: 32px; height: 32px; border-radius: 6px; cursor: pointer;
  border: 2px solid transparent;
  transition: transform .15s, border-color .15s;
  flex-shrink: 0;
}
.bg-swatch:hover { transform: scale(1.12); }
.bg-swatch.active { border-color: rgba(255,255,255,0.8); transform: scale(1.1); }
.bg-swatch-none {
  width: 32px; height: 32px; border-radius: 6px; cursor: pointer;
  border: 1.5px solid var(--faint);
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s, border-color .15s;
  background: transparent; flex-shrink: 0;
}
.bg-swatch-none svg { width: 12px; height: 12px; fill: none; stroke: var(--meta); stroke-width: 2; stroke-linecap: round; }
.bg-swatch-none:hover { transform: scale(1.1); border-color: var(--label); }
.bg-swatch-none.active { border-color: var(--text); }
