:root {
  font-family: "Noto Sans JP", "Yu Gothic", Meiryo, sans-serif;
  color: #17212b;
  background: #eef2f1;
  font-synthesis: none;
  --green: #166534;
  --green-dark: #14532d;
  --line: #d8dfdc;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: #eef2f1; }
body.editing { overflow: hidden; }
button, input { font: inherit; }
button { touch-action: manipulation; }
[hidden] { display: none !important; }

.app-header {
  display: flex;
  align-items: center;
  min-height: 72px;
  padding: 10px 14px;
  padding-top: calc(10px + var(--safe-top));
  color: white;
  background: linear-gradient(135deg, var(--green-dark), var(--green));
  box-shadow: 0 2px 12px rgb(0 0 0 / 18%);
}
.header-brand { display: flex; align-items: center; gap: 10px; }
.header-logo { width: 46px; height: 46px; border-radius: 50%; object-fit: cover; background: white; }
.app-header h1 { margin: 0; font-size: 19px; }
.app-header p { margin: 2px 0 0; font-size: 11px; opacity: .82; }

.start-panel { min-height: calc(100dvh - 150px); display: grid; place-items: center; padding: 24px; }
.start-card {
  width: min(100%, 430px);
  padding: 30px 22px;
  border-radius: 20px;
  text-align: center;
  background: white;
  box-shadow: 0 10px 35px rgb(20 60 43 / 12%);
}
.hero-logo { width: 108px; height: 108px; border-radius: 50%; object-fit: cover; box-shadow: 0 6px 18px rgb(0 0 0 / 10%); }
.start-card h2 { margin: 16px 0 10px; font-size: 22px; }
.start-card p { color: #56616b; line-height: 1.65; }
.file-button {
  display: inline-block;
  margin-top: 10px;
  padding: 13px 22px;
  border-radius: 12px;
  color: white;
  font-weight: 700;
  background: var(--green);
  cursor: pointer;
}
.file-button input { display: none; }
.small-note { font-size: 12px; }
.app-footer { padding: 14px 16px calc(16px + var(--safe-bottom)); color: #64706b; font-size: 12px; text-align: center; }
.app-footer nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 14px; margin-top: 8px; }
.app-footer a { color: #315f4a; text-decoration: none; }
.app-footer a:hover { text-decoration: underline; }

.editor-panel {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #eef2f1;
}
.editor-shell {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.editor-topbar {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  min-height: 58px;
  padding: 7px 9px;
  padding-top: calc(7px + var(--safe-top));
  color: white;
  background: linear-gradient(135deg, var(--green-dark), var(--green));
  box-shadow: 0 2px 10px rgb(0 0 0 / 20%);
}
.page-nav { display: flex; align-items: center; justify-content: center; gap: 9px; min-width: 0; }
.page-nav strong { min-width: 54px; text-align: center; font-size: 17px; white-space: nowrap; }
.topbar-button {
  min-height: 42px;
  border: 0;
  border-radius: 11px;
  padding: 8px 12px;
  font-weight: 700;
  background: white;
}
.topbar-button.secondary { color: #41504a; font-size: 12px; }
.topbar-button.square { min-width: 42px; padding-inline: 8px; color: #087ac1; font-size: 19px; }
.topbar-button.save { color: var(--green-dark); font-size: 15px; }
.topbar-button:disabled { opacity: .45; }

.document-area { position: relative; flex: 1 1 auto; min-height: 0; overflow: hidden; background: #cfd6d3; }
.canvas-stage { position: absolute; inset: 0; overflow: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.canvas-content { width: max-content; min-width: 100%; min-height: 100%; padding: 16px; }
.canvas-wrap {
  position: relative;
  margin: 0 auto;
  line-height: 0;
  background: white;
  box-shadow: 0 5px 22px rgb(0 0 0 / 28%);
}
.canvas-wrap canvas { display: block; width: 100%; height: 100%; }
#overlayCanvas { position: absolute; inset: 0; touch-action: none; cursor: crosshair; }
.loading-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #334155;
  font-weight: 700;
  background: rgb(255 255 255 / 78%);
}
.loading-overlay[hidden] { display: none !important; }

.floating-zoom {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px;
  border: 1px solid rgb(0 0 0 / 12%);
  border-radius: 14px;
  background: rgb(255 255 255 / 94%);
  box-shadow: 0 4px 16px rgb(0 0 0 / 20%);
  backdrop-filter: blur(8px);
}
.floating-zoom button {
  min-width: 40px;
  min-height: 40px;
  border: 1px solid #cad3cf;
  border-radius: 10px;
  color: #24312c;
  font-weight: 800;
  background: white;
}
.floating-zoom strong { min-width: 50px; text-align: center; font-size: 12px; }
.floating-zoom .zoom-text-button { min-width: 46px; padding-inline: 7px; font-size: 11px; }

.context-panel {
  flex: 0 0 auto;
  padding: 8px 9px 6px;
  border-top: 1px solid #b8c7c0;
  background: rgb(255 255 255 / 98%);
  box-shadow: 0 -2px 12px rgb(0 0 0 / 10%);
}
.context-text-row { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 7px; }
.context-text-row label { font-size: 12px; font-weight: 700; color: #52605a; }
.context-text-row input {
  min-width: 0;
  height: 40px;
  border: 1px solid #bfcac5;
  border-radius: 10px;
  padding: 7px 10px;
  font-size: 16px;
  background: white;
}
.context-delete { height: 36px; border: 1px solid #e1aaa5; border-radius: 10px; padding: 6px 12px; color: #b42318; font-weight: 700; background: #fff5f4; }
.size-control { display: flex; align-items: center; gap: 6px; min-width: 0; margin-top: 7px; }
.size-control label { font-size: 11px; color: #52605a; }
.size-control button { min-width: 40px; height: 36px; border: 1px solid #bfcac5; border-radius: 9px; font-weight: 800; background: white; }
.size-control input[type="range"] { flex: 1 1 auto; min-width: 70px; }
.size-control output { min-width: 23px; color: #34423c; font-size: 12px; text-align: center; }
.context-color-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 7px; }
.color-control { display: flex; align-items: center; gap: 8px; }
.color-control > span { font-size: 11px; color: #52605a; }
.color-swatch {
  width: 31px;
  height: 31px;
  border: 3px solid white;
  border-radius: 50%;
  padding: 0;
  background: var(--swatch);
  box-shadow: 0 0 0 1px #aab6b0;
}
.color-swatch.active { box-shadow: 0 0 0 3px #f5c542, 0 0 0 5px #2f4038; }
.context-hint { margin: 5px 2px 0; color: #64706b; font-size: 11px; text-align: center; }

.tool-bar {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 2px;
  padding: 5px 4px calc(5px + var(--safe-bottom));
  border-top: 1px solid #c5cfca;
  background: rgb(255 255 255 / 98%);
}
.tool {
  min-width: 0;
  min-height: 62px;
  border: 0;
  border-radius: 11px;
  padding: 5px 1px;
  color: #4b5563;
  font-size: 10px;
  background: transparent;
}
.tool span { display: block; margin-bottom: 3px; font-size: 23px; line-height: 1; }
.tool.active { color: white; background: var(--green); }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(78px + var(--safe-bottom));
  z-index: 250;
  max-width: calc(100% - 32px);
  padding: 11px 16px;
  border-radius: 999px;
  color: white;
  font-size: 13px;
  background: rgb(17 24 39 / 92%);
  opacity: 0;
  transform: translate(-50%, 15px);
  pointer-events: none;
  transition: .2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

dialog { width: min(90%, 380px); border: 0; border-radius: 16px; padding: 22px; }
dialog::backdrop { background: rgb(0 0 0 / 45%); }
dialog h3 { margin-top: 0; }
.dialog-buttons { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.dialog-buttons button { padding: 10px 14px; border: 0; border-radius: 9px; }
.danger-button { color: white; background: #b42318; }

@media (max-width: 390px) {
  .topbar-button { padding-inline: 9px; }
  .size-control { gap: 4px; }
  .color-control { gap: 5px; }
  .color-swatch { width: 28px; height: 28px; }
  .color-control { gap: 4px; }
  .tool { font-size: 9px; }
}


.feature-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 7px;
  margin: 14px 0 3px;
}
.feature-badges span {
  padding: 6px 10px;
  border: 1px solid #bdd5c8;
  border-radius: 999px;
  color: #14532d;
  font-size: 12px;
  font-weight: 700;
  background: #effaf3;
}
.privacy-note {
  margin: 15px auto 0;
  padding: 10px 12px;
  border-radius: 11px;
  color: #39544a !important;
  font-size: 12px;
  background: #f2f7f5;
}
.start-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 15px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid #e1e8e5;
}
.start-links a {
  color: #315f4a;
  font-size: 12px;
  text-decoration: none;
}
.start-links a:hover { text-decoration: underline; }

body.modal-open { overflow: hidden; }
.support-modal {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: grid;
  place-items: center;
  padding: 18px;
  padding-top: calc(18px + var(--safe-top));
  padding-bottom: calc(18px + var(--safe-bottom));
  background: rgb(8 24 17 / 68%);
  backdrop-filter: blur(5px);
}
.support-modal[hidden] { display: none !important; }
.support-card {
  position: relative;
  width: min(100%, 420px);
  max-height: 92dvh;
  overflow: auto;
  padding: 25px 20px 20px;
  border-radius: 22px;
  text-align: center;
  background: white;
  box-shadow: 0 20px 60px rgb(0 0 0 / 35%);
}
.support-close-top {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  color: #52605a;
  font-size: 25px;
  line-height: 1;
  background: #eef2f1;
}
.support-logo {
  width: 82px;
  height: 82px;
  border-radius: 50%;
  object-fit: cover;
}
.saved-label {
  display: inline-block;
  margin: 12px 0 4px;
  padding: 5px 10px;
  border-radius: 999px;
  color: #14532d;
  font-size: 12px;
  font-weight: 800;
  background: #dcfce7;
}
.support-card h2 { margin: 6px 0 8px; font-size: 22px; }
.support-copy { margin: 0 0 16px; color: #52605a; font-size: 14px; line-height: 1.7; }
.support-web,
.share-link,
.support-return {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 12px;
  padding: 13px 14px;
  font-weight: 800;
  text-decoration: none;
}
.support-web { color: white; background: var(--green); }

.support-download {
  display: block;
  width: 100%;
  margin: 12px 0 6px;
  padding: 14px 16px;
  border: 0;
  border-radius: 12px;
  color: white;
  font-weight: 800;
  background: var(--green);
  box-shadow: 0 3px 10px rgb(20 83 45 / 22%);
}
.support-download:disabled { opacity: .55; }
.support-save-hint {
  margin: 0 0 16px;
  color: #5f6c66;
  font-size: 12px;
  line-height: 1.6;
}

.social-links {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 10px 0;
}
.social-links a {
  min-width: 0;
  padding: 11px 4px;
  border: 1px solid #cad3cf;
  border-radius: 11px;
  color: #26342e;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
  background: white;
}
.social-x { border-color: #aeb7b3 !important; }
.social-instagram { border-color: #d7b6c8 !important; }
.social-bluesky { border-color: #a9c8df !important; }
.share-link { color: #315f4a; font-size: 13px; background: #eef7f2; }
.support-return { margin-top: 10px; color: #35433d; background: #e8eeeb; }
.support-note { margin: 10px 0 0; color: #78837e; font-size: 10px; line-height: 1.5; }

@media (max-width: 360px) {
  .social-links { grid-template-columns: 1fr; }
  .support-card { padding-inline: 16px; }
}

.analytics-note {
  margin: 8px auto 0;
  max-width: 36rem;
  color: #64706b;
  font-size: 11px;
  line-height: 1.6;
}
