:root {
  --bg: #efeff5;
  --surface: #ffffff;
  --text: #202124;
  --muted: #6b7280;
  --accent: #e83b3b;
  --line: #e5e7eb;
  /* 全画面ドロップオーバーレイの上端（.topbar 直下） */
  --upload-overlay-top: 56px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Yu Gothic UI", "Meiryo", sans-serif;
  color: var(--text);
  background: var(--bg);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 10px 18px;
  background: #f7f7fa;
  border-bottom: 1px solid var(--line);
}

.brand {
  font-size: 34px;
  font-weight: 900;
  letter-spacing: 0.5px;
  color: #111827;
  text-decoration: none;
}

.brand span {
  color: var(--accent);
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.nav-item {
  border: none;
  background: transparent;
  color: #282c34;
  cursor: pointer;
  font-weight: 700;
  font-size: 15px;
  padding: 10px 8px;
  text-decoration: none;
}

.nav-item.active {
  color: var(--accent);
}

.nav-item:hover {
  color: var(--accent);
}

.menu-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.menu-trigger::after {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-1px);
  transition: transform 0.18s ease;
}

.menu-wrap.open .menu-trigger::after {
  transform: rotate(-135deg) translateY(-1px);
}

.menu-wrap {
  position: relative;
}

.dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  display: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(31, 41, 55, 0.15);
  padding: 18px;
  min-width: 380px;
  gap: 20px;
}

.dropdown.wide {
  min-width: 900px;
}

.menu-wrap.open .dropdown {
  display: flex;
}

