:root {
  --ink: #231d18;
  --page-bg:
    radial-gradient(circle at 40% 16%, rgba(255, 247, 231, 0.26), transparent 0 22%),
    radial-gradient(circle at 60% 82%, rgba(71, 62, 53, 0.08), transparent 0 24%),
    radial-gradient(circle at center, rgba(255, 247, 234, 0.08), transparent 0 42%),
    linear-gradient(180deg, #b5aa96 0%, #c0b5a1 10%, #b8ae9b 44%, #b0a693 100%);
  --body-before-filter: none;
  --body-before-opacity: 0.5;
  --body-after-filter: none;
  --body-after-opacity: 0.36;
  --layout-before-filter: none;
  --layout-before-opacity: 0.18;
  --layout-overlay:
    radial-gradient(circle at 50% 54%, rgba(255, 248, 236, 0.06), transparent 0 28%),
    repeating-linear-gradient(
      0deg,
      rgba(97, 84, 68, 0.028),
      rgba(97, 84, 68, 0.028) 1px,
      transparent 1px,
      transparent 18px
    );
  --overlay-scrim:
    radial-gradient(circle at 50% 28%, rgba(255, 243, 216, 0.06), transparent 0 20%),
    linear-gradient(180deg, rgba(18, 13, 10, 0.98), rgba(7, 5, 4, 0.96));
  --focus-core: rgba(255, 246, 228, 0.92);
  --focus-ring: rgba(125, 92, 52, 0.44);
  --focus-shadow: 0 0 0 2px var(--focus-core), 0 0 0 5px var(--focus-ring);
  --toast-text: #2b1f17;
  --toast-border: rgba(125, 92, 52, 0.3);
  --toast-bg:
    radial-gradient(circle at 24% 24%, rgba(255, 253, 247, 0.58), rgba(255, 253, 247, 0) 34%),
    linear-gradient(180deg, rgba(247, 238, 221, 0.98), rgba(235, 221, 194, 0.98));
  --toast-warn-text: #65431f;
  --toast-warn-border: rgba(163, 114, 44, 0.34);
  --toast-error-text: #742419;
  --toast-error-border: rgba(166, 67, 46, 0.34);
  --switch-text: #34271d;
  --switch-text-active: #241a12;
  --switch-paper:
    radial-gradient(circle at 18% 14%, rgba(145, 117, 74, 0.12), rgba(145, 117, 74, 0) 26%),
    radial-gradient(circle at 82% 20%, rgba(145, 117, 74, 0.08), rgba(145, 117, 74, 0) 24%),
    repeating-linear-gradient(
      0deg,
      rgba(126, 102, 70, 0.035),
      rgba(126, 102, 70, 0.035) 1px,
      transparent 1px,
      transparent 20px
    ),
    linear-gradient(180deg, #f8eedf 0%, #f3e5d0 18%, #f6ead7 52%, #eedfc9 100%);
  --switch-paper-active:
    radial-gradient(circle at 18% 14%, rgba(160, 130, 84, 0.14), rgba(160, 130, 84, 0) 26%),
    radial-gradient(circle at 82% 20%, rgba(160, 130, 84, 0.1), rgba(160, 130, 84, 0) 24%),
    repeating-linear-gradient(
      0deg,
      rgba(126, 102, 70, 0.04),
      rgba(126, 102, 70, 0.04) 1px,
      transparent 1px,
      transparent 20px
    ),
    linear-gradient(180deg, #fbf2e5 0%, #f3e5cf 18%, #f6ead7 52%, #eddab8 100%);
  --switch-shadow:
    0 14px 24px rgba(28, 20, 12, 0.16),
    inset 0 1px 0 rgba(255, 250, 239, 0.74),
    inset 0 -10px 16px rgba(134, 103, 64, 0.08),
    inset 1px 0 0 rgba(123, 95, 56, 0.08),
    inset -1px 0 0 rgba(123, 95, 56, 0.08);
  --switch-shadow-active:
    0 18px 30px rgba(32, 21, 11, 0.2),
    inset 0 1px 0 rgba(255, 251, 244, 0.88),
    inset 0 -10px 16px rgba(134, 103, 64, 0.1),
    inset 1px 0 0 rgba(123, 95, 56, 0.1),
    inset -1px 0 0 rgba(123, 95, 56, 0.1);
  --switch-title-shadow: 0 1px 0 rgba(255, 248, 238, 0.45);
  --control-text: #34271d;
  --control-paper:
    radial-gradient(circle at 28% 30%, rgba(255, 255, 255, 0.45), rgba(255, 255, 255, 0) 28%),
    linear-gradient(180deg, #f8eedf 0%, #efe0c7 52%, #ead6b7 100%);
  --control-shadow:
    0 8px 14px rgba(28, 20, 12, 0.15),
    inset 0 1px 0 rgba(255, 250, 239, 0.72),
    inset 0 -6px 12px rgba(134, 103, 64, 0.08);
  --rod-bar: linear-gradient(90deg, #7e5530 0%, #5e3c1f 45%, #3b2414 100%);
  --rod-cap: linear-gradient(90deg, #4a2b14, #2a160c);
  --rod-flare: rgba(255, 231, 192, 0.55);
  --rod-shadow: 0 5px 8px rgba(35, 21, 11, 0.16);
  --scroll-paper:
    radial-gradient(circle at 18% 14%, rgba(145, 117, 74, 0.12), rgba(145, 117, 74, 0) 26%),
    radial-gradient(circle at 82% 20%, rgba(145, 117, 74, 0.08), rgba(145, 117, 74, 0) 24%),
    linear-gradient(180deg, #f8eedf 0%, #f3e5d0 18%, #f6ead7 52%, #eedfc9 100%);
  --scroll-paper-shadow:
    0 40px 60px rgba(56, 40, 22, 0.12),
    inset 0 1px 0 rgba(255, 250, 240, 0.78),
    inset 0 -16px 20px rgba(138, 104, 62, 0.08);
  --scroll-paper-overlay:
    radial-gradient(circle at 24% 24%, rgba(44, 34, 24, 0.08), rgba(44, 34, 24, 0) 16%),
    radial-gradient(circle at 78% 68%, rgba(44, 34, 24, 0.06), rgba(44, 34, 24, 0) 18%),
    repeating-linear-gradient(
      0deg,
      rgba(126, 102, 70, 0.035),
      rgba(126, 102, 70, 0.035) 1px,
      transparent 1px,
      transparent 24px
    );
  --scroll-edge-left: rgba(123, 95, 56, 0.08);
  --scroll-edge-right: rgba(123, 95, 56, 0.08);
  --scroll-rod-bar: linear-gradient(180deg, #7e5530 0%, #5e3c1f 45%, #3b2414 100%);
  --scroll-rod-cap: linear-gradient(180deg, #4a2b14, #2a160c);
  --scroll-rod-flare: rgba(255, 231, 192, 0.55);
  --scroll-rod-shadow:
    0 6px 12px rgba(38, 23, 11, 0.18),
    inset 0 2px 1px rgba(255, 228, 188, 0.18),
    inset 0 -3px 6px rgba(33, 18, 8, 0.3);
  --scroll-rod-cap-shadow:
    0 4px 8px rgba(27, 16, 8, 0.26),
    inset 0 1px 1px rgba(255, 221, 170, 0.2);
  --image-filter: saturate(0.92) contrast(1.01);
  --title-main-color: rgba(251, 248, 240, 0.94);
  --title-main-glow: rgba(255, 255, 255, 0.4);
  --title-main-edge: rgba(255, 255, 255, 0.5);
  --title-shadow-color: rgba(19, 14, 11, 0.62);
  --title-shadow-deep: rgba(0, 0, 0, 0.18);
  --title-shadow-soft: rgba(0, 0, 0, 0.12);
  --bg-title-main-color: rgba(245, 236, 219, 0.58);
  --bg-title-main-glow: rgba(255, 249, 240, 0.26);
  --bg-title-main-edge: rgba(255, 255, 255, 0.18);
  --bg-title-shadow-color: rgba(52, 39, 27, 0.38);
  --bg-title-shadow-deep: rgba(29, 20, 12, 0.22);
  --bg-title-shadow-soft: rgba(29, 20, 12, 0.14);
}

body[data-theme="refined"] {
  --page-bg:
    radial-gradient(circle at 42% 16%, rgba(246, 252, 239, 0.26), transparent 0 22%),
    radial-gradient(circle at 60% 82%, rgba(85, 103, 75, 0.08), transparent 0 24%),
    radial-gradient(circle at center, rgba(247, 253, 242, 0.08), transparent 0 42%),
    linear-gradient(180deg, #a5af9a 0%, #b3bca8 12%, #adb89f 44%, #a3ae95 100%);
  --layout-overlay:
    radial-gradient(circle at 50% 54%, rgba(242, 252, 236, 0.06), transparent 0 28%),
    repeating-linear-gradient(
      0deg,
      rgba(63, 86, 54, 0.038),
      rgba(63, 86, 54, 0.038) 1px,
      transparent 1px,
      transparent 18px
    );
  --layout-before-filter: sepia(1) saturate(1.3) hue-rotate(-28deg);
  --switch-text: #20301b;
  --switch-text-active: #1d2918;
  --switch-paper:
    radial-gradient(circle at 28% 30%, rgba(248, 255, 244, 0.45), rgba(248, 255, 244, 0) 28%),
    linear-gradient(180deg, #edf4e5 0%, #dce7d0 52%, #cddabd 100%);
  --switch-paper-active:
    radial-gradient(circle at 28% 30%, rgba(252, 255, 249, 0.54), rgba(252, 255, 249, 0) 28%),
    linear-gradient(180deg, #f2f7eb 0%, #e1ebd5 48%, #d2dfc3 100%);
  --switch-shadow:
    0 12px 22px rgba(26, 39, 24, 0.18),
    inset 0 1px 0 rgba(249, 255, 245, 0.72),
    inset 0 -8px 14px rgba(77, 107, 68, 0.1);
  --switch-shadow-active:
    0 18px 30px rgba(22, 38, 19, 0.2),
    inset 0 1px 0 rgba(253, 255, 250, 0.88),
    inset 0 -10px 16px rgba(83, 112, 73, 0.12);
  --control-text: #20301b;
  --control-paper:
    radial-gradient(circle at 28% 30%, rgba(248, 255, 244, 0.45), rgba(248, 255, 244, 0) 28%),
    linear-gradient(180deg, #edf4e5 0%, #dce7d0 52%, #cddabd 100%);
  --control-shadow:
    0 10px 18px rgba(26, 39, 24, 0.18),
    inset 0 1px 0 rgba(249, 255, 245, 0.72),
    inset 0 -8px 14px rgba(77, 107, 68, 0.1);
  --rod-bar: linear-gradient(90deg, #5d794e 0%, #3a4f31 45%, #202d1b 100%);
  --rod-cap: linear-gradient(90deg, #8c4036, #4d1e19);
  --rod-flare: rgba(255, 226, 213, 0.58);
  --rod-shadow: 0 5px 8px rgba(26, 37, 20, 0.2);
  --scroll-paper:
    radial-gradient(circle at 18% 14%, rgba(97, 123, 84, 0.12), rgba(97, 123, 84, 0) 26%),
    radial-gradient(circle at 82% 20%, rgba(156, 68, 62, 0.08), rgba(156, 68, 62, 0) 24%),
    linear-gradient(180deg, #edf4e6 0%, #e0e9d5 18%, #eaf1df 52%, #d7e2ca 100%);
  --scroll-paper-shadow:
    0 40px 60px rgba(37, 55, 30, 0.13),
    inset 0 1px 0 rgba(248, 255, 244, 0.82),
    inset 0 -16px 20px rgba(93, 118, 77, 0.1);
  --scroll-paper-overlay:
    radial-gradient(circle at 24% 24%, rgba(43, 61, 37, 0.08), rgba(43, 61, 37, 0) 16%),
    radial-gradient(circle at 78% 68%, rgba(118, 48, 43, 0.06), rgba(118, 48, 43, 0) 18%),
    repeating-linear-gradient(
      0deg,
      rgba(84, 110, 71, 0.04),
      rgba(84, 110, 71, 0.04) 1px,
      transparent 1px,
      transparent 24px
    );
  --scroll-edge-left: rgba(87, 110, 74, 0.12);
  --scroll-edge-right: rgba(129, 55, 50, 0.1);
  --scroll-rod-bar: linear-gradient(180deg, #5d794e 0%, #3a4f31 45%, #202d1b 100%);
  --scroll-rod-cap: linear-gradient(180deg, #8c4036, #4d1e19);
  --scroll-rod-flare: rgba(255, 226, 213, 0.58);
  --scroll-rod-shadow:
    0 8px 14px rgba(26, 37, 20, 0.22),
    inset 0 2px 1px rgba(233, 247, 223, 0.18),
    inset 0 -3px 6px rgba(16, 24, 14, 0.3);
}

body[data-theme="legend"] {
  --page-bg:
    radial-gradient(circle at 36% 16%, rgba(255, 250, 209, 0.3), transparent 0 24%),
    radial-gradient(circle at 64% 74%, rgba(209, 155, 39, 0.14), transparent 0 26%),
    radial-gradient(circle at center, rgba(255, 246, 202, 0.08), transparent 0 42%),
    linear-gradient(180deg, #8a6b2f 0%, #b48a3a 14%, #9a742d 48%, #6f5323 100%);
  --body-before-filter: sepia(1) saturate(1.3) hue-rotate(-10deg);
  --body-before-opacity: 0.3;
  --body-after-filter: sepia(1) saturate(1.9) hue-rotate(-14deg);
  --body-after-opacity: 0.32;
  --layout-before-filter: sepia(1) saturate(1.75) hue-rotate(-10deg);
  --layout-overlay:
    radial-gradient(circle at 50% 54%, rgba(255, 246, 215, 0.06), transparent 0 28%),
    repeating-linear-gradient(
      0deg,
      rgba(101, 77, 25, 0.045),
      rgba(101, 77, 25, 0.045) 1px,
      transparent 1px,
      transparent 18px
    );
  --switch-text: #30220c;
  --switch-paper:
    radial-gradient(circle at 28% 30%, rgba(255, 249, 215, 0.5), rgba(255, 249, 215, 0) 28%),
    linear-gradient(180deg, #f8e6a8 0%, #e4c46d 52%, #c79638 100%);
  --switch-paper-active:
    radial-gradient(circle at 28% 30%, rgba(255, 252, 227, 0.58), rgba(255, 252, 227, 0) 28%),
    linear-gradient(180deg, #faebb5 0%, #efd07a 48%, #d5a53f 100%);
  --switch-shadow:
    0 12px 22px rgba(79, 56, 15, 0.2),
    inset 0 1px 0 rgba(255, 252, 232, 0.74),
    inset 0 -8px 14px rgba(143, 103, 24, 0.16);
  --switch-shadow-active:
    0 18px 30px rgba(88, 61, 16, 0.24),
    inset 0 1px 0 rgba(255, 252, 233, 0.84),
    inset 0 -10px 16px rgba(153, 111, 24, 0.18);
  --control-text: #30220c;
  --control-paper:
    radial-gradient(circle at 28% 30%, rgba(255, 249, 215, 0.5), rgba(255, 249, 215, 0) 28%),
    linear-gradient(180deg, #f8e6a8 0%, #e4c46d 52%, #c79638 100%);
  --control-shadow:
    0 10px 18px rgba(79, 56, 15, 0.2),
    inset 0 1px 0 rgba(255, 252, 232, 0.74),
    inset 0 -8px 14px rgba(143, 103, 24, 0.16);
  --rod-bar: linear-gradient(90deg, #426e74 0%, #2d5055 45%, #182f32 100%);
  --rod-cap: linear-gradient(90deg, #f0cf6c, #9e7417);
  --rod-flare: rgba(255, 251, 220, 0.66);
  --rod-shadow: 0 5px 8px rgba(18, 39, 42, 0.2);
  --scroll-paper:
    radial-gradient(circle at 18% 14%, rgba(255, 237, 173, 0.14), rgba(255, 237, 173, 0) 26%),
    radial-gradient(circle at 82% 20%, rgba(188, 215, 219, 0.1), rgba(188, 215, 219, 0) 24%),
    linear-gradient(180deg, #f6e2a4 0%, #ebcc72 18%, #f1d88d 52%, #d7a94a 100%);
  --scroll-paper-shadow:
    0 40px 60px rgba(88, 61, 16, 0.16),
    inset 0 1px 0 rgba(255, 252, 233, 0.82),
    inset 0 -16px 20px rgba(153, 111, 24, 0.14);
  --scroll-paper-overlay:
    radial-gradient(circle at 24% 24%, rgba(119, 90, 20, 0.08), rgba(119, 90, 20, 0) 16%),
    radial-gradient(circle at 78% 68%, rgba(44, 82, 88, 0.08), rgba(44, 82, 88, 0) 18%),
    repeating-linear-gradient(
      0deg,
      rgba(121, 92, 29, 0.05),
      rgba(121, 92, 29, 0.05) 1px,
      transparent 1px,
      transparent 24px
    );
  --scroll-edge-left: rgba(48, 87, 92, 0.16);
  --scroll-edge-right: rgba(164, 122, 26, 0.16);
  --scroll-rod-bar: linear-gradient(180deg, #426e74 0%, #2d5055 45%, #182f32 100%);
  --scroll-rod-cap: linear-gradient(180deg, #f0cf6c, #9e7417);
  --scroll-rod-flare: rgba(255, 251, 220, 0.66);
  --scroll-rod-shadow:
    0 8px 14px rgba(18, 39, 42, 0.24),
    inset 0 2px 1px rgba(214, 238, 240, 0.18),
    inset 0 -3px 6px rgba(14, 27, 29, 0.3);
  --title-main-color: rgba(255, 241, 179, 0.96);
  --title-main-glow: rgba(255, 244, 195, 0.45);
  --title-main-edge: rgba(239, 255, 255, 0.2);
  --title-shadow-color: rgba(32, 72, 78, 0.58);
  --title-shadow-deep: rgba(17, 43, 46, 0.24);
  --title-shadow-soft: rgba(10, 28, 31, 0.14);
  --bg-title-main-color: rgba(255, 232, 164, 0.56);
  --bg-title-main-glow: rgba(255, 244, 191, 0.24);
  --bg-title-main-edge: rgba(221, 245, 248, 0.16);
  --bg-title-shadow-color: rgba(34, 79, 86, 0.37);
}

body[data-theme="rare"] {
  --page-bg:
    radial-gradient(circle at 38% 18%, rgba(246, 231, 255, 0.28), transparent 0 24%),
    radial-gradient(circle at 64% 76%, rgba(110, 50, 175, 0.12), transparent 0 24%),
    radial-gradient(circle at center, rgba(248, 240, 255, 0.08), transparent 0 42%),
    linear-gradient(180deg, #82759b 0%, #8f7eab 10%, #856fa2 44%, #77638f 100%);
  --body-before-filter: hue-rotate(132deg) saturate(1.1);
  --body-before-opacity: 0.42;
  --body-after-filter: hue-rotate(130deg) saturate(1.6);
  --body-after-opacity: 0.34;
  --layout-before-filter: hue-rotate(130deg) saturate(1.45);
  --layout-overlay:
    radial-gradient(circle at 50% 54%, rgba(250, 244, 255, 0.06), transparent 0 28%),
    repeating-linear-gradient(
      0deg,
      rgba(96, 65, 129, 0.042),
      rgba(96, 65, 129, 0.042) 1px,
      transparent 1px,
      transparent 18px
    );
  --switch-text: #281d38;
  --switch-paper:
    radial-gradient(circle at 28% 30%, rgba(250, 242, 255, 0.46), rgba(250, 242, 255, 0) 28%),
    linear-gradient(180deg, #efe6fb 0%, #dbcdf0 52%, #c6b2e2 100%);
  --switch-paper-active:
    radial-gradient(circle at 28% 30%, rgba(255, 248, 255, 0.56), rgba(255, 248, 255, 0) 28%),
    linear-gradient(180deg, #f3ebfe 0%, #e1d3f4 48%, #ceb7eb 100%);
  --switch-shadow:
    0 12px 22px rgba(42, 24, 57, 0.18),
    inset 0 1px 0 rgba(252, 248, 255, 0.74),
    inset 0 -8px 14px rgba(100, 61, 146, 0.1);
  --switch-shadow-active:
    0 18px 30px rgba(42, 24, 57, 0.22),
    inset 0 1px 0 rgba(255, 251, 255, 0.84),
    inset 0 -10px 16px rgba(110, 70, 158, 0.12);
  --control-text: #281d38;
  --control-paper:
    radial-gradient(circle at 28% 30%, rgba(250, 242, 255, 0.46), rgba(250, 242, 255, 0) 28%),
    linear-gradient(180deg, #efe6fb 0%, #dbcdf0 52%, #c6b2e2 100%);
  --control-shadow:
    0 10px 18px rgba(42, 24, 57, 0.18),
    inset 0 1px 0 rgba(252, 248, 255, 0.74),
    inset 0 -8px 14px rgba(100, 61, 146, 0.1);
  --rod-bar: linear-gradient(90deg, #684e88 0%, #473261 45%, #261c34 100%);
  --rod-cap: linear-gradient(90deg, #bf79e6, #712fa6);
  --rod-flare: rgba(255, 231, 255, 0.58);
  --rod-shadow: 0 5px 8px rgba(42, 24, 57, 0.2);
  --scroll-paper:
    radial-gradient(circle at 18% 14%, rgba(126, 93, 166, 0.12), rgba(126, 93, 166, 0) 26%),
    radial-gradient(circle at 82% 20%, rgba(176, 83, 204, 0.08), rgba(176, 83, 204, 0) 24%),
    linear-gradient(180deg, #efe7fb 0%, #e2d5f1 18%, #ebe0f8 52%, #d5c3e8 100%);
  --scroll-paper-shadow:
    0 40px 60px rgba(52, 32, 73, 0.14),
    inset 0 1px 0 rgba(253, 247, 255, 0.82),
    inset 0 -16px 20px rgba(114, 73, 160, 0.1);
  --scroll-paper-overlay:
    radial-gradient(circle at 24% 24%, rgba(68, 49, 95, 0.08), rgba(68, 49, 95, 0) 16%),
    radial-gradient(circle at 78% 68%, rgba(132, 57, 164, 0.06), rgba(132, 57, 164, 0) 18%),
    repeating-linear-gradient(
      0deg,
      rgba(108, 74, 144, 0.04),
      rgba(108, 74, 144, 0.04) 1px,
      transparent 1px,
      transparent 24px
    );
  --scroll-edge-left: rgba(92, 69, 123, 0.12);
  --scroll-edge-right: rgba(132, 57, 164, 0.11);
  --scroll-rod-bar: linear-gradient(180deg, #684e88 0%, #473261 45%, #261c34 100%);
  --scroll-rod-cap: linear-gradient(180deg, #bf79e6, #712fa6);
  --scroll-rod-flare: rgba(255, 231, 255, 0.58);
  --title-main-color: rgba(243, 230, 255, 0.96);
  --title-main-glow: rgba(249, 239, 255, 0.42);
  --title-main-edge: rgba(232, 212, 255, 0.34);
  --title-shadow-color: rgba(65, 36, 101, 0.6);
  --title-shadow-deep: rgba(38, 19, 63, 0.24);
  --title-shadow-soft: rgba(25, 11, 42, 0.14);
  --bg-title-main-color: rgba(235, 220, 255, 0.56);
  --bg-title-main-glow: rgba(246, 236, 255, 0.24);
  --bg-title-main-edge: rgba(226, 213, 255, 0.16);
  --bg-title-shadow-color: rgba(69, 39, 108, 0.37);
}

body[data-theme="epic"] {
  --page-bg:
    radial-gradient(circle at 50% 10%, rgba(255, 232, 145, 0.28), transparent 0 18%),
    radial-gradient(circle at 14% 18%, rgba(255, 120, 39, 0.22), transparent 0 22%),
    radial-gradient(circle at 86% 22%, rgba(255, 180, 74, 0.18), transparent 0 18%),
    radial-gradient(circle at 50% 54%, rgba(148, 29, 7, 0.22), transparent 0 38%),
    radial-gradient(circle at 50% 88%, rgba(255, 98, 31, 0.12), transparent 0 18%),
    linear-gradient(180deg, #120805 0%, #261009 12%, #5b1c0e 34%, #742207 50%, #341107 74%, #120805 100%);
  --body-before-filter: sepia(1) saturate(2.1) hue-rotate(-28deg);
  --body-before-opacity: 0.34;
  --body-after-filter: sepia(1) saturate(2.1) hue-rotate(-28deg);
  --body-after-opacity: 0.34;
  --layout-before-filter: sepia(1) saturate(2.1) hue-rotate(-28deg);
  --layout-overlay:
    radial-gradient(circle at 50% 54%, rgba(255, 229, 172, 0.14), transparent 0 30%),
    linear-gradient(
      90deg,
      rgba(255, 190, 84, 0.1) 0%,
      rgba(255, 111, 34, 0.02) 10%,
      transparent 22%,
      transparent 78%,
      rgba(255, 111, 34, 0.02) 90%,
      rgba(255, 190, 84, 0.1) 100%
    ),
    repeating-linear-gradient(
      0deg,
      rgba(119, 66, 30, 0.07),
      rgba(119, 66, 30, 0.07) 1px,
      transparent 1px,
      transparent 18px
    );
  --overlay-scrim:
    radial-gradient(circle at 50% 20%, rgba(255, 206, 111, 0.12), transparent 0 18%),
    linear-gradient(180deg, rgba(20, 8, 5, 0.98), rgba(8, 3, 2, 0.96));
  --focus-ring: rgba(255, 167, 67, 0.42);
  --switch-text: #fff1df;
  --switch-text-active: #fff4e7;
  --switch-paper:
    radial-gradient(circle at 22% 18%, rgba(255, 238, 187, 0.28), rgba(255, 238, 187, 0) 28%),
    linear-gradient(90deg, rgba(255, 195, 92, 0.12), rgba(255, 112, 35, 0.02) 14%, transparent 24%, transparent 76%, rgba(255, 112, 35, 0.02) 86%, rgba(255, 195, 92, 0.12)),
    repeating-linear-gradient(0deg, rgba(150, 72, 32, 0.08), rgba(150, 72, 32, 0.08) 1px, transparent 1px, transparent 14px),
    linear-gradient(180deg, #8f4122 0%, #632717 42%, #31120d 100%);
  --switch-paper-active:
    radial-gradient(circle at 22% 18%, rgba(255, 243, 196, 0.34), rgba(255, 243, 196, 0) 28%),
    linear-gradient(90deg, rgba(255, 214, 128, 0.16), rgba(255, 134, 43, 0.03) 14%, transparent 24%, transparent 76%, rgba(255, 134, 43, 0.03) 86%, rgba(255, 214, 128, 0.16)),
    repeating-linear-gradient(0deg, rgba(170, 82, 39, 0.1), rgba(170, 82, 39, 0.1) 1px, transparent 1px, transparent 14px),
    linear-gradient(180deg, #a34b25 0%, #742d19 44%, #3b140e 100%);
  --switch-shadow:
    0 0 0 1px rgba(255, 211, 116, 0.42),
    0 0 14px rgba(255, 112, 35, 0.42),
    0 0 34px rgba(255, 73, 0, 0.28),
    0 0 68px rgba(255, 201, 91, 0.24),
    inset 0 1px 0 rgba(255, 236, 193, 0.32),
    inset 0 -12px 18px rgba(186, 50, 19, 0.28);
  --switch-shadow-active:
    0 0 0 1px rgba(255, 214, 128, 0.54),
    0 0 18px rgba(255, 126, 36, 0.48),
    0 0 40px rgba(255, 78, 0, 0.34),
    0 0 82px rgba(255, 214, 120, 0.28),
    inset 0 1px 0 rgba(255, 241, 205, 0.34),
    inset 0 -14px 20px rgba(202, 58, 18, 0.34);
  --switch-title-shadow:
    0 1px 0 rgba(255, 248, 231, 0.32),
    0 0 12px rgba(255, 202, 108, 0.22),
    0 0 24px rgba(255, 90, 20, 0.14);
  --control-text: #fff1df;
  --control-paper:
    radial-gradient(circle at 22% 18%, rgba(255, 236, 184, 0.26), rgba(255, 236, 184, 0) 28%),
    linear-gradient(90deg, rgba(255, 190, 84, 0.1), rgba(255, 111, 34, 0.02) 18%, transparent 82%, rgba(255, 190, 84, 0.1)),
    linear-gradient(180deg, #8b3c21 0%, #5d2616 52%, #30140d 100%);
  --control-shadow:
    0 0 0 1px rgba(255, 200, 104, 0.36),
    0 0 14px rgba(255, 104, 34, 0.34),
    0 0 30px rgba(255, 69, 0, 0.24),
    0 0 56px rgba(255, 198, 90, 0.2),
    inset 0 1px 0 rgba(255, 234, 188, 0.24),
    inset 0 -10px 16px rgba(156, 53, 26, 0.24);
  --rod-bar: linear-gradient(90deg, #8a3717 0%, #541d13 45%, #2a0f0c 100%);
  --rod-cap: linear-gradient(90deg, #ff8d37, #bd2515);
  --rod-flare: rgba(255, 243, 179, 0.64);
  --rod-shadow: 0 5px 10px rgba(255, 102, 31, 0.24);
  --scroll-paper:
    radial-gradient(circle at 18% 14%, rgba(255, 214, 130, 0.18), rgba(255, 214, 130, 0) 26%),
    radial-gradient(circle at 82% 20%, rgba(255, 117, 46, 0.16), rgba(255, 117, 46, 0) 24%),
    radial-gradient(circle at 50% 12%, rgba(255, 234, 166, 0.12), rgba(255, 234, 166, 0) 20%),
    linear-gradient(180deg, #7a391b 0%, #552414 18%, #6c2b12 52%, #35140d 100%);
  --scroll-paper-shadow:
    0 0 0 1px rgba(255, 210, 124, 0.3),
    0 0 18px rgba(255, 106, 31, 0.28),
    0 0 40px rgba(255, 68, 0, 0.26),
    0 0 88px rgba(255, 206, 102, 0.22),
    inset 0 1px 0 rgba(255, 238, 198, 0.22),
    inset 0 -18px 24px rgba(191, 58, 22, 0.18);
  --scroll-paper-overlay:
    radial-gradient(circle at 24% 24%, rgba(255, 204, 106, 0.16), rgba(255, 204, 106, 0) 16%),
    radial-gradient(circle at 78% 68%, rgba(255, 96, 42, 0.14), rgba(255, 96, 42, 0) 18%),
    radial-gradient(circle at 50% 8%, rgba(255, 236, 174, 0.08), rgba(255, 236, 174, 0) 18%),
    repeating-linear-gradient(
      0deg,
      rgba(122, 63, 29, 0.075),
      rgba(122, 63, 29, 0.075) 1px,
      transparent 1px,
      transparent 24px
    );
  --scroll-edge-left: rgba(255, 205, 118, 0.34);
  --scroll-edge-right: rgba(255, 108, 48, 0.34);
  --scroll-rod-bar: linear-gradient(180deg, #b04a1f 0%, #74250f 44%, #330f09 100%);
  --scroll-rod-cap: linear-gradient(180deg, #ffb247, #cb2a15);
  --scroll-rod-flare: rgba(255, 248, 199, 0.78);
  --scroll-rod-shadow:
    0 0 0 1px rgba(255, 208, 120, 0.34),
    0 0 12px rgba(255, 120, 36, 0.38),
    0 0 28px rgba(255, 74, 0, 0.28),
    0 0 50px rgba(255, 201, 91, 0.24),
    inset 0 2px 1px rgba(255, 238, 196, 0.24),
    inset 0 -3px 6px rgba(84, 18, 9, 0.4);
  --image-filter:
    saturate(1.1)
    contrast(1.08)
    drop-shadow(0 0 16px rgba(255, 168, 70, 0.14))
    drop-shadow(0 14px 24px rgba(0, 0, 0, 0.28));
  --title-main-color: rgba(255, 234, 176, 0.99);
  --title-main-glow: rgba(255, 211, 115, 0.62);
  --title-main-edge: rgba(255, 246, 214, 0.46);
  --title-shadow-color: rgba(118, 26, 8, 0.78);
  --title-shadow-deep: rgba(74, 9, 2, 0.34);
  --title-shadow-soft: rgba(46, 6, 2, 0.22);
  --bg-title-main-color: rgba(255, 214, 136, 0.74);
  --bg-title-main-glow: rgba(255, 203, 112, 0.34);
  --bg-title-main-edge: rgba(255, 239, 193, 0.24);
  --bg-title-shadow-color: rgba(108, 24, 7, 0.54);
}

* { box-sizing: border-box; }

html, body {
  min-height: 100%;
  height: 100%;
}

html.is-frame-blocked body { display: none !important; }

body {
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  font-family: "STKaiti", "KaiTi", "Noto Serif SC", "Songti SC", serif;
  background: var(--page-bg);
}

body::before,
body::after {
  content: "";
  position: fixed;
  pointer-events: none;
  z-index: 0;
}

body::before {
  left: -2vw;
  bottom: 4vh;
  width: min(32vw, 420px);
  height: min(40vw, 520px);
  background: url("assets/bg-landscape.svg") no-repeat left bottom / contain;
  filter: var(--body-before-filter);
  opacity: var(--body-before-opacity);
}

body::after {
  right: -2vw;
  top: 3vh;
  width: min(34vw, 520px);
  height: min(34vw, 520px);
  background: url("assets/bg-cloud.svg") no-repeat right top / contain;
  filter: var(--body-after-filter);
  opacity: var(--body-after-opacity);
}

.seo-copy,
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

[hidden] { display: none !important; }

.seo-fallback {
  padding: 20px;
  color: var(--ink);
}

.seo-fallback img {
  display: block;
  max-width: min(100%, 360px);
  height: auto;
  margin-top: 12px;
}

.file-input-proxy {
  position: fixed;
  left: -9999px;
  top: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.layout {
  position: relative;
  isolation: isolate;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(236px, 320px) minmax(0, 1fr) minmax(236px, 320px);
  min-height: 100vh;
  min-height: 100svh;
  min-height: 100dvh;
  height: 100vh;
  height: 100svh;
  height: 100dvh;
  overflow: hidden;
}

.layout::before,
.layout::after {
  content: "";
  position: absolute;
  pointer-events: none;
  z-index: 0;
}

.layout::before {
  right: -3vw;
  bottom: 2vh;
  width: min(30vw, 420px);
  height: min(30vw, 420px);
  background: url("assets/bg-cloud.svg") no-repeat right bottom / contain;
  transform: rotate(20deg);
  filter: var(--layout-before-filter);
  opacity: var(--layout-before-opacity);
}

.layout::after {
  inset: 0;
  background: var(--layout-overlay);
  mix-blend-mode: multiply;
}

.sidebar {
  position: relative;
  display: flex;
  align-items: center;
  padding: 20px 14px 20px 0;
  color: #f7f1e6;
  overflow: visible;
  z-index: 1;
}

.sidebar-right {
  padding: 20px 0 20px 14px;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
}

.drawer-nav,
.mobile-rail-panel {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.drawer-nav-right,
.mobile-rail-panel-right { align-items: flex-end; }

.switch-btn.mobile-rail-toggle { display: none; }

.switch-btn,
.text-edit-btn {
  position: relative;
  border: 0;
  border-radius: 0;
  cursor: pointer;
  overflow: visible;
  transition: width 220ms ease, transform 180ms ease, filter 180ms ease, box-shadow 220ms ease;
}

.switch-btn {
  --drawer-rod-size: 14px;
  --drawer-rod-core: 8px;
  display: block;
  width: calc(100% - 56px);
  min-height: 74px;
  padding: 18px 32px 18px 40px;
  color: var(--switch-text);
  text-align: left;
  background: var(--switch-paper);
  box-shadow: var(--switch-shadow);
}

.switch-btn::before,
.switch-btn::after,
.text-edit-btn::before,
.text-edit-btn::after {
  content: "";
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background:
    radial-gradient(circle at center, var(--rod-flare), rgba(255, 255, 255, 0) 38%) center top / var(--rod-size) var(--rod-size) no-repeat,
    radial-gradient(circle at center, var(--rod-flare), rgba(255, 255, 255, 0) 38%) center bottom / var(--rod-size) var(--rod-size) no-repeat,
    var(--rod-bar) center / var(--rod-core) calc(100% - var(--rod-core)) no-repeat,
    var(--rod-cap) center top / var(--rod-size) var(--rod-size) no-repeat,
    var(--rod-cap) center bottom / var(--rod-size) var(--rod-size) no-repeat;
  box-shadow: var(--rod-shadow);
  z-index: 2;
}

.switch-btn::before,
.switch-btn::after {
  --rod-size: var(--drawer-rod-size);
  --rod-core: var(--drawer-rod-core);
  width: var(--drawer-rod-size);
  height: calc(100% + var(--drawer-rod-size));
}

.switch-btn::before { left: -6px; }
.switch-btn::after { right: -6px; }
.switch-btn:hover { width: calc(100% - 34px); filter: brightness(1.02); }

.switch-btn.active {
  width: calc(100% - 6px);
  color: var(--switch-text-active);
  background: var(--switch-paper-active);
  box-shadow: var(--switch-shadow-active);
}

.switch-btn.active::before,
.switch-btn.active::after { filter: brightness(1.08); }

.switch-btn-right {
  margin-left: auto;
  padding: 18px 40px 18px 32px;
  text-align: right;
}

.switch-title {
  display: block;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.05;
  text-shadow: var(--switch-title-shadow);
}

.action-btn {
  width: calc(100% - 56px);
  min-height: 70px;
  font-size: 20px;
  font-weight: 700;
}

.action-btn:hover { width: calc(100% - 34px); }

.viewer {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  padding: 8px 28px 8px 18px;
}

.scroll-stage {
  position: relative;
  display: grid;
  place-items: center;
  width: min(42vw, 500px);
  padding: 10px 0 12px;
  z-index: 1;
}

.scroll-paper {
  position: relative;
  width: 100%;
  height: min(calc(100vh - 72px), 900px);
  height: min(calc(100svh - 72px), 900px);
  height: min(calc(100dvh - 72px), 900px);
  margin: 14px 0;
  background: var(--scroll-paper);
  box-shadow: var(--scroll-paper-shadow);
  overflow: hidden;
  z-index: 1;
}

.scroll-paper::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--scroll-paper-overlay);
  mix-blend-mode: multiply;
  pointer-events: none;
}

.scroll-paper::after {
  content: "";
  position: absolute;
  left: 5mm;
  right: 5mm;
  top: 5mm;
  bottom: 5mm;
  border-left: 1px solid var(--scroll-edge-left);
  border-right: 1px solid var(--scroll-edge-right);
  pointer-events: none;
}

.scroll-paper img {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  filter: var(--image-filter);
  cursor: default;
  user-select: none;
  -webkit-user-drag: none;
}

.scroll-rod {
  position: absolute;
  left: 50%;
  width: calc(100% + 18px);
  height: 16px;
  transform: translateX(-50%);
  background: var(--scroll-rod-bar);
  box-shadow: var(--scroll-rod-shadow);
  z-index: 3;
}

.scroll-rod::before,
.scroll-rod::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  transform: translateY(-50%);
  background:
    radial-gradient(circle at 35% 35%, var(--scroll-rod-flare), rgba(255, 255, 255, 0) 38%),
    var(--scroll-rod-cap);
  box-shadow: var(--scroll-rod-cap-shadow);
}

.scroll-rod::before { left: -10px; }
.scroll-rod::after { right: -10px; }
.scroll-rod-top { top: 8px; }
.scroll-rod-bottom { bottom: 8px; }

.image-title-stack {
  position: absolute;
  left: 9.2%;
  top: 8.8%;
  width: max-content;
  height: max-content;
  z-index: 2;
  pointer-events: none;
}

.image-title-layer,
.side-verse-layer {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: row;
  writing-mode: vertical-rl;
  text-orientation: upright;
  font-family: "STKaiti", "KaiTi", "Noto Serif SC", "Songti SC", serif;
  white-space: nowrap;
}

.image-title-layer {
  gap: 10px;
  font-size: clamp(18px, 1.5vw, 24px);
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.18em;
}

.image-title-main {
  position: relative;
  color: var(--title-main-color);
  text-shadow: 0 0 6px var(--title-main-glow), 0 1px 1px var(--title-main-edge);
}

.image-title-shadow {
  transform: translate(4px, 4px);
  color: var(--title-shadow-color);
  text-shadow: 0 1px 3px var(--title-shadow-deep), 0 0 3px var(--title-shadow-soft);
}

.side-verse {
  position: absolute;
  top: 50%;
  width: max-content;
  height: max-content;
  z-index: 0;
  pointer-events: none;
  transform: translateY(-50%);
}

.side-verse-left { left: calc(0px - clamp(74px, 7.2vw, 108px)); }
.side-verse-right { right: calc(0px - clamp(74px, 7.2vw, 108px)); }

.side-verse-layer {
  font-size: clamp(20px, 1.55vw, 28px);
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: 0.12em;
}

.side-verse-main {
  position: relative;
  color: var(--bg-title-main-color);
  text-shadow: 0 0 10px var(--bg-title-main-glow), 0 1px 1px var(--bg-title-main-edge);
}

.side-verse-shadow {
  transform: translate(4px, 4px);
  color: var(--bg-title-shadow-color);
  text-shadow: 0 2px 6px var(--bg-title-shadow-deep), 0 0 4px var(--bg-title-shadow-soft);
}

.control-deck {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: calc(100% - 6px);
  margin: 8px 0 0;
}

.dpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 6px;
  width: 112px;
  height: 112px;
  flex: 0 0 112px;
}

.dpad-btn {
  border: 0;
  border-radius: 14px;
  color: var(--control-text);
  font: inherit;
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
  background: var(--control-paper);
  box-shadow: var(--control-shadow);
  transition: transform 180ms ease, filter 180ms ease, box-shadow 180ms ease;
}

.dpad-btn:hover { transform: translateY(-2px); filter: brightness(1.03); }
.dpad-btn:active { transform: translateY(0); }
.dpad-up { grid-column: 2; grid-row: 1; }
.dpad-left { grid-column: 1; grid-row: 2; }
.dpad-right { grid-column: 3; grid-row: 2; }
.dpad-down { grid-column: 2; grid-row: 3; }

.text-edit-tools {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
  width: max-content;
  height: 112px;
}

.text-edit-btn {
  --mini-rod-size: 10px;
  --mini-rod-core: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: max-content;
  flex: 1 1 0;
  min-height: 0;
  padding: 8px 10px;
  color: var(--switch-text);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: 0.04em;
  white-space: nowrap;
  background: var(--switch-paper);
  box-shadow:
    0 8px 14px rgba(28, 20, 12, 0.15),
    inset 0 1px 0 rgba(255, 250, 239, 0.72),
    inset 0 -6px 12px rgba(134, 103, 64, 0.08),
    inset 1px 0 0 rgba(123, 95, 56, 0.08),
    inset -1px 0 0 rgba(123, 95, 56, 0.08);
}

.text-edit-btn::before,
.text-edit-btn::after {
  --rod-size: var(--mini-rod-size);
  --rod-core: var(--mini-rod-core);
  width: var(--mini-rod-size);
  height: calc(100% + var(--mini-rod-size));
}

.text-edit-btn::before { left: -4px; }
.text-edit-btn::after { right: -4px; }
.text-edit-btn:hover { transform: translateY(-1px); filter: brightness(1.03); }
.text-edit-btn:active { transform: translateY(0); }

.switch-btn:focus-visible,
.dpad-btn:focus-visible,
.text-edit-btn:focus-visible,
.editor-btn:focus-visible,
.editor-input:focus-visible,
.editor-textarea:focus-visible { outline: none; }

.switch-btn:focus-visible { box-shadow: var(--focus-shadow), var(--switch-shadow); }
.switch-btn.active:focus-visible { box-shadow: var(--focus-shadow), var(--switch-shadow-active); }
.dpad-btn:focus-visible { box-shadow: var(--focus-shadow), var(--control-shadow); }
.text-edit-btn:focus-visible {
  box-shadow:
    var(--focus-shadow),
    0 8px 14px rgba(28, 20, 12, 0.15),
    inset 0 1px 0 rgba(255, 250, 239, 0.72),
    inset 0 -6px 12px rgba(134, 103, 64, 0.08);
}

.status-toast[hidden],
.editor-overlay[hidden] { display: none; }

.status-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 60;
  max-width: min(calc(100vw - 32px), 460px);
  padding: 12px 18px;
  border: 1px solid var(--toast-border);
  border-radius: 4px;
  color: var(--toast-text);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-align: center;
  background: var(--toast-bg);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.18), inset 0 1px 0 rgba(255, 253, 247, 0.72);
  opacity: 0;
  transform: translate(-50%, 12px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.status-toast.visible { opacity: 1; transform: translate(-50%, 0); }
.status-toast[data-tone="warn"] { color: var(--toast-warn-text); border-color: var(--toast-warn-border); }
.status-toast[data-tone="error"] { color: var(--toast-error-text); border-color: var(--toast-error-border); }

.editor-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(18, 12, 8, 0.5);
  backdrop-filter: blur(3px);
}

.editor-dialog {
  position: relative;
  width: min(560px, calc(100vw - 32px));
  padding: 42px 26px 26px;
  border: 0;
  color: var(--ink);
  background: var(--scroll-paper);
  box-shadow: var(--scroll-paper-shadow);
}

.editor-dialog::before,
.editor-dialog::after {
  content: "";
  position: absolute;
  left: 50%;
  width: calc(100% + 18px);
  height: 14px;
  transform: translateX(-50%);
  background: var(--scroll-rod-bar);
  box-shadow: var(--scroll-rod-shadow);
}

.editor-dialog::before { top: 8px; }
.editor-dialog::after { bottom: 8px; }

.editor-title {
  margin: 0 0 18px;
  font-size: clamp(22px, 2.2vw, 28px);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-align: center;
}

.editor-name-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.editor-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.editor-label {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: rgba(52, 39, 29, 0.82);
}

.editor-input,
.editor-textarea {
  width: 100%;
  border: 1px solid rgba(121, 95, 58, 0.18);
  border-radius: 0;
  color: var(--ink);
  font: inherit;
  font-size: 17px;
  line-height: 1.5;
  background:
    radial-gradient(circle at 16% 14%, rgba(145, 117, 74, 0.08), rgba(145, 117, 74, 0) 24%),
    linear-gradient(180deg, rgba(255, 252, 245, 0.9), rgba(246, 237, 220, 0.92));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.66), inset 0 -6px 12px rgba(129, 99, 62, 0.06);
}

.editor-input { min-height: 54px; padding: 12px 14px; }
.editor-textarea { min-height: 166px; padding: 14px 16px; resize: none; }
.editor-input:focus-visible,
.editor-textarea:focus-visible { box-shadow: var(--focus-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.66); }

.editor-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.editor-btn {
  min-width: 88px;
  min-height: 46px;
  padding: 10px 16px;
  border: 0;
  color: var(--control-text);
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.06em;
  background: var(--control-paper);
  box-shadow: var(--control-shadow);
  cursor: pointer;
  transition: transform 180ms ease, filter 180ms ease, box-shadow 180ms ease;
}

.editor-btn:hover { transform: translateY(-1px); filter: brightness(1.02); }
.editor-btn:active { transform: translateY(0); }
.editor-btn:focus-visible { box-shadow: var(--focus-shadow), var(--control-shadow); }
.editor-btn-primary {
  color: var(--switch-text-active);
  background: var(--switch-paper-active);
  box-shadow: var(--switch-shadow-active);
}

body[data-theme="epic"] .viewer::before {
  content: "";
  position: absolute;
  inset: 6% 10% 8%;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 44%, rgba(255, 178, 78, 0.24), transparent 0 28%),
    radial-gradient(circle at 50% 56%, rgba(255, 86, 26, 0.2), transparent 0 42%);
  filter: blur(20px);
}

body[data-theme="epic"] .scroll-stage::before,
body[data-theme="epic"] .scroll-stage::after {
  content: "";
  position: absolute;
  pointer-events: none;
  z-index: 0;
}

body[data-theme="epic"] .scroll-stage::before {
  inset: -18px -42px -24px;
  background:
    linear-gradient(180deg, rgba(255, 214, 128, 0.12), rgba(255, 104, 30, 0.04) 26%, rgba(0, 0, 0, 0) 40%, rgba(255, 104, 30, 0.04) 74%, rgba(255, 214, 128, 0.12) 100%),
    linear-gradient(90deg, rgba(255, 190, 84, 0.14), rgba(255, 94, 24, 0.04) 14%, transparent 24%, transparent 76%, rgba(255, 94, 24, 0.04) 86%, rgba(255, 190, 84, 0.14));
  border: 1px solid rgba(255, 186, 88, 0.28);
  box-shadow: 0 0 18px rgba(255, 114, 34, 0.18), 0 0 42px rgba(255, 196, 92, 0.16), inset 0 0 22px rgba(255, 215, 134, 0.08);
}

body[data-theme="epic"] .scroll-stage::after {
  inset: -34px -60px;
  background:
    radial-gradient(circle at 8% 10%, rgba(255, 188, 86, 0.2), transparent 0 12%),
    radial-gradient(circle at 92% 10%, rgba(255, 188, 86, 0.2), transparent 0 12%),
    radial-gradient(circle at 10% 92%, rgba(255, 118, 34, 0.18), transparent 0 12%),
    radial-gradient(circle at 90% 92%, rgba(255, 118, 34, 0.18), transparent 0 12%);
  filter: blur(2px);
}

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .side-verse,
  .control-deck { display: none; }
  .sidebar {
    position: fixed;
    top: 16px;
    width: min(44vw, 238px);
    padding: 0;
    flex-direction: column;
    pointer-events: none;
    z-index: 8;
  }
  .sidebar > * { pointer-events: auto; }
  .sidebar-left { left: 0; align-items: flex-start; }
  .sidebar-right { right: 0; padding: 0; align-items: flex-end; justify-content: flex-start; gap: 0; }
  .switch-btn.mobile-rail-toggle { display: block; min-height: 72px; }
  .mobile-rail-panel {
    gap: 14px;
    max-height: 0;
    padding-top: 0;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
    transition: max-height 220ms ease, opacity 180ms ease, padding-top 180ms ease;
  }
  .sidebar.is-open .mobile-rail-panel {
    max-height: 76vh;
    max-height: 76dvh;
    padding-top: 12px;
    opacity: 1;
    pointer-events: auto;
  }
  .switch-btn,
  .action-btn { min-height: 72px; }
  .switch-title,
  .action-btn { font-size: 20px; }
  .switch-btn.active { width: calc(100% - 8px); }
  .viewer {
    min-height: 100vh;
    min-height: 100svh;
    min-height: 100dvh;
    padding: 92px 14px 20px;
  }
  .scroll-stage { width: min(82vw, 420px); padding: 18px 0 20px; }
  .scroll-paper {
    height: min(68vh, 720px);
    height: min(68svh, 720px);
    height: min(68dvh, 720px);
  }
  .scroll-paper img { cursor: default; touch-action: pan-y; }
  .image-title-layer { gap: 8px; font-size: clamp(16px, 2.6vw, 22px); }
  .image-title-shadow { transform: translate(3px, 3px); }
  .status-toast { bottom: 16px; padding: 11px 16px; font-size: 14px; letter-spacing: 0.04em; }
}

@media (max-width: 620px) {
  .sidebar { top: 12px; width: min(48vw, 216px); }
  .switch-btn.mobile-rail-toggle,
  .switch-btn,
  .action-btn { min-height: 66px; }
  .switch-title,
  .action-btn { font-size: 18px; }
  .viewer { padding-top: 86px; }
  .scroll-stage { width: min(86vw, 392px); }
  .image-title-stack { left: 9%; top: 9.5%; }
  .editor-overlay { padding: 16px; }
  .editor-dialog { width: calc(100vw - 24px); padding: 38px 18px 20px; }
  .editor-name-grid { grid-template-columns: 1fr; }
  .editor-actions { flex-wrap: wrap; justify-content: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .switch-btn:hover,
  .dpad-btn:hover,
  .text-edit-btn:hover,
  .editor-btn:hover { transform: none; }
}
}
