:root {
  --fg: rgba(255, 255, 255, 0.92);
  --fg-dim: rgba(255, 255, 255, 0.5);
  --glass: rgba(16, 20, 26, 0.52);
  --glass-2: rgba(255, 255, 255, 0.07);
  --line: rgba(255, 255, 255, 0.12);
  --accent: #9dc6e8;
  --r: 18px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #05070a;
  color: var(--fg);
  font: 400 13px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI",
        "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.ui-hidden .console,
.ui-hidden .orb,
.ui-hidden .hint,
.ui-hidden .sheet { opacity: 0; pointer-events: none; }

/* ---------- corner hint ---------- */

.hint {
  position: fixed;
  left: 22px;
  top: 20px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  transition: opacity 0.5s;
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.7);
  pointer-events: none;
}
.hint-title { font-size: 15px; letter-spacing: 0.42em; opacity: 0.86; }
.hint-sub { font-size: 11px; color: var(--fg-dim); letter-spacing: 0.04em; }
kbd {
  font: inherit;
  padding: 0 4px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.05);
}

/* ---------- floating orb ---------- */

.orb {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 54px;
  height: 54px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--glass);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.14);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: opacity 0.4s, transform 0.35s cubic-bezier(.2,.9,.3,1.4), background 0.3s;
  z-index: 10;
}
.orb:hover { transform: scale(1.07); background: rgba(26, 33, 42, 0.68); }
.orb:active { transform: scale(0.96); }
.orb.is-hidden { opacity: 0; transform: scale(0.7); pointer-events: none; }
.orb svg { width: 27px; height: 27px; fill: none; stroke: var(--accent); stroke-width: 1.35; }
.orb .drop-a, .orb .drop-b { fill: rgba(157, 198, 232, 0.22); }
.orb .streak { stroke-linecap: round; opacity: 0.55; stroke-dasharray: 4 5; animation: fall 2.4s linear infinite; }
@keyframes fall { to { stroke-dashoffset: -18; } }

/* ---------- console ---------- */

.console {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 306px;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--glass);
  backdrop-filter: blur(26px) saturate(150%);
  -webkit-backdrop-filter: blur(26px) saturate(150%);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.13);
  opacity: 0;
  transform: translateY(14px) scale(0.96);
  transform-origin: 100% 100%;
  pointer-events: none;
  transition: opacity 0.32s, transform 0.36s cubic-bezier(.2,.9,.3,1.2);
  z-index: 11;
  overflow: hidden;
}
.console.is-open { opacity: 1; transform: none; pointer-events: auto; }

