:root {
  --bg: #080c0f;
  --bg-soft: #0d1216;
  --panel: rgba(17, 23, 27, 0.78);
  --panel-solid: #11171b;
  --panel-raised: #171f24;
  --panel-input: #0d1317;
  --line: rgba(234, 220, 198, 0.1);
  --line-strong: rgba(234, 220, 198, 0.19);
  --text: #f2ebdf;
  --text-soft: #c8bdae;
  --text-dim: #988d7e;
  --text-faint: #6f675d;
  --gold: #e3b97c;
  --gold-strong: #f1ca91;
  --gold-ink: #231b10;
  --gold-wash: rgba(227, 185, 124, 0.11);
  --user-bubble: linear-gradient(135deg, #e5c08a, #c7975d);
  --user-text: #241b10;
  --assistant-bubble: rgba(255, 255, 255, 0.035);
  --danger: #e58d86;
  --danger-wash: rgba(229, 141, 134, 0.1);
  --success: #8fc3a8;
  --shadow-lg: 0 32px 90px rgba(0, 0, 0, 0.46);
  --shadow-md: 0 16px 45px rgba(0, 0, 0, 0.25);
  --serif: "Songti SC", "Noto Serif SC", "Source Han Serif SC", "STSong", "SimSun", Georgia, serif;
  --sans: "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", sans-serif;
  --mono: "Cascadia Code", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --radius-lg: 26px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --chat-art: var(--theme-art);
  --chat-art-opacity: 0.06;
  --stage-glow: rgba(227, 185, 124, 0.12);
  --stage-glow-2: rgba(116, 146, 180, 0.08);
  --affinity-color: #cbb9e6;
  --affinity-track: rgba(203, 185, 230, 0.16);
}

[data-theme="light"] {
  --bg: #eee7da;
  --bg-soft: #f5efe4;
  --panel: rgba(255, 252, 246, 0.76);
  --panel-solid: #fbf7ef;
  --panel-raised: #f4ecdf;
  --panel-input: #fffdf8;
  --line: rgba(69, 53, 34, 0.11);
  --line-strong: rgba(69, 53, 34, 0.2);
  --text: #2b241b;
  --text-soft: #4e4336;
  --text-dim: #786b5b;
  --text-faint: #9b8c7a;
  --gold: #a8752f;
  --gold-strong: #8d5d1d;
  --gold-ink: #fff9ef;
  --gold-wash: rgba(168, 117, 47, 0.1);
  --user-bubble: linear-gradient(135deg, #bd8f53, #a17438);
  --user-text: #fff9ef;
  --assistant-bubble: rgba(255, 255, 255, 0.5);
  --danger: #b3544b;
  --danger-wash: rgba(179, 84, 75, 0.08);
  --success: #4f896d;
  --shadow-lg: 0 32px 90px rgba(92, 70, 42, 0.18);
  --shadow-md: 0 16px 45px rgba(92, 70, 42, 0.12);
}

/* --------------------------------------------------------------- theme skins */

:root,
[data-skin="night"] {
  --theme-art: url("/assets/themes/night.svg");
  --theme-art-opacity: 0.48;
  --theme-art-position: center;
  --chat-art-opacity: 0.075;
  --stage-glow: rgba(141, 177, 214, 0.12);
  --stage-glow-2: rgba(227, 185, 124, 0.06);
  --affinity-color: #b7cbe4;
  --affinity-track: rgba(183, 203, 228, 0.15);
}

[data-skin="white"] {
  --theme-art: url("/assets/themes/white.svg");
  --theme-art-opacity: 0.72;
  --theme-art-position: center;
  --chat-art-opacity: 0.04;
  --stage-glow: rgba(157, 116, 58, 0.09);
  --stage-glow-2: rgba(255, 255, 255, 0.22);
  --affinity-color: #9d743a;
  --affinity-track: rgba(157, 116, 58, 0.14);
  --bg: #f7f5ef;
  --bg-soft: #efede5;
  --panel: rgba(255, 255, 255, 0.8);
  --panel-solid: #fffdf9;
  --panel-raised: #f2f0e8;
  --panel-input: #ffffff;
  --line: rgba(46, 44, 37, 0.1);
  --line-strong: rgba(46, 44, 37, 0.19);
  --text: #20211d;
  --text-soft: #45463f;
  --text-dim: #6e6e64;
  --text-faint: #99988d;
  --gold: #9d743a;
  --gold-strong: #7e5928;
  --gold-ink: #fffdf7;
  --gold-wash: rgba(157, 116, 58, 0.1);
  --user-bubble: linear-gradient(135deg, #2b2b26, #4b4a41);
  --user-text: #fffdf7;
  --assistant-bubble: rgba(255, 255, 255, 0.72);
  --danger: #a75047;
  --danger-wash: rgba(167, 80, 71, 0.07);
  --success: #4f8068;
  --shadow-lg: 0 32px 90px rgba(83, 74, 58, 0.16);
  --shadow-md: 0 16px 45px rgba(83, 74, 58, 0.1);
}

[data-skin="columbina"] {
  --theme-art: url("/assets/themes/columbina.webp");
  --theme-art-opacity: 0.34;
  --theme-art-position: center 18%;
  --chat-art-opacity: 0.085;
  --stage-glow: rgba(178, 156, 222, 0.15);
  --stage-glow-2: rgba(121, 168, 218, 0.09);
  --affinity-color: #d6c3f0;
  --affinity-track: rgba(214, 195, 240, 0.16);
  --bg: #07101f;
  --bg-soft: #0b1729;
  --panel: rgba(12, 24, 43, 0.76);
  --panel-solid: #0d1a2c;
  --panel-raised: #14243a;
  --panel-input: #0a1525;
  --line: rgba(195, 218, 246, 0.11);
  --line-strong: rgba(195, 218, 246, 0.22);
  --text: #f4f0fc;
  --text-soft: #d3d3ea;
  --text-dim: #9da8c4;
  --text-faint: #70809e;
  --gold: #cbb9e6;
  --gold-strong: #eadcff;
  --gold-ink: #171026;
  --gold-wash: rgba(203, 185, 230, 0.13);
  --user-bubble: linear-gradient(135deg, #d7caec, #a996ce);
  --user-text: #191326;
  --assistant-bubble: rgba(184, 213, 245, 0.06);
  --danger: #e7a0a8;
  --danger-wash: rgba(231, 160, 168, 0.1);
  --success: #9dc9c2;
  --shadow-lg: 0 32px 90px rgba(0, 4, 12, 0.56);
  --shadow-md: 0 16px 45px rgba(0, 4, 12, 0.32);
}

[data-skin="guofeng"] {
  --theme-art: url("/assets/themes/guofeng.svg");
  --theme-art-opacity: 0.65;
  --theme-art-position: center;
  --chat-art-opacity: 0.05;
  --stage-glow: rgba(156, 59, 47, 0.1);
  --stage-glow-2: rgba(96, 105, 74, 0.08);
  --affinity-color: #9c3b2f;
  --affinity-track: rgba(156, 59, 47, 0.14);
  --bg: #f2ecdf;
  --bg-soft: #e9dfcd;
  --panel: rgba(251, 247, 238, 0.82);
  --panel-solid: #fbf7ed;
  --panel-raised: #efe5d3;
  --panel-input: #fffaf0;
  --line: rgba(55, 45, 35, 0.12);
  --line-strong: rgba(55, 45, 35, 0.22);
  --text: #24231e;
  --text-soft: #4d493f;
  --text-dim: #756d5f;
  --text-faint: #9c9283;
  --gold: #9c3b2f;
  --gold-strong: #76251d;
  --gold-ink: #fff7e8;
  --gold-wash: rgba(156, 59, 47, 0.09);
  --user-bubble: linear-gradient(135deg, #a33d2f, #76251d);
  --user-text: #fff8ec;
  --assistant-bubble: rgba(255, 252, 244, 0.72);
  --danger: #9d3b34;
  --danger-wash: rgba(157, 59, 52, 0.08);
  --success: #4e7c66;
  --shadow-lg: 0 32px 90px rgba(66, 50, 33, 0.16);
  --shadow-md: 0 16px 45px rgba(66, 50, 33, 0.1);
}

[data-skin="butterfly"] {
  --theme-art: url("/assets/themes/butterfly.webp");
  --theme-art-opacity: 0.4;
  --theme-art-position: center;
  --chat-art-opacity: 0.08;
  --stage-glow: rgba(185, 214, 122, 0.12);
  --stage-glow-2: rgba(120, 154, 113, 0.08);
  --affinity-color: #c4dd8b;
  --affinity-track: rgba(196, 221, 139, 0.16);
  --bg: #0b100d;
  --bg-soft: #121813;
  --panel: rgba(18, 25, 20, 0.8);
  --panel-solid: #131b16;
  --panel-raised: #1b261e;
  --panel-input: #0e1510;
  --line: rgba(196, 216, 182, 0.11);
  --line-strong: rgba(196, 216, 182, 0.2);
  --text: #eef2e5;
  --text-soft: #cbd4c0;
  --text-dim: #98a58d;
  --text-faint: #6d7b66;
  --gold: #b9d67a;
  --gold-strong: #d8edaa;
  --gold-ink: #141d0e;
  --gold-wash: rgba(185, 214, 122, 0.12);
  --user-bubble: linear-gradient(135deg, #b9d67a, #8fb24c);
  --user-text: #152008;
  --assistant-bubble: rgba(210, 232, 198, 0.055);
  --danger: #e39a83;
  --danger-wash: rgba(227, 154, 131, 0.1);
  --success: #94c8a8;
  --shadow-lg: 0 32px 90px rgba(0, 0, 0, 0.55);
  --shadow-md: 0 16px 45px rgba(0, 0, 0, 0.3);
}

[data-skin="newyear"] {
  --theme-art: url("/assets/themes/newyear.svg");
  --theme-art-opacity: 0.58;
  --theme-art-position: center;
  --chat-art-opacity: 0.065;
  --stage-glow: rgba(227, 180, 95, 0.14);
  --stage-glow-2: rgba(181, 58, 48, 0.1);
  --affinity-color: #ecc077;
  --affinity-track: rgba(236, 192, 119, 0.16);
  --bg: #210708;
  --bg-soft: #3a0c0e;
  --panel: rgba(47, 11, 13, 0.8);
  --panel-solid: #2c0a0c;
  --panel-raised: #431214;
  --panel-input: #260709;
  --line: rgba(244, 207, 139, 0.13);
  --line-strong: rgba(244, 207, 139, 0.24);
  --text: #fff4df;
  --text-soft: #e8cfaa;
  --text-dim: #c1a27e;
  --text-faint: #8e7258;
  --gold: #e3b45f;
  --gold-strong: #f4d18a;
  --gold-ink: #2b1307;
  --gold-wash: rgba(227, 180, 95, 0.13);
  --user-bubble: linear-gradient(135deg, #e3b45f, #ba7b35);
  --user-text: #2b1307;
  --assistant-bubble: rgba(255, 235, 204, 0.055);
  --danger: #f0a09b;
  --danger-wash: rgba(240, 160, 155, 0.1);
  --success: #a9c7a1;
  --shadow-lg: 0 32px 90px rgba(0, 0, 0, 0.52);
  --shadow-md: 0 16px 45px rgba(0, 0, 0, 0.28);
}

.theme-art {
  position: absolute;
  inset: 0;
  display: block;
  background-image: var(--theme-art);
  background-position: var(--theme-art-position, center);
  background-size: cover;
  background-repeat: no-repeat;
  opacity: var(--theme-art-opacity, 0.4);
  filter: saturate(0.92);
  transition: opacity 0.5s ease, background-image 0.5s ease;
}

.theme-art::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--bg) 42%, transparent), var(--bg) 88%),
    radial-gradient(ellipse 80% 60% at 50% 0%, transparent, color-mix(in srgb, var(--bg) 72%, transparent));
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

[hidden] {
  display: none !important;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

button,
[role="button"],
a,
input,
textarea,
select {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

button:focus-visible,
[role="button"]:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

a {
  color: var(--gold);
  text-underline-offset: 3px;
}

a:hover {
  color: var(--gold-strong);
}

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

::selection {
  background: rgba(227, 185, 124, 0.3);
  color: var(--text);
}

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 99px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-faint);
  background-clip: padding-box;
}

/* ---------------------------------------------------------------- atmosphere */

.ambient {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  background:
    radial-gradient(ellipse 60% 45% at 82% -10%, rgba(202, 153, 91, 0.14), transparent 70%),
    radial-gradient(ellipse 55% 50% at -5% 105%, rgba(94, 119, 111, 0.12), transparent 70%),
    linear-gradient(160deg, var(--bg) 0%, var(--bg-soft) 48%, var(--bg) 100%);
}

.ambient-orb {
  position: absolute;
  display: block;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.55;
  animation: drift 24s ease-in-out infinite alternate;
}

.orb-one {
  width: 40vw;
  height: 40vw;
  right: -8vw;
  top: -12vw;
  background: rgba(191, 137, 76, 0.17);
}

.orb-two {
  width: 35vw;
  height: 35vw;
  left: -10vw;
  bottom: -12vw;
  background: rgba(74, 103, 95, 0.13);
  animation-delay: -8s;
}

.ambient-grain {
  position: absolute;
  inset: 0;
  opacity: 0.18;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.35'/%3E%3C/svg%3E");
  mix-blend-mode: soft-light;
}

@keyframes drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(3vw, 2vw, 0) scale(1.08); }
}

/* -------------------------------------------------------------------- shell */

.app-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 286px minmax(0, 1fr);
  gap: 14px;
  height: 100dvh;
  padding: 14px;
}

.sidebar,
.stage {
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(26px) saturate(115%);
  -webkit-backdrop-filter: blur(26px) saturate(115%);
  box-shadow: var(--shadow-lg);
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 24px 15px 15px;
  border-radius: 24px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--panel-raised) 76%, transparent), var(--panel));
}

