/* =========================================================
   c4rbn — монохромный моноширинный интерфейс в стиле iOS
   ========================================================= */

@font-face {
  font-family: "JBMono";
  src: local("JetBrains Mono");
}

:root {
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", "Menlo", "Consolas",
    "Roboto Mono", monospace;

  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --tabbar-h: 64px;
  --tabbar-gap: 14px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --mascot-accent: #ff9f6b;
  --mascot-blush: #ff7a8a;
}

/* ---------- тема: тёмная (по умолчанию) ---------- */
:root,
html[data-theme="dark"] {
  --bg: #0b0b0c;
  --bg-elevated: #151517;
  --bg-input: #1d1d20;
  --bg-tabbar: rgba(15, 15, 16, 0.82);
  --text-primary: #f0f0f0;
  --text-secondary: #a7a7ac;
  --text-tertiary: #6b6b70;
  --border: #2a2a2d;
  --border-strong: #3c3c40;
  --accent: #ffffff;
  --accent-dim: #8f8f94;
  --chip-bg: #1f1f22;
  --shadow: rgba(0, 0, 0, 0.5);
  --active-fill: #ffffff;
  --active-text: #0b0b0c;
}

/* ---------- тема: светлая ---------- */
html[data-theme="light"] {
  --bg: #f2f2f0;
  --bg-elevated: #ffffff;
  --bg-input: #e8e8e6;
  --bg-tabbar: rgba(246, 246, 244, 0.85);
  --text-primary: #16161a;
  --text-secondary: #55555c;
  --text-tertiary: #8a8a90;
  --border: #dcdcd8;
  --border-strong: #c7c7c2;
  --accent: #16161a;
  --accent-dim: #66666c;
  --chip-bg: #e4e4e1;
  --shadow: rgba(0, 0, 0, 0.12);
  --active-fill: #16161a;
  --active-text: #f2f2f0;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-mono);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

* {
  font-family: var(--font-mono) !important;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ---------- иконки (инлайн SVG вместо иконочного шрифта) ---------- */

.icon {
  width: 1em;
  height: 1em;
  display: inline-block;
  vertical-align: -0.15em;
  flex-shrink: 0;
}

.icon-spin {
  animation: iconSpin 0.8s linear infinite;
}

@keyframes iconSpin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

button {
  font-family: var(--font-mono);
  border: none;
  background: none;
  cursor: pointer;
  color: inherit;
}

/* ---------- шапка ---------- */

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px 10px;
  background: linear-gradient(to bottom, var(--bg) 70%, transparent);
}

.app-header .logo-mark {
  width: 30px;
  height: 30px;
  color: var(--text-primary);
  flex-shrink: 0;
}

.app-header .logo-text {
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.5px;
}

.app-header .logo-text .num {
  color: var(--text-tertiary);
}

.app-header .header-spacer {
  flex: 1;
}

.header-badge {
  font-size: 11px;
  color: var(--text-tertiary);
  border: 1px solid var(--border);
  padding: 4px 9px;
  border-radius: 20px;
  letter-spacing: 0.5px;
}

/* ---------- основная область ---------- */

.app-main {
  flex: 1;
  padding: 4px 18px calc(var(--tabbar-h) + var(--tabbar-gap) * 2 + var(--safe-bottom) + 20px);
  max-width: 560px;
  width: 100%;
  margin: 0 auto;
}

.tab-panel {
  display: none;
  animation: fadeUp 0.28s ease;
}

.tab-panel.active {
  display: block;
}

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

/* ---------- маскот-герой ---------- */

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 22px 0 10px;
  text-align: center;
}

.mascot {
  width: 136px;
  height: 136px;
  color: var(--text-primary);
  overflow: visible;
}

/* ---- лиса: используется и в шапке (мини-лого), и в hero-маскоте ---- */

.logo-mark .fox-head,
.mascot .fox-head {
  fill: var(--mascot-accent);
  stroke: var(--text-primary);
  stroke-width: 2.6;
  stroke-linejoin: round;
}

.logo-mark .fox-ear,
.mascot .fox-ear {
  fill: var(--mascot-accent);
  stroke: var(--text-primary);
  stroke-width: 2.4;
  stroke-linejoin: round;
}

.mascot .fox-ear-inner {
  fill: var(--bg-elevated);
  opacity: 0.85;
}