.dropdown-col {
  min-width: 150px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dropdown-col h4 {
  margin: 0 0 6px;
  font-size: 14px;
  color: #4b5563;
}

.dropdown-col a {
  text-decoration: none;
  color: #1f2937;
  font-size: 14px;
}

.dropdown-col a:hover {
  color: var(--accent);
}

.dropdown-col a.active {
  color: var(--accent);
  font-weight: 700;
}

.profile-circle {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: 2px solid #d1d5db;
  background: #fff;
}

.logout-form {
  margin: 0;
}

.logout-btn {
  border: 1px solid #fecdd3;
  background: #fff1f2;
  color: #be123c;
  border-radius: 10px;
  padding: 8px 12px;
  font-weight: 700;
  cursor: pointer;
}

.logout-btn:hover {
  background: #ffe4e6;
}

main {
  min-height: calc(100vh - 120px);
}

.hero {
  text-align: center;
  padding: 46px 16px 60px;
}

.hero h2 {
  font-size: 42px;
  margin: 0 0 8px;
}

.hero p {
  margin: 0;
  color: #4b5563;
  font-size: 20px;
}

.hidden-input {
  display: none;
}

.upload-intro {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  text-align: center;
  min-height: calc(100vh - 140px);
  padding: 28px 16px 48px;
}

.upload-title {
  margin: 0 0 8px;
  font-size: 42px;
}

.upload-tagline {
  margin: 0 0 28px;
  color: #4b5563;
  font-size: 22px;
  max-width: 720px;
}

.upload-drop-hint-text {
  margin: 18px 0 0;
  font-size: 15px;
  color: #6b7280;
  text-align: center;
  max-width: 720px;
  line-height: 1.5;
}

.upload-full-drop-overlay {
  position: fixed;
  left: 0;
  right: 0;
  top: var(--upload-overlay-top);
  bottom: 0;
  z-index: 40;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(17, 24, 39, 0.76);
  backdrop-filter: blur(1px);
  pointer-events: auto;
}

.upload-full-drop-overlay.is-visible {
  display: flex;
}

.upload-full-drop-overlay-text {
  margin: 0;
  font-size: clamp(28px, 5vw, 44px);
  font-weight: 800;
  color: #fff;
  text-align: center;
  letter-spacing: 0.02em;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

.merge-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 290px;
  gap: 0;
  border-top: 1px solid #d4d4de;
  border-bottom: 1px solid #d4d4de;
  min-height: 560px;
  position: relative;
}

.workspace-board {
  position: relative;
  padding: 56px 24px 88px;
  min-height: 560px;
  transition: background-color 0.2s, border-color 0.2s;
}

.workspace-board.drag-over {
  background: #fff4f4;
}

.board-fab {
  position: absolute;
  top: 16px;
  right: 20px;
  z-index: 2;
}

.fab-add {
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(232, 59, 59, 0.35);
}

.file-count-badge {
  position: absolute;
  top: -4px;
  left: -4px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  background: #111827;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.add-file-btn {
  border: none;
  background: var(--accent);
  color: #fff;
  border-radius: 14px;
  padding: 16px 26px;
  font-size: 28px;
  font-weight: 700;
  cursor: pointer;
}

.file-cards {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  margin: 0;
  padding: 0;
}

.file-card {
  background: #fff;
  border: 1px solid #dddfe7;
  border-radius: 10px;
  padding: 10px;
  cursor: grab;
  user-select: none;
}

.file-card:active {
  cursor: grabbing;
}

.file-card.dragging {
  opacity: 0.55;
}

.file-card.drag-over-target {
  outline: 2px dashed var(--accent);
  outline-offset: 3px;
}

.file-preview {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 130px;
  border-radius: 6px;
  border: 1px solid #d1d5db;
  overflow: hidden;
  background: #f3f4f6;
}

.file-preview--loading {
  background: repeating-linear-gradient(
    0deg,
    #f5f6fa 0 8px,
    #edf0f8 8px 16px
  );
}

.file-preview-body {
  width: 100%;
  height: 100%;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease;
}

.file-preview-actions {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 4;
  display: flex;
  gap: 6px;
}

.file-action-btn {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
  line-height: 0;
}

.file-action-rotate {
  background: var(--accent);
  color: #fff;
}

.file-action-remove {
  background: #e5e7eb;
  color: #1f2937;
  font-size: 20px;
  font-weight: 700;
}

.file-action-btn svg {
  display: block;
}

.file-preview-body canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.file-preview-status {
  font-size: 12px;
  color: #6b7280;
  padding: 0 6px;
  text-align: center;
}

.file-name {
  margin-top: 8px;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-meta {
  margin-top: 4px;
  font-size: 12px;
  color: #6b7280;
}

.card-actions {
  margin-top: 8px;
  display: flex;
  gap: 6px;
}

.card-actions button {
  border: 1px solid #d1d5db;
  background: #f8fafc;
  border-radius: 6px;
  padding: 4px 7px;
  font-size: 12px;
  cursor: pointer;
}

.workspace-side {
  border-left: 1px solid #d4d4de;
  background: #f7f8fb;
  padding: 18px 16px 88px;
}

.workspace-side h2 {
  margin: 2px 0 14px;
  text-align: center;
}

.workspace-side p {
  margin: 0 0 10px;
  background: #e8f2ff;
  color: #334155;
  border-radius: 8px;
  padding: 10px;
  font-size: 14px;
}

.j2p-side .j2p-side-section {
  margin-bottom: 18px;
}

.j2p-side-label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: #374151;
  margin-bottom: 8px;
}

.j2p-toggle-row,
.j2p-margin-row {
  display: flex;
  gap: 8px;
}

.j2p-toggle-btn,
.j2p-margin-btn {
  flex: 1;
  border: 2px solid #d1d5db;
  background: #fff;
  border-radius: 10px;
  padding: 10px 8px;
  font-size: 14px;
  font-weight: 700;
  color: #374151;
  cursor: pointer;
}

.j2p-toggle-btn.is-active,
.j2p-margin-btn.is-active {
  border-color: var(--accent);
  color: var(--accent);
  background: #fff4f4;
}

.j2p-select {
  width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  background: #fff;
  color: #111827;
}

.j2p-merge-row {
  margin-top: 4px;
}

.j2p-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 14px;
  color: #1f2937;
  cursor: pointer;
  line-height: 1.45;
}

.j2p-check input {
  margin-top: 3px;
  flex-shrink: 0;
}

.file-preview-body .j2p-preview-img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.pw-side {
  padding-top: 10px;
}

.pw-option-card {
  border: 1px solid #d7dbe3;
  border-radius: 8px;
  background: #f8fafc;
  padding: 12px 10px;
  margin-bottom: 10px;
  cursor: pointer;
}

.pw-option-card h3 {
  margin: 0 0 8px;
  color: #9f1d1d;
  font-size: 24px;
}

.pw-option-card p {
  margin: 0;
  font-size: 14px;
  line-height: 1.45;
  background: transparent;
  padding: 0;
}