.stage {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background:
    radial-gradient(ellipse 65% 40% at 50% -5%, var(--gold-wash), transparent 65%),
    var(--panel);
}

/* Low-weight theme wallpaper: present, but never louder than the conversation. */
.stage::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: var(--chat-art);
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  opacity: var(--chat-art-opacity, 0.06);
  filter: blur(3px) saturate(0.84);
  transform: scale(1.035);
  -webkit-mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.72), transparent 55%, rgba(0, 0, 0, 0.42));
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.72), transparent 55%, rgba(0, 0, 0, 0.42));
}

.stage::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 44% 40% at 78% 10%, var(--stage-glow), transparent 70%),
    radial-gradient(ellipse 32% 32% at 8% 88%, var(--stage-glow-2), transparent 72%);
}

.stage > .topbar {
  position: relative;
  z-index: 5;
}

.stage > .message-list,
.stage > .composer-area {
  position: relative;
  z-index: 1;
}

/* ------------------------------------------------------------------- brand */

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 2px 8px 23px;
}

.brand-seal {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border: 1px solid color-mix(in srgb, var(--gold) 55%, transparent);
  border-radius: 13px;
  color: var(--gold);
  font-family: var(--serif);
  font-size: 21px;
  line-height: 1;
  background: linear-gradient(145deg, var(--gold-wash), transparent 70%);
  box-shadow: inset 0 0 0 3px var(--bg-soft);
}

.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.brand-name {
  font-family: var(--serif);
  font-size: 23px;
  font-weight: 600;
  letter-spacing: 0.16em;
  line-height: 1;
}

.brand-sub {
  color: var(--text-faint);
  font-size: 8.5px;
  font-weight: 600;
  letter-spacing: 0.22em;
}

.new-character {
  justify-content: center;
  margin: 0 2px 24px;
}

/* ------------------------------------------------------------------ buttons */

.button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 10px 16px;
  min-height: 40px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: transform 160ms ease, filter 160ms ease, background 160ms ease, border-color 160ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.06);
}

.button:active:not(:disabled) {
  transform: translateY(0);
}

.button.primary {
  color: var(--gold-ink);
  background: linear-gradient(135deg, var(--gold-strong), var(--gold));
  border-color: color-mix(in srgb, var(--gold-strong) 65%, transparent);
  box-shadow: 0 8px 24px rgba(196, 145, 82, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.32);
}

.button.secondary {
  color: var(--text);
  background: var(--panel-raised);
  border-color: var(--line-strong);
}

.button.danger-button {
  color: #fff8f4;
  background: linear-gradient(135deg, #b5544c, #d56f64);
  border-color: rgba(122, 42, 36, 0.55);
  box-shadow: 0 8px 22px rgba(142, 53, 45, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.button.compact,
.ghost-button.compact {
  min-height: 34px;
  padding: 7px 12px;
  font-size: 12px;
}

.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: transparent;
  color: var(--text-soft);
  font-size: 12.5px;
  transition: background 150ms ease, color 150ms ease, border-color 150ms ease;
}

.ghost-button:hover:not(:disabled) {
  color: var(--text);
  background: var(--gold-wash);
  border-color: color-mix(in srgb, var(--gold) 40%, transparent);
}

.text-button {
  min-height: 32px;
  padding: 5px 4px;
  border: 0;
  background: none;
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.6;
  transition: color 150ms ease;
}

.text-button:hover {
  color: var(--gold);
}

.danger-text {
  color: var(--danger) !important;
}

.danger-text:hover {
  filter: brightness(1.15);
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text-dim);
  transition: color 150ms ease, background 150ms ease, border-color 150ms ease;
}

.icon-button:hover:not(:disabled) {
  color: var(--text);
  background: var(--gold-wash);
  border-color: var(--line);
}

.icon-button svg {
  width: 19px;
  height: 19px;
}

.mini-icon {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text-faint);
  transition: color 150ms ease, background 150ms ease;
}

.mini-icon:hover {
  color: var(--gold);
  background: var(--gold-wash);
}

.mini-icon svg {
  width: 15px;
  height: 15px;
}

/* -------------------------------------------------------------- char library */

.library-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 9px 10px;
  color: var(--text-faint);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.library-tools {
  display: flex;
  align-items: center;
  gap: 4px;
}

.count-badge {
  display: inline-grid;
  place-items: center;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text-dim);
  font-size: 9px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

.character-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 0;
  overflow-y: auto;
  padding: 1px 2px 12px;
  scrollbar-gutter: stable;
}

.character-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  min-height: 58px;
  padding: 8px 9px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: transparent;
  color: var(--text);
  text-align: left;
  transition: background 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.character-card:hover {
  background: color-mix(in srgb, var(--panel-raised) 70%, transparent);
  border-color: var(--line);
}

.character-card.is-active {
  background: linear-gradient(135deg, var(--gold-wash), color-mix(in srgb, var(--panel-raised) 55%, transparent));
  border-color: color-mix(in srgb, var(--gold) 25%, var(--line));
}

.character-card.is-active::before {
  content: "";
  position: absolute;
  left: -1px;
  top: 17px;
  bottom: 17px;
  width: 2px;
  border-radius: 0 2px 2px 0;
  background: var(--gold);
  box-shadow: 0 0 12px color-mix(in srgb, var(--gold) 65%, transparent);
}

.character-card-copy {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.character-card-name {
  overflow: hidden;
  color: var(--text);
  font-family: var(--serif);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.character-card-tag {
  overflow: hidden;
  color: var(--text-faint);
  font-size: 10.5px;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-empty {
  padding: 12px 10px;
  color: var(--text-faint);
  font-size: 11px;
  line-height: 1.7;
}

.sidebar-bottom {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.key-status {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  padding: 8px 9px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text-dim);
  font-size: 11px;
  text-align: left;
  transition: background 150ms ease, border-color 150ms ease;
}

.key-status:hover {
  background: var(--gold-wash);
  border-color: var(--line);
}

.status-dot {
  width: 6px;
  height: 6px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--text-faint);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--text-faint) 12%, transparent);
}

.key-status.is-ready .status-dot {
  background: var(--success);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 14%, transparent);
}

.key-status.is-ready {
  color: var(--text-soft);
}

.key-status-action {
  margin-left: auto;
  color: var(--text-faint);
  font-size: 10px;
}

.sidebar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sidebar-action {
  display: flex;
  flex: 1;
  align-items: center;
  min-height: 40px;
  gap: 8px;
  padding: 10px 9px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text-dim);
  font-size: 11.5px;
  text-align: left;
  transition: background 150ms ease, color 150ms ease, border-color 150ms ease;
}

.sidebar-action:hover {
  color: var(--text);
  background: var(--gold-wash);
  border-color: var(--line);
}

.sidebar-action svg {
  width: 16px;
  height: 16px;
}

.theme-toggle {
  border-color: var(--line);
}

[data-theme="dark"] .icon-sun,
[data-theme="light"] .icon-moon {
  display: none;
}

.local-note {
  margin: 0;
  padding: 0 9px;
  color: var(--text-faint);
  font-size: 9px;
  letter-spacing: 0.02em;
}

