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

:root {
    --primary-color: #0ea5e9;
    --primary-dark: #0284c7;
    --primary-light: #e0f2fe;
    --primary-gradient: linear-gradient(135deg, #0ea5e9 0%, #06b6d4 100%);
    --success-color: #10b981;
    --success-light: #d1fae5;
    --success-gradient: linear-gradient(135deg, #10b981 0%, #059669 100%);
    --warning-color: #f59e0b;
    --warning-light: #fef3c7;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --bg-primary: rgba(255, 255, 255, 0.95);
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --border-color: rgba(226, 232, 240, 0.8);
    --border-focus: rgba(14, 165, 233, 0.4);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 8px 16px rgba(0, 0, 0, 0.08), 0 4px 8px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --shadow-glow: 0 0 20px rgba(14, 165, 233, 0.15);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background: #f8fafc;
    min-height: 100vh;
}

/* Container */
.container {
    max-width: 720px;
    margin: 0 auto;
    padding: 24px 16px;
    position: relative;
    z-index: 1;
}

@media (min-width: 768px) {
    .container {
        padding: 40px 24px;
    }
}

/* Header */
header {
    text-align: center;
    margin-bottom: 32px;
    animation: slideDown 0.6s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

header h1 {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 12px;
    letter-spacing: -0.02em;
}

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

/* Organization Badge */
.organization-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 12px;
}

.badge-from {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 400;
    font-style: italic;
}

.organization-logo {
    height: 28px;
    width: auto;
    object-fit: contain;
    transition: var(--transition);
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.organization-logo:hover {
    transform: scale(1.05);
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.15));
}

@media (min-width: 768px) {
    .organization-logo {
        height: 32px;
    }
}

.subtitle {
    font-size: 0.9375rem;
    color: var(--text-secondary);
    font-weight: 400;
}

/* Form Sections */
.form-section {
    background: var(--bg-primary);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    transition: var(--transition);
    animation: fadeInUp 0.5s ease-out backwards;
}

.form-section:nth-child(1) { animation-delay: 0.1s; }
.form-section:nth-child(2) { animation-delay: 0.2s; }
.form-section:nth-child(3) { animation-delay: 0.3s; }
.form-section:nth-child(4) { animation-delay: 0.4s; }

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

.form-section:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    border-color: var(--primary-color);
}

.form-section h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

/* Info Box */
.info-box {
    background: linear-gradient(135deg, rgba(241, 245, 249, 0.8) 0%, rgba(226, 232, 240, 0.6) 100%);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    margin-bottom: 16px;
    border-left: 3px solid var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.info-box p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Radio Group */
.radio-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

@media (min-width: 480px) {
    .radio-group {
        flex-direction: row;
        gap: 24px;
    }
}

.radio-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    position: relative;
}

.radio-label input[type="radio"] {
    position: absolute;
    opacity: 0;
    cursor: pointer;
}

.radio-custom {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    margin-right: 10px;
    transition: var(--transition);
    position: relative;
}

.radio-label input[type="radio"]:checked + .radio-custom {
    border-color: var(--primary-color);
}

.radio-label input[type="radio"]:checked + .radio-custom::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 10px;
    height: 10px;
    background: var(--primary-color);
    border-radius: 50%;
}

.radio-label input[type="radio"]:focus + .radio-custom {
    box-shadow: 0 0 0 3px var(--border-focus);
}

.radio-text {
    font-size: 0.9375rem;
    color: var(--text-primary);
}

/* Toggle Labels */
.input-type-toggle {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

@media (min-width: 480px) {
    .input-type-toggle {
        flex-direction: row;
        gap: 16px;
    }
}

.toggle-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 10px 16px;
    background: rgba(241, 245, 249, 0.6);
    border-radius: var(--radius-md);
    border: 2px solid transparent;
    transition: var(--transition);
}

.toggle-label:hover {
    background: rgba(226, 232, 240, 0.8);
    transform: translateX(2px);
}

.toggle-label input[type="radio"] {
    margin-right: 8px;
    accent-color: var(--primary-color);
}

.toggle-label input[type="radio"]:checked ~ .toggle-text {
    color: var(--primary-color);
    font-weight: 600;
}

.toggle-label:has(input[type="radio"]:checked) {
    border-color: var(--primary-color);
    background: var(--primary-light);
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.15);
}

.toggle-text {
    font-size: 0.875rem;
    color: var(--text-secondary);
    transition: var(--transition);
}

/* Select Wrapper */
.select-wrapper {
    position: relative;
}

.select-wrapper select {
    width: 100%;
    padding: 14px 40px 14px 16px;
    font-size: 0.9375rem;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid rgba(226, 232, 240, 0.5);
    border-radius: var(--radius-md);
    appearance: none;
    cursor: pointer;
    transition: var(--transition);
}

.select-wrapper select:hover {
    border-color: rgba(14, 165, 233, 0.3);
    background: rgba(255, 255, 255, 1);
}

.select-wrapper select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--border-focus), 0 4px 12px rgba(14, 165, 233, 0.1);
    background: rgba(255, 255, 255, 1);
}

.select-wrapper::after {
    content: '';
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid var(--text-muted);
    pointer-events: none;
}

