:root {
  --ink: #272d30;
  --muted: #657379;
  --line: rgba(200, 200, 200, 0.4);
  --paper: #f8fcfc;
  --panel: #ffffff;
  --moss: #56aacf;
  --moss-dark: #287597;
  --clay: #287597;
  --danger: #ec5757;
  --code: #1f2f38;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "Avenir Next", "Hiragino Sans", "Yu Gothic", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(86, 170, 207, 0.18), transparent 28rem),
    linear-gradient(135deg, #f8fcfc 0%, #eef6f8 48%, #e5f1f6 100%);
  min-height: 100vh;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 0.75rem 1.2rem;
  background: var(--moss);
  color: white;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 0.75rem 1.8rem rgba(49, 93, 74, 0.22);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button.secondary {
  background: rgba(86, 170, 207, 0.12);
  color: var(--moss-dark);
  box-shadow: none;
}

button.danger {
  background: var(--danger);
}

.shell {
  width: min(1480px, calc(100% - 3.5rem));
  margin: 0 auto;
  padding: 2rem 0 3rem;
}

.hero,
.workspace,
.events-panel,
.portal-links,
.guide-panel {
  border: 1px solid rgba(86, 170, 207, 0.18);
  background: rgba(255, 255, 255, 0.88);
  border-radius: 2rem;
  box-shadow: 0 1.5rem 4rem rgba(40, 117, 151, 0.12);
  backdrop-filter: blur(18px);
}

.hero {
  display: block;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
}

.portal-links {
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
  padding: 0.9rem 1.2rem;
  margin-bottom: 1rem;
}

.portal-link {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.7rem 1rem;
  color: white;
  background: var(--moss);
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 0.75rem 1.8rem rgba(49, 93, 74, 0.22);
}

.portal-tabs {
  display: flex;
  gap: 0.35rem;
  padding: 0.35rem;
  margin-bottom: 1rem;
  border: 1px solid rgba(86, 170, 207, 0.18);
  background: rgba(255, 255, 255, 0.88);
  border-radius: 999px;
  box-shadow: 0 1.5rem 4rem rgba(40, 117, 151, 0.12);
  backdrop-filter: blur(18px);
}

.portal-tab {
  flex: 1;
  border-radius: 999px;
  padding: 0.7rem 1rem;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  box-shadow: none;
}

.portal-tab:hover {
  color: var(--moss-dark);
  background: rgba(86, 170, 207, 0.08);
}

.portal-tab.active,
.portal-tab[aria-selected="true"] {
  background: var(--moss);
  color: white;
  box-shadow: 0 0.75rem 1.8rem rgba(49, 93, 74, 0.22);
}

.portal-tab.active:hover,
.portal-tab[aria-selected="true"]:hover {
  color: white;
  background: var(--moss);
}

.tab-panel[hidden] {
  display: none;
}

.tab-panel > .events-panel:first-child {
  margin-top: 0;
}

.guide-panel {
  padding: 1.5rem;
}

.guide-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.guide-card {
  border: 1px solid var(--line);
  border-radius: 1.25rem;
  background: rgba(86, 170, 207, 0.08);
  padding: 1rem 1.05rem;
}

.guide-card p {
  margin: 0.7rem 0 0;
  color: var(--muted);
  line-height: 1.8;
}

.guide-list,
.guide-steps {
  margin: 0.75rem 0 0;
  padding-left: 1.2rem;
  color: var(--muted);
  line-height: 1.8;
}

.guide-note {
  margin-top: 0.9rem;
  padding: 0.85rem 0.95rem;
  border-radius: 1rem;
  background: rgba(40, 117, 151, 0.08);
}

.code-inline {
  display: inline-block;
  margin: 0 0.15rem;
  padding: 0.1rem 0.45rem;
  border-radius: 0.5rem;
  background: rgba(40, 117, 151, 0.12);
  color: var(--moss-dark);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.92em;
  font-weight: 700;
  word-break: break-all;
}

.eyebrow {
  color: var(--clay);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  margin: 0 0 0.5rem;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.08;
}

h1 {
  font-size: clamp(2.3rem, 6vw, 5rem);
  letter-spacing: -0.08em;
}

.hero h1 {
  font-size: clamp(1.45rem, 2.6vw, 2.15rem);
  letter-spacing: -0.05em;
}

.hero .lead {
  margin: 0.35rem 0 0;
  font-size: 0.92rem;
  line-height: 1.55;
}

h2 {
  font-size: clamp(1.3rem, 3vw, 2rem);
  letter-spacing: -0.04em;
}

h3 {
  margin-bottom: 0.75rem;
}

.lead {
  max-width: 42rem;
  color: var(--muted);
  line-height: 1.8;
}

.hero .eyebrow {
  margin-bottom: 0.25rem;
  font-size: 0.72rem;
}

/* max-height だけだと height:auto のままになり、子の height:100% が効かずスクロールしない */
.workspace {
  display: grid;
  grid-template-columns: 25rem 1fr;
  grid-template-rows: minmax(0, 1fr);
  height: 90vh;
  max-height: 90vh;
  min-height: 0;
  overflow: hidden;
  align-items: stretch;
}

.workspace > .operation-panel,
.workspace > .runner-panel {
  min-height: 0;
}

.operation-panel {
  display: flex;
  flex-direction: column;
  align-self: stretch;
  min-height: 0;
  border-right: 1px solid var(--line);
  padding: 1rem;
  background: rgba(86, 170, 207, 0.08);
  overflow: hidden;
}

.toolbar {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  flex: 0 0 auto;
}

.example-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.9rem;
  padding: 0.8rem 1rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: rgba(86, 170, 207, 0.08);
}

.example-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.example-buttons {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.shape-notes {
  margin-bottom: 0.9rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: rgba(86, 170, 207, 0.08);
}

.shape-notes-body {
  display: grid;
  gap: 0.5rem;
}

.shape-note {
  margin: 0;
  color: var(--ink);
  font-size: 0.9rem;
  line-height: 1.55;
}

.shape-note code {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.85em;
  background: rgba(40, 117, 151, 0.1);
  border-radius: 0.45rem;
  padding: 0.1rem 0.35rem;
}

.example-button {
  padding: 0.45rem 0.8rem;
  background: rgba(86, 170, 207, 0.12);
  color: var(--moss-dark);
  box-shadow: none;
  font-size: 0.82rem;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--panel);
  color: var(--ink);
  padding: 0.85rem 1rem;
}

textarea {
  min-height: 9rem;
  resize: vertical;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.84rem;
  line-height: 1.55;
}

.operation-list {
  display: grid;
  gap: 0.55rem;
  flex: 1 1 0;
  min-height: 0;
  overflow: auto;
  overflow-x: hidden;
  padding-right: 0.25rem;
  align-content: start;
  overscroll-behavior: contain;
}

.operation-item {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 1.1rem;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  padding: 0.85rem;
  text-align: left;
  box-shadow: none;
}

.operation-item.active {
  border-color: var(--moss);
  background: rgba(86, 170, 207, 0.12);
}

.operation-id {
  display: block;
  font-weight: 800;
  word-break: break-word;
}

.operation-path {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 0.35rem;
  word-break: break-all;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.2rem 0.5rem;
  margin-right: 0.35rem;
  background: rgba(86, 170, 207, 0.12);
  color: var(--moss-dark);
  font-size: 0.72rem;
  font-weight: 800;
}

.badge.mutates {
  background: rgba(236, 87, 87, 0.12);
  color: #b23f3f;
}

.runner-panel {
  align-self: stretch;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 1.5rem;
  overscroll-behavior: contain;
}

.events-panel {
  padding: 1.5rem;
}

.runner-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1.25rem;
}

