:root {
  --bg: #f7fbfa;
  --surface: #ffffff;
  --surface-soft: #f1f8f6;
  --line: #dde9e6;
  --text: #172522;
  --muted: #667571;
  --brand: #008f7a;
  --brand-dark: #006c5d;
  --brand-soft: #dff6f1;
  --accent: #f48a68;
  --accent-soft: #fff0ea;
  --blue-soft: #e8f2ff;
  --yellow-soft: #fff7dc;
  --danger: #c43f4d;
  --danger-soft: #fff0f2;
  --shadow: 0 16px 40px rgba(15, 48, 42, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(135deg, rgba(223, 246, 241, 0.9), rgba(255, 247, 220, 0.55) 42%, rgba(232, 242, 255, 0.65)),
    var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.6;
}

body.modal-open {
  overflow: hidden;
}

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

button {
  border: 0;
  cursor: pointer;
}

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

.app-shell {
  width: min(100%, 980px);
  margin: 0 auto;
  padding: 18px 14px 48px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 0 18px;
}

.app-header h1,
.section-title h2,
.center-card h2,
.detail-head h2 {
  margin: 0;
  line-height: 1.18;
}

.app-header h1 {
  font-size: 2rem;
  font-weight: 850;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--brand-dark);
  font-size: 0.78rem;
  font-weight: 800;
}

.auth-pill,
.mini-badge,
.status-pill {
  flex: 0 0 auto;
  border-radius: 999px;
  color: var(--brand-dark);
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid rgba(0, 143, 122, 0.16);
  font-size: 0.78rem;
  font-weight: 800;
  padding: 7px 11px;
  white-space: nowrap;
}

.message {
  display: none;
  margin: 0 0 14px;
  border-radius: 8px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.message.is-visible {
  display: block;
}

.message.is-error {
  border-color: rgba(196, 63, 77, 0.3);
  background: var(--danger-soft);
  color: var(--danger);
}

.message.is-success {
  border-color: rgba(0, 143, 122, 0.26);
  background: var(--brand-soft);
  color: var(--brand-dark);
}

.page {
  display: none;
}

.page.is-active {
  display: block;
}

.center-card,
.composer-card,
.detail-card,
.poll-card,
.chart-card,
.demo-notice {
  border: 1px solid rgba(221, 233, 230, 0.88);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.center-card {
  width: min(100%, 560px);
  margin: 28px auto 0;
  padding: 24px;
}

.center-card .lead {
  margin: 10px 0 22px;
  color: var(--muted);
}

.loader {
  width: 34px;
  height: 34px;
  margin-bottom: 14px;
  border-radius: 50%;
  border: 4px solid var(--brand-soft);
  border-top-color: var(--brand);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.stack-form,
.poll-form {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  outline: 0;
  padding: 12px 13px;
  font-weight: 650;
}

textarea {
  resize: vertical;
  min-height: 104px;
}

input::placeholder,
textarea::placeholder {
  color: #9aa7a4;
  font-weight: 600;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(0, 143, 122, 0.58);
  box-shadow: 0 0 0 4px rgba(0, 143, 122, 0.12);
}

.primary-button,
.ghost-button,
.back-button,
.detail-button,
.option-button,
.remove-option-button,
.report-button,
.modal-close {
  min-height: 44px;
  border-radius: 999px;
  font-weight: 850;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.primary-button {
  color: #ffffff;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  box-shadow: 0 12px 24px rgba(0, 108, 93, 0.24);
  padding: 12px 18px;
}

.primary-button:hover,
.ghost-button:hover,
.back-button:hover,
.detail-button:hover,
.option-button:hover,
.remove-option-button:hover,
.report-button:hover,
.modal-close:hover {
  transform: translateY(-1px);
}

.ghost-button,
.back-button,
.detail-button {
  color: var(--brand-dark);
  background: #ffffff;
  border: 1px solid rgba(0, 143, 122, 0.22);
  padding: 10px 15px;
}

.composer-card {
  padding: 18px;
  margin-bottom: 20px;
}

.demo-notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 14px;
  padding: 12px 14px;
  background: rgba(255, 247, 220, 0.72);
  border-color: rgba(242, 193, 78, 0.34);
  box-shadow: 0 10px 28px rgba(95, 75, 18, 0.07);
}

.demo-notice strong {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 4px 9px;
  background: #ffffff;
  color: #8b6516;
  font-size: 0.76rem;
  line-height: 1.3;
}

.demo-notice p {
  margin: 0;
  color: #6c5a24;
  font-size: 0.86rem;
  font-weight: 720;
  line-height: 1.55;
}

.section-title,
.detail-head,
.poll-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.section-title {
  margin-bottom: 15px;
}

.section-title h2 {
  font-size: 1.28rem;
}

.option-grid {
  display: grid;
  gap: 12px;
}

.option-field {
  display: grid;
  gap: 8px;
}

.option-field.has-remove {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
}

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

.add-option-button {
  width: auto;
}

.option-meta {
  display: grid;
  justify-items: end;
  gap: 2px;
}

.option-count {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
  white-space: nowrap;
}

.option-help {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.remove-option-button {
  min-width: 68px;
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid rgba(196, 63, 77, 0.2);
  padding: 10px 12px;
}

.feed-section {
  padding-bottom: 12px;
}

.poll-list {
  display: grid;
  gap: 14px;
}

.poll-card {
  position: relative;
  overflow: hidden;
  border-color: rgba(0, 143, 122, 0.13);
}

.poll-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: linear-gradient(90deg, var(--brand), var(--accent));
}

.poll-inner {
  padding: 22px 18px 18px;
}

.poll-question {
  margin: 0 0 12px;
  font-size: 1.12rem;
  font-weight: 850;
  line-height: 1.45;
}

.poll-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 750;
}

.option-buttons {
  display: grid;
  gap: 9px;
  margin: 18px 0;
}

.option-button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 48px;
  padding: 11px 14px;
  border: 1px solid rgba(0, 143, 122, 0.18);
  background: #ffffff;
  color: var(--text);
  text-align: left;
  box-shadow: 0 6px 18px rgba(15, 48, 42, 0.05);
}

.option-button.is-selected {
  border-color: rgba(0, 143, 122, 0.56);
  background: var(--brand-soft);
  color: var(--brand-dark);
}

.option-button span:first-child {
  min-width: 0;
  overflow-wrap: anywhere;
}

.option-button .vote-mark {
  flex: 0 0 auto;
  color: var(--brand-dark);
  font-size: 0.78rem;
}

.poll-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  border-top: 1px solid rgba(221, 233, 230, 0.72);
  padding-top: 14px;
}

