/* Общее для главной страницы и веб-версии: цвета темы, кнопки, поля, окна, меню и сообщения. */

:root {
  /* Тема «Полночь»; цвета выбранной темы подставляет скрипт (те же ключи, что в themes.json). */
  --Bg: #0D1117;
  --Panel: #161B22;
  --Panel2: #1C2230;
  --Border: #30363D;
  --BorderHover: #484F58;
  --HoverBg: #262D3A;
  --CardActive: #17202E;
  --CardHoverBorder: #2F5A94;
  --Text: #E6EDF3;
  --Body: #C9D1D9;
  --Muted: #8B949E;
  --Bright: #FFFFFF;
  --Button: #141A24;
  --ButtonHover: #1A2638;
  --ButtonPressed: #22324A;
  --ButtonBorder: #3B4B66;
  --Accent: #2F81F7;
  --AccentHover: #4A93F8;
  --AccentPressed: #1F6FE0;
  --AccentBright: #58A6FF;
  --AccentGlow: #79B8FF;
  --AccentText: #79C0FF;
  --AccentOn: #DCEBFF;
  --AccentEdge: #3D6FB8;
  --Tip: #14233A;
  --Done: #3FB950;
  --DoneText: #56D364;
  --DoneOn: #C2F5CB;
  --DoneEdge: #2F8F43;
  --DoneBg: #14301F;
  --Danger: #F85149;
  --DangerHover: #FF7B72;
  --DangerText: #FFB4AE;
  --DangerOn: #FFC1BC;
  --DangerBg: #2D1618;
  --Warning: #E3B341;
  --WarningText: #F0CF7A;
  --WarningOn: #FFE7A6;
  --WarningEdge: #B39032;
  --Info: #2EC4B6;
  --InfoOn: #C8F7F1;
  --InfoEdge: #23887F;
  --Purple: #A371F7;
  --PurpleText: #C9A8FF;
  --PurpleOn: #E8DCFF;
  --PurpleEdge: #7653B8;
  --glow: 1;

  --radius: 10px;
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Roboto", "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Mono", "Consolas", ui-monospace, "SF Mono", "Roboto Mono", monospace;
  color-scheme: dark;
}

:root[data-scheme="light"] {
  color-scheme: light;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--Bg);
  color: var(--Text);
  font: 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

a {
  color: var(--AccentText);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--AccentBright);
  outline-offset: 2px;
}

::selection {
  background: color-mix(in srgb, var(--Accent) 45%, transparent);
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--Muted);
}

.icon {
  width: 1em;
  height: 1em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -0.125em;
}

/* ---------------------------------------------------------------- кнопки */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 34px;
  padding: 6px 14px;
  border: 1px solid var(--ButtonBorder);
  border-radius: 8px;
  background: var(--Button);
  color: var(--Text);
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, color 0.15s;
}

.btn:hover {
  background: var(--ButtonHover);
  border-color: var(--AccentEdge);
  text-decoration: none;
}

.btn:active {
  background: var(--ButtonPressed);
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.btn .icon {
  font-size: 15px;
}

.btn-accent {
  background: var(--Accent);
  border-color: var(--Accent);
  color: #fff;
  box-shadow: 0 0 calc(14px * var(--glow)) color-mix(in srgb, var(--Accent) calc(55% * var(--glow)), transparent);
}

.btn-accent:hover {
  background: var(--AccentHover);
  border-color: var(--AccentHover);
  box-shadow: 0 0 calc(20px * var(--glow)) color-mix(in srgb, var(--AccentGlow) calc(60% * var(--glow)), transparent);
}

.btn-accent:active {
  background: var(--AccentPressed);
}

.btn-danger {
  border-color: color-mix(in srgb, var(--Danger) 60%, transparent);
  color: var(--DangerText);
  background: var(--DangerBg);
}

.btn-danger:hover {
  border-color: var(--Danger);
  background: color-mix(in srgb, var(--Danger) 22%, var(--Panel));
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
}

.btn-ghost:hover {
  background: var(--HoverBg);
  border-color: transparent;
}

.btn-lg {
  min-height: 46px;
  padding: 10px 22px;
  font-size: 15px;
  border-radius: 10px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  flex: none;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--Muted);
  font-size: 15px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.icon-btn:hover {
  background: var(--HoverBg);
  color: var(--Text);
}

.icon-btn.danger:hover {
  background: var(--DangerBg);
  color: var(--Danger);
}

.icon-btn.success:hover {
  background: color-mix(in srgb, var(--Done) 18%, transparent);
  color: var(--DoneText);
}

.icon-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

/* ---------------------------------------------------------------- поля */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.field > label,
.field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--Muted);
}

.input,
.textarea,
.select {
  width: 100%;
  min-height: 38px;
  padding: 8px 11px;
  border: 1px solid var(--Border);
  border-radius: 8px;
  background: var(--Bg);
  color: var(--Text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input:hover,
.textarea:hover,
.select:hover {
  border-color: var(--BorderHover);
}

.input:focus,
.textarea:focus,
.select:focus {
  border-color: var(--Accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--Accent) 22%, transparent);
}

.textarea {
  min-height: 110px;
  resize: vertical;
  line-height: 1.5;
}

.input::placeholder,
.textarea::placeholder {
  color: color-mix(in srgb, var(--Muted) 75%, transparent);
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-wrap .input {
  padding-right: 40px;
}

.input-wrap .icon-btn {
  position: absolute;
  right: 4px;
}

.hint {
  font-size: 12px;
  color: var(--Muted);
}

.error-box {
  margin: 0 0 14px;
  padding: 9px 12px;
  border: 1px solid color-mix(in srgb, var(--Danger) 55%, transparent);
  border-radius: 8px;
  background: var(--DangerBg);
  color: var(--DangerText);
  font-size: 13px;
}

.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.segmented button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--Border);
  border-radius: 999px;
  background: var(--Bg);
  color: var(--Body);
  font-size: 13px;
}

