/* ============================================
   CSV Rescue - Global Stylesheet
   Design: Clean × Trustworthy × Japanese-Friendly
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* --- CSS Variables --- */
:root {
  /* Brand Colors */
  --teal-50: #f0fdfa;
  --teal-100: #ccfbf1;
  --teal-200: #99f6e4;
  --teal-300: #5eead4;
  --teal-400: #2dd4bf;
  --teal-500: #14b8a6;
  --teal-600: #0d9488;
  --teal-700: #0f766e;
  --teal-800: #115e59;
  --teal-900: #134e4a;

  /* Neutrals */
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;

  /* Semantic */
  --primary: var(--teal-600);
  --primary-hover: var(--teal-700);
  --primary-light: var(--teal-50);
  --primary-border: var(--teal-200);
  --bg: #ffffff;
  --bg-alt: var(--gray-50);
  --text: var(--gray-800);
  --text-secondary: var(--gray-500);
  --text-tertiary: var(--gray-400);
  --border: var(--gray-200);
  --success: #059669;
  --success-bg: #ecfdf5;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --error: #dc2626;
  --error-bg: #fef2f2;

  /* Typography */
  --font-sans: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Consolas', monospace;

  /* Spacing */
  --nav-height: 60px;
  --max-width: 960px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.08), 0 8px 10px -6px rgba(0,0,0,0.04);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg);
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img, svg { display: block; max-width: 100%; }
a { color: var(--primary); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--primary-hover); }

/* --- Navigation --- */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  height: var(--nav-height);
}

.nav-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--gray-800);
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}

.nav-logo svg { flex-shrink: 0; }

.nav-logo:hover { color: var(--primary); }

.nav-links {
  display: flex;
  align-items: center;
  gap: 2px;
  list-style: none;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

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

.nav-links a {
  display: block;
  padding: 6px 10px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--gray-600);
  border-radius: var(--radius-sm);
  white-space: nowrap;
  transition: all 0.2s;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--primary);
  background: var(--primary-light);
}

/* Mobile nav toggle */
.nav-toggle { display: none; }

@media (max-width: 1024px) {
  .nav-links {
    position: fixed;
    top: var(--nav-height);
    left: 0;
    right: 0;
    background: white;
    flex-direction: column;
    padding: 12px;
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    transform: translateY(-120%);
    transition: transform 0.3s ease;
    z-index: 99;
    max-height: calc(100vh - var(--nav-height));
    overflow-y: auto;
  }
  .nav-links.open { transform: translateY(0); }
  .nav-links a { padding: 12px 16px; font-size: 0.95rem; }
  .nav-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    background: none;
    cursor: pointer;
    color: var(--gray-600);
  }
}

/* --- Main Content --- */
.main {
  flex: 1;
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

/* --- Hero Section --- */
.hero {
  text-align: center;
  padding: 48px 0 32px;
}

.hero h1 {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.4;
  color: var(--gray-900);
  margin-bottom: 12px;
}

.hero p {
  font-size: 1rem;
  color: var(--text-secondary);
  max-width: 520px;
  margin: 0 auto;
}

@media (max-width: 768px) {
  .hero { padding: 32px 0 24px; }
  .hero h1 { font-size: 1.35rem; }
}

@media (max-width: 1024px) {
  .landing-hero h1 { font-size: 1.6rem; }
}

/* --- Drop Zone --- */
.drop-zone {
  position: relative;
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius-xl);
  padding: 56px 32px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  background: var(--bg);
  margin-bottom: 16px;
}

.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--primary);
  background: var(--teal-50);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.drop-zone.dragover {
  border-style: solid;
  box-shadow: 0 0 0 4px rgba(13, 148, 136, 0.1);
}

.drop-zone-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  color: var(--gray-400);
  transition: color 0.3s;
}

.drop-zone:hover .drop-zone-icon,
.drop-zone.dragover .drop-zone-icon {
  color: var(--primary);
}

.drop-zone-text {
  font-size: 1rem;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 4px;
}

.drop-zone-sub {
  font-size: 0.85rem;
  color: var(--text-tertiary);
}

.drop-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

/* --- Security Badge --- */
.security-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--success-bg);
  color: var(--success);
  font-size: 0.8rem;
  font-weight: 500;
  border-radius: 100px;
  margin: 0 auto 32px;
}

