*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Noto Sans JP", "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: #333;
  background: #f3f4f6;
}

/* ========== Header ========== */
header {
  background: #1e293b;
  color: #fff;
  padding: 1.25rem 1rem;
}

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

header h1 {
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.3;
}

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

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

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

/* ========== Tab Nav ========== */
.tab-nav {
  display: flex;
  gap: 0.25rem;
  background: #e2e8f0;
  border-radius: 10px;
  padding: 0.3rem;
  margin-bottom: 1rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.tab-nav::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  flex: 0 0 auto;
  padding: 0.55rem 1rem;
  min-height: 44px;
  font-size: 0.875rem;
  font-weight: 600;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.tab-btn:hover {
  background: #cbd5e1;
  color: #1e293b;
}

.tab-btn.active {
  background: #fff;
  color: #1e293b;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}

/* ========== Tab Panels ========== */
.tab-panel {
  display: none;
}

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

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

.editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.editor-header h2 {
  font-size: 1rem;
  font-weight: 700;
  color: #1e293b;
}

.editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

/* ========== Buttons ========== */
.btn-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  padding: 0 0.875rem;
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #f8fafc;
  color: #334155;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
  text-decoration: none;
}

.btn-sm:hover {
  background: #e2e8f0;
  border-color: #94a3b8;
}

.btn-file {
  cursor: pointer;
  position: relative;
}

.btn-file input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 48px;
  padding: 0 1.5rem;
  font-size: 0.9rem;
  font-weight: 700;
  border: none;
  border-radius: 8px;
  background: #1e293b;
  color: #fff;
  cursor: pointer;
  transition: background 0.15s;
  min-width: 160px;
}

.btn-primary:hover {
  background: #334155;
}

/* ========== Drop Zone ========== */
.drop-zone {
  position: relative;
  border: 2px dashed #cbd5e1;
  border-radius: 8px;
  transition: border-color 0.2s, background 0.2s;
}

.drop-zone.dragover {
  border-color: #3b82f6;
  background: #eff6ff;
}

.drop-hint {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.8rem;
  color: #94a3b8;
  pointer-events: none;
  white-space: nowrap;
  z-index: 0;
}

.drop-zone:focus-within .drop-hint,
.drop-zone .json-textarea:not(:placeholder-shown) ~ .drop-hint {
  display: none;
}

/* ========== Textarea ========== */
.json-textarea {
  width: 100%;
  min-height: 260px;
  padding: 0.75rem;
  font-family: "Consolas", "Menlo", "Monaco", "Courier New", monospace;
  font-size: 0.85rem;
  line-height: 1.6;
  border: none;
  border-radius: 6px;
  background: transparent;
  resize: vertical;
  outline: none;
  color: #1e293b;
  position: relative;
  z-index: 1;
}

.json-textarea--half {
  min-height: 140px;
}

.json-textarea[readonly] {
  background: #f8fafc;
  cursor: default;
  border: 1px solid #e2e8f0;
}

/* ========== Status Bar ========== */
.status-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  border-top: 1px solid #e2e8f0;
  min-height: 36px;
}

.status-icon {
  font-size: 1rem;
  line-height: 1;
}

.status-bar.ok {
  color: #16a34a;
}

.status-bar.error {
  color: #dc2626;
}

.status-bar.neutral {
  color: #64748b;
}

.char-count {
  margin-left: auto;
  color: #94a3b8;
  font-size: 0.75rem;
}

/* ========== Tree View ========== */
.tree-view {
  padding: 0.5rem;
  min-height: 260px;
  overflow-x: auto;
}

.tree-node {
  font-family: "Consolas", "Menlo", "Monaco", "Courier New", monospace;
  font-size: 0.83rem;
  line-height: 1.7;
}

.tree-node ul {
  list-style: none;
  padding-left: 1.25rem;
  border-left: 1px dashed #e2e8f0;
  margin-left: 0.25rem;
}

.tree-toggle {
  cursor: pointer;
  user-select: none;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

.tree-toggle::before {
  content: "▼";
  font-size: 0.6rem;
  transition: transform 0.15s;
  display: inline-block;
}

.tree-toggle.collapsed::before {
  transform: rotate(-90deg);
}

.tree-key {
  color: #9333ea;
}

.tree-string {
  color: #16a34a;
}

.tree-number {
  color: #2563eb;
}

.tree-boolean {
  color: #d97706;
  font-weight: 600;
}

.tree-null {
  color: #94a3b8;
  font-style: italic;
}

.tree-type-badge {
  font-size: 0.7rem;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  margin-left: 0.25rem;
  vertical-align: middle;
}

.badge-object {
  background: #ede9fe;
  color: #7c3aed;
}

.badge-array {
  background: #dbeafe;
  color: #1d4ed8;
}

.placeholder-text {
  color: #94a3b8;
  font-size: 0.85rem;
  text-align: center;
  padding: 2rem 0;
}

/* ========== Section Desc ========== */
.section-desc {
  font-size: 0.875rem;
  color: #64748b;
  margin-bottom: 0.75rem;
}

/* ========== Field Label ========== */
.field-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 0.25rem;
  margin-top: 0.75rem;
}

/* ========== Validate Result ========== */
.validate-result {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
}

.validate-result.pass {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #bbf7d0;
}

.validate-result.fail {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.validate-result ul {
  margin-top: 0.5rem;
  padding-left: 1.25rem;
  font-weight: 400;
}

.validate-result li {
  margin-bottom: 0.3rem;
}

/* ========== Convert ========== */
.convert-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.convert-output-header {
  margin-top: 0.75rem;
}

.error-msg {
  margin-top: 0.5rem;
  padding: 0.75rem;
  background: #fee2e2;
  color: #b91c1c;
  border-radius: 6px;
  font-size: 0.85rem;
}

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

.howto-section h2 {
  font-size: 1rem;
  font-weight: 700;
  color: #1e293b;
  margin-top: 1.25rem;
  margin-bottom: 0.6rem;
}

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

.howto-list {
  padding-left: 1.5rem;
  font-size: 0.9rem;
  color: #475569;
}

.howto-list li {
  margin-bottom: 0.5rem;
}

.howto-section p {
  font-size: 0.9rem;
  color: #475569;
  line-height: 1.75;
}

/* ========== FAQ ========== */
.faq-list {
  font-size: 0.9rem;
}

.faq-list dt {
  font-weight: 700;
  color: #1e293b;
  margin-top: 1rem;
}

.faq-list dd {
  color: #475569;
  margin-left: 0;
  margin-top: 0.25rem;
}

.faq-list code {
  font-family: "Consolas", "Menlo", monospace;
  font-size: 0.8rem;
  background: #f1f5f9;
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
}

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

footer a {
  color: #64748b;
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

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

  main {
    padding: 1.5rem 2rem;
  }

  .json-textarea {
    min-height: 320px;
  }

  .tab-btn {
    flex: 1 1 auto;
  }
}

@media (min-width: 960px) {
  header h1 {
    font-size: 1.5rem;
  }
}
