:root{
  --bg:#f5f7f6;
  --card:#ffffff;
  --text:#17231c;
  --muted:#66736b;
  --line:#dfe7e2;
  --accent:#3f9568;
  --accent-dark:#28704d;
  --accent-soft:#eaf5ee;
  --header:#1f6648;
  --shadow:0 12px 34px rgba(31,102,72,.055);
}

*{box-sizing:border-box}

body{
  margin:0;
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans JP","Yu Gothic",sans-serif;
  background:var(--bg);
  color:var(--text);
}

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

button{cursor:pointer}

.wrap{
  width:min(1120px,calc(100% - 36px));
  margin:auto;
}

.site-header{
  background:var(--header);
}

.brand{
  display:inline-flex;
  flex-direction:column;
  padding:16px 0;
  color:white;
  text-decoration:none;
}

.brand strong{
  font-size:18px;
}

.brand span{
  margin-top:2px;
  font-size:9px;
  letter-spacing:.17em;
  opacity:.7;
}

.main{
  padding-top:22px;
  padding-bottom:68px;
}

.breadcrumb{
  display:flex;
  gap:8px;
  margin-bottom:28px;
  color:var(--muted);
  font-size:13px;
}

.breadcrumb a{
  color:var(--accent-dark);
  text-decoration:none;
}

.hero{
  display:flex;
  justify-content:space-between;
  align-items:flex-end;
  gap:30px;
  margin-bottom:25px;
}

.eyebrow,
.section-kicker{
  margin:0 0 5px;
  color:var(--accent-dark);
  font-size:11px;
  font-weight:800;
  letter-spacing:.15em;
}

.hero h1{
  margin:0 0 10px;
  font-size:clamp(36px,5vw,52px);
  letter-spacing:-.04em;
}

.hero>div:first-child>p:last-child{
  max-width:650px;
  margin:0;
  color:var(--muted);
  line-height:1.8;
}

.trust-box{
  flex:0 0 360px;
  display:flex;
  gap:12px;
  align-items:flex-start;
  padding:16px;
  border:1px solid #cde1d4;
  border-radius:15px;
  background:#f6fbf8;
}

.trust-box>span,
.privacy-icon{
  flex:0 0 32px;
  height:32px;
  display:grid;
  place-items:center;
  border-radius:50%;
  background:var(--accent);
  color:white;
  font-weight:900;
}

.trust-box div{
  display:flex;
  flex-direction:column;
  gap:4px;
}

.trust-box strong{
  font-size:14px;
}

.trust-box small{
  color:var(--muted);
  line-height:1.5;
}

.tool-grid{
  display:grid;
  grid-template-columns:minmax(0,.9fr) minmax(430px,1.1fr);
  gap:20px;
  align-items:start;
}

.settings-card,
.preview-card,
.privacy-card,
.guide-card{
  border:1px solid var(--line);
  border-radius:18px;
  background:var(--card);
  box-shadow:var(--shadow);
}

.settings-card,
.preview-card{
  padding:24px;
}

.section-head h2,
.preview-head h2{
  margin:0;
  font-size:19px;
}

#qrText{
  width:100%;
  margin-top:14px;
  padding:14px;
  border:1px solid var(--line);
  border-radius:11px;
  resize:vertical;
  min-height:120px;
  color:var(--text);
  background:#fbfcfb;
  line-height:1.6;
  font-size:16px;
}

#qrText:focus{
  outline:none;
  border-color:var(--accent);
  box-shadow:0 0 0 3px rgba(63,149,104,.10);
}

.quick-row{
  display:flex;
  gap:8px;
  margin-top:9px;
}

.quick-btn,
.reset-btn{
  border:1px solid var(--line);
  border-radius:9px;
  background:#fff;
  color:var(--accent-dark);
  padding:8px 12px;
  font-size:12px;
  font-weight:750;
}