/* ------------------------------------------------------------------- avatar */

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.17);
  border-radius: 50%;
  color: rgba(255, 251, 242, 0.94);
  font-family: var(--serif);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0;
  text-shadow: 0 1px 5px rgba(0, 0, 0, 0.24);
  user-select: none;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar.tone-0 { background: linear-gradient(145deg, #99745b, #d0a67d); }
.avatar.tone-1 { background: linear-gradient(145deg, #536f6c, #93b1a8); }
.avatar.tone-2 { background: linear-gradient(145deg, #80606d, #c4969e); }
.avatar.tone-3 { background: linear-gradient(145deg, #625f83, #a6a0c4); }
.avatar.tone-4 { background: linear-gradient(145deg, #8a764c, #c9b077); }
.avatar.tone-5 { background: linear-gradient(145deg, #496478, #8ea9bb); }

.avatar-large {
  width: 86px;
  height: 86px;
  border-radius: 22px;
  font-size: 28px;
}

.current-avatar {
  width: 41px;
  height: 41px;
}

/* ------------------------------------------------------------------ sidebar mobile */

.sidebar-scrim {
  display: none;
}

.mobile-only {
  display: none !important;
}

/* -------------------------------------------------------------------- topbar */

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 76px;
  padding: 13px clamp(17px, 3.4vw, 34px);
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, color-mix(in srgb, var(--panel-solid) 35%, transparent), transparent);
}

.current-identity {
  min-width: 0;
}

.current-identity h1 {
  overflow: hidden;
  margin: 0;
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.035em;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.current-identity p {
  overflow: hidden;
  margin: 3px 0 0;
  color: var(--text-dim);
  font-size: 10.5px;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-spacer {
  flex: 1;
}

.context-meter {
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: 255px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text-faint);
  font-size: 9.5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  cursor: default;
}

.context-bar {
  position: relative;
  display: block;
  width: 64px;
  height: 3px;
  overflow: hidden;
  border-radius: 9px;
  background: var(--line-strong);
}

.context-bar > span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--gold), var(--gold-strong));
  transition: width 300ms ease;
}

.menu-wrap {
  position: relative;
}

.popup-menu {
  position: absolute;
  top: calc(100% + 7px);
  right: 0;
  z-index: 20;
  width: 206px;
  padding: 5px;
  border: 1px solid var(--line-strong);
  border-radius: 13px;
  background: var(--panel-solid);
  box-shadow: var(--shadow-md);
  animation: pop-in 130ms ease-out;
}

.popup-menu button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 40px;
  padding: 10px 11px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-soft);
  font-size: 12px;
  text-align: left;
}

.popup-menu button:hover {
  background: var(--gold-wash);
  color: var(--text);
}

.popup-menu kbd {
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 9px;
}

.menu-divider {
  height: 1px;
  margin: 4px 5px;
  background: var(--line);
}

@keyframes pop-in {
  from { opacity: 0; transform: translateY(-4px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ------------------------------------------------------------------ messages */

.message-list {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 30px clamp(16px, 4vw, 46px) 18px;
  scroll-behavior: smooth;
}

.message-row {
  display: flex;
  gap: 11px;
  width: min(100%, 850px);
  margin: 0 auto 23px;
  animation: message-in 260ms ease-out both;
}

@keyframes message-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.message-row.user {
  justify-content: flex-end;
}

.message-avatar {
  width: 31px;
  height: 31px;
  margin-top: 20px;
  font-size: 11px;
  opacity: 0.9;
}

.message-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
  max-width: min(710px, 86%);
}

.message-row.user .message-stack {
  align-items: flex-end;
  max-width: min(680px, 78%);
}

.message-name {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 6px 2px;
  color: var(--text-faint);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
}

.message-time {
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 8.5px;
  font-weight: 400;
  letter-spacing: 0;
  opacity: 0.75;
}

.message-row.user .message-name {
  margin-right: 2px;
}

.bubble {
  position: relative;
  max-width: 100%;
  padding: 12px 17px;
  border: 1px solid var(--line);
  border-radius: 4px 18px 18px 18px;
  background: var(--assistant-bubble);
  color: var(--text-soft);
  font-family: var(--serif);
  font-size: 15.5px;
  line-height: 1.92;
  letter-spacing: 0.012em;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.message-row.user .bubble {
  padding: 10px 15px;
  border: 0;
  border-radius: 17px 4px 17px 17px;
  background: var(--user-bubble);
  color: var(--user-text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.75;
  letter-spacing: 0;
  box-shadow: 0 7px 20px rgba(142, 100, 56, 0.13);
}

.bubble .act {
  color: var(--text-dim);
  font-style: italic;
}

.pending .bubble::after {
  content: "";
  display: inline-block;
  width: 2px;
  height: 1.05em;
  margin-left: 3px;
  border-radius: 2px;
  background: var(--gold);
  vertical-align: -0.14em;
  animation: blink 1s steps(2, end) infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

.message-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 15px;
  margin-top: 5px;
  padding: 0 3px;
  color: var(--text-faint);
  font-size: 9px;
  font-variant-numeric: tabular-nums;
}

.local-badge {
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--text-faint);
  font-size: 8px;
  letter-spacing: 0.03em;
}

.thinking-block {
  width: 100%;
  margin: 0 0 7px;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  background: color-mix(in srgb, var(--panel-raised) 42%, transparent);
}

.thinking-block summary {
  padding: 7px 11px;
  color: var(--text-faint);
  font-size: 10px;
  cursor: pointer;
  list-style: none;
}

.thinking-block summary::-webkit-details-marker {
  display: none;
}

.thinking-block summary::before {
  content: "◌ ";
  color: var(--gold);
}

.thinking-block[open] summary::before {
  content: "◍ ";
}

.thinking-text {
  max-height: 220px;
  overflow-y: auto;
  padding: 0 11px 10px;
  color: var(--text-faint);
  font-family: var(--sans);
  font-size: 11px;
  line-height: 1.7;
  white-space: pre-wrap;
}

.error-note {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
  margin-top: 7px;
  padding: 9px 11px;
  border: 1px solid color-mix(in srgb, var(--danger) 28%, transparent);
  border-radius: 10px;
  background: var(--danger-wash);
  color: var(--danger);
  font-size: 11px;
  line-height: 1.6;
}

.error-note button {
  margin-left: auto;
  padding: 2px 7px;
  border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent);
  border-radius: 6px;
  background: transparent;
  color: var(--danger);
  font-size: 10px;
}

.error-note button:hover {
  background: color-mix(in srgb, var(--danger) 12%, transparent);
}

/* ----------------------------------------------------------------- empty state */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: min(560px, 100%);
  min-height: 100%;
  margin: 0 auto;
  padding: 28px 12px 36px;
  text-align: center;
  animation: fade-in 450ms ease-out both;
}

.empty-halo {
  position: relative;
  display: grid;
  place-items: center;
  width: 132px;
  height: 132px;
  margin-bottom: 25px;
  border: 1px solid color-mix(in srgb, var(--gold) 23%, transparent);
  border-radius: 50%;
}

.empty-halo::before,
.empty-halo::after {
  content: "";
  position: absolute;
  border: 1px solid var(--line);
  border-radius: 50%;
}

.empty-halo::before {
  inset: 9px;
}

.empty-halo::after {
  inset: -12px;
  border-color: color-mix(in srgb, var(--gold) 9%, transparent);
}

.empty-halo .avatar {
  width: 92px;
  height: 92px;
  border: 1px solid color-mix(in srgb, var(--gold) 32%, transparent);
  border-radius: 30px;
  font-size: 33px;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.22);
}

.empty-kicker,
.eyebrow {
  margin: 0 0 10px;
  color: var(--gold);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.23em;
  text-transform: uppercase;
}

.empty-title {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(28px, 4vw, 39px);
  font-weight: 500;
  letter-spacing: 0.06em;
  line-height: 1.3;
}

.empty-tagline {
  max-width: 430px;
  margin: 13px 0 0;
  color: var(--text-dim);
  font-family: var(--serif);
  font-size: 14px;
  line-height: 1.8;
}

.empty-scenario {
  max-width: 470px;
  margin: 16px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--text-faint);
  font-size: 11px;
  line-height: 1.8;
}

.starter-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 24px;
}

.starter-chip {
  padding: 8px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 99px;
  background: color-mix(in srgb, var(--panel-raised) 45%, transparent);
  color: var(--text-dim);
  font-size: 11px;
  transition: border-color 150ms ease, color 150ms ease, background 150ms ease, transform 150ms ease;
}

.starter-chip:hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--gold) 45%, transparent);
  background: var(--gold-wash);
  color: var(--text);
}

.empty-note {
  margin: 20px 0 0;
  color: var(--text-faint);
  font-size: 9px;
  letter-spacing: 0.02em;
}

.onboarding-seal {
  display: grid;
  place-items: center;
  width: 92px;
  height: 92px;
  margin-bottom: 26px;
  border: 1px solid color-mix(in srgb, var(--gold) 40%, transparent);
  border-radius: 28px;
  color: var(--gold);
  font-family: var(--serif);
  font-size: 38px;
  background:
    linear-gradient(145deg, var(--gold-wash), transparent),
    var(--panel-raised);
  box-shadow: inset 0 0 0 5px var(--panel-solid), 0 20px 50px rgba(0, 0, 0, 0.17);
}

.onboarding-copy {
  max-width: 390px;
  margin: 13px 0 0;
  color: var(--text-dim);
  font-size: 12.5px;
  line-height: 1.85;
}

.onboarding-steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  width: min(440px, 100%);
  margin: 26px 0 22px;
}

.onboarding-step {
  padding: 12px 9px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--panel-raised) 38%, transparent);
  text-align: left;
}

.onboarding-step .step-number {
  display: block;
  margin-bottom: 5px;
  color: var(--gold);
  font-family: var(--mono);
  font-size: 9px;
}

.onboarding-step strong {
  display: block;
  color: var(--text-soft);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.45;
}

.onboarding-step small {
  display: block;
  margin-top: 4px;
  color: var(--text-faint);
  font-size: 8.5px;
  line-height: 1.5;
}

.empty-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.preset-start {
  width: min(480px, 100%);
  margin-top: 24px;
  padding-top: 19px;
  border-top: 1px solid var(--line);
}

.preset-start-label {
  margin: 0 0 9px;
  color: var(--text-faint);
  font-size: 9px;
  letter-spacing: 0.1em;
}

.preset-gallery {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.preset-card {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: color-mix(in srgb, var(--panel-raised) 42%, transparent);
  color: var(--text-soft);
  text-align: left;
  transition: border-color 150ms ease, background 150ms ease, transform 150ms ease;
}

.preset-card:hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--gold) 42%, transparent);
  background: var(--gold-wash);
}

.preset-avatar {
  width: 34px;
  height: 34px;
  font-size: 12px;
}

.preset-card-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.preset-card-copy strong {
  overflow: hidden;
  color: var(--text);
  font-family: var(--serif);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preset-card-copy small {
  overflow: hidden;
  color: var(--text-faint);
  font-size: 8.5px;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.key-warning {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 18px;
  padding: 6px 10px;
  border: 1px solid color-mix(in srgb, var(--gold) 26%, transparent);
  border-radius: 7px;
  background: var(--gold-wash);
  color: var(--gold);
  font-size: 9.5px;
  cursor: pointer;
}

/* ------------------------------------------------------------------ composer */

.composer-area {
  position: relative;
  padding: 5px clamp(15px, 4vw, 38px) 16px;
  background: linear-gradient(180deg, transparent, color-mix(in srgb, var(--panel-solid) 62%, transparent) 45%);
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  width: min(850px, 100%);
  margin: 0 auto;
  padding: 7px 8px 7px 17px;
  border: 1px solid var(--line-strong);
  border-radius: 19px;
  background: color-mix(in srgb, var(--panel-input) 86%, transparent);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.13), inset 0 1px 0 color-mix(in srgb, white 4%, transparent);
  transition: border-color 170ms ease, box-shadow 170ms ease;
}

.composer:focus-within {
  border-color: color-mix(in srgb, var(--gold) 45%, var(--line));
  box-shadow: 0 12px 38px rgba(0, 0, 0, 0.16), 0 0 0 3px color-mix(in srgb, var(--gold) 8%, transparent);
}

.composer textarea {
  flex: 1;
  min-width: 0;
  max-height: 165px;
  min-height: 28px;
  margin: 6px 0;
  padding: 0 4px 0 0;
  overflow-y: auto;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  line-height: 1.65;
  resize: none;
}

.composer textarea::placeholder {
  color: var(--text-faint);
}

.send-button {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--gold-strong) 55%, transparent);
  border-radius: 13px;
  background: linear-gradient(140deg, var(--gold-strong), var(--gold));
  color: var(--gold-ink);
  box-shadow: 0 7px 18px rgba(183, 133, 71, 0.22);
  transition: transform 150ms ease, filter 150ms ease;
}

.send-button:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.06);
}

.send-button svg {
  width: 19px;
  height: 19px;
  stroke-width: 2;
}

.stop-button {
  border-color: var(--line-strong);
  background: var(--panel-raised);
  color: var(--danger);
  box-shadow: none;
}

.stop-button span {
  display: block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: currentColor;
}

.composer-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: min(850px, 100%);
  margin: 7px auto 0;
  padding: 0 5px;
  color: var(--text-faint);
  font-size: 9px;
  line-height: 1.5;
}

.composer-foot kbd {
  font-family: var(--mono);
  font-size: 8px;
  color: var(--text-dim);
}

#usageSummary {
  overflow: hidden;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.config-notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: min(850px, 100%);
  margin: 0 auto 7px;
  padding: 8px 12px;
  border: 1px solid color-mix(in srgb, var(--gold) 25%, transparent);
  border-radius: 9px;
  background: var(--gold-wash);
  color: var(--gold);
  font-size: 10.5px;
  text-align: left;
}

.notice-action {
  flex: 0 0 auto;
  opacity: 0.8;
}

.jump-bottom {
  position: absolute;
  left: 50%;
  bottom: 134px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 4px;
  transform: translateX(-50%);
  padding: 6px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 99px;
  background: var(--panel-solid);
  color: var(--text-dim);
  font-size: 10px;
  box-shadow: var(--shadow-md);
}

.jump-bottom:hover {
  color: var(--gold);
}

.jump-bottom svg {
  width: 13px;
  height: 13px;
}

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

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
}

