:root {
  color-scheme: light;
  font-family:
    "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #eef7ff;
  color: #17212b;
  --ton-blue: #0098ea;
  --telegram-blue: #2aabee;
  --ink: #17212b;
  --muted: #66788a;
  --line: rgba(0, 82, 136, 0.14);
  --surface: rgba(255, 255, 255, 0.82);
  --surface-strong: #ffffff;
  --shadow: 0 24px 60px rgba(0, 77, 128, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 16% 12%, rgba(0, 152, 234, 0.2), transparent 34%),
    radial-gradient(circle at 88% 4%, rgba(42, 171, 238, 0.2), transparent 30%),
    linear-gradient(180deg, #f6fbff 0%, #e9f6ff 44%, #f7fbff 100%);
}

button,
input {
  font: inherit;
}

button,
input,
summary,
a {
  touch-action: manipulation;
}

input[type="url"],
input[type="number"] {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
  color: var(--ink);
}

.app-shell {
  width: min(1160px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 18px 0 36px;
}

.topbar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 20px;
  min-height: 42px;
  margin-bottom: 8px;
}

#ton-connect {
  position: absolute;
  top: 0;
  right: 0;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 24px;
  align-items: start;
}

.side-column {
  display: grid;
  gap: 10px;
}

.site-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding-top: 22px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.site-footer a {
  color: var(--muted);
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--ton-blue);
}

.board-wrap {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.board-viewport {
  position: relative;
  aspect-ratio: 1 / 1;
  width: 100%;
  overflow: hidden;
  border-radius: 0;
  background: #ffffff;
  box-shadow: inset 0 0 0 1px rgba(116, 132, 148, 0.24);
  touch-action: none;
  user-select: none;
}

.board-viewport.panning {
  cursor: grab;
}

.board-viewport.draft-move-mode .pixel-canvas {
  cursor: move;
}

.pixel-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  user-select: none;
  cursor: pointer;
  image-rendering: pixelated;
}

.panel {
  display: grid;
  gap: 16px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface-strong);
  box-shadow: var(--shadow);
}

.panel-links {
  display: flex;
  justify-content: center;
  padding-top: 0;
  font-size: 13px;
  font-weight: 800;
}

.panel-links a {
  color: var(--telegram-blue);
  text-decoration: none;
}

.panel-links a:hover {
  color: var(--ton-blue);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  min-height: 28px;
}

.language-control {
  display: flex;
  gap: 4px;
  padding: 3px;
  border: 1px solid rgba(0, 82, 136, 0.16);
  border-radius: 999px;
  background: #eef7ff;
}

.lang-button {
  min-width: 34px;
  height: 24px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 800;
}

.lang-button.active {
  background: #ffffff;
  color: var(--ton-blue);
  box-shadow: 0 6px 14px rgba(0, 119, 190, 0.12);
}

.info-button {
  appearance: none;
  min-width: 0;
  height: 28px;
  border: 1px solid rgba(0, 82, 136, 0.24);
  border-radius: 999px;
  background: #ffffff;
  color: var(--ton-blue);
  cursor: pointer;
  padding: 0 10px;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
}

.info-button:hover {
  border-color: rgba(0, 152, 234, 0.5);
  background: #f2f9ff;
}

.mobile-mode-control {
  display: none;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border: 1px solid rgba(0, 82, 136, 0.16);
  border-radius: 999px;
  background: #eef7ff;
}

.mode-button {
  min-width: 0;
  height: 34px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

.mode-button.active {
  background: #ffffff;
  color: var(--ton-blue);
  box-shadow: 0 8px 20px rgba(0, 119, 190, 0.12);
}

.field-row,
.color-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.field-row span,
.color-control span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.field-row strong {
  color: var(--ink);
  font-weight: 700;
}

.draft-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f7fbff;
}

.draft-details {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #ffffff;
}

.draft-details summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 40px;
  padding: 0 12px;
  color: var(--ton-blue);
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
  list-style: none;
}

.draft-details summary::-webkit-details-marker {
  display: none;
}

.draft-details summary::after {
  content: "+";
  color: var(--muted);
  font-size: 16px;
  font-weight: 800;
}

.draft-details[open] summary::after {
  content: "-";
}