.divider{
  height:1px;
  margin:22px 0;
  background:var(--line);
}

.setting-grid{
  display:grid;
  gap:15px;
  margin-top:15px;
}

.setting{
  display:grid;
  grid-template-columns:minmax(0,1fr) 170px;
  gap:14px;
  align-items:center;
}

.setting>span{
  display:flex;
  flex-direction:column;
  gap:2px;
}

.setting strong{
  font-size:13px;
}

.setting small{
  color:var(--muted);
  font-size:10px;
}

.setting select,
.setting input[type=text]{
  width:100%;
  padding:8px 9px;
  border:1px solid var(--line);
  border-radius:8px;
  background:white;
}

.color-row{
  display:grid;
  grid-template-columns:43px 1fr;
  gap:7px;
}

.color-row input[type=color]{
  width:43px;
  height:38px;
  padding:3px;
  border:1px solid var(--line);
  border-radius:8px;
  background:white;
}

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

.preview-head{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:20px;
}

.status-badge{
  padding:5px 10px;
  border-radius:999px;
  background:var(--accent-soft);
  color:var(--accent-dark);
  font-size:11px;
  font-weight:800;
}

.qr-stage{
  display:grid;
  place-items:center;
  min-height:500px;
  margin-top:16px;
  padding:28px;
  border:1px solid var(--line);
  border-radius:15px;
  background:#f8faf9;
}

#qrCanvas{
  display:block;
  width:min(100%,440px);
  height:auto;
  background:white;
  box-shadow:0 8px 30px rgba(0,0,0,.07);
}

.qr-info{
  min-height:20px;
  margin-top:10px;
  color:var(--muted);
  text-align:center;
  font-size:12px;
}

.download-grid{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:10px;
  margin-top:16px;
}

.primary-btn,
.secondary-btn{
  border-radius:11px;
  padding:13px 16px;
  font-weight:800;
}

.primary-btn{
  border:0;
  background:var(--accent);
  color:white;
}

.primary-btn:hover{
  background:var(--accent-dark);
}

.secondary-btn{
  border:1px solid #bfd5c7;
  background:white;
  color:var(--accent-dark);
}

.download-note{
  margin:12px 0 0;
  color:var(--muted);
  text-align:center;
  font-size:11px;
  line-height:1.6;
}

.privacy-card{
  display:flex;
  gap:17px;
  margin-top:20px;
  padding:22px;
  background:#f7fbf8;
}

.privacy-card h2,
.guide-card h2{
  margin:0 0 7px;
  font-size:18px;
}

.privacy-card p{
  margin:0;
  color:var(--muted);
  line-height:1.8;
}

.guide-card{
  margin-top:18px;
  padding:22px;
}

.guide-grid{
  display:grid;
  grid-template-columns:repeat(3,1fr);
  gap:22px;
  margin-top:16px;
}

.guide-grid article{
  padding-left:14px;
  border-left:3px solid var(--accent-soft);
}

.guide-grid strong{
  font-size:13px;
}

.guide-grid p{
  margin:5px 0 0;
  color:var(--muted);
  font-size:12px;
  line-height:1.7;
}

.trademark{
  margin-top:18px;
  color:#7b857f;
  font-size:11px;
}

.site-footer{
  padding:25px 0;
  border-top:1px solid var(--line);
  color:var(--muted);
  font-size:12px;
}

.site-footer .wrap{
  display:flex;
  justify-content:space-between;
}

.site-footer a{
  color:var(--accent-dark);
  text-decoration:none;
}

@media(max-width:850px){

  .hero{
    display:block;
  }

  .trust-box{
    width:100%;
    margin-top:18px;
  }

  .tool-grid{
    grid-template-columns:1fr;
  }

  .preview-card{
    order:-1;
  }

  .qr-stage{
    min-height:auto;
  }

  .guide-grid{
    grid-template-columns:1fr;
  }
}