.overlay-scrim {
  position: absolute;
  inset: 0;
  background: rgba(3, 6, 8, 0.63);
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
  animation: fade-in 180ms ease-out;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.overlay.right {
  align-items: stretch;
  justify-content: flex-end;
  padding: 0;
}

.overlay.center {
  z-index: 60;
}

.drawer {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(460px, 100%);
  height: 100%;
  border-left: 1px solid var(--line-strong);
  background: var(--panel-solid);
  box-shadow: -25px 0 80px rgba(0, 0, 0, 0.28);
  animation: drawer-in 220ms cubic-bezier(0.22, 0.8, 0.25, 1);
}

@keyframes drawer-in {
  from { transform: translateX(26px); opacity: 0.5; }
  to { transform: translateX(0); opacity: 1; }
}

.drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 25px 25px 19px;
  border-bottom: 1px solid var(--line);
}

.drawer-head .eyebrow {
  margin-bottom: 7px;
}

.drawer-head h2,
.small-modal-head h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: 0.04em;
}

.drawer-scroll,
.drawer-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 0 25px calc(32px + env(safe-area-inset-bottom));
}

.drawer-body {
  padding-inline: 20px;
}

.setting-section {
  padding: 21px 0 23px;
  border-bottom: 1px solid var(--line);
}

.setting-section:last-child {
  border-bottom: 0;
}

.setting-section h3 {
  margin: 0;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: 99px;
  color: var(--text-dim);
  font-size: 8px;
  white-space: nowrap;
}

.pill.subtle {
  color: var(--text-faint);
}

.pill.warm {
  border-color: color-mix(in srgb, var(--gold) 25%, transparent);
  background: var(--gold-wash);
  color: var(--gold);
}

.field-label {
  display: block;
  margin: 0 0 7px;
  color: var(--text-dim);
  font-size: 10.5px;
}

.key-input-row {
  display: flex;
  gap: 6px;
}

input[type="text"],
input[type="password"],
input[type="number"],
select,
.field input,
.field textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--panel-input);
  color: var(--text);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

input[type="text"],
input[type="password"],
input[type="number"],
select {
  height: 38px;
  padding: 0 11px;
  font-size: 12px;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
select:focus,
.field input:focus,
.field textarea:focus {
  outline: 0;
  border-color: color-mix(in srgb, var(--gold) 55%, var(--line));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 8%, transparent);
}

.key-input-row input {
  flex: 1;
  min-width: 0;
  font-family: var(--mono);
  font-size: 11px;
}

.inline-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 9px;
}

.inline-status {
  color: var(--text-faint);
  font-size: 10px;
  line-height: 1.4;
}

.inline-status.is-ok {
  color: var(--success);
}

.inline-status.is-error {
  color: var(--danger);
}

.inline-status.is-loading {
  color: var(--gold);
}

.hint {
  margin: 9px 0 0;
  color: var(--text-faint);
  font-size: 9.5px;
  line-height: 1.7;
}

.default-key-hint {
  padding: 7px 9px;
  border: 1px solid rgba(135, 200, 179, 0.18);
  border-radius: 7px;
  background: rgba(135, 200, 179, 0.06);
  color: var(--text-dim);
  font-size: 9px;
}

.default-key-hint.is-warning {
  border-color: color-mix(in srgb, var(--gold) 26%, transparent);
  background: var(--gold-wash);
  color: color-mix(in srgb, var(--gold) 80%, var(--text-soft));
}

.hint a {
  display: inline-block;
  margin-left: 4px;
}

.warning-hint {
  color: color-mix(in srgb, var(--gold) 65%, var(--text-faint));
}

select {
  padding-right: 30px;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-dim) 50%), linear-gradient(135deg, var(--text-dim) 50%, transparent 50%);
  background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%;
  background-repeat: no-repeat;
  background-size: 5px 5px, 5px 5px;
}

.range-field {
  margin-top: 19px;
}

.range-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
}

.range-head label {
  color: var(--text-soft);
  font-size: 10.5px;
}

.range-head output {
  color: var(--gold);
  font-family: var(--mono);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.hint-inline {
  margin-left: 5px;
  color: var(--text-faint);
  font-size: 8.5px;
}

input[type="range"] {
  width: 100%;
  height: 16px;
  margin: 0;
  appearance: none;
  background: transparent;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 4px;
  background: linear-gradient(to right, var(--gold) var(--fill, 50%), var(--line-strong) var(--fill, 50%));
}

input[type="range"]::-moz-range-track {
  height: 3px;
  border-radius: 4px;
  background: var(--line-strong);
}

input[type="range"]::-moz-range-progress {
  height: 3px;
  border-radius: 4px;
  background: var(--gold);
}

input[type="range"]::-webkit-slider-thumb {
  width: 13px;
  height: 13px;
  margin-top: -5px;
  appearance: none;
  border: 2px solid var(--panel-solid);
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--gold) 60%, transparent);
}

input[type="range"]::-moz-range-thumb {
  width: 11px;
  height: 11px;
  border: 2px solid var(--panel-solid);
  border-radius: 50%;
  background: var(--gold);
}

input[type="range"]:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.range-scale {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  color: var(--text-faint);
  font-size: 8.5px;
}

.two-ranges {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 17px;
}

.segmented-field {
  margin: 20px 0 0;
  padding: 0;
  border: 0;
}

.segmented-field legend {
  margin-bottom: 9px;
  color: var(--text-soft);
  font-size: 10.5px;
}

.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-input);
}

.segmented label {
  position: relative;
  cursor: pointer;
}

.segmented input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.segmented span {
  display: block;
  padding: 7px 5px;
  border-radius: 7px;
  color: var(--text-faint);
  font-size: 10.5px;
  text-align: center;
  transition: color 150ms ease, background 150ms ease;
}

.segmented input:checked + span {
  background: var(--gold-wash);
  color: var(--gold);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--gold) 22%, transparent);
}

.segmented input:focus-visible + span {
  outline: 2px solid var(--gold);
  outline-offset: -2px;
}

.saving-card {
  display: flex;
  gap: 11px;
  margin-top: 21px;
  padding: 13px;
  border: 1px solid color-mix(in srgb, var(--gold) 17%, var(--line));
  border-radius: 11px;
  background: linear-gradient(135deg, var(--gold-wash), transparent);
}

.saving-card svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  margin-top: 1px;
  color: var(--gold);
}

.saving-card strong {
  display: block;
  margin-bottom: 3px;
  color: var(--text-soft);
  font-size: 10.5px;
  font-weight: 600;
}

.saving-card p {
  margin: 0;
  color: var(--text-faint);
  font-size: 9.5px;
  line-height: 1.65;
}

.usage-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
}

.usage-grid > div {
  padding: 10px 8px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: color-mix(in srgb, var(--panel-input) 55%, transparent);
}

.usage-grid span {
  display: block;
  margin-bottom: 4px;
  color: var(--text-faint);
  font-size: 8.5px;
}

.usage-grid strong {
  color: var(--text-soft);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.privacy-section p {
  margin: 9px 0 0;
  color: var(--text-dim);
  font-size: 10px;
  line-height: 1.75;
}

.privacy-section code {
  padding: 1px 4px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel-input);
  font-family: var(--mono);
  font-size: 9px;
}

/* ------------------------------------------------------------------- editor */

.editor-overlay {
  padding: 24px;
}

.editor-modal {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(1130px, 100%);
  height: min(900px, calc(100dvh - 48px));
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 24px;
  background: var(--panel-solid);
  box-shadow: var(--shadow-lg);
  animation: modal-in 220ms cubic-bezier(0.22, 0.8, 0.25, 1);
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(12px) scale(0.992); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.editor-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 26px 17px;
  border-bottom: 1px solid var(--line);
}

.editor-heading .eyebrow {
  margin-bottom: 6px;
}

.editor-heading h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 500;
  letter-spacing: 0.04em;
}

.editor-head-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.preset-select {
  width: auto;
  min-width: 124px;
  height: 34px;
  padding: 5px 29px 5px 11px;
  border-color: var(--line-strong);
  border-radius: 10px;
  background-color: transparent;
  color: var(--text-soft);
  font-size: 11.5px;
  cursor: pointer;
}

.preset-select:hover {
  border-color: color-mix(in srgb, var(--gold) 40%, var(--line));
  color: var(--text);
}

.editor-body {
  display: grid;
  grid-template-columns: 208px minmax(0, 1fr);
  flex: 1;
  min-height: 0;
}

.editor-tabs {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 20px 13px;
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel-raised) 35%, transparent);
}

.editor-tab {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  width: 100%;
  padding: 11px 10px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  color: var(--text-faint);
  text-align: left;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
}

.editor-tab:hover {
  background: var(--gold-wash);
  color: var(--text-soft);
}

.editor-tab.is-active {
  border-color: color-mix(in srgb, var(--gold) 20%, var(--line));
  background: var(--gold-wash);
  color: var(--text);
}

.tab-number {
  margin-top: 2px;
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 8.5px;
}

.editor-tab.is-active .tab-number {
  color: var(--gold);
}

.editor-tab span:last-child {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.editor-tab strong {
  font-family: var(--serif);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.05em;
}

.editor-tab small {
  color: var(--text-faint);
  font-size: 8.5px;
  line-height: 1.4;
}

.editor-tip {
  margin-top: auto;
  padding: 13px 11px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: color-mix(in srgb, var(--panel-input) 50%, transparent);
}

.editor-tip span {
  display: block;
  margin-bottom: 5px;
  color: var(--gold);
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.15em;
}

.editor-tip p {
  margin: 0;
  color: var(--text-faint);
  font-size: 9px;
  line-height: 1.7;
}

.character-form {
  min-height: 0;
}

.editor-scroll {
  height: 100%;
  overflow-y: auto;
  padding: 25px clamp(22px, 4vw, 48px) 45px;
  scroll-behavior: smooth;
}

.form-panel {
  display: none;
  animation: fade-in 180ms ease-out;
}

.form-panel.is-active {
  display: block;
}

.panel-heading {
  margin-bottom: 23px;
}

.panel-heading h3 {
  margin: 0 0 7px;
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: 0.04em;
}

.panel-heading p {
  margin: 0;
  color: var(--text-dim);
  font-size: 11px;
  line-height: 1.7;
}

.avatar-editor {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 26px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: color-mix(in srgb, var(--panel-raised) 36%, transparent);
}

.avatar-pick {
  position: relative;
  flex: 0 0 auto;
  padding: 0;
  border: 0;
  border-radius: 22px;
  background: transparent;
}

.avatar-pick:hover .avatar {
  filter: brightness(1.08);
}

.avatar-badge {
  position: absolute;
  right: -4px;
  bottom: -4px;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 2px solid var(--panel-solid);
  border-radius: 50%;
  background: var(--gold);
  color: var(--gold-ink);
  font-size: 8px;
  font-weight: 700;
}

.avatar-copy {
  padding-top: 4px;
}

.avatar-copy strong {
  display: block;
  margin-bottom: 4px;
  font-size: 11.5px;
  font-weight: 600;
}

.avatar-copy p {
  margin: 0 0 5px;
  color: var(--text-faint);
  font-size: 9.5px;
  line-height: 1.6;
}

.avatar-copy .hint {
  margin: 7px 0 8px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 17px 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
}

.field.full {
  grid-column: 1 / -1;
}

.field > span {
  display: flex;
  align-items: baseline;
  gap: 7px;
  color: var(--text-soft);
  font-size: 10.5px;
  font-weight: 500;
}

.field > span b {
  color: var(--gold);
  font-weight: 500;
}

.field > span em {
  color: var(--text-faint);
  font-size: 8.5px;
  font-style: normal;
  font-weight: 400;
}

.field input,
.field textarea {
  padding: 9px 11px;
  font-size: 12px;
  line-height: 1.7;
}

.field input {
  height: 38px;
}

.field textarea {
  min-height: 64px;
  overflow-y: auto;
  resize: vertical;
}

.field input::placeholder,
.field textarea::placeholder {
  color: var(--text-faint);
  opacity: 0.8;
}

.field small {
  color: var(--text-faint);
  font-size: 8.5px;
  line-height: 1.6;
}

.form-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 26px 0 18px;
  color: var(--text-faint);
  font-size: 8.5px;
  letter-spacing: 0.14em;
}