.draft-details .draft-panel {
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0 0 14px 14px;
}

.draft-url-control,
.range-control {
  display: grid;
  gap: 7px;
}

.draft-url-control span,
.range-control span,
.draft-position-grid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.draft-url-control input {
  width: 100%;
  height: 36px;
  padding: 0 10px;
  font-size: 13px;
}

.draft-actions {
  display: grid;
  grid-template-columns: 1fr 74px;
  gap: 8px;
}

.soft-button {
  min-height: 34px;
  border: 1px solid rgba(0, 152, 234, 0.22);
  border-radius: 10px;
  background: #ffffff;
  color: var(--ton-blue);
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

.soft-button:hover,
.soft-button.active {
  border-color: rgba(0, 152, 234, 0.5);
  background: #e9f7ff;
}

.primary-soft-button {
  background: #e9f7ff;
}

.soft-button:disabled {
  cursor: not-allowed;
  color: #8fc8e8;
  background: #f7fbff;
  opacity: 0.68;
}

.range-control {
  grid-template-columns: 70px minmax(0, 1fr) 44px;
  align-items: center;
}

.range-control input {
  width: 100%;
}

.range-control strong {
  color: var(--ink);
  font-size: 12px;
  text-align: right;
}

.draft-position-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.draft-position-grid label {
  display: grid;
  gap: 5px;
}

.draft-position-grid input {
  width: 100%;
  height: 34px;
  padding: 0 7px;
  font-size: 13px;
}

input[type="color"] {
  width: 58px;
  height: 42px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
  cursor: pointer;
}

#paint-button {
  min-height: 44px;
  width: 100%;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--ton-blue), var(--telegram-blue));
  color: #ffffff;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(0, 152, 234, 0.28);
}

#paint-button:disabled {
  cursor: not-allowed;
  background: #7dc8ee;
  box-shadow: none;
  opacity: 0.72;
}

.actions {
  display: grid;
  grid-template-columns: 46px 1fr;
  gap: 10px;
}

.icon-button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f2f9ff;
  color: var(--ton-blue);
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
}

.icon-button:disabled {
  cursor: not-allowed;
  color: #8fc8e8;
  opacity: 0.68;
}

.batch-list {
  display: grid;
  gap: 8px;
  min-height: 44px;
}

.batch-item {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) 28px;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f7fbff;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
}

.batch-remove {
  appearance: none;
  width: 28px;
  height: 28px;
  border: 1px solid rgba(0, 82, 136, 0.14);
  border-radius: 8px;
  background: #ffffff;
  color: var(--muted);
  cursor: pointer;
  font-size: 15px;
  font-weight: 800;
  line-height: 1;
}

.batch-remove:hover {
  border-color: rgba(0, 152, 234, 0.4);
  color: var(--ton-blue);
}

.batch-toggle {
  appearance: none;
  width: 100%;
  min-height: 34px;
  border: 1px solid rgba(0, 152, 234, 0.22);
  border-radius: 10px;
  background: #eef8ff;
  color: var(--ton-blue);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

.batch-toggle:hover {
  border-color: rgba(0, 152, 234, 0.46);
  background: #e5f5ff;
}

.batch-swatch {
  width: 22px;
  height: 22px;
  border: 1px solid rgba(0, 71, 117, 0.18);
  border-radius: 6px;
}

.tips-dialog {
  width: min(460px, calc(100vw - 32px));
  padding: 0;
  border: 0;
  border-radius: 18px;
  background: transparent;
}

.tips-dialog::backdrop {
  background: rgba(23, 33, 43, 0.34);
  backdrop-filter: blur(4px);
}

.tips-modal {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.tips-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.tips-head h2 {
  margin: 0;
  color: var(--ink);
  font-size: 20px;
  font-weight: 800;
}

.tips-close {
  appearance: none;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f7fbff;
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
  font-weight: 800;
  line-height: 1;
}

.tips-close:hover {
  color: var(--ton-blue);
}

.tips-modal ol {
  margin: 0;
  padding-left: 20px;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.55;
}

.tips-modal li + li {
  margin-top: 10px;
}

@media (max-width: 820px) {
  .topbar,
  .workspace {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .panel {
    width: 100%;
  }

  .mobile-mode-control {
    display: grid;
  }

}