.muted {
  color: var(--muted);
}

.form-grid,
.result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

label span {
  display: inline-block;
  margin: 0 0 0.4rem;
  color: var(--muted);
  font-weight: 700;
}

.inline-helper {
  display: flex;
  align-items: end;
}

.execution-bar,
.button-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 1rem;
  margin: 1rem 0;
}

.execution-bar {
  align-items: end;
}

.execution-actions {
  display: flex;
  justify-content: flex-end;
  margin: 0 0 1rem;
}

.execution-actions button {
  min-width: 10rem;
}

.checkbox-row {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
}

.checkbox-row input {
  width: auto;
}

.message {
  border-radius: 1rem;
  background: rgba(86, 170, 207, 0.12);
  color: #287597;
  padding: 0.9rem 1rem;
  margin: 0.75rem 0;
  font-weight: 700;
}

pre {
  min-height: 12rem;
  margin: 0;
  border-radius: 1.25rem;
  background: var(--code);
  color: #dff3dd;
  overflow: auto;
  padding: 1rem;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.82rem;
  line-height: 1.55;
}

.events-panel {
  margin-top: 1.5rem;
}

#eventsOutput {
  min-height: 16rem;
}

@media (max-width: 980px) {
  .hero,
  .workspace,
  .guide-grid,
  .form-grid,
  .result-grid {
    grid-template-columns: 1fr;
  }

  .hero {
    align-items: start;
  }

  .workspace {
    grid-template-rows: minmax(0, auto) minmax(0, auto);
    height: auto;
    max-height: none;
    min-height: 0;
    overflow: visible;
  }

  .operation-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    height: 90vh;
    max-height: 90vh;
    overflow: hidden;
  }

  .runner-panel {
    height: 90vh;
    max-height: 90vh;
    overflow-y: auto;
  }

  .operation-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
  }

  .runner-header,
  .execution-bar,
  .execution-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .execution-actions {
    justify-content: stretch;
  }

  .execution-actions button {
    width: 100%;
  }
}