.form-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.editor-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 66px;
  padding: 12px 26px;
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel-solid) 82%, var(--panel-raised));
}

.editor-token-state {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 11px;
  color: var(--text-faint);
  font-size: 9.5px;
}

#editorTokenHint {
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 9px;
}

.editor-actions {
  display: flex;
  align-items: center;
  gap: 13px;
}

/* --------------------------------------------------------------- small modals */

.small-modal {
  position: relative;
  width: min(620px, 100%);
  max-height: min(760px, calc(100dvh - 44px));
  padding: 24px;
  overflow-y: auto;
  border: 1px solid var(--line-strong);
  border-radius: 19px;
  background: var(--panel-solid);
  box-shadow: var(--shadow-lg);
  animation: modal-in 180ms ease-out;
}

.small-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.small-modal-head .eyebrow {
  margin-bottom: 6px;
}

.prompt-meta {
  margin: 0 0 12px;
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 9.5px;
  line-height: 1.7;
}

.prompt-text {
  max-height: min(52vh, 460px);
  margin: 0;
  padding: 15px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--panel-input);
  color: var(--text-soft);
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 1.8;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.confirm-modal {
  width: min(370px, 100%);
  padding: 25px;
}

.confirm-modal h2 {
  margin: 0 0 9px;
  font-family: var(--serif);
  font-size: 21px;
  font-weight: 500;
}

.confirm-modal p {
  margin: 0;
  color: var(--text-dim);
  font-size: 11.5px;
  line-height: 1.8;
  white-space: pre-line;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 23px;
}

/* --------------------------------------------------------------------- toasts */

.toast-container {
  position: fixed;
  left: 50%;
  top: 92px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  max-width: min(480px, calc(100vw - 32px));
  padding: 10px 15px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--panel-solid);
  color: var(--text-soft);
  font-size: 11px;
  line-height: 1.5;
  text-align: center;
  box-shadow: var(--shadow-md);
  animation: toast-in 200ms ease-out both;
}

.toast.is-error {
  border-color: color-mix(in srgb, var(--danger) 38%, transparent);
  color: var(--danger);
}

.toast.is-success {
  border-color: color-mix(in srgb, var(--success) 35%, transparent);
  color: var(--success);
}

.toast.is-leaving {
  animation: toast-out 220ms ease-in both;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes toast-out {
  to { opacity: 0; transform: translateY(5px); }
}

/* ------------------------------------------------------------------ responsive */

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 244px minmax(0, 1fr);
    gap: 10px;
    padding: 10px;
  }

  .sidebar {
    padding: 20px 12px 12px;
  }

  .brand {
    padding-left: 5px;
  }

  .brand-name {
    font-size: 21px;
  }

  .topbar {
    padding-inline: 20px;
  }

  .editor-body {
    grid-template-columns: 178px minmax(0, 1fr);
  }

  .editor-tabs {
    padding-inline: 9px;
  }

  .editor-tab {
    gap: 7px;
    padding: 10px 8px;
  }

  .editor-tip {
    display: none;
  }

  .context-meter {
    max-width: 200px;
  }
}

@media (max-width: 780px) {
  .app-shell {
    display: block;
    height: 100dvh;
    padding: 0;
  }

  .stage {
    height: 100dvh;
    border: 0;
    border-radius: 0;
  }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 40;
    width: min(292px, 86vw);
    border-radius: 0 22px 22px 0;
    border-left: 0;
    transform: translateX(-102%);
    transition: transform 230ms cubic-bezier(0.22, 0.8, 0.25, 1);
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-scrim {
    position: fixed;
    inset: 0;
    z-index: 31;
    display: block;
    background: rgba(0, 0, 0, 0.52);
    backdrop-filter: blur(4px);
  }

  .mobile-only {
    display: inline-grid !important;
  }

  .topbar {
    min-height: 68px;
    padding: 11px 14px;
    gap: 9px;
  }

  .current-avatar {
    width: 37px;
    height: 37px;
  }

  .current-identity h1 {
    font-size: 16px;
  }

  .current-identity p {
    max-width: 46vw;
    font-size: 9.5px;
  }

  .context-meter {
    display: none;
  }

  .message-list {
    padding: 22px 14px 14px;
  }

  .message-row {
    gap: 8px;
    margin-bottom: 19px;
  }

  .message-avatar {
    width: 28px;
    height: 28px;
    margin-top: 19px;
    font-size: 10px;
  }

  .message-stack {
    max-width: calc(100% - 38px);
  }

  .message-row.user .message-stack {
    max-width: 86%;
  }

  .bubble {
    padding: 11px 14px;
    font-size: 15px;
    line-height: 1.86;
  }

  .composer-area {
    padding: 5px 12px calc(10px + env(safe-area-inset-bottom));
  }

  .composer {
    padding-left: 14px;
  }

  .composer-foot {
    padding-inline: 3px;
  }

  .composer-foot > span:first-child {
    display: none;
  }

  .composer-foot {
    justify-content: flex-end;
  }

  .jump-bottom {
    bottom: 126px;
  }

  .overlay.editor-overlay {
    padding: 0;
  }

  .editor-modal {
    width: 100%;
    height: 100dvh;
    max-height: none;
    border: 0;
    border-radius: 0;
  }

  .editor-head {
    padding: 17px 16px 13px;
  }

  .editor-heading h2 {
    font-size: 21px;
  }

  .preset-select {
    min-width: 104px;
    max-width: 124px;
    font-size: 10.5px;
  }

  .editor-body {
    display: flex;
    flex-direction: column;
  }

  .editor-tabs {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 2px;
    padding: 7px 9px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .editor-tab {
    justify-content: center;
    gap: 0;
    padding: 7px 3px;
    text-align: center;
  }

  .editor-tab .tab-number,
  .editor-tab small {
    display: none;
  }

  .editor-tab strong {
    font-family: var(--sans);
    font-size: 11.5px;
  }

  .character-form {
    flex: 1;
    min-height: 0;
  }

  .editor-scroll {
    padding: 20px 16px 35px;
  }

  .form-grid {
    grid-template-columns: 1fr;
    gap: 15px;
  }

  .field.full {
    grid-column: auto;
  }

  .avatar-editor {
    gap: 13px;
    padding: 12px;
  }

  .avatar-large {
    width: 68px;
    height: 68px;
    border-radius: 18px;
    font-size: 23px;
  }

  .avatar-copy p {
    font-size: 9px;
  }

  .avatar-copy .hint {
    display: none;
  }

  .editor-foot {
    flex-wrap: wrap;
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
    gap: 8px;
  }

  .editor-token-state {
    width: 100%;
    justify-content: space-between;
    gap: 6px;
  }

  .editor-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .editor-actions .button.primary {
    flex: 1;
    justify-content: center;
  }

  .drawer {
    width: 100%;
  }

  .drawer-head {
    padding: 19px 17px 15px;
  }

  .drawer-scroll {
    padding-inline: 17px;
  }

  .small-modal {
    padding: 19px;
    max-height: calc(100dvh - 28px);
  }

  .toast-container {
    top: 76px;
    bottom: auto;
  }

  .overlay {
    padding: 14px;
  }

  .overlay.center {
    padding: 14px;
  }

  .empty-state {
    padding-top: 12px;
  }

  .empty-halo {
    width: 112px;
    height: 112px;
    margin-bottom: 22px;
  }

  .empty-halo .avatar {
    width: 78px;
    height: 78px;
    border-radius: 26px;
    font-size: 28px;
  }

  .onboarding-steps {
    grid-template-columns: 1fr;
    width: min(320px, 100%);
    gap: 5px;
    margin: 20px 0 18px;
  }

  .onboarding-step {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 11px;
  }

  .onboarding-step .step-number {
    margin: 0;
  }
}

@media (max-width: 420px) {
  .editor-head-actions .ghost-button {
    display: none;
  }

  .preset-gallery {
    grid-template-columns: 1fr;
  }

  .editor-actions #exportCharacterBtn {
    display: none !important;
  }

  .starter-list {
    gap: 6px;
  }

  .starter-chip {
    padding: 7px 10px;
    font-size: 10px;
  }

  .current-identity p {
    max-width: 40vw;
  }
}

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

/* --------------------------------------------------------------- auth & sync */

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  overflow-y: auto;
  padding: 28px 18px;
  background:
    radial-gradient(ellipse 60% 45% at 50% 0%, rgba(227, 185, 124, 0.12), transparent 65%),
    linear-gradient(160deg, var(--bg) 0%, var(--bg-soft) 52%, var(--bg) 100%);
}

.auth-gate[hidden] {
  display: none;
}

.auth-gate::before,
.auth-gate::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.auth-gate::before {
  background-image: var(--theme-art);
  background-position: var(--theme-art-position, center);
  background-size: cover;
  opacity: var(--theme-art-opacity, 0.4);
  filter: saturate(0.9);
}

.auth-gate::after {
  background:
    linear-gradient(160deg, color-mix(in srgb, var(--bg) 28%, transparent), color-mix(in srgb, var(--bg) 88%, transparent)),
    radial-gradient(ellipse 70% 55% at 50% 0%, transparent, color-mix(in srgb, var(--bg) 58%, transparent));
}

.auth-gate > .auth-card,
.auth-gate > .auth-orbs {
  position: relative;
  z-index: 1;
}

.auth-orbs {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.auth-orbs span {
  position: absolute;
  width: 50vw;
  height: 50vw;
  min-width: 360px;
  min-height: 360px;
  border-radius: 50%;
  filter: blur(95px);
  opacity: 0.22;
}

.auth-orbs span:first-child {
  top: -22%;
  left: -10%;
  background: #537c78;
}

.auth-orbs span:last-child {
  right: -15%;
  bottom: -30%;
  background: #8c6b3e;
}

.auth-card {
  position: relative;
  width: min(460px, 100%);
  padding: 28px 30px 22px;
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  background: color-mix(in srgb, var(--panel-solid) 90%, transparent);
  box-shadow: 0 36px 90px rgba(0, 0, 0, 0.48);
  backdrop-filter: blur(24px);
  animation: auth-rise 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes auth-rise {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 26px;
}

.auth-brand > div:last-child {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.auth-card h1 {
  margin: 5px 0 12px;
  color: var(--text);
  font-family: var(--serif);
  font-size: clamp(29px, 5vw, 38px);
  font-weight: 500;
  letter-spacing: -0.06em;
  line-height: 1.18;
}

.auth-lead {
  margin: 0 0 20px;
  color: var(--text-dim);
  font-size: 10px;
  line-height: 1.8;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.auth-field > span {
  color: var(--text-soft);
  font-size: 9px;
}

.auth-field > input,
.auth-input-row {
  display: flex;
  align-items: stretch;
  overflow: hidden;
  width: 100%;
  min-height: 42px;
  padding: 11px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  outline: 0;
  background: var(--panel-input);
  color: var(--text);
  font-family: inherit;
  font-size: 11px;
}

.auth-input-row {
  padding: 0;
}

.auth-field > input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-wash);
}

.auth-field > input::placeholder {
  color: var(--text-faint);
}

.auth-input-row:focus-within {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-wash);
}

.auth-input-row input {
  flex: 1;
  min-width: 0;
  padding: 11px 12px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 11px;
}

.auth-input-row input::placeholder {
  color: var(--text-faint);
}

.auth-inline-button {
  flex: 0 0 auto;
  padding: 0 12px;
  border: 0;
  border-left: 1px solid var(--line);
  background: var(--gold-wash);
  color: var(--gold);
  font-size: 9px;
  cursor: pointer;
}

.auth-inline-button:disabled {
  color: var(--text-faint);
  cursor: default;
}

.auth-consent {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: var(--text-faint);
  font-size: 8px;
  line-height: 1.65;
  cursor: pointer;
}

.auth-consent input {
  flex: 0 0 auto;
  margin-top: 2px;
  accent-color: var(--gold);
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin: 0 0 13px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel-input);
}