.pw-option-card.is-active {
  border-color: #86efac;
  box-shadow: inset 0 0 0 2px rgba(34, 197, 94, 0.25);
  background: #f0fdf4;
}

.pw-option-card.is-disabled {
  opacity: 0.7;
}

.workspace-action {
  position: absolute;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.merge-action-btn {
  border: none;
  border-radius: 12px;
  padding: 13px 24px;
  background: var(--accent);
  color: #fff;
  font-size: 28px;
  font-weight: 700;
  cursor: pointer;
}

.merge-action-btn:disabled {
  background: #9ca3af;
  cursor: not-allowed;
}

.status-message {
  margin: 0;
  color: #1f2937;
  font-size: 14px;
  min-height: 20px;
}

.hidden {
  display: none !important;
}

.processing-view {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 60vh;
}

.processing-card {
  text-align: center;
}

.processing-brand {
  font-size: 52px;
}

.processing-card p {
  font-size: 42px;
  margin: 10px 0 20px;
}

.spinner {
  width: 86px;
  height: 86px;
  border-radius: 999px;
  border: 8px solid #d9dce4;
  border-left-color: var(--accent);
  animation: spin 0.9s linear infinite;
  margin: 0 auto;
}

.result-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 38px 16px 48px;
}

.result-view h2 {
  font-size: 48px;
  margin: 0 0 20px;
}

.download-btn {
  border: none;
  border-radius: 14px;
  background: var(--accent);
  color: #fff;
  font-size: 28px;
  padding: 16px 26px;
  cursor: pointer;
}

.reset-btn {
  margin-top: 16px;
  border: none;
  border-radius: 14px;
  background: #374151;
  color: #fff;
  font-size: 16px;
  padding: 16px 20px;
  cursor: pointer;
}

.result-message {
  color: #374151;
  margin: 12px 0 0;
  max-width: 520px;
}

.result-stats {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 32px;
  margin: 28px 0 8px;
  flex-wrap: wrap;
}

.result-stats-visual {
  position: relative;
  width: 132px;
  height: 132px;
  flex-shrink: 0;
}

.result-ring-svg {
  width: 132px;
  height: 132px;
  display: block;
}

.result-ring-track {
  fill: none;
  stroke: #d1d5db;
  stroke-width: 10;
}

.result-ring-fill {
  fill: none;
  stroke: var(--accent);
  stroke-width: 10;
  stroke-linecap: round;
  /* r=52 の円周に近い値（JS が getTotalLength() で上書き） */
  stroke-dasharray: 326.726;
  stroke-dashoffset: 326.726;
}

.result-ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  text-align: center;
}

.result-ring-pct-line {
  font-size: 34px;
  font-weight: 800;
  color: #111827;
  line-height: 1;
}

.result-pct-suffix {
  font-size: 22px;
  font-weight: 800;
}

.result-ring-sub {
  font-size: 12px;
  color: #6b7280;
  margin-top: 4px;
}

.result-stats-copy {
  max-width: 420px;
}

.result-stats-line1 {
  margin: 0 0 10px;
  font-size: 19px;
  font-weight: 700;
  color: #1f2937;
}

.result-stats-size {
  margin: 0;
  font-size: 21px;
  font-weight: 700;
  color: #111827;
}

.result-stats-arrow {
  margin: 0 10px;
  color: #6b7280;
  font-weight: 600;
}

.tools {
  padding: 0 16px 40px;
  max-width: 1220px;
  margin: 0 auto;
}

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

.tool-card {
  display: block;
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  color: inherit;
}

.tool-card h3 {
  margin: 0 0 8px;
}

.tool-card p {
  margin: 0;
  color: #4b5563;
}

.tool-page {
  max-width: 980px;
  margin: 48px auto;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.back-home {
  color: var(--accent);
  text-decoration: none;
}

.delivery-form {
  margin: 22px 0 18px;
  display: grid;
  gap: 10px;
}

.delivery-form-label {
  font-size: 15px;
  font-weight: 700;
  color: #1f2937;
}

.delivery-form-input,
.delivery-form-textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 15px;
  font-family: inherit;
  color: #111827;
  background: #fff;
}

.delivery-form-input:focus,
.delivery-form-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(225, 29, 72, 0.15);
}

.delivery-form-textarea {
  resize: vertical;
  line-height: 1.5;
}

