/* ===== リセット・ベース ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Segoe UI', 'Hiragino Sans', 'Noto Sans JP', sans-serif;
  background: #f0f2f5;
  color: #1a1a2e;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 24px 16px;
}

/* ===== コンテナ ===== */
.app-container {
  width: 100%;
  max-width: 560px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
  padding: 32px 28px;
  height: fit-content;
}

/* ===== ヘッダー ===== */
.app-header {
  text-align: center;
  margin-bottom: 20px;
}

.app-header h1 {
  font-size: 22px;
  font-weight: 700;
  color: #1a1a2e;
}

.subtitle {
  font-size: 12px;
  color: #6b7280;
  margin-top: 2px;
}

/* ===== タブ ===== */
.tab-nav {
  display: flex;
  gap: 4px;
  background: #f3f4f6;
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 24px;
}

.tab-btn {
  flex: 1;
  padding: 10px;
  border: none;
  border-radius: 8px;
  background: transparent;
  font-size: 14px;
  font-weight: 600;
  color: #6b7280;
  cursor: pointer;
  transition: all 0.2s;
}

.tab-btn.active {
  background: #fff;
  color: #4a6cf7;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.tab-btn:hover:not(.active) {
  color: #374151;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* ===== セクション ===== */
.section {
  margin-bottom: 18px;
}

/* ===== ラベル ===== */
.label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 6px;
}

/* ===== ファイル選択 ===== */
.file-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 16px;
  border: 2px dashed #d1d5db;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.file-label:hover {
  border-color: #4a6cf7;
  background: #f8f9ff;
}

.file-icon {
  font-size: 28px;
  margin-bottom: 8px;
}

.file-text {
  font-size: 14px;
  font-weight: 600;
  color: #374151;
}

.file-hint {
  font-size: 11px;
  color: #9ca3af;
  margin-top: 4px;
}

.selected-file {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: #f0f7ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  font-size: 13px;
  color: #1e40af;
  margin-top: 8px;
}

.clear-btn {
  background: none;
  border: none;
  font-size: 18px;
  color: #6b7280;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.clear-btn:hover {
  color: #ef4444;
}

/* ===== セレクト ===== */
.select {
  width: 100%;
  padding: 10px 36px 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  color: #1a1a2e;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E") no-repeat right 12px center;
  appearance: none;
  cursor: pointer;
  transition: border-color 0.2s;
}

.select:focus {
  outline: none;
  border-color: #4a6cf7;
  box-shadow: 0 0 0 3px rgba(74, 108, 247, 0.1);
}

/* ===== 入力 ===== */
.input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  color: #1a1a2e;
  transition: border-color 0.2s;
}

.input:focus {
  outline: none;
  border-color: #4a6cf7;
  box-shadow: 0 0 0 3px rgba(74, 108, 247, 0.1);
}

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

.input-with-toggle .input {
  padding-right: 42px;
}

.toggle-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
  opacity: 0.6;
}

.toggle-btn:hover {
  opacity: 1;
}

/* ===== ボタン ===== */
.btn-primary {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, #4a6cf7, #6366f1);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(74, 108, 247, 0.3);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  padding: 8px 16px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #fff;
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: #f9fafb;
  border-color: #9ca3af;
}

.btn-small {
  padding: 8px 14px;
  border: none;
  border-radius: 8px;
  background: #4a6cf7;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s;
}

.btn-small:hover {
  background: #3b5de7;
}

/* ===== プログレス ===== */
.progress-area {
  margin-top: 20px;
}

.progress-bar {
  width: 100%;
  height: 6px;
  background: #e5e7eb;
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #4a6cf7, #6366f1);
  border-radius: 3px;
  transition: width 0.3s;
}

.progress-text {
  font-size: 13px;
  color: #6b7280;
  margin-top: 8px;
  text-align: center;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ===== 結果 ===== */
.result-area {
  margin-top: 20px;
  padding: 16px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 12px;
}

.result-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: #166534;
  margin-bottom: 12px;
}

.result-icon {
  font-size: 16px;
}

.result-textarea {
  width: 100%;
  min-height: 200px;
  padding: 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  color: #1a1a2e;
  background: #fff;
  resize: vertical;
  line-height: 1.6;
}

.result-textarea:focus {
  outline: none;
  border-color: #4a6cf7;
}

.result-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

/* ===== エラー ===== */
.error-area {
  margin-top: 20px;
  padding: 16px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 12px;
}

.error-text {
  font-size: 13px;
  color: #991b1b;
  margin-bottom: 12px;
  line-height: 1.5;
}

.error-actions {
  display: flex;
  gap: 8px;
}

/* ===== 設定カード ===== */
.settings-card {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
}

.settings-title {
  font-size: 15px;
  font-weight: 700;
  color: #1a1a2e;
  margin-bottom: 16px;
}

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

.form-group:last-child {
  margin-bottom: 0;
}

.hint {
  font-size: 11px;
  color: #9ca3af;
  margin-top: 6px;
}

.hint a {
  color: #4a6cf7;
  text-decoration: none;
}

.hint a:hover {
  text-decoration: underline;
}

/* ===== カスタムモデル ===== */
.custom-model-input {
  display: flex;
  gap: 8px;
}

.custom-model-input .input {
  flex: 1;
}

.custom-model-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.model-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: #e0e7ff;
  border-radius: 6px;
  font-size: 12px;
  color: #3730a3;
}

.model-tag-remove {
  background: none;
  border: none;
  font-size: 14px;
  color: #6366f1;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.model-tag-remove:hover {
  color: #ef4444;
}

/* ===== フォルダ表示 ===== */
.folder-display {
  padding: 10px 14px;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 13px;
  color: #6b7280;
  margin-bottom: 8px;
  word-break: break-all;
}

.folder-display.active {
  background: #f0f7ff;
  border-color: #bfdbfe;
  color: #1e40af;
}

.folder-actions {
  display: flex;
  gap: 8px;
}

/* ===== 保存成功 ===== */
.save-success {
  text-align: center;
  padding: 10px;
  color: #166534;
  font-size: 13px;
  font-weight: 600;
  margin-top: 12px;
  animation: fadeIn 0.3s;
}

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

/* ===== レスポンシブ ===== */
@media (max-width: 480px) {
  body {
    padding: 12px 8px;
  }

  .app-container {
    padding: 24px 18px;
    border-radius: 12px;
  }

  .app-header h1 {
    font-size: 20px;
  }

  .file-label {
    padding: 20px 12px;
  }

  .result-actions,
  .error-actions,
  .folder-actions {
    flex-wrap: wrap;
  }
}
