/* ============================================
   Finance Calc — Shared Design System
   warikan color scheme
   ============================================ */

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

:root {
  --accent:     #2563eb;
  --accent2:    #1d4ed8;
  --accent3:    #3b82f6;
  --accent-light: rgba(96,165,250,0.15);
  --text:       #1e293b;
  --text-sub:   #475569;
  --text-dim:   #94a3b8;
  --text-muted: #64748b;
  --gold:       #d97706;
  --red:        #dc2626;
  --green:      #219234;
  --radius:     1.25rem;
  --radius-sm:  0.625rem;
  --shadow-card: 0 4px 20px rgba(0,0,0,0.06);
  --shadow-dark: 0 10px 40px rgba(15,23,42,0.25), 0 0 0 1px rgba(96,165,250,0.08), inset 0 1px 0 rgba(255,255,255,0.04);
}

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

html { font-size: 16px; }

body {
  background: linear-gradient(160deg, #dbeafe 0%, #93c5fd 35%, #bfdbfe 65%, #eff6ff 100%);
  background-attachment: fixed;
  color: var(--text);
  font-family: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 400;
  min-height: 100vh;
  min-height: 100dvh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* ── Layout ── */
.page {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 1rem 5rem;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

/* ── Site Header ── */
.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0 4px;
  margin-bottom: 4px;
}

.site-logo {
  font-family: 'Shippori Mincho', serif;
  font-size: 0.8125rem;
  color: rgba(59,130,246,0.85);
  text-decoration: none;
  letter-spacing: 0.1em;
  font-weight: 500;
  transition: color 0.2s;
}
.site-logo:hover { color: var(--accent); }

.page-name {
  font-family: 'Shippori Mincho', serif;
  font-size: 0.8125rem;
  color: rgba(59,130,246,0.7);
  letter-spacing: 0.08em;
  font-weight: 500;
}

/* ── App Header ── */
.app-header {
  margin-bottom: 0.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.app-tag {
  display: inline-flex;
  align-items: center;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 0.65rem;
  color: var(--accent);
  background: rgba(37,99,235,0.08);
  border: 1px solid rgba(37,99,235,0.2);
  border-radius: 4px;
  padding: 3px 8px;
  letter-spacing: 0.08em;
  flex-shrink: 0;
}

.app-title {
  font-family: 'Syne', sans-serif;
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin: 0;
}

.app-desc {
  flex-basis: 100%;
  font-size: 0.875rem;
  color: var(--text-sub);
  font-weight: 300;
  margin: 2px 0 0;
}

/* ── Card (glassmorphic — input area) ── */
.card {
  background: rgba(255,255,255,0.55);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255,255,255,0.65);
  border-radius: var(--radius);
  padding: 1.25rem 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-card);
}

.card-title {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 1rem;
}

/* ── Form Elements ── */
.field { margin-bottom: 1rem; }
.field:last-child { margin-bottom: 0; }

label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-sub);
  margin-bottom: 5px;
  letter-spacing: 0.01em;
}

label .unit {
  font-weight: 400;
  color: var(--text-dim);
  margin-left: 4px;
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-wrap .prefix,
.input-wrap .suffix {
  position: absolute;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 0.85rem;
  color: var(--text-muted);
  pointer-events: none;
}
.input-wrap .prefix { left: 14px; }
.input-wrap .suffix { right: 14px; }

input[type="number"],
input[type="text"],
select {
  width: 100%;
  background: rgba(255,255,255,0.8);
  border: 1px solid rgba(147,197,253,0.5);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 1rem;
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  -moz-appearance: textfield;
  min-height: 48px;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.04);
}
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; }
input::placeholder, textarea::placeholder {
  color: rgba(100, 116, 139, 0.4);
  font-weight: 400;
}

input:focus, select:focus {
  border-color: var(--accent3);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
  background: rgba(255,255,255,0.95);
}

.has-prefix input  { padding-left: 32px; }
.has-suffix input  { padding-right: 36px; }

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

/* Grid layout for fields */
.fields-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media (max-width: 380px) {
  .fields-grid { grid-template-columns: 1fr; }
}

/* ── Button ── */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 15px;
  border: none;
  border-radius: 9999px;
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: all 0.12s ease;
  margin-top: 1.25rem;
  min-height: 52px;
}
.btn:active { transform: scale(0.96); }

.btn-primary {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 50%, #3b82f6 100%);
  color: #fff;
  box-shadow: 0 4px 18px rgba(37,99,235,0.35), inset 0 1px 0 rgba(255,255,255,0.15);
  border: 1px solid rgba(96,165,250,0.25);
}
.btn-primary:hover {
  box-shadow: 0 6px 24px rgba(37,99,235,0.5), inset 0 1px 0 rgba(255,255,255,0.15);
}

/* ── Result Panel (dark navy — like warikan display card) ── */
.result {
  display: none;
  background: linear-gradient(145deg, #0c1929 0%, #152d50 55%, #1e3a5f 100%);
  border: 1px solid rgba(96,165,250,0.15);
  border-radius: var(--radius);
  padding: 1.25rem 1.375rem;
  margin-top: 1rem;
  box-shadow: var(--shadow-dark);
  animation: fadeSlideIn 0.3s ease;
}
.result.visible { display: block; }

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

.result-main {
  margin-bottom: 1.25rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid rgba(96,165,250,0.15);
}

.result-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: rgba(148,163,184,0.9);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.result-value {
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 2.4rem;
  font-weight: 200;
  color: #ffffff;
  letter-spacing: 0.08em;
  line-height: 1;
}

.result-unit {
  font-size: 1rem;
  font-weight: 600;
  color: rgba(96,165,250,0.7);
  margin-left: 6px;
}

/* Result breakdown rows */
.result-rows { display: flex; flex-direction: column; gap: 10px; }

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
}

