/* ===== Reset & Base ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Noto Sans JP", "Hiragino Sans", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: #222;
  background: #f4f6f9;
}

/* ===== Header ===== */
header {
  background: linear-gradient(135deg, #1e3a5f 0%, #2d6a9f 100%);
  color: #fff;
  padding: 1.25rem 1rem 1.5rem;
}

.header-inner {
  max-width: 860px;
  margin: 0 auto;
}

.back-link {
  display: inline-block;
  color: rgba(255,255,255,0.8);
  text-decoration: none;
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
  padding: 0.25rem 0;
  min-height: 44px;
  line-height: 44px;
  padding-left: 0;
  transition: color 0.2s;
}

.back-link:hover {
  color: #fff;
}

header h1 {
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.4;
}

.subtitle {
  font-size: 0.85rem;
  opacity: 0.85;
  margin-top: 0.4rem;
}

/* ===== Main Layout ===== */
main {
  max-width: 860px;
  margin: 0 auto;
  padding: 1rem;
}

/* ===== Ad Units ===== */
.ad-unit {
  margin: 1.25rem 0;
}

/* ===== Tool Section ===== */
.tool-section {
  background: #fff;
  border-radius: 10px;
  padding: 1.25rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
}

/* ===== Settings Panel ===== */
.settings-panel {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.setting-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.setting-group label {
  font-size: 0.85rem;
  font-weight: 700;
  color: #1e3a5f;
  letter-spacing: 0.02em;
}

/* slider row */
.slider-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.slider-row input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  background: #dce4ef;
  outline: none;
  cursor: pointer;
}

.slider-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #2d6a9f;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.slider-row input[type="range"]::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #2d6a9f;
  cursor: pointer;
  border: none;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.size-display {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
  font-weight: 700;
  font-size: 1rem;
  color: #1e3a5f;
  min-width: 80px;
}

.size-display select {
  font-size: 0.85rem;
  padding: 0.2rem 0.3rem;
  border: 1px solid #c0cfe0;
  border-radius: 4px;
  background: #f4f6f9;
  cursor: pointer;
  color: #333;
}

#line-height-val,
#letter-spacing-val {
  font-weight: 700;
  font-size: 0.95rem;
  color: #1e3a5f;
  min-width: 40px;
  text-align: right;
}

/* line-letter row */
.line-letter-row {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.setting-group.half {
  width: 100%;
}

/* ===== Ratio Grid ===== */
.ratio-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}

.ratio-btn {
  min-height: 56px;
  padding: 0.5rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  background: #f0f4fa;
  color: #2d4a6e;
  border: 2px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  text-align: center;
  line-height: 1.4;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.ratio-btn span {
  display: block;
  font-size: 0.9rem;
  font-weight: 700;
  margin-top: 0.1rem;
}

.ratio-btn:hover {
  background: #dce8f5;
  border-color: #2d6a9f;
}

.ratio-btn.active {
  background: #2d6a9f;
  color: #fff;
  border-color: #2d6a9f;
}

/* ===== Preview Area ===== */
.preview-area {
  border: 1px solid #dce4ef;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 1.25rem;
}

.preview-row {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #edf1f7;
  transition: background 0.15s;
}

.preview-row:last-child {
  border-bottom: none;
}

.preview-row:hover {
  background: #f7f9fc;
}

.preview-meta {
  flex-shrink: 0;
  width: 90px;
  text-align: right;
}

.preview-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  color: #6b8099;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.preview-size {
  display: block;
  font-size: 0.75rem;
  color: #2d6a9f;
  font-weight: 700;
  margin-top: 0.15rem;
  font-variant-numeric: tabular-nums;
}

.preview-text {
  flex: 1;
  font-family: -apple-system, BlinkMacSystemFont, "Noto Sans JP", "Hiragino Sans", sans-serif;
  color: #1a2533;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

/* ===== Output Panel ===== */
.output-panel {
  margin-top: 0.5rem;
}

.output-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.tab-btn {
  min-height: 44px;
  padding: 0 1.25rem;
  font-size: 0.9rem;
  font-weight: 600;
  background: #f0f4fa;
  color: #2d4a6e;
  border: 2px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.tab-btn:hover {
  background: #dce8f5;
}

.tab-btn.active {
  background: #1e3a5f;
  color: #fff;
  border-color: #1e3a5f;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.code-block {
  background: #111827;
  color: #a5f3fc;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.8rem;
  line-height: 1.65;
  padding: 1rem;
  border-radius: 8px;
  overflow-x: auto;
  white-space: pre;
  max-height: 280px;
  overflow-y: auto;
}

.copy-btn {
  display: block;
  width: 100%;
  min-height: 56px;
  margin-top: 0.75rem;
  padding: 0 1rem;
  font-size: 1rem;
  font-weight: 700;
  background: #2d6a9f;
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
}

.copy-btn:hover {
  background: #1e3a5f;
}

.copy-btn.copied {
  background: #16a34a;
}

/* ===== How-to Section ===== */
.howto-section {
  background: #fff;
  border-radius: 10px;
  padding: 1.5rem 1.25rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
  margin-top: 0;
}

.howto-section h2 {
  font-size: 1.05rem;
  font-weight: 700;
  color: #1e3a5f;
  margin-bottom: 0.75rem;
  margin-top: 1.5rem;
  padding-bottom: 0.3rem;
  border-bottom: 2px solid #dce8f5;
}

.howto-section h2:first-child {
  margin-top: 0;
}

.howto-section ol,
.howto-section p {
  font-size: 0.93rem;
  color: #444;
  line-height: 1.75;
}

.howto-section ol {
  padding-left: 1.4rem;
}

.howto-section li {
  margin-bottom: 0.55rem;
}

.howto-section code {
  background: #f0f4fa;
  color: #1e3a5f;
  padding: 0.1em 0.35em;
  border-radius: 3px;
  font-size: 0.88em;
  font-family: "SFMono-Regular", Consolas, monospace;
}

.guide-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.guide-list li {
  font-size: 0.9rem;
  color: #444;
  padding: 0.5rem 0.75rem;
  background: #f7f9fc;
  border-left: 3px solid #2d6a9f;
  border-radius: 0 4px 4px 0;
}

/* ===== Footer ===== */
footer {
  text-align: center;
  padding: 2rem 1rem;
  font-size: 0.85rem;
  color: #888;
}

footer a {
  color: #666;
  text-decoration: underline;
}

footer p + p {
  margin-top: 0.4rem;
}

/* ===== Tablet / Desktop ===== */
@media (min-width: 640px) {
  header h1 {
    font-size: 1.6rem;
  }

  .subtitle {
    font-size: 0.95rem;
  }

  main {
    padding: 1.5rem 2rem;
  }

  .ratio-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .line-letter-row {
    flex-direction: row;
    gap: 1.5rem;
  }

  .setting-group.half {
    width: 50%;
  }

  .preview-meta {
    width: 110px;
  }

  .code-block {
    font-size: 0.85rem;
  }
}

@media (min-width: 860px) {
  .tool-section {
    padding: 2rem;
  }
}