.auth-tab {
  min-height: 38px;
  padding: 9px 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-faint);
  font-family: inherit;
  font-size: 9px;
  cursor: pointer;
}

.auth-tab.is-active {
  background: var(--gold-wash);
  color: var(--gold);
}

.auth-consent-strong {
  margin: 13px 0 3px;
  padding: 9px 10px;
  border: 1px solid color-mix(in srgb, var(--danger) 24%, var(--line));
  border-radius: 8px;
  background: color-mix(in srgb, var(--danger-wash) 55%, transparent);
  color: var(--text-dim);
}

.auth-consent-strong strong {
  color: var(--danger);
}

.auth-submit {
  width: 100%;
  margin-top: 3px;
  padding: 11px;
  font-size: 10px;
}

#idRevealOverlay {
  z-index: 1300;
}

.id-reveal-modal {
  max-width: 430px;
}

.id-reveal-modal h2 {
  margin: 4px 0 8px;
}

.id-reveal-modal p {
  color: var(--text-dim);
  font-size: 9.5px;
  line-height: 1.8;
}

.id-reveal-code {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 14px 0;
  padding: 12px;
  border: 1px solid color-mix(in srgb, var(--gold) 40%, var(--line));
  border-radius: 9px;
  background: var(--gold-wash);
}

.id-reveal-code code {
  flex: 1;
  color: var(--gold);
  font-family: var(--mono);
  font-size: 14px;
  letter-spacing: 0.04em;
  word-break: break-all;
}

.account-id-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-input);
}

.account-id-box code {
  color: var(--gold);
  font-family: var(--mono);
  font-size: 11px;
  word-break: break-all;
}

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

.theme-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-input);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  overflow: hidden;
}

.theme-card:hover {
  border-color: color-mix(in srgb, var(--gold) 40%, var(--line));
}

.theme-card.is-active {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px var(--gold-wash);
}

.theme-thumb {
  display: block;
  height: 64px;
  border-radius: 6px;
  background: var(--thumb, linear-gradient(135deg, var(--panel-raised), var(--bg)));
  background-size: cover;
  background-position: center;
}

.theme-card-copy {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px;
}

.theme-card-copy strong {
  font-size: 9px;
  font-weight: 600;
}

.theme-card-copy small {
  color: var(--text-faint);
  font-size: 7px;
}

.account-drawer .field-label {
  display: block;
  margin-top: 12px;
}

.auth-error {
  margin: 0;
  color: var(--danger);
  font-size: 9px;
  line-height: 1.6;
}

.auth-notice {
  margin: 0;
  color: var(--mint);
  font-size: 9px;
  line-height: 1.6;
}

.auth-foot,
.auth-copyright {
  margin: 18px 0 0;
  color: var(--text-faint);
  font-size: 7.5px;
  line-height: 1.75;
  text-align: center;
}

.auth-copyright {
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.account-button {
  display: flex;
  align-items: center;
  min-height: 36px;
  gap: 7px;
  padding: 3px 8px 3px 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--panel-raised) 55%, transparent);
  color: var(--text-dim);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.account-button:hover {
  border-color: color-mix(in srgb, var(--gold) 38%, var(--line));
  background: var(--gold-wash);
}

.account-avatar {
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), #98733f);
  color: var(--gold-ink);
  font-family: var(--serif);
  font-size: 11px;
  font-weight: 600;
}

.account-btn-name {
  max-width: 110px;
  overflow: hidden;
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sync-state-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 2px 5px;
  color: var(--text-faint);
  font-size: 7.5px;
}

.sync-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-faint);
  flex: 0 0 auto;
}

.sync-dot.is-synced {
  background: var(--mint);
  box-shadow: 0 0 6px color-mix(in srgb, var(--mint) 60%, transparent);
}

.sync-dot.is-syncing {
  background: var(--gold);
  animation: sync-pulse 1s ease-in-out infinite;
}

.sync-dot.is-error {
  background: var(--danger);
}

@keyframes sync-pulse {
  50% { opacity: 0.28; }
}

.account-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.account-summary strong,
.account-summary small {
  display: block;
}

.account-summary strong {
  color: var(--text);
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 500;
}

.account-summary small {
  margin-top: 3px;
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 8px;
}

.account-avatar-large {
  width: 46px;
  height: 46px;
  font-size: 17px;
}

.account-drawer .inline-actions {
  flex-wrap: wrap;
}

/* --------------------------------------------------------- affinity & identity */

[data-tone="hostile"],
.affinity-pill[data-tone="hostile"],
.identity-current[data-tone="hostile"] {
  --affinity-color: #e36f68;
  --affinity-track: rgba(227, 111, 104, 0.2);
}

[data-tone="disgust"],
.affinity-pill[data-tone="disgust"],
.identity-current[data-tone="disgust"] {
  --affinity-color: #d98c73;
  --affinity-track: rgba(217, 140, 115, 0.18);
}

[data-tone="resent"],
.affinity-pill[data-tone="resent"],
.identity-current[data-tone="resent"] {
  --affinity-color: #c7a17b;
  --affinity-track: rgba(199, 161, 123, 0.17);
}

[data-tone="neutral"],
.affinity-pill[data-tone="neutral"],
.identity-current[data-tone="neutral"] {
  --affinity-color: #a7b0b8;
  --affinity-track: rgba(167, 176, 184, 0.16);
}

[data-tone="cold"],
.affinity-pill[data-tone="cold"],
.identity-current[data-tone="cold"] {
  --affinity-color: #96a4b4;
  --affinity-track: rgba(150, 164, 180, 0.16);
}

[data-tone="wary"],
.affinity-pill[data-tone="wary"],
.identity-current[data-tone="wary"] {
  --affinity-color: #df9d86;
  --affinity-track: rgba(223, 157, 134, 0.16);
}

[data-tone="notice"],
.affinity-pill[data-tone="notice"],
.identity-current[data-tone="notice"] {
  --affinity-color: #e0b779;
  --affinity-track: rgba(224, 183, 121, 0.16);
}

[data-tone="known"],
.affinity-pill[data-tone="known"],
.identity-current[data-tone="known"] {
  --affinity-color: #a8c5a0;
  --affinity-track: rgba(168, 197, 160, 0.16);
}

[data-tone="close"],
.affinity-pill[data-tone="close"],
.identity-current[data-tone="close"] {
  --affinity-color: #e8c488;
  --affinity-track: rgba(232, 196, 136, 0.18);
}

[data-tone="trust"],
.affinity-pill[data-tone="trust"],
.identity-current[data-tone="trust"] {
  --affinity-color: #e5a9c2;
  --affinity-track: rgba(229, 169, 194, 0.18);
}

[data-tone="bond"],
.affinity-pill[data-tone="bond"],
.identity-current[data-tone="bond"] {
  --affinity-color: #cbb9ec;
  --affinity-track: rgba(203, 185, 236, 0.2);
}

.affinity-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid color-mix(in srgb, var(--affinity-color) 34%, var(--line));
  border-radius: 999px;
  background: color-mix(in srgb, var(--affinity-color) 9%, transparent);
  color: var(--affinity-color);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s, background 0.2s;
}

.affinity-pill:hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--affinity-color) 64%, var(--line));
  background: color-mix(in srgb, var(--affinity-color) 14%, transparent);
}

.affinity-pill.is-risky {
  border-color: color-mix(in srgb, var(--danger) 42%, var(--line));
  box-shadow: 0 0 0 2px var(--danger-wash);
}

.affinity-heart {
  font-size: 12px;
  line-height: 1;
}

.affinity-label {
  color: var(--text-dim);
  font-family: var(--sans);
  font-size: 8px;
}

.identity-overlay {
  z-index: 70;
}

#confirmOverlay {
  z-index: 200;
}

.identity-panel {
  position: relative;
  width: min(720px, 100%);
  max-height: min(88vh, 820px);
  overflow-y: auto;
  padding: 26px clamp(18px, 4vw, 34px) 22px;
  border: 1px solid var(--line-strong);
  border-radius: 22px;
  background:
    radial-gradient(ellipse 80% 55% at 88% 0%, var(--stage-glow), transparent 68%),
    linear-gradient(160deg, color-mix(in srgb, var(--panel-solid) 96%, transparent), var(--panel));
  box-shadow: var(--shadow-lg);
  scrollbar-width: thin;
}

.identity-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.identity-head h2 {
  margin: 4px 0 0;
  font-family: var(--serif);
  font-size: clamp(22px, 3vw, 30px);
  font-weight: 500;
  letter-spacing: 0.045em;
}

.identity-intro {
  max-width: 590px;
  margin: 12px 0 19px;
  color: var(--text-dim);
  font-size: 10.5px;
  line-height: 1.85;
}

.identity-current {
  padding: 17px;
  border: 1px solid color-mix(in srgb, var(--affinity-color) 26%, var(--line));
  border-radius: 14px;
  background: color-mix(in srgb, var(--affinity-color) 5%, transparent);
}

.identity-current-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.identity-emblem {
  display: grid;
  place-items: center;
  width: 45px;
  height: 45px;
  flex: 0 0 auto;
  border: 1px solid color-mix(in srgb, var(--affinity-color) 50%, var(--line));
  border-radius: 12px;
  color: var(--affinity-color);
  font-family: var(--serif);
  font-size: 19px;
  background: color-mix(in srgb, var(--affinity-color) 10%, transparent);
}

.identity-current h3 {
  margin: 3px 0 4px;
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 500;
}

.identity-current-head p {
  margin: 0;
  color: var(--text-dim);
  font-size: 10px;
  line-height: 1.75;
}

.identity-badge {
  display: inline-block;
  padding: 2px 6px;
  border: 1px solid color-mix(in srgb, var(--affinity-color) 30%, var(--line));
  border-radius: 999px;
  color: var(--affinity-color);
  font-family: var(--mono);
  font-size: 7px;
  letter-spacing: 0.06em;
}

.affinity-summary {
  margin-top: 17px;
}

.affinity-summary-copy {
  display: flex;
  align-items: baseline;
  gap: 8px;
  color: var(--text-dim);
  font-size: 9px;
}

.affinity-summary-copy strong {
  color: var(--affinity-color);
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 500;
  line-height: 1;
}

.affinity-summary-copy strong small {
  margin-left: 3px;
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 8px;
}

.affinity-summary-copy em {
  margin-left: auto;
  color: var(--affinity-color);
  font-style: normal;
}

.affinity-track {
  height: 5px;
  margin-top: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--affinity-track);
}

.affinity-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, color-mix(in srgb, var(--affinity-color) 55%, transparent), var(--affinity-color));
  transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.affinity-track span.is-negative {
  background: linear-gradient(90deg, color-mix(in srgb, var(--danger) 45%, transparent), var(--danger));
}

.affinity-risk {
  margin: 9px 0 0;
  padding: 7px 9px;
  border: 1px solid color-mix(in srgb, var(--danger) 24%, var(--line));
  border-radius: 7px;
  background: var(--danger-wash);
  color: var(--danger);
  font-size: 9px;
  line-height: 1.6;
}

.identity-card.is-warning {
  border-color: color-mix(in srgb, var(--danger) 35%, var(--line));
}

.identity-card.is-warning:hover {
  border-color: var(--danger);
  background: color-mix(in srgb, var(--danger-wash) 50%, var(--panel-input));
}

.identity-card-warning {
  margin: 0;
  padding: 6px 7px;
  border-radius: 6px;
  background: var(--danger-wash);
  color: var(--danger);
  font-size: 8.5px;
  line-height: 1.6;
}

.composer.is-rejected {
  animation: composer-reject 0.42s ease;
}

@keyframes composer-reject {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  55% { transform: translateX(4px); }
  80% { transform: translateX(-2px); }
}

.affinity-history-wrap {
  margin-top: 18px;
}

