* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  height: 100%;
  font-family: Inter, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

button, textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  width: 260px;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
}

.brand {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 3px;
  padding: 8px 10px 22px;
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg);
}

.new-chat {
  width: 100%;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-strong);
  border-radius: 10px;
  padding: 12px;
  text-align: left;
}

.new-chat:hover {
  background: var(--border);
}

.conversation-list {
  flex: 1;
  overflow-y: auto;
  margin-top: 16px;
}

.logout {
  width: 100%;
  padding: 11px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted-2);
}

.logout:hover {
  background: var(--surface-hover);
  color: var(--text-strong);
}

.topbar {
  height: 58px;
  border-bottom: 1px solid var(--surface-hover);
  display: flex;
  align-items: center;
  padding: 0 24px;
}

.status {
  color: var(--accent);
  font-size: 12px;
  margin-left: 10px;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 32px 24px 150px;
}

.welcome {
  text-align: center;
  margin: 18vh auto 0;
}

.welcome h1 {
  font-size: 38px;
  margin-bottom: 8px;
}

.welcome p {
  color: var(--muted);
  font-size: 17px;
}

.message {
  max-width: 820px;
  margin: 0 auto 18px;
  line-height: 1.55;
}

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

.message.user .bubble {
  background: var(--user-bubble);
  border: 1px solid var(--user-bubble-border);
  color: var(--user-bubble-text);
  border-radius: 16px;
  padding: 12px 16px;
  max-width: 75%;
}

.message.assistant .bubble {
  background: transparent;
  padding: 8px 2px;
  max-width: 100%;
}

.composer-wrap {
  position: absolute;
  left: 260px;
  right: 0;
  bottom: 0;
  padding: 18px 24px 26px;
  background: linear-gradient(
    transparent,
    var(--bg) 35%
  );
}

.composer {
  max-width: 820px;
  margin: 0 auto;
  display: flex;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--composer-border);
  border-radius: 18px;
  padding: 10px;
}

.composer textarea {
  flex: 1;
  resize: none;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text-strong);
  padding: 9px 10px;
  min-height: 42px;
  max-height: 160px;
}

.composer button {
  align-self: flex-end;
  border: 0;
  border-radius: 12px;
  padding: 10px 18px;
  background: var(--button-bg);
  color: var(--button-text);
  font-weight: 700;
}

.composer button:disabled {
  opacity: .5;
  cursor: default;
}

@media (max-width: 700px) {
  .sidebar {
    display: none;
  }

  .composer-wrap {
    left: 0;
    padding: 14px;
  }

  .messages {
    padding-left: 16px;
    padding-right: 16px;
  }
}

.conversation-item {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--soft-text);
  padding: 10px 11px;
  margin-bottom: 3px;
  border-radius: 8px;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-item:hover {
  background: var(--surface-hover-2);
  color: var(--text-strong);
}

