* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: #f8fafc;
  min-height: 100vh;
  padding: 20px;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  background: white;
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.06);
  overflow: hidden;
  border: 1px solid #e2e8f0;
}

.header {
  background: #2563eb;
  color: white;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: relative;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.settings-button,
.icon-button {
  background: #f8fafc;
  border: 1px solid #d8dee9;
  color: #475569;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.settings-button:hover,
.icon-button:hover:not(:disabled) {
  background: #e2e8f0;
  border-color: #cbd5e1;
}

.download-icon:not(:disabled) {
  color: #2563eb;
}

.copy-icon:not(:disabled) {
  color: #0ea5e9;
}

.history-icon:not(:disabled) {
  color: #059669;
}

.icon-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.settings-button svg,
.icon-button svg {
  pointer-events: none;
}

.history-panel {
  position: absolute;
  top: 100%;
  right: 50px;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  padding: 20px;
  width: 400px;
  max-height: 500px;
  overflow-y: auto;
  z-index: 99;
  display: none;
  margin-top: 10px;
}

.history-panel.show {
  display: block;
}

.history-panel h3 {
  color: #1e293b;
  font-size: 1.2em;
  font-weight: 600;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid #e2e8f0;
}

.history-item {
  padding: 12px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  background: #f8fafc;
}

.history-item:hover {
  background: #e2e8f0;
  border-color: #cbd5e1;
}

.history-item-date {
  font-size: 12px;
  color: #64748b;
  margin-bottom: 5px;
}

.history-item-title {
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 3px;
  font-size: 14px;
}

.history-item-preview {
  font-size: 12px;
  color: #64748b;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.clear-history-btn {
  background: #ef4444;
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.2s;
}

.clear-history-btn:hover {
  background: #dc2626;
}

.no-history {
  text-align: center;
  color: #64748b;
  font-style: italic;
  padding: 20px;
}

.settings-panel {
  position: absolute;
  top: 100%;
  right: 0;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  padding: 20px;
  width: 350px;
  z-index: 100;
  display: none;
  margin-top: 10px;
}

.settings-panel.show {
  display: block;
}

.settings-panel h3 {
  color: #1e293b;
  font-size: 1.2em;
  font-weight: 600;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid #e2e8f0;
}

.settings-item {
  margin-bottom: 20px;
}

.settings-item:last-child {
  margin-bottom: 0;
}

.settings-label {
  display: block;
  font-weight: 600;
  color: #374151;
  margin-bottom: 8px;
  font-size: 14px;
}

.main-content {
  padding: 30px;
}

.controls-section {
  display: flex;
  gap: 30px;
  margin-bottom: 30px;
}

.recording-controls {
  flex: 0 0 300px;
  display: flex;
  flex-direction: column;
}

.recording-start-control {
  display: flex;
  align-items: center;
  gap: 8px;
}

.memo-section {
  flex: 1;
}

.recording-button {
  background: #ffffff;
  color: #1f2937;
  border: 2px solid #d1d5db;
  width: auto;
  height: 44px;
  padding: 0 20px;
  margin-bottom: 0;
  border-radius: 9999px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.recording-button .icon {
  font-size: 18px;
  color: #dc2626;
}

.record-toggle-button {
  justify-content: center;
  background: #ffffff;
  color: #1f2937;
  border: 2px solid #d1d5db;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.15s ease;
}

.record-toggle-button:hover:not(:disabled) {
  background: #eff6ff;
  border-color: #2563eb;
  color: #1d4ed8;
  transform: translateY(-1px);
}

.record-toggle-button.recording {
  background: #dc2626;
  border-color: #dc2626;
  color: #ffffff;
}

.record-toggle-button.recording:hover:not(:disabled) {
  background: #b91c1c;
  border-color: #b91c1c;
}

.record-toggle-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.recording-status {
  text-align: right;
  font-weight: 600;
}

.info-tooltip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #2563eb;
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
  cursor: help;
  flex-shrink: 0;
}

.info-tooltip:focus {
  outline: 2px solid rgba(37, 99, 235, 0.35);
  outline-offset: 2px;
}

.info-tooltip .tooltip-content {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: min(360px, 80vw);
  background: #fef3c7;
  border: 1px solid #f59e0b;
  border-radius: 10px;
  padding: 14px 16px;
  color: #92400e;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.15);
  font-size: 13px;
  line-height: 1.6;
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 20;
}

.info-tooltip:hover .tooltip-content,
.info-tooltip:focus-within .tooltip-content {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.tooltip-title {
  font-weight: 600;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.recording {
  color: #ff6b6b;
  animation: pulse 1.5s infinite;
}

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

.memo-textarea {
  width: 100%;
  height: 120px;
  padding: 16px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  transition: border-color 0.2s ease;
  background: #ffffff;
}

.memo-textarea:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.template-select {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #ffffff;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.template-select:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-select {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #ffffff;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.form-select:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #ffffff;
  transition: border-color 0.2s ease;
}

.form-input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.status-message {
  margin: 20px 0;
  padding: 16px;
  border-radius: 8px;
  font-weight: 500;
  text-align: center;
}

.status-success {
  background: #dbeafe;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

.status-error {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
}

.content-layout {
  display: block;
  margin-top: 30px;
}

.section-title {
  font-size: 1.3em;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 15px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.result-textarea {
  width: 100%;
  min-height: 500px;
  padding: 20px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  resize: vertical;
  transition: border-color 0.2s ease;
  background: #ffffff;
}

.result-textarea:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.icon {
  font-size: 18px;
}

/* チャット機能のスタイル */
.chat-container {
  height: 420px;
  display: flex;
  flex-direction: column;
}

.chat-messages {
  flex: 1;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 20px;
  overflow-y: auto;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  gap: 15px;
  max-height: 100%;
}

.message {
  padding: 12px 16px;
  border-radius: 12px;
  max-width: 80%;
  word-wrap: break-word;
}

.message.user {
  background: #2563eb;
  color: white;
  align-self: flex-end;
  margin-left: auto;
}

.message.assistant {
  background: #f1f5f9;
  color: #1e293b;
  align-self: flex-start;
  border: 1px solid #e2e8f0;
}

.message.loading {
  background: #f1f5f9;
  color: #64748b;
  align-self: flex-start;
  border: 1px solid #e2e8f0;
  animation: pulse 1.5s infinite;
}

.chat-input-container {
  display: flex;
  gap: 10px;
  margin-top: 15px;
}

.chat-input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  min-height: 44px;
  max-height: 120px;
}

.chat-input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.chat-send-btn {
  padding: 12px 20px;
  background: #2563eb;
  color: white;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.chat-send-btn:hover:not(:disabled) {
  background: #1d4ed8;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

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

/* オーバーレイスタイル */
.processing-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.95);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  z-index: 10;
}

.processing-overlay h3 {
  color: #2563eb;
  font-size: 1.5em;
  margin-bottom: 20px;
}

.processing-spinner {
  border: 4px solid #f3f4f6;
  border-top: 4px solid #2563eb;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  animation: spin 1s linear infinite;
  margin-bottom: 20px;
}

.progress-container {
  width: 300px;
  height: 8px;
  background-color: #f3f4f6;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 10px;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #2563eb, #3b82f6);
  border-radius: 4px;
  transition: width 0.3s ease;
  width: 0%;
}

.progress-text {
  font-size: 0.9em;
  color: #64748b;
  text-align: center;
}

.controls-section {
  position: relative;
}

@media (max-width: 768px) {
  .controls-section {
    flex-direction: column;
    gap: 20px;
  }
  
  .recording-controls {
    flex: none;
  }
  
  .chat-container {
    height: 360px;
  }
  
  .chat-input-container {
    flex-direction: column;
  }
  
  .chat-send-btn {
    align-self: flex-end;
  }
}

.chat-drawer {
  margin-top: 30px;
  border: 1px solid #d1d5db;
  border-radius: 12px;
  background: #f8fafc;
  overflow: hidden;
  transition: box-shadow 0.3s ease, border-color 0.3s ease;
}

.chat-drawer.collapsed {
  cursor: pointer;
}

.chat-drawer.expanded {
  background: #ffffff;
  box-shadow: 0 14px 40px rgba(15, 23, 42, 0.15);
  border-color: #cbd5e1;
}

.chat-drawer-header {
  width: 100%;
  border: none;
  background: transparent;
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 16px;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
}

.chat-drawer-header:hover,
.chat-drawer-header:focus-visible {
  background: rgba(148, 163, 184, 0.12);
  outline: none;
}

.chat-drawer-text {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-drawer-title {
  color: #1e293b;
}

.chat-drawer-chevron {
  font-size: 18px;
  color: #64748b;
  transition: transform 0.3s ease;
}

.chat-drawer.expanded .chat-drawer-chevron {
  transform: rotate(180deg);
}

.chat-drawer-body {
  display: none;
  padding: 0 24px 24px;
  border-top: 1px solid #e2e8f0;
  background: #ffffff;
}

.chat-drawer.expanded .chat-drawer-body {
  display: block;
}

@media (max-width: 768px) {
  .chat-drawer-body {
    padding: 0 16px 16px;
  }
}

.result-controls-wrapper {
  margin-bottom: 30px;
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.result-header .section-title {
  margin-bottom: 0;
  display: flex;
  align-items: center;
  height: 44px;
  gap: 10px;
}

.result-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.recording-feedback {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  min-height: 40px;
}

.recording-timer {
  display: none;
}

.recording-timer.show {
  display: block;
}

.recording-timer-label {
  text-align: right;
  font-size: 0.95em;
  font-weight: 600;
  color: #2563eb;
}