.result-row .rr-label { color: rgba(148,163,184,0.8); }

.result-row .rr-val {
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-weight: 500;
  color: #cbd5e1;
}

.result-row .rr-val.highlight { color: #60a5fa; }
.result-row .rr-val.gold      { color: #fbbf24; }
.result-row .rr-val.red       { color: #f87171; }
.result-row .rr-val.blue      { color: #93c5fd; }

/* Divider inside result */
.result-divider {
  height: 1px;
  background: rgba(96,165,250,0.12);
  margin: 4px 0;
}

/* ── Error ── */
.error-msg {
  display: none;
  color: #dc2626;
  font-size: 0.82rem;
  margin-top: 8px;
  padding: 10px 14px;
  background: rgba(220,38,38,0.07);
  border: 1px solid rgba(220,38,38,0.2);
  border-radius: var(--radius-sm);
}
.error-msg.visible { display: block; }

/* ── Site Footer ── */
.site-footer {
  margin-top: auto;
  padding-top: 2rem;
  padding-bottom: 1.5rem;
  border-top: 1px solid rgba(147,197,253,0.35);
}

.footer-section {
  margin-bottom: 1.5rem;
}

.footer-heading {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-sub);
  letter-spacing: 0.06em;
  margin-bottom: 0.625rem;
}

.footer-dl {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.footer-dl-row {
  display: flex;
  gap: 10px;
  font-size: 0.75rem;
}

.footer-dl dt {
  font-weight: 600;
  color: var(--text-sub);
  min-width: 5.5rem;
  flex-shrink: 0;
}

.footer-dl dd { color: var(--text-muted); }

.footer-dl a {
  color: var(--accent);
  text-decoration: none;
}
.footer-dl a:hover { color: var(--accent2); text-decoration: underline; }

.footer-sns-official {
  margin-bottom: 1rem;
}
.sns-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.sns-link-official {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  font-size: 0.75rem;
  font-weight: 500;
  background: rgba(255,255,255,0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(147,197,253,0.4);
  border-radius: 9999px;
  color: var(--text-sub);
  text-decoration: none;
  transition: all 0.15s;
  font-family: 'Noto Sans JP', sans-serif;
}
.sns-link-official:hover {
  background: rgba(255,255,255,0.8);
  border-color: var(--accent3);
  color: var(--accent);
}

.share-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.share-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 12px;
  font-size: 0.7rem;
  font-weight: 500;
  background: rgba(255,255,255,0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(147,197,253,0.4);
  border-radius: 9999px;
  color: var(--text-sub);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s;
  font-family: 'Noto Sans JP', sans-serif;
}
.share-pill:hover {
  background: rgba(255,255,255,0.8);
  border-color: var(--accent3);
  color: var(--accent);
}
.share-pill svg {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

.footer-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.75;
  margin-bottom: 0.5rem;
}
.footer-text:last-child { margin-bottom: 0; }

.footer-updated {
  text-align: center;
  font-size: 0.63rem;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.footer-copyright {
  text-align: center;
  padding-top: 0.75rem;
  font-size: 0.63rem;
  color: var(--text-dim);
  letter-spacing: 0.04em;
}

/* ── Content Sections (SEO/LLMO) ── */
.content-section {
  margin-top: 1.5rem;
  background: rgba(255,255,255,0.78);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.65);
  border-radius: var(--radius);
  padding: 1.25rem 1.25rem;
  box-shadow: 0 4px 20px rgba(0,0,0,0.04);
}

.content-section h2 {
  font-family: 'Syne', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.875rem;
  padding-bottom: 0.625rem;
  border-bottom: 1px solid rgba(147,197,253,0.3);
}

.content-section p {
  font-size: 0.85rem;
  color: var(--text-sub);
  line-height: 1.8;
  margin-bottom: 0.625rem;
}
.content-section p:last-child { margin-bottom: 0; }

/* Formula box */
.formula-box {
  background: rgba(37,99,235,0.06);
  border: 1px solid rgba(37,99,235,0.15);
  border-radius: var(--radius-sm);
  padding: 0.875rem 1rem;
  margin: 0.75rem 0;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 0.85rem;
  color: var(--text);
  line-height: 1.6;
}
.formula-box .formula-label {
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 0.375rem;
}

/* Example table */
.example-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  margin-top: 0.75rem;
}
.example-table th {
  background: rgba(37,99,235,0.08);
  color: var(--text-sub);
  font-weight: 600;
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid rgba(147,197,253,0.3);
}
.example-table td {
  padding: 8px 10px;
  color: var(--text-sub);
  border-bottom: 1px solid rgba(147,197,253,0.15);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
.example-table tr:last-child td { border-bottom: none; }
.example-table td.em { color: var(--accent); font-weight: 600; }

/* How-to list */
.howto-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  margin-top: 0.25rem;
}
.howto-list li {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  font-size: 0.85rem;
  color: var(--text-sub);
  line-height: 1.6;
}
.howto-list li .step-num {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 0.65rem;
  font-weight: 700;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

/* FAQ accordion */
.faq-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-top: 0.25rem;
}
.faq-item {
  border-bottom: 1px solid rgba(147,197,253,0.2);
}
.faq-item:last-child { border-bottom: none; }
.faq-question {
  width: 100%;
  background: none;
  border: none;
  text-align: left;
  padding: 0.75rem 0;
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}
.faq-question .faq-icon {
  font-size: 1.1rem;
  color: var(--accent);
  line-height: 1;
  flex-shrink: 0;
  transition: transform 0.2s;
}
.faq-item.open .faq-icon { transform: rotate(45deg); }
.faq-answer {
  display: none;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.75;
  padding-bottom: 0.875rem;
}
.faq-item.open .faq-answer { display: block; }