.security-badge svg { width: 14px; height: 14px; flex-shrink: 0; }

/* --- Tool Panel --- */
.tool-panel {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 24px;
  animation: slideUp 0.4s ease;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.tool-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 8px;
}

.tool-panel-header .file-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--gray-700);
}

.tool-panel-header .file-info svg {
  width: 18px;
  height: 18px;
  color: var(--primary);
}

.tool-panel-header .file-size {
  font-size: 0.8rem;
  color: var(--text-tertiary);
  font-weight: 400;
}

.tool-panel-header .reset-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--gray-500);
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
}

.tool-panel-header .reset-btn:hover {
  color: var(--error);
  border-color: var(--error);
}

/* --- Encoding Selector --- */
.encoding-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.encoding-bar label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--gray-600);
  white-space: nowrap;
}

.encoding-detected {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: var(--teal-100);
  color: var(--teal-800);
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 100px;
  font-family: var(--font-mono);
}

.encoding-arrow {
  color: var(--gray-400);
  font-size: 1.1rem;
}

.encoding-select {
  padding: 6px 12px;
  font-size: 0.85rem;
  font-family: var(--font-mono);
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: white;
  color: var(--gray-700);
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s;
}

.encoding-select:focus { border-color: var(--primary); }

/* --- Preview Table --- */
.preview-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.preview-table th {
  background: var(--bg-alt);
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--gray-600);
  text-align: left;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
}

.preview-table td {
  padding: 8px 16px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
  white-space: nowrap;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.preview-table tr:hover td { background: var(--teal-50); }

.preview-label {
  padding: 8px 20px;
  font-size: 0.75rem;
  color: var(--text-tertiary);
  border-top: 1px solid var(--border);
  background: var(--bg-alt);
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 28px;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn svg { width: 18px; height: 18px; }

.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 2px 8px rgba(13, 148, 136, 0.25);
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(13, 148, 136, 0.35);
}

.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: white;
  color: var(--gray-700);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-alt);
  border-color: var(--gray-300);
}

.btn-block {
  width: 100%;
  padding: 14px 28px;
}

.download-area {
  padding: 20px;
  text-align: center;
}

/* --- Related Tools --- */
.related-tools {
  margin: 40px 0 32px;
}

.related-tools h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 16px;
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.related-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--gray-700);
  transition: all 0.2s;
}

.related-card:hover {
  border-color: var(--primary-border);
  background: var(--primary-light);
  color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.related-card-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-alt);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  font-size: 1.1rem;
}

.related-card:hover .related-card-icon { background: white; }

.related-card-text {
  font-size: 0.85rem;
  font-weight: 500;
}

/* --- SEO Content Section --- */
.seo-section, .seo-content {
  margin: 48px 0 32px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
}

.seo-section h2, .seo-content h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--gray-800);
  margin-bottom: 16px;
}

.seo-section h3, .seo-content h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-700);
  margin: 24px 0 8px;
}

.seo-section p, .seo-content p {
  font-size: 0.9rem;
  color: var(--gray-600);
  line-height: 1.8;
  margin-bottom: 12px;
}

/* --- FAQ --- */
.faq { margin: 40px 0; }

.faq h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--gray-800);
  margin-bottom: 16px;
}

.faq-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  overflow: hidden;
}

.faq-q {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--gray-700);
  background: white;
  border: none;
  cursor: pointer;
  text-align: left;
  transition: background 0.2s;
}

.faq-q:hover { background: var(--bg-alt); }

.faq-q svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--gray-400);
  transition: transform 0.3s;
}

.faq-item.open .faq-q svg { transform: rotate(180deg); }

.faq-a {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.faq-item.open .faq-a { max-height: 500px; }

.faq-a-inner {
  padding: 0 20px 16px;
  font-size: 0.85rem;
  color: var(--gray-600);
  line-height: 1.8;
}

/* --- Footer --- */
.footer {
  margin-top: auto;
  padding: 32px 24px;
  border-top: 1px solid var(--border);
  text-align: center;
}

.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
}

.footer p {
  font-size: 0.8rem;
  color: var(--text-tertiary);
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 8px;
}

.footer-links a {
  font-size: 0.8rem;
  color: var(--text-tertiary);
}

