/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html { font-size: 16px; }
body {
    font-family: 'Noto Sans JP', system-ui, -apple-system, Segoe UI, Roboto, 'Helvetica Neue', Arial, 'Hiragino Kaku Gothic ProN', Meiryo, sans-serif;
    line-height: 1.7;
    color: #1b1b1b;
    background: #f5f6f7;
    min-height: 100vh;
    padding: 24px 0;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.1);
    overflow: hidden;
}

/* Header */
header {
    background: #fff;
    color: #111827;
    padding: 20px 24px;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
}

header h1 {
    font-size: 1.75rem;
    margin-bottom: 4px;
    font-weight: 700;
}

header p {
    font-size: 0.95rem;
    color: #4b5563;
}

/* Form sections */
.form-section {
    padding: 30px;
    border-bottom: 1px solid #eee;
}

.form-section:last-of-type {
    border-bottom: none;
}

.form-section h2 {
    color: #111827;
    margin-bottom: 16px;
    font-size: 1.25rem;
    font-weight: 700;
}

.subsection h3 {
    color: #34495e;
    margin: 20px 0 15px 0;
    font-size: 1.2rem;
    font-weight: 500;
}

.h3-sub {
    font-size: 0.85em;
    font-weight: 400;
    color: #6b7280;
}

.h3-help {
    font-size: 0.75rem;
    font-weight: normal;
    color: #9ca3af;
    margin-left: 8px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

/* Form groups */
.form-group {
    margin-bottom: 20px;
}

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

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

label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #111827;
}

.required {
    color: #e74c3c;
    font-weight: bold;
}

input[type="text"],
input[type="email"],
input[type="number"],
input[type="file"] {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 16px;
    transition: border-color .2s ease, box-shadow .2s ease;
    background: #fff;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="number"]:focus,
input[type="file"]:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.25);
}

input[type="file"] {
    padding: 10px;
    background: #fff;
    border: 1px dashed #d1d5db;
}

input[type="file"]:hover {
    border-color: #3498db;
    background: #f8f9fa;
}

small {
    display: block;
    margin-top: 5px;
    color: #6b7280;
    font-size: 0.9rem;
}

/* Buttons */
.form-actions {
    padding: 30px;
    display: flex;
    gap: 15px;
    justify-content: flex-end;
    background: #f8f9fa;
}

.btn {
    padding: 12px 30px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background: #2563eb;
    color: #fff;
}

.btn-primary:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(29,78,216,.25);
}

.btn-secondary {
    background: #6b7280;
    color: #fff;
}

.btn-secondary:hover {
    background: #4b5563;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(75,85,99,.25);
}

/* Loading animation */
.loading {
    text-align: center;
    padding: 40px;
}

.loading.hidden {
    display: none;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Result display */
.result {
    padding: 30px;
    background: #f8f9fa;
    border-top: 1px solid #eee;
}

.result.hidden {
    display: none;
}

.result.success {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
    border-radius: 8px;
}

.result.error {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
    border-radius: 8px;
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        margin: 10px;
        border-radius: 10px;
    }
    
    header {
        padding: 20px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .form-section {
        padding: 20px;
    }
    
    .form-actions {
        padding: 20px;
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
        text-align: center;
    }
}

/* Form validation styles */
input:invalid {
    border-color: #dc2626;
}

input:invalid:focus {
    box-shadow: 0 0 0 3px rgba(220,38,38,0.15);
}

/* Skip link */
.skip-link {
  position: absolute;
  left: -999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
.skip-link:focus {
  position: static;
  width: auto;
  height: auto;
  padding: 8px 12px;
  background: #111827;
  color: #fff;
}

/* Mineral hydrophobicity table format */
.mineral-table-container {
  margin-bottom: 16px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  overflow: hidden;
}

.mineral-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
}

.mineral-table th {
  background: #f8fafc;
  padding: 12px 8px;
  text-align: left;
  font-weight: 600;
  font-size: 0.9rem;
  color: #374151;
  border-bottom: 1px solid #e5e7eb;
}

.mineral-table th:nth-child(3) {
  text-align: center;
}


.mineral-table td {
  padding: 8px;
  border-bottom: 1px solid #f3f4f6;
  vertical-align: middle;
}

.mineral-table td:nth-child(3) {
  text-align: center;
}

.mineral-table tr:last-child td {
  border-bottom: none;
}

.mineral-table input[type="text"],
.mineral-table input[type="number"] {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 14px;
  background: white;
}

.mineral-table input[type="text"]:focus,
.mineral-table input[type="number"]:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}


.btn-remove-mineral {
  background: #dc2626;
  color: white;
  border: none;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  transition: background-color 0.2s ease;
  min-width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-remove-mineral:hover {
  background: #b91c1c;
}

#addMineralBtn {
  margin-top: 8px;
}

/* フリーテキスト欄のスタイル */
textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 16px;
  font-family: inherit;
  line-height: 1.5;
  resize: vertical;
  min-height: 120px;
  background: white;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

textarea:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

textarea::placeholder {
  color: #9ca3af;
}

/* File upload styling */
input[type="file"]::-webkit-file-upload-button {
    background: #3498db;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    margin-right: 10px;
}

input[type="file"]::-webkit-file-upload-button:hover {
    background: #2980b9;
}

/* Hover effects */
.form-section:hover {
    background: #fafbfc;
}

.form-group:hover label {
    color: #3498db;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal-overlay.hidden { display: none; }
.modal {
    background: #fff;
    width: min(720px, 92vw);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    padding: 24px;
}
.modal h3 {
    margin-bottom: 12px;
    color: #2c3e50;
}
.confirm-content { max-height: 50vh; overflow: auto; margin: 8px 0 16px; }
.confirm-content dl { display: grid; grid-template-columns: 1fr 2fr; gap: 10px 16px; }
.confirm-content dt { color: #555; }
.confirm-content dd { margin: 0; font-weight: 500; color: #222; }
.modal-actions { display: flex; gap: 12px; justify-content: flex-end; }
