/* ============================================
   KEISAN.WORLD - MODERN CALCULATOR STYLES
   Compact Hero, Mobile-First, Fast Loading
   ============================================ */

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

:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #818cf8;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #06b6d4;
  --bg: #fafbfc;
  --card: #ffffff;
  --text: #0f172a;
  --text-secondary: #475569;
  --text-light: #64748b;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --shadow-xs: 0 1px 2px rgba(0,0,0,.04);
  --shadow-sm: 0 2px 8px rgba(0,0,0,.06);
  --shadow-md: 0 4px 16px rgba(0,0,0,.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.12);
  --gradient-primary: linear-gradient(135deg, #6366f1, #8b5cf6);
  --gradient-hero: linear-gradient(135deg, #1e293b 0%, #334155 100%);
}

::selection { background: var(--primary-light); color: #fff; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans JP', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 20px;
}

@media (max-width: 768px) {
  .container { padding: 0 16px; }
}

a { color: inherit; text-decoration: none; transition: all .2s; }
ul { list-style: none; }
img { max-width: 100%; height: auto; display: block; }
button { font-family: inherit; }

/* ============================================
   HEADER - Compact & Sticky
   ============================================ */
.header {
  background: rgba(255,255,255,.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: var(--shadow-xs);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 18px;
  color: var(--text);
}

.logo svg {
  width: 24px;
  height: 24px;
  stroke: var(--primary);
}

.nav {
  display: flex;
  gap: 24px;
  align-items: center;
}

.nav a {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: all .2s;
}

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

@media (max-width: 768px) {
  .nav { display: none; }
  .header-inner { height: 52px; }
}

/* ============================================
   HERO - Compact Version
   ============================================ */
.hero {
  background: var(--gradient-hero);
  color: #fff;
  padding: 40px 0 48px;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -10%;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(99,102,241,.15), transparent 70%);
  border-radius: 50%;
}

.hero-content {
  max-width: 800px;
  margin: 0 auto;
  text-align: center;
  position: relative;
  z-index: 1;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.2);
  padding: 6px 14px;
  border-radius: 100px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 16px;
}

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

.hero-title {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 900;
  line-height: 1.2;
  margin-bottom: 12px;
  letter-spacing: -.02em;
}

.hero-subtitle {
  font-size: clamp(14px, 2vw, 16px);
  opacity: .9;
  margin-bottom: 24px;
  font-weight: 400;
  color: rgba(255,255,255,.9);
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

.hero-buttons {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 700;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  transition: all .3s;
  white-space: nowrap;
}

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

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(99,102,241,.3);
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(99,102,241,.4);
}

.btn-secondary {
  background: rgba(255,255,255,.1);
  color: #fff;
  border: 2px solid rgba(255,255,255,.2);
}

.btn-secondary:hover {
  background: rgba(255,255,255,.15);
  border-color: rgba(255,255,255,.3);
}

.hero-stats {
  display: flex;
  justify-content: center;
  gap: 40px;
  flex-wrap: wrap;
}

.hero-stat {
  text-align: center;
}

.hero-stat-value {
  display: block;
  font-size: 28px;
  font-weight: 900;
  margin-bottom: 2px;
}

.hero-stat-label {
  font-size: 12px;
  opacity: .8;
}

@media (max-width: 768px) {
  .hero { padding: 32px 0 40px; }
  .hero-buttons { flex-direction: column; align-items: stretch; }
  .btn { width: 100%; max-width: 260px; margin: 0 auto; }
  .hero-stats { gap: 24px; }
  .hero-stat-value { font-size: 24px; }
}

/* ============================================
   TOOLS GRID
   ============================================ */
.tools-section {
  padding: 56px 0;
}

.section-header {
  text-align: center;
  margin-bottom: 40px;
}

.section-title {
  font-size: clamp(24px, 4vw, 32px);
  font-weight: 900;
  margin-bottom: 10px;
  color: var(--text);
  letter-spacing: -.02em;
}

.section-subtitle {
  color: var(--text-secondary);
  font-size: 15px;
}

.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}

@media (max-width: 768px) {
  .tools-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
}

@media (max-width: 400px) {
  .tools-grid {
    grid-template-columns: 1fr;
  }
}

.tool-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 16px;
  text-align: center;
  transition: all .3s;
  position: relative;
  cursor: pointer;
}

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

.tool-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  font-size: 24px;
  transition: transform .3s;
}

.tool-card:hover .tool-icon {
  transform: scale(1.1);
}

.tool-icon svg {
  width: 24px;
  height: 24px;
}