.footer-links a:hover { color: var(--primary); }

/* --- Landing Page Specific --- */
.landing-hero {
  text-align: center;
  padding: 64px 0 48px;
}

.landing-hero h1 {
  font-size: 2.2rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--gray-900);
  margin-bottom: 16px;
  letter-spacing: -0.02em;
}

.landing-hero h1 span { color: var(--primary); }

.landing-hero p {
  font-size: 1.1rem;
  color: var(--text-secondary);
  max-width: 540px;
  margin: 0 auto 8px;
}

.landing-badges {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 24px;
  flex-wrap: wrap;
}

.landing-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 0.8rem;
  font-weight: 500;
  border-radius: 100px;
  border: 1px solid var(--border);
  color: var(--gray-600);
}

.landing-badge svg { width: 14px; height: 14px; }

.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin: 40px 0 64px;
}

.tool-card {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: var(--text);
  transition: all 0.25s ease;
}

.tool-card:hover {
  border-color: var(--primary-border);
  background: var(--primary-light);
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.tool-card-icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-alt);
  border-radius: var(--radius-md);
  font-size: 1.3rem;
  flex-shrink: 0;
  transition: background 0.2s;
}

.tool-card:hover .tool-card-icon { background: white; }

.tool-card-body h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--gray-800);
  margin-bottom: 4px;
}

.tool-card-body p {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.tool-card .coming-soon {
  font-size: 0.7rem;
  padding: 2px 8px;
  background: var(--warning-bg);
  color: var(--warning);
  border-radius: 100px;
  font-weight: 600;
}

/* --- Notification Toast --- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  padding: 12px 24px;
  background: var(--gray-800);
  color: white;
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 200;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* --- Options Row --- */
.options-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.option-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.option-group label {
  font-size: 0.8rem;
  color: var(--gray-500);
  white-space: nowrap;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--gray-600);
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

/* --- Utilities --- */
.text-center { text-align: center; }
.mt-4 { margin-top: 16px; }
.mt-8 { margin-top: 32px; }
.mb-4 { margin-bottom: 16px; }
.mb-8 { margin-bottom: 32px; }
.hidden { display: none !important; }

/* --- Merge specific --- */
.file-list {
  padding: 16px 20px;
}

.file-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--bg-alt);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  font-size: 0.85rem;
  animation: slideUp 0.3s ease;
}

.file-list-item .file-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  color: var(--gray-700);
}

.file-list-item .remove-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--gray-400);
  cursor: pointer;
  border-radius: 50%;
  transition: all 0.2s;
}

.file-list-item .remove-btn:hover {
  background: var(--error-bg);
  color: var(--error);
}

/* --- Related Tools Section --- */
.related-tools {
  margin: 48px 0 32px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
}

.related-tools .related-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--gray-800);
  margin-bottom: 16px;
}

.related-tools .tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

/* --- Blog Cards --- */
.blog-grid {
  display: grid;
  gap: 16px;
  max-width: 720px;
  margin: 0 auto;
}

.blog-card {
  display: block;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: var(--text);
  transition: all 0.25s ease;
}

.blog-card:hover {
  border-color: var(--primary-border);
  background: var(--primary-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.blog-card:hover h2 { color: var(--primary); }

.blog-card h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-800);
  margin-bottom: 8px;
  line-height: 1.5;
}

.blog-card p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 8px;
}

.blog-card .meta {
  font-size: 0.78rem;
  color: var(--text-tertiary);
}

/* --- Ad Placeholder --- */
.ad-slot {
  padding: 24px;
  text-align: center;
  background: var(--bg-alt);
  border-radius: var(--radius-md);
  margin: 24px 0;
  font-size: 0.75rem;
  color: var(--text-tertiary);
  border: 1px dashed var(--border);
  min-height: 100px;
  display: none; /* AdSense承認前は非表示 */
  align-items: center;
  justify-content: center;
}

/* --- Loading Overlay --- */
.drop-zone.loading {
  pointer-events: none;
  border-color: var(--primary);
  background: var(--primary-light);
}
.drop-zone.loading .drop-zone-text::after {
  content: '';
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid var(--primary);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-left: 8px;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

.btn.loading {
  pointer-events: none;
  opacity: 0.6;
  position: relative;
}

/* --- Focus Visible --- */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
