:root {
  --background: #f4f6fb;
  --surface: #ffffff;
  --primary: #1f6fd8;
  --primary-strong: #194f9f;
  --text: #0f172a;
  --muted: #52607b;
  --border: #d6dce8;
  --danger: #d92d20;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--background);
  color: var(--text);
  font-family: 'Noto Sans JP', 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'BIZ UDPGothic', 'Yu Gothic', Meiryo, sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

.header-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1.25rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand-title {
  margin: 0;
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--primary-strong);
}

.brand-title .brand-sub {
  font-size: 0.52em;
  font-weight: 700;
  letter-spacing: 0.05em;
  margin-left: 0.4em;
  white-space: nowrap;
  color: var(--primary);
}

main {
  max-width: 1200px;
  margin: 2.5rem auto;
  padding: 0 2rem 3.5rem;
}

.editor-layout main {
  max-width: none;
  margin: 0;
  padding: 0;
  width: 100%;
}

.landing {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 2.25rem;
}

.card + .card {
  margin-top: 2.5rem;
}

.card h2 {
  margin: 0 0 0.5rem;
  font-size: 1.4rem;
  font-weight: 600;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.label {
  font-weight: 600;
  color: var(--muted);
}

.label-icon {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.label-icon .icon svg {
  width: 1.5rem;
  height: 1.5rem;
  display: block;
  color: var(--primary);
}

.label-icon .icon svg path {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.help-text {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}

body:not(.editor-layout) select,
body:not(.editor-layout) input[type="text"],
body:not(.editor-layout) input[type="password"],
body:not(.editor-layout) input[type="file"],
.editor-layout .top-controls select,
.editor-layout .top-controls input[type="text"] {
  appearance: none;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  background: #ffffff;
  transition: border-color 0.12s ease, outline-color 0.12s ease;
}

body:not(.editor-layout) select:focus,
body:not(.editor-layout) input[type="text"]:focus,
body:not(.editor-layout) input[type="password"]:focus,
body:not(.editor-layout) input[type="file"]:focus,
.editor-layout .top-controls select:focus,
.editor-layout .top-controls input[type="text"]:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
  border-color: var(--primary);
}

.pill-button,
body:not(.editor-layout) button,
.editor-layout .top-controls button {
  cursor: pointer;
  background: var(--primary);
  color: #ffffff;
  font-weight: 700;
  letter-spacing: 0.01em;
  border: 1px solid var(--primary);
  border-radius: 999px;
  padding: 0.55rem 1.4rem;
  transition: background-color 0.15s ease, transform 0.1s ease, color 0.15s ease, border-color 0.15s ease;
}

.pill-button:hover,
body:not(.editor-layout) button:hover,
.editor-layout .top-controls button:hover {
  background: var(--primary-strong);
  border-color: var(--primary-strong);
  transform: translateY(-1px);
}

.pill-button:disabled,
body:not(.editor-layout) button:disabled,
.editor-layout .top-controls button:disabled {
  background: #cbd5e1;
  border-color: #cbd5e1;
  color: #ffffff;
  cursor: not-allowed;
  transform: none;
}

.pill-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  text-decoration: none;
}

.pill-button.secondary {
  background: transparent;
  color: var(--primary);
  border-color: var(--primary);
}

.pill-button.secondary:hover {
  background: rgba(31, 111, 216, 0.12);
  color: var(--primary-strong);
}

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

.pill-button.danger:hover {
  background: #b42318;
  border-color: #b42318;
}

.notice {
  padding: 1rem;
  border-radius: 12px;
  background: #e8f0fd;
  border: 1px solid var(--border);
  color: var(--primary-strong);
}

.footer-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
  color: var(--primary-strong);
  text-decoration: none;
  margin-top: 2rem;
}

.footer-link svg {
  width: 1.1rem;
  height: 1.1rem;
}

.editor-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.editor-main {
  flex: 1;
  display: flex;
  min-height: 0;
  width: 100%;
}

#editor-container {
  flex: 1;
  min-width: 0;
  min-height: 320px;
  height: var(--editor-viewport-height, calc(100vh - 72px));
}

