:root {
  --bg: #f6f8fb;
  --panel: #ffffff;
  --ink: #283445;
  --muted: #667386;
  --line: #dbe3ee;
  --blue: #407fed;
  --blue-deep: #1d2d75;
  --blue-soft: #edf4ff;
  --mint: #1fc49d;
  --amber: #d98a14;
  --red: #c8432b;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  font-size: 15px;
  line-height: 1.6;
}

button,
textarea {
  font: inherit;
}

h1,
h2,
p,
dl,
dd {
  margin: 0;
}

.app-shell {
  display: grid;
  gap: 16px;
  max-width: 1080px;
  margin: 0 auto;
  padding: 20px 16px;
}

.topbar {
  padding: 4px 4px 0;
}

.kicker {
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1 {
  margin-top: 3px;
  color: var(--blue-deep);
  font-size: 28px;
  line-height: 1.2;
}

.lead {
  margin-top: 6px;
  color: var(--muted);
}

.editor {
  display: grid;
  gap: 12px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

textarea {
  width: 100%;
  min-height: 220px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.7;
  resize: vertical;
}

textarea:focus {
  outline: 2px solid var(--blue);
  outline-offset: -1px;
}

.editor-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.totals {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
}

.totals div {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.totals dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.totals dd {
  color: var(--blue-deep);
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.buttons {
  display: flex;
  gap: 8px;
}

.button {
  min-height: 40px;
  padding: 8px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--blue);
  font-weight: 700;
  cursor: pointer;
}

.button.primary {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

.platforms {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.platform {
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.platform-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.platform h2 {
  color: var(--blue-deep);
  font-size: 15px;
  line-height: 1.4;
}

.platform-count {
  flex: none;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.platform-count .used {
  color: var(--ink);
  font-size: 20px;
}

.meter {
  height: 8px;
  overflow: hidden;
  background: var(--blue-soft);
  border-radius: 999px;
}

.meter span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--mint);
  border-radius: inherit;
  transition: width 0.15s ease;
}

.platform-status {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.platform-hint {
  color: var(--muted);
  font-size: 12px;
}

.platform-note {
  padding: 8px 10px;
  background: #fff6e8;
  border-radius: 6px;
  color: #7a4a06;
  font-size: 12px;
}

.platform.is-near .meter span {
  background: var(--amber);
}

.platform.is-near .platform-status {
  color: var(--amber);
}

.platform.is-over {
  border-color: var(--red);
}

.platform.is-over .meter span {
  background: var(--red);
}

.platform.is-over .platform-status {
  color: var(--red);
}

/* スポンサー枠。Photo Resizerと同じ見た目 */
.sponsor-slot {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.sponsor-banner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  aspect-ratio: 1200 / 628;
  overflow: hidden;
  background: #f9fbfe;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
}

.sponsor-banner.is-filled {
  border-style: solid;
}

.sponsor-banner img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sponsor-label {
  color: var(--blue);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.sponsor-banner strong {
  color: var(--blue-deep);
}

.sponsor-size {
  font-size: 12px;
}

.producer-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.producer-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.producer-logo {
  display: block;
  width: 180px;
  height: auto;
}

.save-toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 24px;
  width: fit-content;
  margin: 0 auto;
  transform: translateY(8px);
  z-index: 60;
  padding: 12px 20px;
  border-radius: 999px;
  background: #17202a;
  color: #fff;
  font-size: 15px;
  font-weight: 650;
  box-shadow: 0 6px 20px rgba(15, 25, 45, .28);
  opacity: 0;
  transition: opacity .18s ease, transform .18s ease;
  pointer-events: none;
}

.save-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .save-toast,
  .meter span {
    transition: none;
  }
}

@media (max-width: 900px) {
  .platforms {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 600px) {
  .app-shell {
    padding: 16px;
  }

  h1 {
    font-size: 24px;
  }

  textarea {
    min-height: 180px;
  }

  .platforms,
  .sponsor-slot {
    grid-template-columns: 1fr;
  }

  .editor-actions {
    align-items: stretch;
  }

  .buttons {
    width: 100%;
  }

  .button {
    flex: 1;
  }
}

/* 使い方とよくある質問 */
.about { max-width: 860px; margin: 0 auto; padding: 28px 20px 48px; line-height: 1.8; }
.about h2 { font-size: 1.2rem; color: var(--blue-deep); margin: 28px 0 10px; }
.about h2:first-child { margin-top: 0; }
.about ul { padding-left: 1.3rem; margin: 0 0 12px; }
.about details { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; margin-bottom: 8px; }
.about summary { cursor: pointer; font-weight: 700; }
.about details p { margin: 6px 0 0; color: var(--muted); }
.about-more { margin-top: 20px; color: var(--muted); }
.about a { color: var(--blue); font-weight: 700; }
