/* Always honor the hidden attribute, even on flex/grid elements */
[hidden] { display: none !important; }

/* Step Sequencer — local CSS (no Tailwind CDN) */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  background: #f3f4f6;
  color: #1f2937;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}
@media (min-width: 768px) {
  body { padding: 2rem; }
}

.T { color: #2563eb; font-weight: 700; }
.D { color: #16a34a; font-weight: 700; }
.A { color: #ca8a04; font-weight: 700; }
.c { color: #9333ea; font-weight: 700; }
.p { color: #ea580c; font-weight: 700; }

.wrap {
  max-width: 56rem;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding-bottom: 5.5rem; /* room for sticky generate on mobile */
}

.card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 1rem;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
  padding: 1.25rem 1.5rem;
}

.card h1 {
  margin: 0;
  font-size: clamp(1.4rem, 4vw, 1.875rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #111827;
}
.card .sub {
  margin: 0.35rem 0 0;
  font-size: 0.875rem;
  color: #6b7280;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}
@media (min-width: 768px) {
  .grid-2 { grid-template-columns: 1fr 1fr; }
}

label.field-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #374151;
  margin-bottom: 0.4rem;
}

select, button, input {
  font: inherit;
}

select {
  width: 100%;
  background: #f9fafb;
  border: 1px solid #d1d5db;
  border-radius: 0.6rem;
  padding: 0.75rem 0.85rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: #1f2937;
  min-height: 48px;
  appearance: auto;
}
select:focus {
  outline: none;
  border-color: #059669;
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.25);
}

.controls-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: none;
  border-radius: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  min-height: 48px;
  padding: 0.75rem 1.25rem;
  transition: background .15s, transform .1s, opacity .15s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  background: #059669;
  color: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,.08);
  width: 100%;
  font-size: 1rem;
}
.btn-primary:hover:not(:disabled) { background: #047857; }

.btn-secondary {
  background: #f3f4f6;
  color: #374151;
  border: 1px solid #d1d5db;
  font-size: 0.875rem;
}
.btn-secondary:hover:not(:disabled) { background: #e5e7eb; }
.btn-secondary.active {
  background: #fef3c7;
  border-color: #f59e0b;
  color: #92400e;
}

.btn-ghost {
  background: transparent;
  color: #6b7280;
  border: 1px solid transparent;
  min-height: 40px;
  padding: 0.4rem 0.65rem;
  font-size: 0.8rem;
}
.btn-ghost:hover { background: #f3f4f6; color: #111827; }

.btn-icon {
  min-width: 40px;
  min-height: 40px;
  padding: 0.4rem;
  border-radius: 0.5rem;
  background: transparent;
  border: 1px solid transparent;
  color: #6b7280;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
}
.btn-icon:hover { background: #f3f4f6; color: #111827; }
.btn-icon.pinned { color: #d97706; }

/* Sticky generate bar on mobile */
.generate-bar {
  position: sticky;
  bottom: 0;
  z-index: 40;
  background: linear-gradient(to top, #f3f4f6 70%, rgba(243,244,246,0));
  padding: 0.75rem 0 0.25rem;
  margin: 0 -0.25rem;
}
@media (min-width: 768px) {
  .wrap { padding-bottom: 0; }
  .generate-bar {
    position: static;
    background: none;
    padding: 0;
    margin: 0;
  }
  .btn-primary { width: auto; min-width: 14rem; }
}

.output {
  position: relative;
  background: #020617;
  color: #f1f5f9;
  border-radius: 1rem;
  padding: 1.5rem;
  border: 1px solid #0f172a;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
}
@media (min-width: 768px) {
  .output { padding: 2rem; }
}

.output-text {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  white-space: pre;
  line-height: 1.45;
  font-size: clamp(1.15rem, 3.8vw, 3.2rem);
  color: #cbd5e1;
  overflow-x: auto;
  margin: 0;
}

.ocho-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(30, 41, 59, 0.9);
  flex-wrap: wrap;
}
.ocho-label {
  font-size: clamp(0.9rem, 2vw, 1.25rem);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: #94a3b8;
}
.ocho-badge {
  font-family: ui-monospace, Menlo, Monaco, Consolas, monospace;
  font-size: clamp(2rem, 6vw, 3rem);
  font-weight: 700;
  color: #9ca3af;
}
.ocho-badge.T { color: #2563eb; }
.ocho-badge.D { color: #16a34a; }
.ocho-badge.neutral { color: #9ca3af; }

.frozen-banner {
  display: none;
  align-items: center;
  gap: 0.5rem;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #f59e0b;
  border-radius: 0.75rem;
  padding: 0.65rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
}
.frozen-banner.show { display: flex; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 5.5rem;
  transform: translateX(-50%) translateY(1rem);
  background: #111827;
  color: #fff;
  padding: 0.65rem 1.1rem;
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 100;
  max-width: 90vw;
  text-align: center;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
@media (min-width: 768px) {
  .toast { bottom: 2rem; }
}

.section-title {
  margin: 0 0 0.75rem;
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #4b5563;
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.list-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  padding: 0.65rem 0.75rem;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  min-height: 48px;
}
.list-item:hover, .list-item:focus {
  border-color: #059669;
  background: #ecfdf5;
  outline: none;
}
.list-item .meta {
  flex: 1;
  min-width: 0;
}
.list-item .pattern {
  font-family: ui-monospace, Menlo, Monaco, Consolas, monospace;
  font-size: 0.8rem;
  color: #111827;
  white-space: pre-wrap;
  word-break: break-word;
}
.list-item .tags {
  margin-top: 0.25rem;
  font-size: 0.7rem;
  color: #6b7280;
}
.list-item .actions {
  display: flex;
  flex-shrink: 0;
  gap: 0.15rem;
}
.empty {
  font-size: 0.875rem;
  color: #9ca3af;
  margin: 0;
  padding: 0.5rem 0;
}

.hint {
  font-size: 0.75rem;
  color: #9ca3af;
  margin: 0.5rem 0 0;
}
.status-dot {
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: #9ca3af;
  margin-right: 0.35rem;
}
.status-dot.online { background: #059669; }
.status-dot.offline { background: #d97706; }

.kbd {
  display: inline-block;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 0.7rem;
  background: #e5e7eb;
  border: 1px solid #d1d5db;
  border-radius: 0.3rem;
  padding: 0.05rem 0.35rem;
}

/* Login */
.login-wrap {
  min-height: 100vh;
  width: 100%;
  max-width: 28rem;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.login-card { width: 100%; }
.login-fields {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin: 1.25rem 0 1rem;
}
input[type="text"],
input[type="password"] {
  width: 100%;
  background: #f9fafb;
  border: 1px solid #d1d5db;
  border-radius: 0.6rem;
  padding: 0.75rem 0.85rem;
  font-size: 1rem;
  font-weight: 500;
  color: #1f2937;
  min-height: 48px;
}
input:focus {
  outline: none;
  border-color: #059669;
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.25);
}
.login-error {
  color: #b91c1c;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  margin: 0 0 0.75rem;
}

.header-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}
.user-chip {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.35rem;
}
.user-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.role-pill {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
  border-radius: 999px;
  padding: 0.15rem 0.5rem;
}
.create-user input {
  width: 100%;
}