/* Input Group */
.input-group {
    display: flex;
    align-items: center;
    position: relative;
}

.input-group input {
    flex: 1;
    padding: 14px 16px;
    font-size: 1.125rem;
    font-weight: 500;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid rgba(226, 232, 240, 0.5);
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.input-group input:hover {
    border-color: rgba(14, 165, 233, 0.3);
    background: rgba(255, 255, 255, 1);
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--border-focus), 0 4px 12px rgba(14, 165, 233, 0.1);
    background: rgba(255, 255, 255, 1);
}

.input-group input::placeholder {
    color: var(--text-muted);
    font-weight: 400;
}

.input-suffix {
    margin-left: 12px;
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.input-hint {
    margin-top: 8px;
    font-size: 0.8125rem;
    color: var(--text-muted);
}

/* Error State */
.input-group input.error {
    border-color: #ef4444;
    background: #fef2f2;
}

.input-group input.error:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

.error-message {
    margin-top: 8px;
    font-size: 0.8125rem;
    color: #ef4444;
}

/* Calculate Button */
.calculate-btn {
    width: 100%;
    padding: 16px 24px;
    font-size: 1.0625rem;
    font-weight: 600;
    color: white;
    background: var(--primary-gradient);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    margin-top: 8px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(14, 165, 233, 0.3);
}

.calculate-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.calculate-btn:hover::before {
    left: 100%;
}

.calculate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(14, 165, 233, 0.4);
}

.calculate-btn:active {
    transform: translateY(0);
    box-shadow: 0 4px 15px rgba(14, 165, 233, 0.3);
}

.calculate-btn:focus {
    outline: none;
    box-shadow: 0 4px 15px rgba(14, 165, 233, 0.3), 0 0 0 3px var(--border-focus);
}

/* Result Section */
.result-section {
    background: var(--bg-primary);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-top: 24px;
    box-shadow: var(--shadow-lg), 0 0 30px rgba(14, 165, 233, 0.15);
    border: 1px solid rgba(226, 232, 240, 0.8);
    animation: fadeIn 0.5s ease, glow 2s ease-in-out infinite alternate;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes glow {
    from {
        box-shadow: var(--shadow-lg), 0 0 30px rgba(14, 165, 233, 0.15);
    }
    to {
        box-shadow: var(--shadow-lg), 0 0 40px rgba(14, 165, 233, 0.25);
    }
}

.result-section h2 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.result-cards {
    display: grid;
    gap: 12px;
}

@media (min-width: 480px) {
    .result-cards {
        grid-template-columns: repeat(2, 1fr);
    }
}

.result-card {
    background: linear-gradient(135deg, rgba(241, 245, 249, 0.8) 0%, rgba(226, 232, 240, 0.8) 100%);
    border-radius: var(--radius-md);
    padding: 16px;
    text-align: center;
    transition: var(--transition);
    border: 1px solid rgba(255, 255, 255, 0.5);
    position: relative;
    overflow: hidden;
}

.result-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.3) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.3s;
}

.result-card:hover::before {
    opacity: 1;
}

.result-card:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
}

.result-card.highlight {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
}

.result-card.success {
    background: var(--success-gradient);
}

.result-card.success .result-label,
.result-card.success .result-value {
    color: white;
}

.result-card.primary {
    background: var(--primary-gradient);
}

.result-card.primary .result-label,
.result-card.primary .result-value {
    color: white;
}

@media (min-width: 480px) {
    .result-card.primary {
        grid-column: span 2;
    }
}

.result-label {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.result-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.result-card.success .result-value {
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.result-card.primary .result-value {
    color: white;
    font-size: 1.5rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Calculation Details */
.calculation-details {
    margin-top: 20px;
    padding: 16px;
    background: rgba(248, 250, 252, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: var(--radius-md);
    border: 1px solid rgba(226, 232, 240, 0.5);
    box-shadow: var(--shadow-sm);
}

.calculation-details h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.calculation-details p {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    line-height: 1.6;
}

.calculation-details .formula {
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', monospace;
    background: var(--bg-tertiary);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    color: var(--text-primary);
    margin: 8px 0;
    overflow-x: auto;
}

/* Hidden Class */
.hidden {
    display: none !important;
}

/* Footer */
footer {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

.disclaimer {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 16px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.disclaimer h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--warning-color);
    margin-bottom: 8px;
}

.disclaimer ul {
    list-style: disc;
    padding-left: 20px;
}

.disclaimer li {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
    line-height: 1.5;
}

.copyright {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Icons */
h1 i, h2 i, h3 i {
    margin-right: 8px;
    opacity: 0.9;
}

.result-label i {
    margin-right: 6px;
    opacity: 0.8;
}

.calculate-btn i {
    margin-right: 8px;
}

.subtitle i {
    margin-right: 4px;
    font-size: 0.875rem;
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus visible for keyboard navigation */
:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Print Styles */
@media print {
    body {
        background: white;
    }

    .container {
        max-width: 100%;
    }

    .calculate-btn,
    .form-section {
        break-inside: avoid;
    }

    .result-section {
        border: 2px solid var(--border-color);
    }
}