@media(max-width:520px){

  .wrap{
    width:calc(100% - 24px);
  }

  .settings-card,
  .preview-card{
    padding:17px;
  }

  .setting{
    grid-template-columns:1fr;
    gap:7px;
  }

  .setting select,
  .setting input[type=text]{
    font-size:16px;
  }

  #qrText{
    font-size:16px;
  }

  .qr-stage{
    padding:16px;
  }

  .download-grid{
    grid-template-columns:1fr;
  }
}

/* =========================================================
   v0.2 Readability diagnostics
   ========================================================= */

.readability-card {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f7fbf8;
}

.readability-main {
  display: flex;
  align-items: center;
  gap: 10px;
}

.readability-icon {
  flex: 0 0 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 17px;
  font-weight: 900;
}

.readability-main > div {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.readability-label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

#readabilityTitle {
  font-size: 14px;
}

.readability-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.readability-card.good {
  border-color: #cce3d5;
  background: #f4faf6;
}

.readability-card.good .readability-icon {
  background: #e0f3e7;
  color: #237a4b;
}

.readability-card.ok {
  border-color: #d7e3ce;
  background: #f8faf4;
}

.readability-card.ok .readability-icon {
  background: #edf3df;
  color: #61782d;
}

.readability-card.warn {
  border-color: #ead8ad;
  background: #fffaf0;
}

.readability-card.warn .readability-icon {
  background: #fff0c9;
  color: #9a6811;
}

.readability-card.bad {
  border-color: #e8c5c5;
  background: #fff6f6;
}

.readability-card.bad .readability-icon {
  background: #f8dede;
  color: #a33d3d;
}

.readability-note {
  margin-top: 7px;
  color: #7a847e;
  font-size: 10px;
  line-height: 1.5;
}

/* =========================================================
   v0.3 Safe color recovery
   ========================================================= */

.safe-color-btn {
  justify-self: start;
  margin-top: 3px;
  padding: 8px 12px;
  border: 1px solid currentColor;
  border-radius: 9px;
  background: #fff;
  color: #28704d;
  font-size: 11px;
  font-weight: 800;
}

.safe-color-btn:hover {
  background: #f2f8f4;
}

.readability-card.warn .safe-color-btn {
  color: #8a5b0a;
}

.readability-card.bad .safe-color-btn {
  color: #9b3434;
}

.safe-color-btn[hidden] {
  display: none;
}

/* =========================================================
   v1.0 mobile flow fix
   Input/settings first -> preview second
   ========================================================= */

@media(max-width:850px){

  .settings-card {
    order: 1;
  }

  .preview-card {
    order: 2;
  }

  .qr-stage {
    min-height: auto;
  }

  #qrCanvas {
    width: min(100%, 360px);
  }
}

@media(max-width:520px){

  #qrCanvas {
    width: min(100%, 320px);
  }
}

/* =========================================================
   v1.0 final3
   Desktop : input/settings left, preview right
   Mobile  : input -> preview -> settings
   ========================================================= */

.input-card {
  grid-area: input;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.settings-card {
  grid-area: settings;
}

.preview-card {
  grid-area: preview;
}

.tool-grid {
  grid-template-columns: minmax(0,.9fr) minmax(430px,1.1fr);
  grid-template-areas:
    "input preview"
    "settings preview";
}

@media(max-width:850px){

  .tool-grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      "input"
      "preview"
      "settings";
  }

  .input-card,
  .settings-card,
  .preview-card {
    order: 0;
  }

  .input-card {
    padding: 20px;
  }

  #qrText {
    min-height: 110px;
  }

  .qr-stage {
    padding: 18px;
  }

  #qrCanvas {
    width: min(100%, 340px);
  }
}

@media(max-width:520px){

  .input-card {
    padding: 17px;
  }

  #qrText {
    min-height: 100px;
  }

  #qrCanvas {
    width: min(100%, 300px);
  }
}