.conversation-item.active {
  background: var(--surface-active);
  color: var(--text-strong);
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.core {
  width: 18px;
  height: 18px;
  position: relative;
  display: inline-block;
}

.core::before,
.core::after {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: 50%;
  border: 1px solid var(--accent);
  opacity: .45;
}

.core::after {
  inset: 4px;
  opacity: .7;
}

.core-center {
  position: absolute;
  width: 5px;
  height: 5px;
  left: 50%;
  top: 50%;
  border-radius: 50%;
  background: var(--accent);
  transform: translate(-50%, -50%);
  box-shadow: 0 0 8px var(--accent);
}

.status.thinking .core::before {
  border-top-color: transparent;
  border-bottom-color: transparent;
  animation: coreSpin 1s linear infinite;
  box-shadow: 0 0 10px var(--accent-glow-strong);
}

.status.thinking .core::after {
  border-left-color: transparent;
  animation: coreSpinReverse .7s linear infinite;
}

.status.thinking .core-center {
  animation: corePulse .8s ease-in-out infinite alternate;
}

@keyframes coreSpin {
  to { transform: rotate(360deg); }
}

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

@keyframes corePulse {
  from {
    transform: translate(-50%, -50%) scale(.7);
    box-shadow: 0 0 5px var(--accent);
  }

  to {
    transform: translate(-50%, -50%) scale(1.45);
    box-shadow: 0 0 16px var(--accent);
  }
}

.thinking-bubble {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
}

.thinking-core {
  width: 34px;
  height: 34px;
  position: relative;
  flex: 0 0 34px;
}

.thinking-core .ring-one,
.thinking-core .ring-two {
  position: absolute;
  border-radius: 50%;
}

.thinking-core .ring-one {
  inset: 0;
  border: 2px solid var(--accent);
  border-top-color: transparent;
  animation: anthonySpin 1s linear infinite;
  box-shadow: 0 0 12px var(--accent-glow);
}

.thinking-core .ring-two {
  inset: 6px;
  border: 2px solid var(--accent);
  border-left-color: transparent;
  opacity: .7;
  animation: anthonySpinReverse .65s linear infinite;
}

.thinking-core .energy {
  position: absolute;
  width: 7px;
  height: 7px;
  left: 50%;
  top: 50%;
  border-radius: 50%;
  background: var(--accent);
  transform: translate(-50%,-50%);
  animation: anthonyEnergy .7s ease-in-out infinite alternate;
}

@keyframes anthonySpin {
  to { transform: rotate(360deg); }
}

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

@keyframes anthonyEnergy {
  from {
    transform: translate(-50%,-50%) scale(.7);
    box-shadow: 0 0 5px var(--accent);
  }
  to {
    transform: translate(-50%,-50%) scale(1.5);
    box-shadow: 0 0 20px var(--accent);
  }
}

.status.responding .core::before {
  border-top-color: transparent;
  animation: coreSpin 2s linear infinite;
}

.status.responding .core::after {
  border-left-color: transparent;
  animation: coreSpinReverse 1.4s linear infinite;
}

.status.responding .core-center {
  animation: corePulse 1.4s ease-in-out infinite alternate;
}

.thinking-bubble.responding-bubble {
  color: var(--text);
  align-items: flex-start;
}

.response-text {
  white-space: pre-wrap;
  line-height: 1.55;
}

/* ===== THEME: CORE DARK ===== */
:root,
html[data-theme="core"][data-mode="dark"] {
  --bg: #0D0D0F;
  --sidebar: #151518;
  --surface: #202024;
  --surface-hover: #252529;
  --surface-hover-2: #242428;
  --surface-active: #2D2D32;

  --text: #F4F4F5;
  --text-strong: #FFFFFF;
  --soft-text: #C9C9CF;
  --muted: #94949D;
  --muted-2: #AAAAAA;

  --border: #29292E;
  --border-strong: #38383E;
  --composer-border: #39393F;

  --accent: #6EE7A8;
  --accent-glow: rgba(110,231,168,.35);
  --accent-glow-strong: rgba(110,231,168,.40);

  --user-bubble: #25252A;
  --user-bubble-border: #35353B;
  --user-bubble-text: #F4F4F5;

  --button-bg: #F4F4F5;
  --button-text: #111111;
}

/* ===== THEME: CORE LIGHT ===== */
html[data-theme="core"][data-mode="light"] {
  --bg: #F3F7F4;
  --sidebar: #E8F0EB;
  --surface: #FFFFFF;
  --surface-hover: #E2ECE6;
  --surface-hover-2: #E7EFEA;
  --surface-active: #D5E5DB;

  --text: #19211C;
  --text-strong: #101512;
  --soft-text: #4D5B52;
  --muted: #6D7C73;
  --muted-2: #7B8980;

  --border: #D3DED7;
  --border-strong: #BFCEC4;
  --composer-border: #C7D5CC;

  --accent: #2F9E68;
  --accent-glow: rgba(47,158,104,.25);
  --accent-glow-strong: rgba(47,158,104,.35);

  --user-bubble: #DDF5E7;
  --user-bubble-border: #B7E4C8;
  --user-bubble-text: #183426;

  --button-bg: #2F9E68;
  --button-text: #FFFFFF;
}

/* ===== THEME: SKY LIGHT ===== */
html[data-theme="sky"][data-mode="light"] {
  --bg: #F4F7FB;
  --sidebar: #FFFFFF;
  --surface: #FFFFFF;
  --surface-hover: #EDF3FA;
  --surface-hover-2: #E8F0F8;
  --surface-active: #DFEAF7;

  --text: #17212B;
  --text-strong: #0B1118;
  --soft-text: #4D5B69;
  --muted: #6E7B89;
  --muted-2: #7C8996;

  --border: #DCE4EE;
  --border-strong: #C7D3E1;
  --composer-border: #CCD8E6;

  --accent: #2F80ED;
  --accent-glow: rgba(47,128,237,.25);
  --accent-glow-strong: rgba(47,128,237,.35);

  --user-bubble: #2F80ED;
  --user-bubble-border: #2A74D6;
  --user-bubble-text: #FFFFFF;

  --button-bg: #2F80ED;
  --button-text: #FFFFFF;
}

/* ===== THEME: SKY DARK ===== */
html[data-theme="sky"][data-mode="dark"] {
  --bg: #0A0F17;
  --sidebar: #101722;
  --surface: #172131;
  --surface-hover: #1D2A3D;
  --surface-hover-2: #192638;
  --surface-active: #22324A;

  --text: #F6F9FC;
  --text-strong: #FFFFFF;
  --soft-text: #C2CCD8;
  --muted: #8E9BAA;
  --muted-2: #A1ACB9;

  --border: #253247;
  --border-strong: #34445C;
  --composer-border: #314158;

  --accent: #56A6FF;
  --accent-glow: rgba(86,166,255,.28);
  --accent-glow-strong: rgba(86,166,255,.40);

  --user-bubble: #2F80ED;
  --user-bubble-border: #4A95EC;
  --user-bubble-text: #FFFFFF;

  --button-bg: #56A6FF;
  --button-text: #07111C;
}

/* ===== THEME: ANTHONY LIGHT ===== */
html[data-theme="anthony"][data-mode="light"] {
  --bg: #F1EFF1;
  --sidebar: #E8E4E7;
  --surface: #FFFFFF;
  --surface-hover: #F3EBEF;
  --surface-hover-2: #EEE7EB;
  --surface-active: #E8DCE3;

  --text: #2B2529;
  --text-strong: #1D191C;
  --soft-text: #5B5057;
  --muted: #786C74;
  --muted-2: #8B7E86;

  --border: #D9D0D6;
  --border-strong: #CBBFC7;
  --composer-border: #D1C5CC;

  --accent: #FF5C8A;
  --accent-glow: rgba(255,92,138,.25);
  --accent-glow-strong: rgba(255,92,138,.38);

  --user-bubble: #FFD1E1;
  --user-bubble-border: #F2AFC5;
  --user-bubble-text: #3A202A;

  --button-bg: #FF5C8A;
  --button-text: #FFFFFF;
}

/* ===== THEME: ANTHONY DARK ===== */
html[data-theme="anthony"][data-mode="dark"] {
  --bg: #181619;
  --sidebar: #211D21;
  --surface: #2A252A;
  --surface-hover: #322B31;
  --surface-hover-2: #2E282D;
  --surface-active: #3A3038;

  --text: #F7F2F5;
  --text-strong: #FFFFFF;
  --soft-text: #D1C5CC;
  --muted: #A89CA4;
  --muted-2: #B8ADB4;

  --border: #3B343A;
  --border-strong: #4B4148;
  --composer-border: #493E46;

  --accent: #FF6B98;
  --accent-glow: rgba(255,107,152,.28);
  --accent-glow-strong: rgba(255,107,152,.42);

  --user-bubble: #FFD1E1;
  --user-bubble-border: #F2AFC5;
  --user-bubble-text: #3A202A;

  --button-bg: #FF6B98;
  --button-text: #FFFFFF;
}

.topbar {
  justify-content: space-between;
}

.topbar-left {
  display: flex;
  align-items: center;
}

.appearance-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.appearance-controls select {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 30px 8px 11px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  outline: none;
}

.appearance-controls select:hover {
  background: var(--surface-hover);
}

.appearance-controls select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.settings-button {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.gear-icon {
  display: inline-block;
  font-size: 19px;
  animation: gearSpin 14s linear infinite;
}

.settings-button:hover {
  background: var(--surface-hover);
}

.settings-button:hover .gear-icon {
  animation-duration: 3s;
}

@keyframes gearSpin {
  to { transform: rotate(360deg); }
}

.settings-wrap {
  position: relative;
}

.settings-menu {
  position: absolute;
  top: 46px;
  right: 0;
  width: 190px;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 18px 40px rgba(0,0,0,.22);
  z-index: 50;
}

.settings-menu a,
.settings-menu button {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 10px 12px;
  border-radius: 8px;
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}

.settings-menu a:hover,
.settings-menu button:hover {
  background: var(--surface-hover);
}

.anthony-disclaimer {
  margin: 9px 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.assistant-version {
  flex: 0 0 auto;
  align-self: center;
  margin-left: 8px;
  font-size: .76rem;
  font-weight: 600;
  opacity: .55;
  white-space: nowrap;
  user-select: none;
}

.archive-toggle {
  width: 100%;
  margin-top: 7px;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 8px 11px;
  text-align: left;
}

.archive-toggle:hover {
  color: var(--text-strong);
  background: var(--surface-hover-2);
}

.conversation-row {
  position: relative;
  display: flex;
  align-items: center;
}

.conversation-row .conversation-item {
  padding-right: 40px;
}

.conversation-more {
  position: absolute;
  right: 5px;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.conversation-more:hover {
  background: var(--surface-hover);
  color: var(--text-strong);
}

.conversation-menu {
  position: absolute;
  right: 5px;
  top: 34px;
  z-index: 30;
  min-width: 145px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 12px 32px rgba(0,0,0,.22);
}

.conversation-menu button {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 7px;
  padding: 9px 10px;
  text-align: left;
  background: transparent;
  color: var(--text-strong);
  cursor: pointer;
}

.conversation-menu button:hover {
  background: var(--surface-hover-2);
}

.response-actions {
  position: relative;
  display: flex;
  gap: 4px;
  margin-top: 2px;
}

.response-actions > button {
  border: 0;
  background: transparent;
  opacity: .52;
  font-size: 15px;
  padding: 5px 7px;
  border-radius: 7px;
  cursor: pointer;
}

.response-actions > button:hover {
  opacity: 1;
  background: var(--surface-hover-2);
}

.response-actions .selected-up {
  color: #28b463;
  opacity: 1;
}

.response-actions .selected-down {
  color: #e74c3c;
  opacity: 1;
}

.feedback-pop {
  animation: feedback-pop .42s ease;
}

@keyframes feedback-pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.45); }
  100% { transform: scale(1); }
}

.feedback-menu {
  position: absolute;
  left: 34px;
  bottom: 36px;
  z-index: 25;
  width: 235px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
  box-shadow: 0 14px 34px rgba(0,0,0,.24);
}

.feedback-menu button {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text-strong);
  text-align: left;
  padding: 10px;
  border-radius: 7px;
  cursor: pointer;
}