.delivery-form-fieldset {
  margin: 2px 0 4px;
  padding: 0;
  border: none;
}

.delivery-tax-options {
  display: flex;
  gap: 18px;
  align-items: center;
  margin-top: 4px;
}

.delivery-radio-option {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #1f2937;
}

.delivery-form-help {
  margin: 0;
  color: #6b7280;
  font-size: 13px;
}

.delivery-generate-btn {
  justify-self: start;
  margin-top: 6px;
}

.delivery-status-message {
  margin: 4px 0 0;
  min-height: 1.4em;
  color: #0f766e;
  font-weight: 600;
}

.delivery-status-message.is-error {
  color: #b91c1c;
}

.delivery-settings-page {
  background: linear-gradient(180deg, #fff 0%, #fff8fa 100%);
}

.delivery-settings-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}

.delivery-settings-subtitle {
  margin: 8px 0 0;
  color: #6b7280;
}

.delivery-template-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #fecdd3;
  color: #be123c;
  background: #fff1f2;
  border-radius: 10px;
  padding: 8px 12px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.delivery-template-link:hover {
  background: #ffe4e6;
}

.delivery-mode-switch {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.delivery-mode-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 100px;
  border: 1px solid #e5e7eb;
  border-radius: 999px;
  padding: 8px 14px;
  background: #fff;
  color: #374151;
  text-decoration: none;
  font-weight: 700;
}

.delivery-mode-pill.is-active {
  border-color: #fb7185;
  background: #fff1f2;
  color: #be123c;
}

.delivery-settings-layout {
  display: block;
}

.delivery-settings-form {
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  background: #fff;
  padding: 18px;
  margin: 0;
}

.delivery-settings-form .delivery-form-label {
  font-size: 14px;
}

.delivery-settings-form .delivery-form-input,
.delivery-settings-form .delivery-form-textarea {
  background: #fcfcfd;
}

footer {
  border-top: 1px solid var(--line);
  background: #e7e7ec;
  color: #374151;
  font-size: 13px;
  padding: 12px 16px;
}

@media (max-width: 1080px) {
  :root {
    --upload-overlay-top: 96px;
  }

  .topbar {
    flex-wrap: wrap;
  }

  .dropdown.wide {
    min-width: 94vw;
  }

  .merge-workspace {
    grid-template-columns: 1fr;
  }

  .workspace-side {
    border-left: none;
    border-top: 1px solid #d4d4de;
    padding-bottom: 16px;
  }

  .workspace-action {
    position: static;
    grid-column: 1 / -1;
    align-items: center;
    padding: 0 0 16px;
  }

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

  .processing-card p {
    font-size: 28px;
  }

  .result-view h2 {
    font-size: 34px;
  }

  .result-stats {
    flex-direction: column;
    gap: 18px;
  }

  .download-btn,
  .add-file-btn {
    font-size: 22px;
  }

  .delivery-settings-layout {
    grid-template-columns: 1fr;
  }

  .delivery-settings-header {
    flex-direction: column;
  }

  .reset-btn {
    margin-top: 14px;
  }
}

@media (max-width: 680px) {
  .tool-grid {
    grid-template-columns: 1fr;
  }

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

  .upload-title {
    font-size: 30px;
  }

  .upload-tagline {
    font-size: 16px;
  }

  .merge-action-btn {
    font-size: 22px;
  }
}

.login-body {
  min-height: 100vh;
  margin: 0;
  background: linear-gradient(180deg, #fff 0%, #fff1f2 100%);
}

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  width: min(440px, 100%);
  background: #fff;
  border: 1px solid #fecdd3;
  border-radius: 14px;
  padding: 24px;
}

.login-card h1 {
  margin: 0 0 8px;
}

.login-card p {
  margin: 0 0 14px;
  color: #6b7280;
}

.login-form {
  display: grid;
  gap: 8px;
}

.login-form label {
  font-weight: 700;
}

.login-form input {
  border: 1px solid #d1d5db;
  border-radius: 10px;
  padding: 10px 12px;
}

.login-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(225, 29, 72, 0.15);
}

.login-form button {
  margin-top: 8px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  padding: 10px 14px;
  cursor: pointer;
}

.login-error {
  color: #b91c1c !important;
  font-weight: 700;
}

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