:root {
  color-scheme: light dark;
  font-family: system-ui, -apple-system, Segoe UI, sans-serif;
  line-height: 1.5;
}

body {
  margin: 0;
  background: #f7f7fb;
  color: #1f2933;
}

header,
footer {
  background: #2d3748;
  color: #f7fafc;
  padding: 1.5rem clamp(1rem, 5vw, 4rem);
}

header h1,
header p,
footer p {
  margin: 0 0 0.75rem 0;
}

main {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  padding: 2rem clamp(1rem, 5vw, 4rem);
  width: 100%;
  max-width: none;
  margin: 0 auto;
  box-sizing: border-box;
}

section {
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
  padding: 1.5rem;
  resize: both;
  overflow: auto;
  min-height: 200px;
  min-width: 280px;
  max-width: 100%;
  box-sizing: border-box;
}

section h2 {
  margin-top: 0;
}

form {
  display: grid;
  gap: 0.75rem;
  margin-top: 1rem;
}

label {
  font-weight: 600;
}

input,
textarea,
button {
  font: inherit;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  border: 1px solid #cbd5e0;
  background: #ffffff;
  color: #1f2933;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
textarea:focus {
  border-color: #5a67d8;
  box-shadow: 0 0 0 3px rgba(90, 103, 216, 0.2);
  outline: none;
}

button {
  cursor: pointer;
  background: linear-gradient(130deg, #5a67d8, #805ad5);
  color: #fff;
  border: none;
  font-weight: 600;
}

button:hover {
  filter: brightness(1.05);
}

.result {
  background: #f1f5f9;
  border-radius: 8px;
  padding: 0.75rem;
  margin-top: 1rem;
  overflow-x: auto;
  white-space: pre-wrap;
  font-family: "Fira Code", "SFMono-Regular", Consolas, monospace;
}

.result.error {
  background: #fff5f5;
  color: #c53030;
  border: 1px solid rgba(229, 62, 62, 0.4);
}

.result:empty {
  display: none;
}

.result.error {
  background: #fff5f5;
  color: #c53030;
  border: 1px solid rgba(229, 62, 62, 0.4);
}

.template-summary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding: 0.75rem;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fafc;
}

.template-card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.template-card-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}

.template-card-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

#template-catalog-link {
  min-width: 180px;
}

.btn-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 1.25rem;
  border-radius: 999px;
  border: 1px solid #5a67d8;
  background: linear-gradient(130deg, #5a67d8, #805ad5);
  color: #fff !important;
  text-decoration: none;
  font-weight: 600;
  transition: filter 0.2s ease;
}

.btn-link:hover {
  filter: brightness(1.05);
}

.template-forms-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem;
  align-items: start;
}

.template-form-wrapper h3 {
  margin-top: 0;
}


.example {
  background: #f8fafc;
  border-radius: 8px;
  padding: 0.75rem;
  border: 1px solid #cbd5e0;
  font-size: 0.95rem;
}

.examples {
  display: grid;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.card-pair {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: 100%;
}

.card-pair > section {
  min-width: 0;
}

.access-shell {
  position: relative;
}

.access-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 1rem 1.25rem;
  border-radius: 999px;
  border: 1px solid #d6d9f5;
  background: linear-gradient(135deg, rgba(90, 103, 216, 0.1), rgba(128, 90, 213, 0.15));
  color: #2d2d48;
  box-shadow: 0 8px 18px rgba(64, 72, 148, 0.15);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  margin-bottom: 0.5rem;
}

.access-pill:hover,
.access-shell.open .access-pill {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(64, 72, 148, 0.2);
}

.access-pill strong {
  font-size: 1rem;
  display: block;
}

.pill-hint {
  font-size: 0.85rem;
  color: #4a5568;
}

.pill-icon {
  font-size: 1.25rem;
  transition: transform 0.2s ease;
}

.access-shell.open .pill-icon {
  transform: rotate(45deg);
}

.access-shell.reminder .access-pill {
  animation: pulse 1.2s ease-in-out infinite;
  border-color: #f56565;
  box-shadow: 0 0 0 0 rgba(245, 101, 101, 0.4);
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(245, 101, 101, 0.45);
  }
  70% {
    box-shadow: 0 0 0 14px rgba(245, 101, 101, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(245, 101, 101, 0);
  }
}

.account-card {
  background: #ffffff;
  margin-top: 0.5rem;
}

#access-panel[hidden] {
  display: none;
}

.access-shell.open #access-panel {
  display: block;
}

.access-card-header {
  margin-bottom: 1rem;
}

.account-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
  margin-top: 1rem;
}

.account-panel {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 1rem;
  background: #fdfdfd;
}

.account-panel form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.form-actions button {
  flex: 1 1 120px;
}

.structure-inputs {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  margin-bottom: 1.5rem;
}

.structure-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  border: 1px dashed #cbd5e0;
  padding: 0.75rem;
  border-radius: 8px;
}

.structure-form h3 {
  margin: 0;
}

.structure-form .result {
  margin-top: 0.25rem;
}

.example summary {
  font-weight: 600;
  cursor: pointer;
  color: #2c5282;
}

.example pre {
  background: #edf2f7;
  padding: 0.75rem;
  border-radius: 6px;
  overflow-x: auto;
}

.example code {
  font-family: "Fira Code", "SFMono-Regular", Consolas, monospace;
}

.editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 0.75rem 0;
}

.editor-actions button {
  flex: 1 1 150px;
}

#jsme-editor-wrapper {
  border: 1px solid #cbd5e0;
  border-radius: 12px;
  background: #fff;
  padding: 0.75rem;
  margin-bottom: 0.75rem;
  resize: both;
  overflow: auto;
  min-height: 420px;
  min-width: 280px;
  max-width: 100%;
  box-sizing: border-box;
}

#jsme-container {
  width: 100%;
  height: 100%;
  min-height: 320px;
}

#structure-viewer {
  width: 100%;
  height: 360px;
  min-height: 320px;
  border: 1px solid #cbd5e0;
  border-radius: 12px;
  background: #ffffff;
  padding: 0;
  margin-bottom: 0.75rem;
  box-sizing: border-box;
  position: relative;
  overflow: hidden;
}

#structure-viewer iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: transparent;
}

.structure-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

@media (max-width: 1100px) {
  .card-pair {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 768px) {
  main {
    padding: 1.5rem;
  }
}
