/* ============================================================
   SEEMOTIONS GLOBAL UI SYSTEM
   Profile modal + theme sync + rail icon color fix
   ============================================================ */

:root,
html[data-theme="night"] {
  --palette-yellow: #E3B126;
  --palette-orange: #E03800;
  --palette-dark: #141414;
  --palette-panel: #1F1F1F;
  --palette-white: #FDFDFD;

  --dark-void: #141414;
  --liquid-lava: #E03800;
  --gluon-grey: #1F1F1F;
  --slate-grey: #1F1F1F;
  --snow: #FDFDFD;

  --brand-orange: #E03800;
  --accent: #E03800;
  --accent-glow: rgba(224, 56, 0, 0.35);

  --bg: #141414;
  --body-bg: #141414;
  --bg-elev: #1F1F1F;
  --bg-card: #1A1A1A;
  --bg-panel: #1F1F1F;
  --bg-input: #1F1F1F;
  --bg-sunken: #141414;

  --ink: #FDFDFD;
  --text: #FDFDFD;
  --ink-soft: rgba(253, 253, 253, 0.72);
  --text-muted: rgba(253, 253, 253, 0.54);
  --ink-faint: rgba(253, 253, 253, 0.48);
  --ink-ghost: rgba(253, 253, 253, 0.34);

  --line: rgba(253, 253, 253, 0.12);
  --line-soft: rgba(253, 253, 253, 0.07);
  --line-faint: rgba(253, 253, 253, 0.045);

  --nav-bg: rgba(20, 20, 20, 0.78);
  --chip-bg: rgba(253, 253, 253, 0.035);
  --chip-border: rgba(253, 253, 253, 0.10);
  --chip-hover: rgba(253, 253, 253, 0.08);

  --rail-active-bg: #FDFDFD;
  --rail-active-fg: #141414;
  --rail-idle-fg: rgba(253, 253, 253, 0.72);
}

html[data-theme="day"] {
  --palette-yellow: #E3B126;
  --palette-orange: #E03800;
  --palette-dark: #141414;
  --palette-panel: #1F1F1F;
  --palette-white: #FDFDFD;

  --dark-void: #141414;
  --liquid-lava: #E03800;
  --gluon-grey: #FFFFFF;
  --slate-grey: #F4F4F4;
  --snow: #FDFDFD;

  --brand-orange: #E03800;
  --accent: #E03800;
  --accent-glow: rgba(224, 56, 0, 0.25);

  --bg: #FDFDFD;
  --body-bg: #FDFDFD;
  --bg-elev: #FFFFFF;
  --bg-card: #FFFFFF;
  --bg-panel: #FFFFFF;
  --bg-input: #FFFFFF;
  --bg-sunken: rgba(20, 20, 20, 0.045);

  --ink: #141414;
  --text: #141414;
  --ink-soft: rgba(20, 20, 20, 0.72);
  --text-muted: rgba(20, 20, 20, 0.54);
  --ink-faint: rgba(20, 20, 20, 0.48);
  --ink-ghost: rgba(20, 20, 20, 0.34);

  --line: rgba(20, 20, 20, 0.12);
  --line-soft: rgba(20, 20, 20, 0.07);
  --line-faint: rgba(20, 20, 20, 0.045);

  --nav-bg: rgba(253, 253, 253, 0.86);
  --chip-bg: rgba(20, 20, 20, 0.035);
  --chip-border: rgba(20, 20, 20, 0.10);
  --chip-hover: rgba(20, 20, 20, 0.07);

  --rail-active-bg: #141414;
  --rail-active-fg: #FDFDFD;
  --rail-idle-fg: rgba(20, 20, 20, 0.72);
}

/* Rail icon day/night correctness */
.rail-item {
  color: var(--rail-idle-fg) !important;
}

.rail-item .ri-icon,
.rail-item .ri-icon svg,
.rail-item svg {
  color: currentColor !important;
  stroke: currentColor !important;
  fill: none !important;
}

.rail-item .ri-icon svg *,
.rail-item svg * {
  stroke: currentColor !important;
}

.rail-item.active {
  background: var(--rail-active-bg) !important;
  color: var(--rail-active-fg) !important;
}

.rail-item.active .ri-icon,
.rail-item.active .ri-icon svg,
.rail-item.active svg {
  color: var(--rail-active-fg) !important;
  stroke: var(--rail-active-fg) !important;
}

/* Universal profile modal */
html.sm-profile-open,
html.sm-profile-open body {
  overflow: hidden !important;
}

.sm-profile-overlay {
  position: fixed;
  inset: 0;
  z-index: 999999;
  display: none;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(18px) saturate(130%);
  -webkit-backdrop-filter: blur(18px) saturate(130%);
}

.sm-profile-overlay.is-open {
  display: grid;
}

.sm-profile-modal {
  width: min(430px, calc(100vw - 32px));
  border-radius: 32px;
  background: rgba(31, 31, 31, 0.94);
  border: 1px solid rgba(253, 253, 253, 0.10);
  box-shadow: 0 28px 90px rgba(0,0,0,0.55), inset 0 1px 0 rgba(255,255,255,0.05);
  color: #FDFDFD;
  overflow: hidden;
  transform: translateY(10px) scale(.985);
  opacity: 0;
  transition:
    opacity .22s cubic-bezier(.22,.61,.36,1),
    transform .22s cubic-bezier(.22,.61,.36,1);
}

