* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Arial, sans-serif;
  color: #111827;
  background: #f3f4f6;
  overflow-x: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  padding: 12px 16px;
  background: #111827;
  color: #fff;
}

.brand {
  font-weight: 700;
  letter-spacing: 0.5px;
}

.topbar-right {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.layout {
  padding: 16px;
}

.auth-card {
  max-width: 440px;
  width: 100%;
  margin: 32px auto;
}

.auth-head {
  display: grid;
  gap: 4px;
  margin-bottom: 12px;
}

.auth-title {
  font-weight: 700;
  font-size: 18px;
}

.auth-subtitle {
  color: #6b7280;
  font-size: 14px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  background: #f3f4f6;
}

.auth-tab {
  border: 1px solid transparent;
  background: transparent;
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  font-weight: 600;
  color: #374151;
}

.auth-tab.active {
  background: #fff;
  border-color: #e5e7eb;
  color: #111827;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.auth-pane {
  margin-top: 12px;
}

.grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 16px;
  max-width: 100%;
}

.grid > * {
  min-width: 0;
}

@media (max-width: 980px) {
  .grid {
    grid-template-columns: 1fr;
  }
}

.card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 16px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

h2,
h3 {
  margin: 0 0 10px;
}

hr {
  border: 0;
  border-top: 1px solid #e5e7eb;
  margin: 16px 0;
}

.row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  min-width: 0;
}

.row-gap {
  gap: 10px;
}

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

.muted {
  color: #6b7280;
  font-size: 14px;
}

.hidden {
  display: none !important;
}

.modal-open {
  overflow: hidden;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.55);
  display: grid;
  place-items: center;
  padding: 12px;
  z-index: 50;
}

.modal {
  max-width: 520px;
  width: 100%;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.form {
  display: grid;
  gap: 10px;
}

label {
  display: grid;
  gap: 6px;
  font-size: 14px;
}

label.inline {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

label.inline input,
label.inline select {
  width: 120px;
  max-width: 100%;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  padding: 8px 10px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
}

input:focus,
select:focus {
  outline: 2px solid rgba(59, 130, 246, 0.35);
  border-color: #93c5fd;
}

.btn {
  border: 1px solid transparent;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}

.btn[disabled],
.btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background: #2563eb;
  color: #fff;
}

.btn-secondary {
  background: #f9fafb;
  border-color: #d1d5db;
  color: #111827;
}

.btn-danger {
  background: #b91c1c;
  color: #fff;
}

.list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.list-item {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 10px;
  cursor: pointer;
  display: grid;
  gap: 6px;
}

.list-item:hover {
  border-color: #93c5fd;
}

.pill {
  display: inline-flex;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  color: #374151;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
}

.msg {
  min-height: 18px;
  color: #b91c1c;
  font-size: 14px;
}

.editor {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 16px;
  margin-top: 14px;
  max-width: 100%;
}

.editor > * {
  min-width: 0;
}

@media (max-width: 980px) {
  .editor {
    grid-template-columns: 1fr;
  }

  .canvas-wrap {
    height: min(55vh, 560px);
  }
}

.canvas-wrap {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 10px;
  overflow: hidden;
  max-width: 100%;
  height: min(70vh, 720px);
  background: repeating-linear-gradient(
    45deg,
    #fafafa,
    #fafafa 10px,
    #f3f4f6 10px,
    #f3f4f6 20px
  );
}

canvas {
  background: transparent;
  border: 1px solid #d1d5db;
}

.props {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 12px;
  background: #fff;
}

@media (max-width: 640px) {
  .layout {
    padding: 10px;
  }

  .card {
    padding: 12px;
  }

  label.inline {
    width: 100%;
  }

  label.inline input,
  label.inline select {
    width: 100%;
  }

  .canvas-wrap {
    height: min(50vh, 520px);
  }
}
