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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', Meiryo, sans-serif;
  background: #faf8f5;
  color: #2c2c2c;
  line-height: 1.6;
  min-height: 100dvh;
}

/* ===== Layout ===== */
.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

/* ===== Header ===== */
header {
  text-align: center;
  margin-bottom: 24px;
}

header h1 {
  font-size: 28px;
  font-weight: 700;
  color: #8b6914;
  letter-spacing: 0.05em;
}

.subtitle {
  font-size: 13px;
  color: #8a8478;
  margin-top: 2px;
}

/* ===== Settings ===== */
.settings {
  margin-bottom: 20px;
}

.settings-toggle {
  background: none;
  border: none;
  color: #8a8478;
  font-size: 13px;
  cursor: pointer;
  padding: 4px 0;
}

.settings-toggle:hover {
  color: #8b6914;
}

.settings-panel {
  background: #fff;
  border: 1px solid #e8e0d6;
  border-radius: 12px;
  padding: 16px;
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.settings-panel.hidden {
  display: none;
}

.settings-panel label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: #8a8478;
}

.settings-panel input,
.settings-panel select {
  font-size: 15px;
  padding: 8px 12px;
  border: 1px solid #e8e0d6;
  border-radius: 8px;
  background: #faf8f5;
  color: #2c2c2c;
  outline: none;
  transition: border-color 0.2s;
}

.settings-panel input:focus,
.settings-panel select:focus {
  border-color: #8b6914;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 500;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  background: #8b6914;
  color: #fff;
  transition: background 0.2s;
}

.btn:hover {
  background: #6d5211;
}

.btn:active {
  transform: scale(0.98);
}

.btn-small {
  padding: 6px 14px;
  font-size: 13px;
  align-self: flex-start;
}

.btn-secondary {
  background: #e8e0d6;
  color: #5a5347;
}

.btn-secondary:hover {
  background: #ddd4c8;
}

/* ===== Drop Zone ===== */
.drop-zone {
  border: 2px dashed #d4cbbf;
  border-radius: 16px;
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: #fdfcfa;
}

.drop-zone:hover,
.drop-zone.dragover {
  border-color: #8b6914;
  background: #f5f0e8;
}

.drop-zone.hidden {
  display: none;
}

.drop-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.drop-main {
  font-size: 17px;
  font-weight: 600;
  color: #5a5347;
}

.drop-hint {
  font-size: 13px;
  color: #a09888;
  margin-top: 4px;
}

.drop-formats {
  font-size: 11px;
  color: #bfb5a5;
  margin-top: 8px;
}

/* ===== Status ===== */
.status {
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 14px;
  margin-bottom: 16px;
  transition: all 0.3s;
}

.status.hidden {
  display: none;
}

.status.info {
  background: #eef3fa;
  color: #4a6fa5;
}

.status.success {
  background: #eef5ee;
  color: #3d7a3d;
}

.status.error {
  background: #faeeee;
  color: #a04444;
}

/* ===== Result ===== */
.result-area {
  margin-top: 8px;
}

.result-area.hidden {
  display: none;
}

.output {
  background: #fff;
  border: 1px solid #e8e0d6;
  border-radius: 12px;
  padding: 20px;
  max-height: 60vh;
  overflow-y: auto;
  font-size: 14px;
  line-height: 1.8;
  margin-bottom: 16px;
  -webkit-overflow-scrolling: touch;
}

/* Markdown content styles */
.output h1 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 12px;
  color: #8b6914;
  border-bottom: 1px solid #e8e0d6;
  padding-bottom: 8px;
}

.output h2 {
  font-size: 16px;
  font-weight: 600;
  margin-top: 20px;
  margin-bottom: 8px;
  color: #5a5347;
}

.output h3 {
  font-size: 14px;
  font-weight: 600;
  margin-top: 16px;
  margin-bottom: 6px;
  color: #6d5211;
}

.output p {
  margin-bottom: 8px;
}

.output strong {
  color: #8b6914;
}

.output hr {
  border: none;
  border-top: 1px solid #e8e0d6;
  margin: 16px 0;
}

.output ul, .output ol {
  padding-left: 20px;
  margin-bottom: 8px;
}

.output blockquote {
  border-left: 3px solid #d4cbbf;
  padding-left: 12px;
  color: #8a8478;
  margin: 8px 0;
}

/* ===== Actions ===== */
.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ===== Loading animation ===== */
.status.info::after {
  content: '';
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid #4a6fa5;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-left: 8px;
  vertical-align: middle;
}

.status.success::after,
.status.error::after {
  content: none;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== Responsive ===== */
@media (max-width: 480px) {
  .container {
    padding: 16px 12px 36px;
  }

  header h1 {
    font-size: 24px;
  }

  .drop-zone {
    padding: 36px 16px;
  }

  .drop-icon {
    font-size: 40px;
  }

  .output {
    max-height: 50vh;
    padding: 16px;
  }

  .actions {
    flex-direction: column;
  }

  .btn {
    justify-content: center;
  }
}
