:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f4f6f8;
  color: #17202c;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
button, input, select, textarea { font: inherit; }

.app-header {
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 32px;
  background: #fff;
  border-bottom: 1px solid #dce2e8;
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px; background: #17202c; color: #fff; font-weight: 800; }
.brand h1, .brand p { margin: 0; }
.brand h1 { font-size: 18px; }
.brand p { margin-top: 2px; color: #6b7685; font-size: 12px; }
.status-badge { padding: 7px 12px; border-radius: 999px; background: #eef1f4; color: #566171; font-size: 12px; font-weight: 700; }
.status-badge.connected { background: #e8f6ef; color: #176b45; }
.status-badge.error { background: #fff0ef; color: #a33a32; }

.app-shell { width: min(1240px, calc(100% - 40px)); margin: 0 auto; padding: 28px 0 80px; }
.scope-nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 28px; }
.scope-button { display: grid; gap: 3px; text-align: left; padding: 16px 18px; border: 1px solid #d6dde5; border-radius: 12px; background: #fff; color: #17202c; cursor: pointer; }
.scope-button.active { border-color: #17202c; box-shadow: 0 0 0 1px #17202c; }
.scope-button strong { font-size: 16px; }
.scope-button small { color: #6b7685; }
.scope-kicker, .section-label { font-size: 10px; font-weight: 800; letter-spacing: .12em; }
.scope-button[data-scope="platform"] .scope-kicker, .platform-label { color: #2463c5; }
.scope-button[data-scope="saas"] .scope-kicker, .saas-label { color: #8a4b12; }

.scope-section.hidden, .toast.hidden { display: none; }
.section-heading { margin-bottom: 20px; }
.section-heading h2, .section-heading p { margin: 0; }
.section-heading h2 { margin-top: 5px; font-size: 26px; }
.section-heading p { margin-top: 6px; color: #687385; }
.split-heading { display: flex; justify-content: space-between; align-items: end; gap: 24px; }
.saas-selector { display: flex; align-items: end; gap: 8px; min-width: min(100%, 470px); }
.saas-selector label { flex: 1; margin: 0; }

.content-grid { display: grid; gap: 18px; }
.two-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.three-columns { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card { background: #fff; border: 1px solid #d9e0e7; border-radius: 12px; padding: 20px; box-shadow: 0 1px 2px rgba(24, 32, 44, .03); }
.form-section { margin-bottom: 16px; }
.card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.card-heading h3, .card-heading p { margin: 0; }
.card-heading h3 { font-size: 16px; }
.card-heading p { margin-top: 4px; color: #758091; font-size: 12px; }
.scope-chip { flex: 0 0 auto; padding: 5px 8px; border-radius: 999px; font-size: 10px; font-weight: 800; }
.platform-chip { background: #eaf1fc; color: #2463c5; }
.saas-chip { background: #f8eee5; color: #8a4b12; }

label { display: grid; gap: 6px; margin-top: 12px; color: #4e5a6b; font-size: 12px; font-weight: 700; }
label small { color: #86909d; font-weight: 500; }
input, select, textarea { width: 100%; min-height: 40px; padding: 9px 11px; border: 1px solid #c8d1dc; border-radius: 7px; background: #fff; color: #17202c; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #c9daf6; border-color: #5b82bd; }
button { min-height: 40px; padding: 9px 14px; border: 1px solid #17202c; border-radius: 7px; background: #17202c; color: #fff; font-weight: 750; cursor: pointer; }
button.secondary { background: #fff; color: #17202c; border-color: #c8d1dc; }
button.small { min-height: 32px; padding: 6px 10px; font-size: 12px; }
button:disabled { opacity: .55; cursor: wait; }
.button-row { display: flex; gap: 8px; margin-top: 16px; }
.subtle-actions { border-top: 1px solid #edf0f3; padding-top: 12px; }
.text-button { min-height: 30px; padding: 3px 0; border: 0; background: transparent; color: #4c6380; font-size: 12px; }

.status-list { display: grid; gap: 0; margin: 0; }
.status-list div { display: flex; justify-content: space-between; gap: 20px; padding: 12px 0; border-bottom: 1px solid #edf0f3; }
.status-list dt { color: #6b7685; }
.status-list dd { margin: 0; font-weight: 750; }
.info-callout { margin-top: 18px; padding: 12px 14px; border-radius: 8px; background: #f1f5f9; color: #536174; font-size: 12px; line-height: 1.6; }

.field-grid { display: grid; gap: 0 14px; }
.field-grid > *, .repeater-row > *, .saas-selector > * { min-width: 0; }
.span-two { grid-column: span 2; }
.capability-group { display: flex; gap: 22px; margin-top: 18px; padding: 14px; border: 1px solid #dbe1e8; border-radius: 8px; }
.capability-group legend { padding: 0 7px; color: #566171; font-size: 12px; font-weight: 750; }
.check-label { display: flex; align-items: center; gap: 8px; margin: 0; }
.check-label input { width: 17px; min-height: 17px; }

.repeater-list { display: grid; gap: 10px; }
.repeater-list:empty::after { content: "項目はまだありません。右上の「追加」から登録してください。"; display: block; padding: 18px; border: 1px dashed #cbd3dc; border-radius: 8px; color: #7a8492; text-align: center; font-size: 12px; }
.repeater-row { position: relative; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0 10px; padding: 14px; border: 1px solid #e0e5eb; border-radius: 9px; background: #fafbfc; }
.repeater-row label { margin-top: 0; }
.repeater-row .remove-button { align-self: end; min-height: 36px; background: #fff; color: #a33a32; border-color: #e2c1bd; }
.secret-row { grid-template-columns: 1fr 1.2fr 1fr 1fr .7fr auto; }
.plan-row, .package-row { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.tool-row .span-two { grid-column: span 2; }

.sticky-actions { position: sticky; bottom: 14px; z-index: 10; display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-top: 20px; padding: 15px 18px; border: 1px solid #cfd7e0; border-radius: 11px; background: rgba(255,255,255,.96); box-shadow: 0 10px 30px rgba(23,32,44,.12); backdrop-filter: blur(8px); }
.sticky-actions div { display: grid; gap: 2px; }
.sticky-actions small { color: #6b7685; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 30; max-width: 460px; padding: 14px 18px; border-radius: 9px; background: #17202c; color: #fff; box-shadow: 0 12px 30px rgba(0,0,0,.2); white-space: pre-wrap; font-size: 13px; }
.toast.error { background: #a33a32; }

@media (max-width: 900px) {
  .two-columns, .three-columns { grid-template-columns: 1fr; }
  .split-heading { display: grid; }
  .saas-selector { min-width: 0; width: 100%; flex-wrap: wrap; }
  .saas-selector label { min-width: 220px; }
  .repeater-row, .secret-row, .plan-row, .package-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span-two { grid-column: 1 / -1; }
}

@media (max-width: 620px) {
  .app-header { padding: 0 16px; }
  .app-shell { width: min(100% - 24px, 1240px); padding-top: 18px; }
  .scope-nav { grid-template-columns: 1fr; }
  .repeater-row, .secret-row, .plan-row, .package-row { grid-template-columns: 1fr; }
  .repeater-row .span-two { grid-column: auto; }
  .sticky-actions { align-items: stretch; flex-direction: column; }
  .sticky-actions button { width: 100%; }
  .brand p, .status-badge { display: none; }
}