.tool-icon.blue { background: linear-gradient(135deg, #dbeafe, #bfdbfe); }
.tool-icon.green { background: linear-gradient(135deg, #dcfce7, #bbf7d0); }
.tool-icon.purple { background: linear-gradient(135deg, #f3e8ff, #e9d5ff); }
.tool-icon.orange { background: linear-gradient(135deg, #ffedd5, #fed7aa); }
.tool-icon.pink { background: linear-gradient(135deg, #fce7f3, #fbcfe8); }
.tool-icon.cyan { background: linear-gradient(135deg, #cffafe, #a5f3fc); }
.tool-icon.yellow { background: linear-gradient(135deg, #fef9c3, #fef08a); }
.tool-icon.red { background: linear-gradient(135deg, #fee2e2, #fecaca); }

.tool-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--success);
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 100px;
  text-transform: uppercase;
  letter-spacing: .5px;
}

.tool-card h3 {
  font-size: 14px;
  font-weight: 800;
  margin-bottom: 6px;
  color: var(--text);
}

.tool-card p {
  font-size: 12px;
  color: var(--text-light);
  margin-bottom: 10px;
  line-height: 1.5;
}

.tool-link {
  font-size: 12px;
  color: var(--primary);
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.tool-link svg {
  width: 12px;
  height: 12px;
}

/* ============================================
   FEATURES
   ============================================ */
.features-section {
  padding: 56px 0;
  background: var(--card);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 32px;
}

@media (max-width: 768px) {
  .features-grid {
    grid-template-columns: 1fr;
    gap: 24px;
  }
}

.feature-card {
  text-align: center;
  padding: 20px;
}

.feature-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  background: var(--gradient-primary);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 24px;
}

.feature-card h3 {
  font-size: 16px;
  font-weight: 800;
  margin-bottom: 10px;
}

.feature-card p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.7;
}

/* ============================================
   CALCULATOR PAGE - COMPACT HERO
   ============================================ */
.calc-page {
  background: var(--bg);
  min-height: 100vh;
}

.calc-hero {
  background: var(--gradient-hero);
  color: #fff;
  padding: 28px 0;
  position: relative;
  overflow: hidden;
}

.calc-hero.compact {
  padding: 20px 0 24px;
}

.calc-hero::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(99,102,241,.15), transparent 70%);
  border-radius: 50%;
}

.breadcrumb {
  font-size: 12px;
  color: rgba(255,255,255,.7);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  position: relative;
  z-index: 1;
}

.breadcrumb a {
  color: rgba(255,255,255,.9);
  font-weight: 600;
}

.breadcrumb a:hover {
  color: #fff;
}

.calc-header {
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: 800px;
  position: relative;
  z-index: 1;
}

.calc-icon-large {
  width: 52px;
  height: 52px;
  background: rgba(255,255,255,.15);
  backdrop-filter: blur(10px);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255,255,255,.2);
  flex-shrink: 0;
}

.calc-icon-large svg {
  width: 26px;
  height: 26px;
}

.calc-header-text h1 {
  font-size: clamp(20px, 4vw, 26px);
  font-weight: 900;
  margin-bottom: 4px;
  letter-spacing: -.02em;
}

.calc-subtitle {
  font-size: 13px;
  opacity: .9;
}

@media (max-width: 768px) {
  .calc-hero.compact { padding: 16px 0 20px; }
  .calc-icon-large { width: 44px; height: 44px; }
  .calc-icon-large svg { width: 22px; height: 22px; }
}

/* ============================================
   CALCULATOR BOX
   ============================================ */
.calc-content {
  padding: 32px 0 64px;
}

.calculator-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 24px;
  margin-bottom: 40px;
  box-shadow: var(--shadow-md);
}

@media (max-width: 768px) {
  .calculator-box { padding: 20px 16px; }
}

.calc-notice {
  background: linear-gradient(135deg, #f0f9ff, #e0f2fe);
  border-left: 4px solid var(--info);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text);
}

.calc-notice svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--info);
}

.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text);
}

.form-input, select.form-input {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 16px;
  transition: all .2s;
  background: var(--card);
  font-family: inherit;
  color: var(--text);
}

.form-input:hover {
  border-color: var(--text-light);
}

.form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,.1);
}

.input-with-icon {
  position: relative;
}

.input-with-icon .form-input {
  padding-right: 50px;
}

.input-icon {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 13px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 480px) {
  .form-row {
    grid-template-columns: 1fr;
  }
}

.radio-card {
  display: block;
  cursor: pointer;
}

.radio-card input {
  display: none;
}

.radio-content {
  display: block;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  transition: all .2s;
  background: var(--card);
}

.radio-content:hover {
  border-color: var(--text-light);
}

.radio-card input:checked + .radio-content {
  border-color: var(--primary);
  background: linear-gradient(135deg, #f0f9ff, #e0f2fe);
  color: var(--primary);
}

.time-inputs {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.time-input {
  width: 70px !important;
}

.calc-buttons {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.calc-buttons .btn {
  flex: 1;
}

@media (max-width: 480px) {
  .calc-buttons {
    flex-direction: column;
  }
  .calc-buttons .btn {
    width: 100%;
  }
}

/* ============================================
   RESULT AREA
   ============================================ */
.calc-result {
  margin-top: 28px;
  padding-top: 28px;
  border-top: 2px solid var(--border-light);
  display: none;
}

.calc-result.show {
  display: block;
  animation: slideIn .4s ease-out;
}

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

.result-main {
  background: var(--gradient-primary);
  border-radius: var(--radius-lg);
  padding: 28px;
  text-align: center;
  margin-bottom: 16px;
  color: #fff;
  position: relative;
  overflow: hidden;
}

.result-label {
  font-size: 13px;
  margin-bottom: 6px;
  opacity: .9;
  font-weight: 600;
}

.result-value {
  font-size: clamp(32px, 8vw, 42px);
  font-weight: 900;
  letter-spacing: -.02em;
}

.result-unit {
  font-size: 16px;
  font-weight: 700;
  margin-left: 6px;
  opacity: .9;
}

.result-badge {
  display: inline-block;
  margin-top: 12px;
  padding: 6px 16px;
  background: rgba(255,255,255,.2);
  border-radius: 100px;
  font-size: 14px;
  font-weight: 700;
}

.result-details {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--border);
}

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-light);
}

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

.result-row span:first-child {
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 13px;
}

.result-row span:last-child {
  font-weight: 800;
  color: var(--text);
  font-size: 16px;
}

.result-note {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 12px;
  padding: 10px 14px;
  background: var(--border-light);
  border-radius: var(--radius-sm);
  text-align: center;
}

/* ============================================
   ERROR MESSAGE
   ============================================ */
.error-message {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fee2e2;
  border-left: 4px solid var(--danger);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 13px;
  color: #7f1d1d;
  animation: slideIn .3s ease-out;
}

.error-message svg {
  color: var(--danger);
  flex-shrink: 0;
}

/* ============================================
   FOOTER
   ============================================ */
.footer {
  background: var(--card);
  border-top: 1px solid var(--border);
  padding: 40px 0 20px;
  margin-top: 80px;
}

.footer-content {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 40px;
  margin-bottom: 40px;
}

@media (max-width: 768px) {
  .footer-content {
    grid-template-columns: repeat(2, 1fr);
    gap: 30px;
  }
}

@media (max-width: 480px) {
  .footer-content {
    grid-template-columns: 1fr;
    gap: 24px;
  }
}

.footer-section h4 {
  font-size: 14px;
  font-weight: 800;
  margin-bottom: 16px;
  color: var(--text);
}

.footer-section a {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 10px;
  transition: all .2s;
}

.footer-section a:hover {
  color: var(--primary);
  transform: translateX(2px);
}

.footer-bottom {
  border-top: 1px solid var(--border-light);
  padding-top: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-secondary);
}

@media (max-width: 480px) {
  .footer-bottom {
    flex-direction: column;
    gap: 16px;
    text-align: center;
  }
}

/* ============================================
   CONTENT SECTIONS
   ============================================ */
.content-section {
  margin-bottom: 48px;
}

.content-section h2 {
  font-size: 20px;
  font-weight: 900;
  margin-bottom: 20px;
  color: var(--text);
}

.content-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  line-height: 1.8;
  font-size: 14px;
  box-shadow: var(--shadow-sm);
}

.content-box p {
  margin-bottom: 16px;
  color: var(--text);
}

.content-box p:last-child {
  margin-bottom: 0;
}

.formula-box {
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin: 16px 0;
}

.formula-title {
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--primary);
  font-size: 14px;
}

.formula-content {
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 14px;
  background: var(--card);
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-weight: 600;
  color: var(--text);
}

/* ============================================
   FAQ
   ============================================ */
.faq-list {
  display: grid;
  gap: 10px;
}

.faq-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all .3s;
  box-shadow: var(--shadow-sm);
}

.faq-item:hover {
  box-shadow: var(--shadow-md);
}

.faq-item[open] {
  border-color: var(--primary);
}

.faq-item summary {
  padding: 16px 20px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  list-style: none;
  font-size: 14px;
  color: var(--text);
  user-select: none;
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

.faq-item summary::after {
  content: '▼';
  font-size: 12px;
  transition: transform .3s;
  margin-left: 8px;
}

.faq-item[open] summary::after {
  transform: rotate(180deg);
}

.faq-content {
  padding: 0 20px 16px;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.8;
}

/* ============================================
   SCROLLBAR
   ============================================ */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-light);
}