.status-pill {
  background: var(--accent-soft);
  border-color: rgba(244, 138, 104, 0.22);
  color: #9b4b31;
}

.detail-button {
  min-width: 120px;
  background: var(--brand-soft);
}

.poll-action-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.report-button {
  color: #9c3f48;
  background: #ffffff;
  border: 1px solid rgba(196, 63, 77, 0.2);
  padding: 10px 14px;
}

.report-button.is-reported {
  background: var(--danger-soft);
}

.empty-state,
.detail-empty {
  border: 1px dashed rgba(0, 143, 122, 0.24);
  border-radius: 8px;
  padding: 22px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  text-align: center;
  font-weight: 750;
}

.empty-state.is-hidden,
.detail-empty.is-hidden,
.chart-grid.is-hidden,
.chart-frame.is-hidden,
.chart-note.is-hidden {
  display: none;
}

.back-button {
  margin: 0 0 13px;
}

.detail-card {
  padding: 18px;
}

.detail-head {
  margin-bottom: 14px;
}

.detail-head h2 {
  font-size: 1.2rem;
  overflow-wrap: anywhere;
}

.vote-total {
  flex: 0 0 auto;
  min-width: 70px;
  border-radius: 8px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  padding: 9px 11px;
  text-align: center;
  font-weight: 900;
}

.chart-grid {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.chart-card {
  min-width: 0;
  overflow: hidden;
  padding: 16px;
}

.chart-card h3 {
  margin: 0 0 12px;
  font-size: 1rem;
}

.chart-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.chart-card-head h3 {
  margin: 0;
}

.chart-toggle {
  display: inline-flex;
  flex-wrap: wrap;
  flex: 0 0 auto;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(0, 143, 122, 0.08);
  border: 1px solid rgba(0, 143, 122, 0.14);
}

.chart-toggle-button {
  min-height: 30px;
  border: 0;
  border-radius: 999px;
  padding: 6px 10px;
  background: transparent;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  white-space: nowrap;
}

.chart-toggle-button.is-active {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 6px 14px rgba(0, 143, 122, 0.18);
}

.chart-toggle-button:focus-visible {
  outline: 3px solid rgba(0, 143, 122, 0.18);
  outline-offset: 2px;
}

.chart-frame {
  position: relative;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 280px;
  overflow: hidden;
}

.chart-frame.large {
  height: 360px;
}

.option-chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  min-width: 0;
}