.feedback-menu button:hover {
  background: var(--surface-hover-2);
}

.message.regenerating .bubble {
  opacity: .38;
  transition: opacity .25s ease;
}

.response-actions > button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  color: var(--muted);
  opacity: .72;
}

.response-actions > button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.response-actions > button:hover {
  color: var(--text-strong);
  opacity: 1;
}

.response-actions .selected-up {
  color: #22c55e;
  opacity: 1;
}

.response-actions .selected-down {
  color: #ef4444;
  opacity: 1;
}

.response-actions .regenerate-action {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--soft-text);
  opacity: .9;
}

.response-actions .regenerate-action:hover {
  background: var(--surface-hover-2);
  color: var(--text-strong);
  opacity: 1;
}

.response-actions .selected-up svg {
  stroke-width: 2.25;
}

.response-actions .selected-down svg {
  stroke-width: 2.25;
}

/* ===== WEB RESEARCH ACTIVITY ===== */
.research-panel {
  margin: 0 0 4px 2px;
  padding: 8px 10px;
  border-left: 2px solid var(--accent);
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--muted);
}

.research-source {
  width: fit-content;
  color: var(--muted);
  text-decoration: none;
}

.research-source::before {
  content: "• ";
  color: var(--accent);
}

.research-source:hover {
  color: var(--text);
  text-decoration: underline;
}