.sm-profile-overlay.is-open .sm-profile-modal {
  opacity: 1;
  transform: translateY(0) scale(1);
}

html[data-theme="day"] .sm-profile-overlay {
  background: rgba(253,253,253,0.50);
}

html[data-theme="day"] .sm-profile-modal {
  background: rgba(253,253,253,0.95);
  border-color: rgba(20,20,20,0.10);
  color: #141414;
  box-shadow: 0 28px 90px rgba(0,0,0,0.22), inset 0 1px 0 rgba(255,255,255,0.75);
}

.sm-profile-head {
  padding: 22px 22px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid rgba(253,253,253,0.07);
}

html[data-theme="day"] .sm-profile-head {
  border-bottom-color: rgba(20,20,20,0.08);
}

.sm-profile-avatar {
  width: 54px;
  height: 54px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  background: #FDFDFD;
  color: #141414;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: -0.02em;
  flex: 0 0 auto;
}

html[data-theme="day"] .sm-profile-avatar {
  background: #141414;
  color: #FDFDFD;
}

.sm-profile-title {
  min-width: 0;
  flex: 1;
}

.sm-profile-name {
  font-size: 17px;
  font-weight: 850;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sm-profile-email {
  margin-top: 3px;
  font-size: 13px;
  color: rgba(253,253,253,0.50);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

html[data-theme="day"] .sm-profile-email {
  color: rgba(20,20,20,0.52);
}

.sm-profile-close {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(253,253,253,0.09);
  background: rgba(253,253,253,0.035);
  color: currentColor;
  cursor: pointer;
}

html[data-theme="day"] .sm-profile-close {
  border-color: rgba(20,20,20,0.09);
  background: rgba(20,20,20,0.035);
}

.sm-profile-close:hover {
  background: currentColor;
  color: var(--bg);
}

.sm-profile-body {
  padding: 20px 22px 22px;
}

.sm-profile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.sm-profile-stat {
  padding: 14px;
  border-radius: 18px;
  background: rgba(253,253,253,0.035);
  border: 1px solid rgba(253,253,253,0.07);
}

html[data-theme="day"] .sm-profile-stat {
  background: rgba(20,20,20,0.035);
  border-color: rgba(20,20,20,0.08);
}

.sm-profile-stat-label,
.sm-profile-field label {
  display: block;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: rgba(253,253,253,0.45);
}

html[data-theme="day"] .sm-profile-stat-label,
html[data-theme="day"] .sm-profile-field label {
  color: rgba(20,20,20,0.48);
}

.sm-profile-stat-value {
  margin-top: 7px;
  font-size: 18px;
  font-weight: 900;
  color: currentColor;
}

.sm-profile-field {
  margin-top: 14px;
}

.sm-profile-field label {
  margin-bottom: 8px;
}

.sm-profile-input-row {
  display: flex;
  gap: 8px;
}

.sm-profile-input {
  flex: 1;
  min-width: 0;
  height: 44px;
  border-radius: 16px;
  border: 1px solid rgba(253,253,253,0.09);
  background: rgba(20,20,20,0.55);
  color: #FDFDFD;
  padding: 0 14px;
  outline: none;
  font: inherit;
  font-size: 14px;
}

html[data-theme="day"] .sm-profile-input {
  border-color: rgba(20,20,20,0.10);
  background: rgba(20,20,20,0.045);
  color: #141414;
}

.sm-profile-input:focus {
  border-color: rgba(224,56,0,.55);
}

.sm-profile-save {
  height: 44px;
  padding: 0 16px;
  border-radius: 16px;
  border: none;
  background: #E03800;
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

.sm-profile-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}

.sm-profile-action {
  height: 44px;
  border-radius: 16px;
  border: 1px solid rgba(253,253,253,0.09);
  background: rgba(253,253,253,0.035);
  color: currentColor;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
  display: grid;
  place-items: center;
}

html[data-theme="day"] .sm-profile-action {
  border-color: rgba(20,20,20,0.10);
  background: rgba(20,20,20,0.035);
}

.sm-profile-action:hover {
  background: currentColor;
  color: var(--bg);
}

.sm-profile-action.danger {
  color: #E03800;
}

.sm-profile-action.danger:hover {
  background: #E03800;
  color: #fff;
}

.sm-profile-login {
  width: 100%;
  height: 46px;
  margin-top: 14px;
  border-radius: 16px;
  background: #E03800;
  color: #fff;
  border: 0;
  font-weight: 900;
  cursor: pointer;
}

@media (max-width: 520px) {
  .sm-profile-overlay {
    align-items: end;
    padding: 12px;
  }

  .sm-profile-modal {
    width: 100%;
    border-radius: 28px;
  }

  .sm-profile-grid,
  .sm-profile-actions {
    grid-template-columns: 1fr;
  }
}
