:root {
  color-scheme: dark;

  --bg: #0a0a0c;
  --stage: #131316;
  --tile: #24242a;
  --panel: #1b1b20;
  --panel-2: #23232a;
  --toolbar: #121215;
  --titlebar: #0d0d10;

  --text: #f4f4f6;
  --text-2: #c9c9d1;
  --muted: #9a9aa6;
  --muted-2: #71717c;

  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.16);

  --blue: #2d8cff;
  --blue-hover: #4d9dff;
  --blue-soft: #a8c6ff;
  --green: #22d364;
  --green-soft: rgba(34, 211, 100, 0.16);
  --red: #e5484d;
  --red-hover: #f0565b;
  --amber: #f5a524;

  --bubble: #2a2e42;
  --bubble-own: #2f4a8a;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;

  --shadow-1: 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-2: 0 16px 48px rgba(0, 0, 0, 0.55);
  --shadow-3: 0 28px 80px rgba(0, 0, 0, 0.65);

  --titlebar-h: 38px;
  --toolbar-h: 76px;
  --panel-w: 372px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html,
body {
  height: 100%;
}

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

body.is-light {
  --bg: #f7f7f9;
  --stage: #eceded;
  --tile: #dcdce1;
  --panel: #ffffff;
  --panel-2: #f2f2f5;
  --toolbar: #ffffff;
  --titlebar: #ffffff;
  --text: #101014;
  --text-2: #3b3b45;
  --muted: #6b6b76;
  --line: rgba(0, 0, 0, 0.1);
  --line-strong: rgba(0, 0, 0, 0.18);
  --bubble: #ececf3;
  color-scheme: light;
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

a {
  color: var(--blue);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

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

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.icon {
  width: 20px;
  height: 20px;
  display: block;
  flex: none;
}

/* ------------------------------------------------------------------ *
 * Buttons
 * ------------------------------------------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 18px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: background 0.16s var(--ease), color 0.16s var(--ease), transform 0.16s var(--ease);
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--blue);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--blue-hover);
}

.btn-primary:disabled {
  background: #2c3340;
  color: #7b8496;
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  border: 1px solid var(--line);
}

.btn-ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.12);
}

.btn-danger {
  background: var(--red);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  background: var(--red-hover);
}

.btn-sm {
  height: 32px;
  padding: 0 12px;
  font-size: 13px;
  border-radius: 8px;
}

/* ------------------------------------------------------------------ *
 * Inputs
 * ------------------------------------------------------------------ */

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

.field > label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.input {
  width: 100%;
  height: 42px;
  padding: 0 14px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  color: var(--text);
  transition: border-color 0.16s var(--ease), background 0.16s var(--ease);
}

.input::placeholder {
  color: var(--muted-2);
}

.input:hover {
  border-color: var(--line-strong);
}

.input:focus {
  outline: none;
  border-color: var(--blue);
  background: rgba(45, 140, 255, 0.08);
}

.input.is-invalid {
  border-color: var(--red);
}

select.input {
  appearance: none;
  cursor: pointer;
  padding-right: 34px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 19px, calc(100% - 13px) 19px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

/* ------------------------------------------------------------------ *
 * Toasts
 * ------------------------------------------------------------------ */

.toasts {
  position: fixed;
  left: 50%;
  bottom: calc(var(--toolbar-h) + 22px);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  z-index: 90;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-radius: 10px;
  background: #26262e;
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-2);
  font-size: 13px;
  animation: toast-in 0.24s var(--ease);
}

.toast.is-error {
  border-color: rgba(229, 72, 77, 0.5);
}

.toast.is-ok {
  border-color: rgba(34, 211, 100, 0.45);
}

.toast.is-leaving {
  animation: toast-out 0.2s var(--ease) forwards;
}

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

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

/* ------------------------------------------------------------------ *
 * Modal
 * ------------------------------------------------------------------ */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 4, 6, 0.62);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  z-index: 120;
  padding: 24px;
  animation: fade-in 0.16s var(--ease);
}

.modal {
  width: min(520px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-3);
  animation: modal-in 0.2s var(--ease);
}

.modal.is-wide {
  width: min(700px, 100%);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 12px;
}

.modal-title {
  font-size: 16px;
  font-weight: 650;
}

.modal-body {
  padding: 4px 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: min(64vh, 560px);
  overflow-y: auto;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px 20px;
  border-top: 1px solid var(--line);
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  color: var(--muted);
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.09);
  color: var(--text);
}

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

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
}

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

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.16);
  border-radius: 99px;
  border: 3px solid transparent;
  background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.28);
  background-clip: content-box;
}

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

/* The hidden attribute must always win over component display rules. */
[hidden] {
  display: none !important;
}
