/* === リセット === */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* === カスタムプロパティ === */
:root {
  --primary-color: #4F46E5;
  --secondary-color: #10B981;
  --background: #FFFFFF;
  --surface: #F9FAFB;
  --text: #111827;
  --text-secondary: #6B7280;
  --border: #E5E7EB;
  --error: #EF4444;
  --success: #10B981;
}

@media (prefers-color-scheme: dark) {
  :root {
    --background: #111827;
    --surface: #1F2937;
    --text: #F9FAFB;
    --text-secondary: #9CA3AF;
    --border: #374151;
  }
}

/* === 基本スタイル === */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--background);
  color: var(--text);
  line-height: 1.6;
  padding: 0;
  margin: 0;
}

header {
  background-color: var(--primary-color);
  color: white;
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

header h1 {
  font-size: 1.5rem;
}

main {
  max-width: 800px;
  margin: 2rem auto;
  padding: 0 1rem;
}

/* === ボタン === */
button, .button {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s;
}

button.primary-button {
  background-color: var(--primary-color);
  color: white;
}

button.primary-button:hover {
  background-color: #4338CA;
}

button.voice-button {
  background-color: var(--secondary-color);
  color: white;
  font-size: 1.2rem;
}

button.voice-button.recording {
  background-color: var(--error);
  animation: pulse 1.5s infinite;
}

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

/* === フォーム === */
.input-area {
  background-color: var(--surface);
  padding: 2rem;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  margin-top: 2rem;
}

textarea {
  width: 100%;
  padding: 1rem;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  background-color: var(--background);
  color: var(--text);
  resize: vertical;
}

textarea:focus {
  outline: none;
  border-color: var(--primary-color);
}

label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text);
}

/* === 入力方法選択 === */
.input-methods {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.method {
  background-color: var(--surface);
  padding: 1.5rem;
  border-radius: 12px;
  border: 2px solid var(--border);
}

.method h3 {
  margin-bottom: 0.5rem;
  color: var(--primary-color);
}

/* === 結果表示 === */
.success, .error {
  padding: 1.5rem;
  border-radius: 12px;
  margin-top: 1rem;
}

.success {
  background-color: #D1FAE5;
  color: #065F46;
  border: 2px solid var(--success);
}

.error {
  background-color: #FEE2E2;
  color: #991B1B;
  border: 2px solid var(--error);
}

/* === プログレスバー === */
progress {
  width: 100%;
  height: 8px;
  border-radius: 4px;
}

/* === 画像生成関連（Phase 4） === */
.image-generate-section {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.image-generate-btn {
  background-color: #8B5CF6;
  color: white;
  width: 100%;
  font-size: 1.1rem;
  padding: 0.75rem 1.5rem;
}

.image-generate-btn:hover:not(:disabled) {
  background-color: #7C3AED;
}

.image-generate-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.cost-notice {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.image-preview {
  margin-top: 1rem;
}

.image-preview h4 {
  margin-bottom: 0.5rem;
}

.image-preview img {
  width: 100%;
  max-width: 512px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.image-preview p {
  margin-top: 0.5rem;
}

.image-error {
  color: var(--error);
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

/* === Instagram投稿関連（Phase 5） === */
.instagram-section {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.instagram-section h4 {
  margin-bottom: 0.5rem;
  color: #E1306C;
}

.instagram-section textarea {
  margin-top: 0.5rem;
  font-size: 0.9rem;
}

.ig-char-count {
  display: block;
  text-align: right;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

.ig-char-count.over-limit {
  color: var(--error);
  font-weight: 600;
}

.ig-post-btn {
  background: linear-gradient(45deg, #405DE6, #5851DB, #833AB4, #C13584, #E1306C, #FD1D1D);
  color: white;
  width: 100%;
  font-size: 1.1rem;
  padding: 0.75rem 1.5rem;
  margin-top: 0.75rem;
}

.ig-post-btn:hover:not(:disabled) {
  opacity: 0.9;
}

.ig-post-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.ig-success {
  margin-top: 0.75rem;
  padding: 0.75rem;
  background-color: #D1FAE5;
  border-radius: 8px;
  color: #065F46;
}

.ig-error {
  color: var(--error);
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

/* === Bluesky投稿関連（Phase 5.5） === */
.bluesky-section {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.bluesky-section h4 {
  margin-bottom: 0.5rem;
  color: #0085FF;
}

.bluesky-section textarea {
  margin-top: 0.5rem;
  font-size: 0.9rem;
}

.bs-grapheme-count {
  display: block;
  text-align: right;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

.bs-grapheme-count.over-limit {
  color: var(--error);
  font-weight: 600;
}

.bs-post-btn {
  background-color: #0085FF;
  color: white;
  width: 100%;
  font-size: 1.1rem;
  padding: 0.75rem 1.5rem;
  margin-top: 0.75rem;
}

.bs-post-btn:hover:not(:disabled) {
  background-color: #0070DD;
}

.bs-post-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.bs-success {
  margin-top: 0.75rem;
  padding: 0.75rem;
  background-color: #D1FAE5;
  border-radius: 8px;
  color: #065F46;
}

.bs-error {
  color: var(--error);
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

/* === Threads投稿関連（Phase 5.5） === */
.threads-section {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.threads-section h4 {
  margin-bottom: 0.5rem;
  color: #000000;
}

@media (prefers-color-scheme: dark) {
  .threads-section h4 {
    color: #FFFFFF;
  }
}

.threads-section textarea {
  margin-top: 0.5rem;
  font-size: 0.9rem;
}

.th-char-count {
  display: block;
  text-align: right;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

.th-char-count.over-limit {
  color: var(--error);
  font-weight: 600;
}

.th-post-btn {
  background-color: #000000;
  color: white;
  width: 100%;
  font-size: 1.1rem;
  padding: 0.75rem 1.5rem;
  margin-top: 0.75rem;
}

@media (prefers-color-scheme: dark) {
  .th-post-btn {
    background-color: #FFFFFF;
    color: #000000;
  }
}

.th-post-btn:hover:not(:disabled) {
  opacity: 0.9;
}

.th-post-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.th-success {
  margin-top: 0.75rem;
  padding: 0.75rem;
  background-color: #D1FAE5;
  border-radius: 8px;
  color: #065F46;
}

.th-error {
  color: var(--error);
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

/* === レスポンシブ === */
@media (max-width: 640px) {
  header h1 {
    font-size: 1.2rem;
  }

  button {
    font-size: 0.9rem;
    padding: 0.6rem 1rem;
  }

  .input-area {
    padding: 1rem;
  }
}