.option-chart-grid.is-percent {
  grid-template-columns: 1fr;
}

.option-chart-grid.is-prefecture-cards {
  display: block;
}

.option-chart-card {
  display: grid;
  gap: 10px;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  padding: 13px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid rgba(0, 143, 122, 0.12);
}

.option-chart-card h4 {
  margin: 0;
  color: var(--text);
  font-size: 0.94rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.option-chart-total {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
}

.option-chart-frame {
  position: relative;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 230px;
  overflow: hidden;
}

.option-chart-frame canvas {
  max-width: 100%;
}

.option-chart-empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

.chart-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
}

.custom-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  max-width: 100%;
  min-width: 0;
  padding-top: 2px;
}

.custom-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.custom-legend-item span:last-child {
  min-width: 0;
  overflow-wrap: anywhere;
}

.custom-legend-swatch {
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.7);
}

.prefecture-option-panel {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.prefecture-option-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  min-width: 0;
}

.prefecture-option-card {
  display: grid;
  gap: 10px;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  padding: 12px;
  border: 1px solid rgba(0, 143, 122, 0.13);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.84);
}

.prefecture-option-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.prefecture-option-title h5 {
  margin: 0;
  min-width: 0;
  color: var(--text);
  font-size: 0.94rem;
  overflow-wrap: anywhere;
}

.prefecture-option-title span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
}

.prefecture-share-bar {
  display: flex;
  width: 100%;
  max-width: 100%;
  height: 28px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-soft);
  box-shadow: inset 0 0 0 1px rgba(0, 143, 122, 0.08);
}

.prefecture-share-segment {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  min-width: 3px;
  overflow: hidden;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
  text-shadow: 0 1px 4px rgba(15, 37, 34, 0.22);
}

.prefecture-breakdown-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  min-width: 0;
  max-width: 100%;
}

canvas {
  display: block;
}

.app-footer {
  display: grid;
  gap: 12px;
  margin-top: 28px;
  padding: 20px 4px 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.footer-brand {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
}

.footer-brand strong {
  color: var(--text);
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
}

.footer-link {
  border: 0;
  padding: 0;
  color: var(--brand-dark);
  background: transparent;
  font-weight: 850;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(15, 37, 34, 0.42);
}

.modal-overlay.is-visible {
  display: flex;
}

.modal-panel {
  width: min(100%, 720px);
  max-height: min(84vh, 760px);
  overflow: auto;
  border: 1px solid rgba(221, 233, 230, 0.9);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 24px 80px rgba(15, 37, 34, 0.22);
}

.modal-head {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}

.modal-head h2 {
  margin: 0;
  font-size: 1.2rem;
}

.modal-close {
  color: var(--brand-dark);
  background: var(--brand-soft);
  border: 1px solid rgba(0, 143, 122, 0.18);
  padding: 9px 13px;
}

.modal-body {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.modal-section {
  display: grid;
  gap: 8px;
}

.modal-section h3 {
  margin: 0;
  font-size: 1rem;
}

.modal-section p,
.modal-section li {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.7;
}

.modal-section p,
.modal-section ul {
  margin: 0;
}

.modal-section ul {
  padding-left: 1.2em;
}

@media (min-width: 720px) {
  .app-shell {
    padding: 26px 22px 64px;
  }

  .app-header h1 {
    font-size: 2.35rem;
  }

  .composer-card,
  .detail-card {
    padding: 22px;
  }

  .option-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .chart-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .chart-card:last-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 720px) {
  .option-chart-grid {
    grid-template-columns: 1fr;
  }

  .prefecture-option-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .demo-notice,
  .chart-card-head,
  .option-controls,
  .poll-actions {
    align-items: stretch;
  }

  .chart-card-head {
    flex-direction: column;
  }

  .chart-toggle {
    width: 100%;
  }

  .chart-toggle-button {
    flex: 1 1 88px;
  }

  .option-chart-grid {
    grid-template-columns: 1fr;
  }

  .demo-notice {
    display: grid;
  }

  .add-option-button,
  .poll-action-buttons,
  .detail-button,
  .report-button {
    width: 100%;
  }

  .option-meta {
    justify-items: start;
  }

  .modal-overlay {
    align-items: flex-end;
    padding: 10px;
  }

  .modal-panel {
    max-height: 88vh;
  }
}