.identity-subhead {
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.affinity-history {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.affinity-history-row {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel-input) 48%, transparent);
}

.affinity-delta {
  flex: 0 0 auto;
  min-width: 36px;
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 8px;
}

.affinity-delta.up {
  color: var(--success);
}

.affinity-delta.down {
  color: var(--danger);
}

.affinity-history-copy p {
  margin: 0;
  color: var(--text-soft);
  font-size: 9px;
  line-height: 1.55;
}

.affinity-history-copy small {
  display: block;
  margin-top: 3px;
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 7px;
}

.affinity-empty {
  margin: 8px 0 0;
  color: var(--text-faint);
  font-size: 9px;
}

.identity-current-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
}

.identity-chooser {
  margin-top: 2px;
}

.identity-chooser-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

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

.identity-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 130px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--panel-input) 62%, transparent);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.2s;
}

.identity-card:hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--gold) 46%, var(--line));
  background: color-mix(in srgb, var(--gold-wash) 62%, var(--panel-input));
}

.identity-card.is-active {
  border-color: var(--gold);
  box-shadow: inset 0 0 0 1px var(--gold-wash);
}

.identity-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.identity-card-top strong {
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 500;
}

.identity-card p {
  flex: 1;
  margin: 0;
  color: var(--text-soft);
  font-size: 9.5px;
  line-height: 1.7;
}

.identity-card-foot {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 7px;
}

.identity-card-foot span:last-child {
  color: var(--gold);
}

.identity-empty-hint,
.identity-locked {
  margin: 10px 0;
  padding: 10px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--text-faint);
  font-size: 9px;
  line-height: 1.7;
}

.identity-custom {
  margin-top: 18px;
  padding-top: 15px;
  border-top: 1px solid var(--line);
}

.identity-custom-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  margin: 9px 0 12px;
}

.identity-custom .field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  color: var(--text-dim);
  font-size: 9px;
}

.identity-custom .field.full {
  grid-column: 1 / -1;
}

.identity-custom input,
.identity-custom textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  outline: none;
  background: var(--panel-input);
  color: var(--text);
  font-family: var(--sans);
  font-size: 10.5px;
  line-height: 1.6;
  resize: vertical;
}

.identity-custom input:focus,
.identity-custom textarea:focus {
  border-color: color-mix(in srgb, var(--gold) 55%, var(--line));
  box-shadow: 0 0 0 2px var(--gold-wash);
}

.identity-footnote {
  margin: 18px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--text-faint);
  font-size: 8px;
  line-height: 1.7;
}

.message-affinity {
  padding: 1px 6px;
  border: 1px solid color-mix(in srgb, var(--affinity-color) 28%, var(--line));
  border-radius: 999px;
  color: var(--affinity-color);
  background: color-mix(in srgb, var(--affinity-color) 7%, transparent);
  font-family: var(--mono);
  font-size: 7px;
}

.message-affinity.down {
  --affinity-color: var(--danger);
}

.account-role-badge {
  margin: 10px 0 0;
  padding: 6px 8px;
  border: 1px solid color-mix(in srgb, var(--gold) 30%, var(--line));
  border-radius: 7px;
  background: var(--gold-wash);
  color: var(--gold);
  font-size: 8.5px;
  line-height: 1.6;
}

.admin-decision-drawer {
  width: min(560px, 100%);
}

.admin-account-line {
  margin: 0 0 14px;
  color: var(--gold);
  font-family: var(--mono);
  font-size: 9px;
}

.admin-affinity-row {
  display: flex;
  align-items: center;
  gap: 9px;
}

.admin-affinity-row input {
  width: 100px;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-input);
  color: var(--text);
  font-family: var(--mono);
}

.admin-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  margin-top: 9px;
}

.admin-form-grid .field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  color: var(--text-dim);
  font-size: 8px;
}

.admin-form-grid input,
.admin-form-grid select {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-input);
  color: var(--text);
  font-family: var(--sans);
  font-size: 10px;
}

.admin-decision-drawer .setting-section {
  margin-top: 15px;
}

.admin-decision-drawer .button.primary {
  margin-top: 14px;
}

#adminOverlay {
  z-index: 75;
}

#adminAffinityLabel[data-tone="hostile"],
#adminAffinityLabel[data-tone="disgust"],
#adminAffinityLabel[data-tone="resent"] {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 30%, var(--line));
}

@media (max-width: 640px) {
  .admin-form-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .affinity-label {
    display: none;
  }

  .affinity-pill {
    padding: 0 8px;
  }

  .identity-panel {
    max-height: 92vh;
    padding: 18px 14px;
    border-radius: 16px;
  }

  .identity-grid,
  .identity-custom-grid {
    grid-template-columns: 1fr;
  }

  .identity-current-head {
    gap: 9px;
  }

  .identity-card {
    min-height: 0;
  }
}

@media (max-width: 640px) {
  .account-btn-name {
    display: none;
  }

  .auth-card {
    padding: 24px 20px 18px;
  }

  .auth-card h1 {
    font-size: 30px;
  }
}

/* ------------------------------------------------------ touch & mobile polish */

@media (pointer: coarse) {
  .icon-button,
  .mini-icon,
  .send-button {
    min-width: 44px;
    min-height: 44px;
  }

  .button,
  .ghost-button,
  .sidebar-action,
  .popup-menu button,
  .auth-tab,
  .auth-submit,
  .text-button,
  .row-open {
    min-height: 44px;
  }

  .text-button {
    padding: 10px 8px;
  }

  .composer textarea,
  .field input,
  .field textarea,
  .field select,
  .auth-field input,
  .identity-custom input,
  .identity-custom textarea,
  .admin-form-grid input,
  .admin-form-grid select,
  .admin-affinity-row input,
  .key-input-row input {
    font-size: 16px;
  }
}

@media (max-width: 780px) {
  .app-shell,
  .stage {
    height: var(--app-height, 100dvh);
    min-height: var(--app-height, 100dvh);
    max-height: var(--app-height, 100dvh);
  }

  .stage {
    overflow: hidden;
  }

  .topbar {
    min-height: 56px;
    padding: calc(7px + env(safe-area-inset-top)) 10px 7px;
    gap: 6px;
  }

  .topbar-spacer {
    display: none;
  }

  .current-avatar {
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
  }

  .current-identity {
    flex: 1 1 0;
    min-width: 0;
    overflow: hidden;
  }

  .current-identity h1 {
    font-size: 15px;
    line-height: 1.25;
  }

  .current-identity p {
    max-width: none;
    font-size: 9px;
  }

  .icon-button {
    width: 44px;
    height: 44px;
  }

  .affinity-pill {
    min-height: 40px;
    min-width: 44px;
    padding: 0 8px;
    gap: 4px;
  }

  .account-button {
    min-width: 44px;
    min-height: 44px;
    justify-content: center;
    padding: 4px;
  }

  .account-btn-name {
    display: none;
  }

  .popup-menu {
    width: min(230px, calc(100vw - 20px));
    max-height: calc(var(--app-height, 100dvh) - 78px);
    overflow-y: auto;
    z-index: 60;
  }

  .popup-menu button {
    min-height: 46px;
    padding: 11px 12px;
  }

  .message-list {
    padding: 14px 10px 12px;
  }

  .message-row {
    gap: 7px;
    margin-bottom: 16px;
  }

  .message-avatar {
    width: 30px;
    height: 30px;
  }

  .message-stack {
    max-width: calc(100% - 36px);
  }

  .bubble {
    padding: 11px 13px;
    font-size: 15px;
    line-height: 1.85;
  }

  .composer-area {
    padding: 5px 8px calc(8px + env(safe-area-inset-bottom));
  }

  .composer {
    gap: 6px;
    padding: 6px 6px 6px 13px;
    border-radius: 14px;
  }

  .composer textarea {
    min-height: 34px;
    margin: 4px 0;
    line-height: 1.55;
  }

  .send-button {
    width: 46px;
    height: 46px;
    border-radius: 12px;
  }

  .composer-foot {
    margin-top: 5px;
    padding-inline: 3px;
  }

  .jump-bottom {
    bottom: calc(108px + env(safe-area-inset-bottom));
    min-height: 40px;
    padding: 8px 12px;
  }

  .config-notice {
    min-height: 42px;
    padding: 8px 12px;
  }

  .sidebar {
    width: min(320px, 90vw);
    padding-top: calc(18px + env(safe-area-inset-top));
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .sidebar-action {
    min-height: 46px;
    padding: 11px 10px;
  }

  .sidebar-actions {
    align-items: stretch;
  }

  .mini-icon {
    width: 44px;
    height: 44px;
    border-radius: 11px;
  }

  .drawer {
    width: 100%;
    height: var(--app-height, 100dvh);
    max-height: var(--app-height, 100dvh);
    padding-bottom: env(safe-area-inset-bottom);
  }

  .overlay.right {
    height: var(--app-height, 100dvh);
    top: 0;
    bottom: auto;
  }

  .drawer-head {
    padding: calc(15px + env(safe-area-inset-top)) 16px 13px;
  }

  .drawer-scroll,
  .drawer-body {
    padding-inline: 16px;
    padding-bottom: calc(26px + env(safe-area-inset-bottom));
  }

  .identity-overlay {
    align-items: flex-start;
    overflow-y: auto;
    padding: calc(8px + env(safe-area-inset-top)) 10px calc(12px + env(safe-area-inset-bottom));
  }

  .identity-panel {
    width: 100%;
    max-height: none;
    margin: 0;
    padding: 16px 13px;
    border-radius: 15px;
  }

  .identity-chooser-head {
    position: sticky;
    top: -1px;
    z-index: 2;
    padding: 5px 0;
    background: var(--panel-solid);
  }

  .identity-custom-grid {
    grid-template-columns: 1fr;
  }

  .identity-custom input,
  .identity-custom textarea {
    min-height: 46px;
    font-size: 16px;
  }

  .identity-custom textarea {
    min-height: 88px;
  }

  .auth-gate {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    height: var(--app-height, 100dvh);
    padding: calc(12px + env(safe-area-inset-top)) 12px calc(24px + env(safe-area-inset-bottom));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  .auth-card {
    width: 100%;
    max-width: 460px;
    margin: 0 auto;
    padding: 22px 17px 18px;
    border-radius: 16px;
  }

  .auth-brand {
    margin-bottom: 18px;
  }

  .auth-card h1 {
    font-size: clamp(28px, 9vw, 36px);
  }

  .auth-lead {
    font-size: 11px;
    line-height: 1.75;
  }

  .auth-field > span {
    font-size: 10px;
  }

  .auth-field > input,
  .auth-input-row {
    min-height: 48px;
    font-size: 16px;
  }

  .auth-tab {
    min-height: 44px;
    font-size: 10px;
  }

  .auth-submit {
    min-height: 50px;
    font-size: 12px;
  }

  .auth-consent {
    align-items: center;
    min-height: 44px;
    font-size: 10px;
  }

  .auth-consent input {
    width: 19px;
    height: 19px;
    margin-top: 0;
  }

  .auth-consent-strong {
    padding: 10px;
  }

  .auth-foot,
  .auth-copyright {
    font-size: 8.5px;
  }

  .small-modal {
    max-height: calc(var(--app-height, 100dvh) - 18px);
  }

  .confirm-actions .button {
    min-width: 92px;
  }

  .toast-container {
    top: calc(64px + env(safe-area-inset-top));
    width: calc(100vw - 24px);
  }

  .toast {
    max-width: 100%;
    font-size: 12px;
  }
}

@media (max-width: 390px) {
  .current-avatar {
    display: none;
  }

  .current-identity h1 {
    font-size: 14px;
  }

  .current-identity p {
    font-size: 8.5px;
  }

  .affinity-pill {
    font-size: 10px;
  }

  .bubble {
    font-size: 14.5px;
  }

  .identity-card {
    padding: 11px;
  }
}

/* --------------------------------------------------- v1.0 QQ & feedback */

.auth-apply {
  margin-top: 18px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--panel-raised) 42%, transparent);
}