.logo-mark .fox-muzzle,
.mascot .fox-muzzle {
  fill: var(--bg-elevated);
}

.logo-mark .fox-eye,
.mascot .mascot-eye {
  fill: var(--text-primary);
}

.mascot .mascot-eye-shine {
  fill: var(--bg-elevated);
}

.logo-mark .fox-nose,
.mascot .fox-nose {
  fill: var(--text-primary);
}

.mascot .fox-whisker {
  stroke: var(--border-strong);
  stroke-width: 1.6;
  stroke-linecap: round;
}

.mascot .mascot-mouth {
  fill: none;
  stroke: var(--text-primary);
  stroke-width: 2.4;
  stroke-linecap: round;
}

.mascot .mascot-mouth-o {
  fill: var(--text-primary);
}

.mascot .mascot-blush {
  fill: var(--mascot-blush);
  opacity: 0.55;
}

.mascot .fox-brow {
  stroke: var(--text-primary);
  stroke-width: 2.2;
  stroke-linecap: round;
}

.mascot .mascot-qmark {
  font-size: 20px;
  font-weight: 800;
  fill: var(--text-primary);
}

.mascot .mascot-bounce {
  transform-origin: 80px 84px;
  animation: mascotBounce 3.6s ease-in-out infinite;
}

.mascot .mascot-eyes {
  transform-origin: 80px 88px;
  animation: mascotBlink 5.2s ease-in-out infinite;
}

@keyframes mascotBounce {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-5px);
  }
}

@keyframes mascotBlink {
  0%,
  92%,
  100% {
    transform: scaleY(1);
  }
  95% {
    transform: scaleY(0.1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .mascot .mascot-bounce,
  .mascot .mascot-eyes {
    animation: none;
  }
}

.hero-title {
  margin-top: 14px;
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.hero-title b {
  color: var(--text-primary);
}

/* ---------- секции / карточки ---------- */

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-bottom: 16px;
}

.section-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-tertiary);
  margin: 0 0 10px 4px;
  font-weight: 600;
}

/* ---------- инпуты (в стиле iOS) ---------- */

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 12px;
  color: var(--text-tertiary);
  margin-bottom: 6px;
  margin-left: 2px;
}

.input,
textarea.input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 13px 14px;
  font-size: 15px;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.input::placeholder {
  color: var(--text-tertiary);
}

.input:focus {
  border-color: var(--border-strong);
  background: var(--bg-elevated);
  box-shadow: 0 0 0 3px var(--chip-bg);
}