.c-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--line);
}
.c-title { display: flex; align-items: center; gap: 9px; letter-spacing: 0.16em; font-size: 12px; }
.badge {
  font-style: normal;
  font-size: 10px;
  letter-spacing: 0.06em;
  padding: 2px 7px;
  border-radius: 20px;
  background: var(--glass-2);
  border: 1px solid var(--line);
  color: var(--fg-dim);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.c-close {
  border: 0; background: none; color: var(--fg-dim);
  font-size: 19px; line-height: 1; cursor: pointer; padding: 2px 4px;
}
.c-close:hover { color: var(--fg); }

.c-bg { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.c-bg-row { display: flex; gap: 8px; }
.c-bg-row .btn-primary { flex: 1; }
.media-name {
  margin-top: 8px;
  font-size: 10.5px;
  color: var(--fg-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-height: 14px;
}
.swatches { display: flex; gap: 8px; margin-top: 6px; }
.swatch {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  color: var(--fg-dim);
  cursor: pointer;
}
.swatch input[type=color] {
  -webkit-appearance: none;
  appearance: none;
  width: 26px; height: 26px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: none;
  cursor: pointer;
}
.swatch input[type=color]::-webkit-color-swatch-wrapper { padding: 2px; }
.swatch input[type=color]::-webkit-color-swatch { border: 0; border-radius: 6px; }

.sliders { padding: 6px 16px 10px; overflow-y: auto; flex: 1; }
.sliders::-webkit-scrollbar { width: 6px; }
.sliders::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }

.row { display: block; padding: 7px 0; }
.row-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 5px; }
.row-name { font-size: 11.5px; color: rgba(255, 255, 255, 0.72); letter-spacing: 0.06em; }
.row-val { font-variant-numeric: tabular-nums; font-size: 10.5px; color: var(--fg-dim); }
.row-core { padding: 9px 0; }
.row-core .row-name { color: var(--fg); font-size: 12.5px; }

input[type=range] {
  --pct: 50%;
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 16px;
  background: none;
  cursor: pointer;
  display: block;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--accent) var(--pct), rgba(255,255,255,0.16) var(--pct));
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 11px; height: 11px;
  margin-top: -4.5px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.5);
  transition: transform 0.15s;
}
input[type=range]:hover::-webkit-slider-thumb { transform: scale(1.22); }
input[type=range]::-moz-range-track { height: 2px; border-radius: 2px; background: rgba(255,255,255,0.16); }
input[type=range]::-moz-range-progress { height: 2px; border-radius: 2px; background: var(--accent); }
input[type=range]::-moz-range-thumb { width: 11px; height: 11px; border: 0; border-radius: 50%; background: #fff; }

.advanced { margin-top: 6px; border-top: 1px solid var(--line); }
.advanced > summary {
  list-style: none;
  cursor: pointer;
  padding: 11px 0 7px;
  font-size: 11px;
  letter-spacing: 0.16em;
  color: var(--fg-dim);
  user-select: none;
}
.advanced > summary::-webkit-details-marker { display: none; }
.advanced > summary::after { content: '＋'; float: right; }
.advanced[open] > summary::after { content: '－'; }
.advanced > summary:hover { color: var(--fg); }

.c-foot {
  display: flex;
  gap: 7px;
  padding: 11px 16px 14px;
  border-top: 1px solid var(--line);
}

.btn {
  font: inherit;
  color: var(--fg);
  background: var(--glass-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 7px 12px;
  cursor: pointer;
  letter-spacing: 0.06em;
  transition: background 0.2s, transform 0.15s;
}
.btn:hover { background: rgba(255, 255, 255, 0.14); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: rgba(157, 198, 232, 0.2); border-color: rgba(157, 198, 232, 0.42); }
.btn-primary:hover { background: rgba(157, 198, 232, 0.3); }
.btn-ghost { flex: 1; padding: 6px 0; font-size: 11.5px; color: var(--fg-dim); }
.btn-ghost:hover { color: var(--fg); }
.btn-ghost.is-on { color: var(--accent); border-color: rgba(157, 198, 232, 0.42); }

/* ---------- writing sheet ---------- */
/* Deliberately NO backdrop blur: the glass shader already wipes the fog open
   inside this rectangle, and blurring here would undo that. Only a faint tint
   keeps the ink legible over whatever the weather is doing. */

.sheet {
  position: fixed;
  left: 50%;
  top: 50%;
  width: min(660px, 92vw);
  height: min(62vh, 620px);
  transform: translate(-50%, -50%) scale(0.985);
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 16px;
  background: rgba(5, 9, 15, 0.34);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s, transform 0.45s cubic-bezier(.2,.9,.3,1.15);
  z-index: 9;
}
.sheet.is-open { opacity: 1; transform: translate(-50%, -50%); pointer-events: auto; }

.s-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 11px;
  color: var(--fg-dim);
  letter-spacing: 0.08em;
}
.s-stats b { color: var(--fg); font-weight: 500; }
.s-saved {
  color: #9fd6b4;
  opacity: 0;
  transition: opacity 0.35s;
}
.s-saved.is-on { opacity: 0.9; }
.s-btns { margin-left: auto; display: flex; gap: 6px; }
.s-btns .btn { padding: 4px 10px; font-size: 11px; }
.s-btns .btn.is-armed { color: #e8b0a6; border-color: rgba(232, 176, 166, 0.5); }

#doc {
  flex: 1;
  width: 100%;
  padding: 26px 36px 34px;
  border: 0;
  outline: none;
  resize: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.92);
  caret-color: var(--accent);
  font: 400 16.5px/2.05 "Songti SC", "Noto Serif SC", "Source Han Serif SC",
       "STSong", SimSun, Georgia, serif;
  letter-spacing: 0.02em;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.55);
}
#doc::placeholder { color: rgba(255, 255, 255, 0.3); }
#doc::selection { background: rgba(157, 198, 232, 0.3); }
#doc::-webkit-scrollbar { width: 6px; }
#doc::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }

.orb-pen { left: 24px; bottom: 24px; right: auto; }
.orb-pen svg { fill: none; stroke: var(--accent); stroke-width: 1.4; stroke-linejoin: round; }

/* ---------- overlays ---------- */

.drophint {
  position: fixed;
  inset: 22px;
  display: grid;
  place-items: center;
  border: 1.5px dashed rgba(157, 198, 232, 0.6);
  border-radius: 26px;
  background: rgba(6, 10, 16, 0.42);
  backdrop-filter: blur(3px);
  font-size: 15px;
  letter-spacing: 0.3em;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s;
}
.drophint.is-on { opacity: 1; }

.fatal {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  padding: 40px;
  text-align: center;
  font-size: 14px;
  line-height: 2;
  background: #05070a;
  color: #e6b8b8;
}
.fatal.is-on { display: grid; }

@media (max-width: 560px) {
  .console { right: 12px; left: 12px; bottom: 12px; width: auto; max-height: 72vh; }
  .orb { right: 14px; bottom: 14px; }
  .hint { left: 14px; bottom: 84px; }
}