.segmented button:hover {
  border-color: var(--BorderHover);
}

.segmented button.on {
  border-color: var(--seg, var(--Accent));
  background: color-mix(in srgb, var(--seg, var(--Accent)) 20%, transparent);
  color: var(--Text);
  box-shadow: 0 0 calc(10px * var(--glow)) color-mix(in srgb, var(--seg, var(--Accent)) calc(35% * var(--glow)), transparent);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--seg, var(--Accent));
  flex: none;
}

kbd {
  display: inline-block;
  padding: 0 6px;
  border: 1px solid var(--Border);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--Panel2);
  font: 12px/1.6 var(--mono);
  color: var(--Text);
}

/* ---------------------------------------------------------------- сообщения внизу */

.toasts {
  position: fixed;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom));
  z-index: 300;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transform: translateX(-50%);
  pointer-events: none;
  width: max-content;
  max-width: calc(100vw - 24px);
}

.toast {
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: 100%;
  padding: 9px 16px;
  border: 1px solid var(--Border);
  border-radius: 999px;
  background: var(--Panel2);
  color: var(--Text);
  font-size: 13px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  animation: toast-in 0.18s ease-out;
}

.toast span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toast .icon {
  color: var(--DoneText);
  font-size: 15px;
}

.toast.error {
  border-color: color-mix(in srgb, var(--Danger) 60%, transparent);
  background: var(--DangerBg);
  color: var(--DangerText);
}

.toast.error .icon {
  color: var(--Danger);
}

.toast.out {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.2s, transform 0.2s;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* ---------------------------------------------------------------- окна */

.backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(1, 4, 9, 0.62);
  backdrop-filter: blur(3px);
  animation: fade-in 0.15s ease-out;
}

.dialog {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 480px;
  max-height: calc(100vh - 48px);
  max-height: calc(100dvh - 48px);
  border: 1px solid var(--Border);
  border-radius: 14px;
  background: var(--Panel);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  animation: pop-in 0.16s ease-out;
}

.dialog.wide {
  max-width: 760px;
}

.dialog.huge {
  max-width: 1080px;
  height: calc(100vh - 48px);
  height: calc(100dvh - 48px);
}

.dialog-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 16px 12px 20px;
}

.dialog-head h2 {
  flex: 1;
  margin: 0;
  font-size: 16px;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dialog-head > .icon {
  font-size: 18px;
  color: var(--AccentBright);
}

.dialog-body {
  flex: 1;
  min-height: 0;
  padding: 4px 20px 6px;
  overflow: auto;
  overscroll-behavior: contain;
}

.dialog-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px 18px;
}

.dialog-foot .spacer {
  flex: 1;
}

.dialog p {
  margin: 0 0 12px;
  color: var(--Body);
  white-space: pre-wrap;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
}

/* ---------------------------------------------------------------- меню */

.menu {
  position: fixed;
  z-index: 250;
  min-width: 220px;
  max-width: min(320px, calc(100vw - 16px));
  max-height: calc(100vh - 16px);
  padding: 5px;
  overflow: auto;
  border: 1px solid var(--Border);
  border-radius: 10px;
  background: var(--Panel2);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  animation: fade-in 0.1s ease-out;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 34px;
  padding: 6px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--Text);
  font-size: 13px;
  text-align: left;
}

.menu-item:hover,
.menu-item:focus-visible {
  background: var(--HoverBg);
  outline: none;
}

.menu-item .icon {
  font-size: 15px;
  color: var(--Muted);
}

.menu-item .label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu-item .check {
  color: var(--AccentBright);
}

.menu-item.danger {
  color: var(--DangerText);
}

.menu-item.danger .icon {
  color: var(--Danger);
}

.menu-item:disabled {
  opacity: 0.45;
  cursor: default;
}

.menu-item:disabled:hover {
  background: transparent;
}

.menu-sep {
  height: 1px;
  margin: 5px 6px;
  background: var(--Border);
}

.menu-title {
  padding: 6px 10px 4px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--Muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------------------------------------------------------------- телефон */

@media (max-width: 640px) {
  .backdrop {
    padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  }

  .dialog,
  .dialog.wide,
  .dialog.huge {
    max-width: none;
    max-height: calc(100vh - 24px);
    max-height: calc(100dvh - 24px);
    border-radius: 14px;
  }

  .dialog.huge {
    height: calc(100vh - 24px);
    height: calc(100dvh - 24px);
  }

  .dialog-foot .btn {
    flex: 1;
  }

  .dialog-foot .spacer {
    display: none;
  }

  .menu.sheet {
    left: 0 !important;
    right: 0;
    top: auto !important;
    bottom: 0;
    max-width: none;
    max-height: 75vh;
    padding: 8px 8px calc(10px + env(safe-area-inset-bottom));
    border-radius: 16px 16px 0 0;
    box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.45);
    animation: sheet-in 0.18s ease-out;
  }

  .menu.sheet .menu-item {
    min-height: 44px;
    font-size: 15px;
  }

  .toasts {
    bottom: calc(86px + env(safe-area-inset-bottom));
  }

  body:has(.backdrop) .toasts {
    top: calc(12px + env(safe-area-inset-top));
    bottom: auto;
  }
}

@keyframes sheet-in {
  from {
    transform: translateY(40px);
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