.auth-apply-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.auth-apply-head .eyebrow {
  margin: 0;
}

.auth-version {
  padding: 2px 6px;
  border: 1px solid color-mix(in srgb, var(--gold) 32%, var(--line));
  border-radius: 999px;
  color: var(--gold);
  font-family: var(--mono);
  font-size: 8px;
}

.auth-qq-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 9px;
}

.auth-qq-copy strong {
  display: block;
  color: var(--text);
  font-size: 11px;
  font-weight: 600;
}

.auth-qq-copy p {
  margin: 4px 0 0;
  color: var(--text-dim);
  font-size: 9.5px;
  line-height: 1.7;
}

.auth-qq-copy b {
  color: var(--gold);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.04em;
}

.auth-qq-copy p span {
  color: var(--text-faint);
  font-size: 8.5px;
}

.auth-qq-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 6px;
}

.auth-qq-actions .ghost-button {
  min-height: 31px;
  padding: 5px 9px;
  font-size: 9px;
}

.auth-apply-links {
  display: flex;
  justify-content: flex-end;
  gap: 13px;
  margin-top: 9px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.auth-apply-links .text-button {
  min-height: 26px;
  padding: 3px 2px;
  font-size: 9px;
}

a.text-button {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.feedback-overlay {
  z-index: 1500;
}

.feedback-modal {
  width: min(540px, 100%);
}

.feedback-lead {
  margin: 0 0 16px;
  color: var(--text-dim);
  font-size: 11px;
  line-height: 1.8;
}

.feedback-modal .field {
  margin-bottom: 12px;
}

.feedback-note {
  margin: 0 0 11px;
  color: var(--text-faint);
  font-size: 9px;
  line-height: 1.7;
}

.feedback-note strong {
  color: var(--gold);
  font-family: var(--mono);
}

.feedback-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}

.feedback-actions .button {
  min-width: 126px;
}

@media (max-width: 640px) {
  .auth-apply {
    padding: 12px;
  }

  .auth-qq-row {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
  }

  .auth-qq-actions {
    justify-content: stretch;
  }

  .auth-qq-actions .ghost-button {
    flex: 1;
    justify-content: center;
    min-height: 44px;
  }

  .auth-apply-links {
    justify-content: space-between;
  }

  .auth-apply-links .text-button {
    min-height: 40px;
    padding: 8px 2px;
    font-size: 10px;
  }

  .feedback-lead {
    font-size: 11px;
  }

  .feedback-modal {
    padding: 17px 14px;
  }

  .feedback-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .feedback-actions .button {
    width: 100%;
    min-height: 48px;
  }

  .feedback-actions .text-button {
    justify-content: center;
  }
}

/* Specificity must beat .overlay.center so feedback can open above the auth gate. */
.overlay.feedback-overlay {
  z-index: 1500;
}

.toast-container {
  z-index: 1600;
}

.sidebar-meta-links {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px 10px;
  margin-top: 5px;
}

.sidebar-meta-links .text-button {
  color: var(--text-faint);
  font-size: 9px;
}

@media (max-width: 780px) {
  .sidebar-meta-links {
    gap: 2px 12px;
  }

  .sidebar-meta-links .text-button {
    min-height: 44px;
    padding: 9px 2px;
    font-size: 10px;
  }
}

/* ------------------------------------------------------- moonlit music player */

.music-widget {
  position: fixed;
  right: 18px;
  bottom: calc(92px + env(safe-area-inset-bottom));
  z-index: 1400;
  font-family: var(--sans);
}

.music-widget.is-admin {
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 3200;
}

.music-fab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 6px 12px 6px 7px;
  border: 1px solid color-mix(in srgb, var(--gold) 34%, var(--line-strong));
  border-radius: 999px;
  background: color-mix(in srgb, var(--panel-solid) 88%, transparent);
  color: var(--text-soft);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(18px);
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.music-fab:hover {
  border-color: color-mix(in srgb, var(--gold) 58%, var(--line-strong));
  background: var(--panel-raised);
  transform: translateY(-1px);
}

.music-fab-icon {
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold-soft), var(--gold));
  color: #2b1b10;
  font-family: var(--serif);
  font-size: 15px;
  box-shadow: 0 0 18px color-mix(in srgb, var(--gold) 25%, transparent);
}

.music-fab-copy {
  font-size: 9px;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.music-eq {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  width: 13px;
  height: 12px;
  opacity: 0;
}

.music-widget.is-playing .music-eq {
  opacity: 1;
}

.music-eq i {
  display: block;
  width: 2px;
  height: 4px;
  border-radius: 2px;
  background: var(--gold);
  animation: music-bar 850ms ease-in-out infinite alternate;
}

.music-eq i:nth-child(2) {
  height: 8px;
  animation-delay: -280ms;
}

.music-eq i:nth-child(3) {
  height: 6px;
  animation-delay: -520ms;
}

@keyframes music-bar {
  from { transform: scaleY(0.45); }
  to { transform: scaleY(1.25); }
}

.music-panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 10px);
  width: min(382px, calc(100vw - 20px));
  max-height: min(680px, calc(100dvh - 128px));
  overflow-y: auto;
  padding: 16px;
  border: 1px solid color-mix(in srgb, var(--gold) 25%, var(--line-strong));
  border-radius: 17px;
  background:
    radial-gradient(ellipse 70% 45% at 100% 0%, color-mix(in srgb, var(--gold) 10%, transparent), transparent 70%),
    color-mix(in srgb, var(--panel-solid) 96%, transparent);
  color: var(--text);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.46);
  backdrop-filter: blur(24px);
}

.music-panel[hidden] {
  display: none;
}

.music-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.music-kicker {
  margin: 0 0 4px;
  color: var(--gold);
  font-family: var(--mono);
  font-size: 7px;
  font-weight: 600;
  letter-spacing: 0.14em;
}

.music-head h2 {
  margin: 0;
  color: var(--text);
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 500;
  letter-spacing: 0.04em;
}

.music-close {
  display: grid;
  place-items: center;
  width: 31px;
  height: 31px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--text-dim);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.music-close:hover {
  color: var(--text);
  border-color: var(--line-strong);
}

.music-now {
  display: flex;
  align-items: center;
  gap: 11px;
  margin: 13px 0 9px;
}

.music-disc {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  border: 1px solid color-mix(in srgb, var(--gold) 32%, var(--line));
  border-radius: 50%;
  background:
    radial-gradient(circle at 38% 32%, color-mix(in srgb, var(--gold-soft) 28%, transparent), transparent 45%),
    var(--panel-input);
  color: var(--gold);
  font-family: var(--serif);
  font-size: 21px;
  box-shadow: inset 0 0 0 5px color-mix(in srgb, var(--gold) 5%, transparent);
}

.music-widget.is-playing .music-disc {
  animation: music-spin 7s linear infinite;
}

@keyframes music-spin {
  to { transform: rotate(360deg); }
}

.music-now-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.music-now-copy strong {
  overflow: hidden;
  color: var(--text);
  font-family: var(--serif);
  font-size: 14px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.music-now-copy span {
  overflow: hidden;
  color: var(--text-faint);
  font-size: 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.music-seek {
  width: 100%;
  height: 15px;
  margin: 0;
  accent-color: var(--gold);
  cursor: pointer;
}

.music-time {
  display: flex;
  justify-content: space-between;
  margin-top: -2px;
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 7.5px;
}

.music-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 8px 0 11px;
}

.music-control {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--text-dim);
  font-size: 10px;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease, border-color 150ms ease;
}

.music-control:hover,
.music-control.is-active {
  color: var(--gold);
  border-color: color-mix(in srgb, var(--gold) 45%, var(--line));
  background: color-mix(in srgb, var(--gold) 8%, transparent);
}

.music-control.is-play {
  width: 42px;
  height: 42px;
  border-color: color-mix(in srgb, var(--gold) 45%, var(--line));
  background: linear-gradient(135deg, var(--gold-soft), var(--gold));
  color: #2b1b10;
  font-size: 13px;
}

.music-control.is-play:hover {
  color: #2b1b10;
  filter: brightness(1.06);
}

.music-volume {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-faint);
  font-size: 8px;
}

.music-volume input {
  flex: 1;
  height: 13px;
  accent-color: var(--gold);
  cursor: pointer;
}

.music-list-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin: 13px 0 7px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  color: var(--text-soft);
  font-size: 9px;
}

.music-list-head span {
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 7px;
}

.music-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.music-track {
  display: flex;
  align-items: stretch;
  gap: 4px;
  border: 1px solid transparent;
  border-radius: 8px;
  transition: background 140ms ease, border-color 140ms ease;
}

.music-track:hover {
  background: color-mix(in srgb, var(--gold) 5%, transparent);
}

.music-track.is-active {
  border-color: color-mix(in srgb, var(--gold) 28%, var(--line));
  background: color-mix(in srgb, var(--gold) 7%, transparent);
}

.music-track.is-missing {
  opacity: 0.72;
}

.music-track-main {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 7px 6px;
  border: 0;
  background: transparent;
  color: var(--text-dim);
  text-align: left;
  cursor: pointer;
}

.music-track-index {
  flex: 0 0 17px;
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 7px;
}

.music-track-copy {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.music-track-copy strong {
  overflow: hidden;
  color: var(--text-soft);
  font-size: 9.5px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.music-track-copy small {
  overflow: hidden;
  color: var(--text-faint);
  font-size: 7.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.music-track-mark {
  flex: 0 0 auto;
  color: var(--gold);
  font-family: var(--mono);
  font-size: 8px;
}

.music-track.is-missing .music-track-mark {
  color: var(--text-faint);
}

.music-remove {
  width: 28px;
  border: 0;
  border-left: 1px solid var(--line);
  background: transparent;
  color: var(--text-faint);
  font-size: 15px;
  cursor: pointer;
}

.music-remove:hover {
  color: var(--danger);
}

.music-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.music-add-button {
  min-height: 30px;
  padding: 6px 10px;
  border: 1px dashed color-mix(in srgb, var(--gold) 32%, var(--line));
  border-radius: 7px;
  background: color-mix(in srgb, var(--gold) 5%, transparent);
  color: var(--gold);
  font-size: 8.5px;
  cursor: pointer;
}

.music-add-button:hover {
  background: color-mix(in srgb, var(--gold) 10%, transparent);
}

.music-private {
  color: var(--text-faint);
  font-size: 7px;
}

.music-hint {
  margin: 9px 0 0;
  color: var(--text-faint);
  font-size: 7.5px;
  line-height: 1.65;
}

.music-status {
  min-height: 0;
  margin: 6px 0 0;
  color: var(--gold);
  font-size: 8px;
  line-height: 1.6;
}

.music-status.is-error {
  color: var(--danger);
}

.music-status.is-ok {
  color: var(--success, var(--mint));
}

@media (max-width: 780px) {
  .music-widget {
    right: 10px;
    bottom: calc(84px + env(safe-area-inset-bottom));
  }

  .music-widget.is-admin {
    right: 10px;
    bottom: calc(12px + env(safe-area-inset-bottom));
  }

  .music-fab {
    width: 46px;
    height: 46px;
    min-height: 46px;
    justify-content: center;
    padding: 0;
  }

  .music-fab-copy,
  .music-widget .music-eq {
    display: none;
  }

  .music-fab-icon {
    width: 32px;
    height: 32px;
    font-size: 17px;
  }

  .music-panel {
    width: calc(100vw - 20px);
    max-height: calc(100dvh - 150px);
    padding: 14px;
  }

  .music-control {
    width: 42px;
    height: 42px;
  }

  .music-control.is-play {
    width: 50px;
    height: 50px;
  }

  .music-track-main {
    min-height: 44px;
  }

  .music-add-button {
    min-height: 40px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .music-eq i,
  .music-widget.is-playing .music-disc {
    animation: none;
  }
}