.top-controls {
  display: flex;
  align-items: flex-end;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.top-controls .field {
  margin: 0;
  min-width: 180px;
}

.top-controls .field select {
  min-width: 200px;
}

.top-controls .status-field {
  min-width: 160px;
}

.top-controls button {
  align-self: flex-end;
}

.status-badge {
  background: var(--surface);
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  border: 1px solid var(--border);
}

.editor-layout .status-badge,
.status-badge.status-version {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.admin-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1.05rem;
  font-size: 0.9rem;
}

.admin-button:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.modal.open {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
}

.modal-dialog {
  position: relative;
  background: #ffffff;
  color: #111827;
  padding: 2rem 1.75rem 1.75rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  width: 520px;
  max-width: 90vw;
  min-width: 420px;
  z-index: 1;
}

.modal-dialog.wide {
  width: 780px;
  max-width: 94vw;
  min-width: 520px;
}

.modal-title {
  margin: 0 0 1.1rem;
  font-size: 1.25rem;
  font-weight: 800;
  text-align: left;
}

.modal-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
  margin: 0 auto 1.2rem;
}

.modal-body.stacked {
  align-items: stretch;
}

.modal-field {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.4rem;
  width: 100%;
}

.modal-body input {
  width: 80%;
  max-width: 360px;
  padding: 0.75rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 1rem;
}

.modal-body input:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
  border-color: var(--primary);
}

.modal-body.stacked input,
.modal-body.stacked select,
.modal-body.stacked input[type="file"] {
  width: 100%;
  max-width: none;
}

.code-input {
  width: 100%;
  min-height: 280px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
  font-size: 0.92rem;
  line-height: 1.4;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  resize: vertical;
  box-sizing: border-box;
}

.modal-actions {
  display: flex;
  justify-content: center;
  gap: 0.6rem;
}

.modal-actions button {
  background: var(--primary);
  color: #fff;
  border: 1px solid var(--primary);
  border-radius: 10px;
  padding: 0.65rem 1.1rem;
  font-weight: 600;
  cursor: pointer;
}

.modal-actions button:hover {
  background: var(--primary-strong);
  border-color: var(--primary-strong);
}

.modal-close {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  width: 2.25rem;
  height: 2.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #6b7280;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
}

.modal-close svg {
  width: 1.1rem;
  height: 1.1rem;
}

.modal-error {
  color: #b91c1c;
  font-size: 0.9rem;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  width: 100%;
}

.admin-section {
  background: #edf1fb;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  width: 100%;
}

.admin-section h4 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  color: #111827;
}

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

.admin-actions .pill-button {
  width: 100%;
  padding-left: 0.7rem;
  padding-right: 0.7rem;
}

.hero {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
  padding: 1.4rem 1.6rem;
  border-radius: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.hero-copy h2 {
  font-size: 2.1rem;
  margin: 0.4rem 0 0.6rem;
  letter-spacing: 0.02em;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-weight: 700;
  color: var(--primary);
  margin: 0;
  font-size: 0.9rem;
}

.lead {
  margin: 0 0 1.2rem;
  color: #1f2937;
  line-height: 1.7;
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.hero-footnote {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  background: #e6edf9;
  color: #0f172a;
  font-weight: 700;
  font-size: 0.9rem;
  border: 1px solid var(--border);
}

.chip.subtle {
  background: #eef3fb;
}

.hero-panel {
  background: var(--surface);
  border-radius: 16px;
  padding: 1.2rem 1.4rem;
  border: 1px solid var(--border);
}

.hero-panel__title {
  font-weight: 800;
  color: var(--primary-strong);
  margin-bottom: 0.6rem;
}

.hero-panel__list {
  margin: 0 0 1rem 1.2rem;
  padding: 0;
  color: #3a4156;
  line-height: 1.6;
}

.hero-panel__list li {
  margin-bottom: 0.35rem;
}

.hero-panel__cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.hero-panel__hint {
  color: var(--muted);
  font-weight: 600;
}

.small-caption {
  font-size: 0.7em;
}

.selection-card {
  margin-top: 0.75rem;
}

.top-controls .footer-link {
  margin: 0;
  padding: 0.6rem 0.4rem;
  align-self: flex-end;
}

.alert {
  background: #ffece8;
  color: #b91c1c;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  margin-top: 1rem;
  border: 1px solid #f2b8ad;
}

.ProseMirror {
  min-height: 1.25em;
  outline: none;
  white-space: pre-wrap;
  word-break: break-word;
}

.ProseMirror p {
  margin: 0;
}

@media (max-width: 768px) {
  .header-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  main {
    padding: 0 1.5rem 2.5rem;
  }

  .card {
    padding: 1.75rem;
  }

  body:not(.editor-layout) button,
  .top-controls button {
    width: 100%;
  }

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