.input-prefix-group {
  display: flex;
  align-items: stretch;
  background: var(--bg-input);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.input-prefix-group .prefix {
  display: flex;
  align-items: center;
  padding: 0 12px;
  color: var(--text-tertiary);
  font-size: 14px;
  border-right: 1px solid var(--border);
  white-space: nowrap;
}

.input-prefix-group .input {
  border-radius: 0;
  background: transparent;
}

/* ---------- сегментированный контрол (длина ссылки) ---------- */

.segmented {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  background: var(--bg-input);
  border-radius: var(--radius-md);
  padding: 5px;
}

.segmented button {
  padding: 9px 0;
  font-size: 13px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-weight: 600;
  transition: background 0.15s ease, color 0.15s ease;
}

.segmented button.active {
  background: var(--active-fill);
  color: var(--active-text);
}

/* ---------- кнопки ---------- */

.btn {
  width: 100%;
  padding: 15px 0;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.3px;
  background: var(--active-fill);
  color: var(--active-text);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.08s ease, opacity 0.15s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.btn.secondary {
  background: var(--chip-bg);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn.ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn.danger-outline {
  background: transparent;
  color: var(--text-primary);
  border: 1px dashed var(--border-strong);
}

.btn.small {
  width: auto;
  padding: 9px 14px;
  font-size: 13px;
}

/* ---------- результат / карточка ссылки ---------- */

.result-card {
  margin-top: 4px;
  display: none;
}

.result-card.show {
  display: block;
}

.result-url-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-input);
  border-radius: var(--radius-md);
  padding: 12px 12px 12px 14px;
}

.result-url-row .url-text {
  flex: 1;
  font-size: 14.5px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-btn {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 15px;
  flex-shrink: 0;
  transition: background 0.15s ease, color 0.15s ease;
}

.icon-btn:hover {
  background: var(--chip-bg);
  color: var(--text-primary);
}

.hint {
  font-size: 12.5px;
  color: var(--text-tertiary);
  margin-top: 10px;
  display: flex;
  align-items: flex-start;
  gap: 7px;
  line-height: 1.5;
}

.hint .icon {
  margin-top: 2px;
}

.error-box {
  display: none;
  font-size: 13px;
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--text-primary);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  margin-top: 10px;
  font-weight: 600;
}

.error-box.show {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

/* ---------- список ссылок ---------- */

.link-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 4px;
  border-bottom: 1px solid var(--border);
}

.link-item:last-child {
  border-bottom: none;
}

.link-item .link-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: var(--chip-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  flex-shrink: 0;
  font-size: 14px;
}

.link-item .link-body {
  flex: 1;
  min-width: 0;
}

.link-item .link-code {
  font-weight: 700;
  font-size: 14.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.link-item .link-target {
  font-size: 12px;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.link-item .link-meta {
  font-size: 11px;
  color: var(--text-tertiary);
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

.link-item .link-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.empty-state {
  text-align: center;
  padding: 40px 10px;
  color: var(--text-tertiary);
}

.empty-state .icon {
  font-size: 30px;
  margin-bottom: 12px;
  display: block;
  color: var(--border-strong);
}

.empty-state p {
  font-size: 13.5px;
  line-height: 1.6;
  margin: 0;
}

/* ---------- токен-блок (настройки) ---------- */

.token-display {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-input);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

.token-display span {
  flex: 1;
  font-size: 13px;
  letter-spacing: 0.5px;
  word-break: break-all;
  color: var(--text-secondary);
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 2px;
  border-bottom: 1px solid var(--border);
}

.settings-row:last-child {
  border-bottom: none;
}

.settings-row .label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14.5px;
}

.settings-row .label .icon {
  width: 20px;
  text-align: center;
  color: var(--text-secondary);
}

.settings-row .value {
  font-size: 13px;
  color: var(--text-tertiary);
}

/* ---------- тема-переключатель ---------- */

.theme-toggle {
  display: flex;
  gap: 8px;
}

.theme-toggle button {
  flex: 1;
  padding: 10px 0;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
}

.theme-toggle button.active {
  background: var(--active-fill);
  color: var(--active-text);
}

/* ---------- таббар: сегментированный контрол (как выбор диапазона) ---------- */

.tabbar {
  position: fixed;
  left: var(--tabbar-gap);
  right: var(--tabbar-gap);
  bottom: calc(var(--tabbar-gap) + var(--safe-bottom));
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  height: var(--tabbar-h);
  padding: 5px;
  background: var(--bg-tabbar);
  backdrop-filter: blur(18px) saturate(1.1);
  -webkit-backdrop-filter: blur(18px) saturate(1.1);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 10px 30px var(--shadow);
}

.tabbar-thumb {
  position: absolute;
  top: 5px;
  left: 5px;
  width: calc((100% - 10px) / 4);
  height: calc(100% - 10px);
  background: var(--active-fill);
  border-radius: var(--radius-md);
  transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
  z-index: 0;
}

.tab-btn {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  transition: color 0.2s ease, transform 0.1s ease;
}

.tab-btn .icon {
  font-size: 18px;
}

.tab-btn span {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.tab-btn.active {
  color: var(--active-text);
}

.tab-btn:active {
  transform: scale(0.94);
}

/* ---------- toast ---------- */

.toast {
  position: fixed;
  bottom: calc(var(--tabbar-h) + var(--tabbar-gap) * 2 + var(--safe-bottom) + 6px);
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--active-fill);
  color: var(--active-text);
  padding: 11px 18px;
  border-radius: 30px;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 50;
  white-space: nowrap;
}

.toast-icon {
  display: flex;
  font-size: 15px;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------- скроллбар ---------- */

::-webkit-scrollbar {
  width: 0;
  height: 0;
}

/* ---------- утилиты ---------- */

.mt-6 {
  margin-top: 6px;
}
.text-center {
  text-align: center;
}
.muted {
  color: var(--text-tertiary);
}

@media (max-width: 380px) {
  .segmented button {
    font-size: 11.5px;
  }
}
