:root {
  --primary: #6750a4;
  --on-primary: #fff;
  --primary-container: #eaddff;
  --secondary: #625b71;
  --tertiary: #7d5260;
  --error: #b3261e;
  --background: #fffbfe;
  --surface: #fffbfe;
  --outline: #79747e;
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

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

html, body {
  width: 100%;
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
  background: var(--background);
  color: #1c1b1f;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
}

/* Header */
.app-header {
  background: linear-gradient(135deg, #f3e9ff 0%, #fffbfe 100%);
  border-bottom: 1px solid #e7e0ec;
  padding: 24px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}

.header-content {
  flex: 1;
}

.app-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 4px;
}

.app-subtitle {
  font-size: 13px;
  color: var(--outline);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.credit-badge {
  background: var(--primary-container);
  color: #21005e;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 13px;
}

.text-link {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 13px;
  cursor: pointer;
  text-decoration: underline;
  font-family: inherit;
}

.text-link:hover {
  color: #5b4c95;
}

/* Main Content */
.search-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 48px 32px;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}

/* Method Selector */
.method-selector {
  background: white;
  padding: 1rem 2rem;
  border-radius: 12px 12px 0 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  border-bottom: 2px solid #f0f0f0;
  margin-bottom: 0;
}

.method-tabs {
  display: flex;
  gap: 1rem;
  justify-content: flex-start;
}

.method-tab {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  cursor: pointer;
  border: 2px solid transparent;
  border-radius: 8px;
  transition: all 0.3s ease;
  font-weight: 500;
  user-select: none;
  background: #f9f9f9;
}

.method-tab input[type="radio"] {
  display: none;
}

.method-tab input[type="radio"]:checked + span,
.method-tab.active {
  color: #6750a4;
  border-color: #6750a4;
  background: #f3f0ff;
}

.method-tab:hover {
  background: #f0f0f0;
}

/* Method Containers */
.method-container {
  display: none;
}

.method-container.active {
  display: block;
}

.search-box-wrapper {
  background: white;
  padding: 2rem;
  border-radius: 0 0 12px 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  margin-bottom: 48px;
}

.search-method-form {
  display: none;
}

.search-method-form[data-method="deepsearch"] {
  display: block;
}

.search-method-form.active {
  display: block;
}

#search-form {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}

#thesis-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Form Title */
.form-title {
  margin: 0 0 1rem 0;
  font-size: 1.2rem;
  color: var(--primary);
  border-bottom: 2px solid #f0f0f0;
  padding-bottom: 0.75rem;
  font-weight: 600;
}

.search-input-group {
  display: flex;
  gap: 12px;
  flex: 1;
  min-width: 300px;
}

#query {
  flex: 1;
  padding: 12px 16px;
  border: 2px solid #e7e0ec;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

#query:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(103, 80, 164, 0.1);
}

#query::placeholder {
  color: #79747e;
}

/* Buttons */
.btn {
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 2px 4px rgba(103, 80, 164, 0.3);
}

.btn-primary:hover {
  background: #5b4c95;
  box-shadow: 0 4px 8px rgba(103, 80, 164, 0.4);
}

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

.btn-outlined {
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--primary);
}

.btn-outlined:hover {
  background: rgba(103, 80, 164, 0.08);
}

.btn-export {
  background: #2196F3;
  color: white;
  padding: 10px 16px;
  font-size: 13px;
  box-shadow: 0 2px 4px rgba(33, 150, 243, 0.3);
}

.btn-export:hover {
  background: #1976D2;
  box-shadow: 0 4px 8px rgba(33, 150, 243, 0.4);
}

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

/* Status Message */
.status-message {
  margin-top: 12px;
  font-size: 13px;
  color: var(--outline);
  min-height: 18px;
}

.status-message.loading {
  color: var(--primary);
  font-weight: 600;
}

.status-message.error {
  color: var(--error);
}

/* Results */
.results-container {
  margin-top: 32px;
  padding: 24px;
  background: white;
  border-radius: var(--radius-lg);
  border: 1px solid #e7e0ec;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}

.results-header {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 16px;
  border-bottom: 1px solid #e7e0ec;
  padding-bottom: 12px;
}

.results-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.result-item {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.result-item h3 {
  font-size: 18px;
  font-weight: 600;
  color: #1c1b1f;
}

.result-item .result-text {
  background: #f5f5f5;
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid #e7e0ec;
  font-size: 13px;
  line-height: 1.7;
  overflow-x: auto;
}

.result-item .result-text a {
  color: #0f4c81;
  text-decoration: underline;
}

/* References Section */
.references-section {
  padding-top: 16px;
  border-top: 2px solid #e7e0ec;
}

.references-section h4 {
  font-size: 14px;
  font-weight: 600;
  color: #1c1b1f;
  margin-bottom: 12px;
}

.reference-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.reference-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: #f3e9ff;
  border: 1px solid #e7e0ec;
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--primary);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s;
  cursor: pointer;
}

.reference-link:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(103, 80, 164, 0.2);
}

.ref-icon {
  font-size: 16px;
  display: flex;
  align-items: center;
}

.ref-name {
  white-space: nowrap;
}

/* Info Section */
.info-section {
  margin-top: 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.info-card {
  background: white;
  padding: 32px 24px;
  border-radius: var(--radius-lg);
  border: 1px solid #e7e0ec;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
  max-width: 500px;
  text-align: center;
  width: 100%;
}

.info-card h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 12px;
  color: #1c1b1f;
}

.info-card p {
  color: #49454e;
  margin-bottom: 16px;
  font-size: 14px;
  line-height: 1.6;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal[hidden] {
  display: none;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  cursor: pointer;
}

.modal-content {
  position: relative;
  background: white;
  border-radius: var(--radius-lg);
  padding: 32px;
  max-width: 500px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 5px 25px rgba(0,0,0,0.3);
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  font-size: 32px;
  cursor: pointer;
  color: var(--outline);
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  color: #1c1b1f;
}

.modal-content h2 {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 16px;
}

.modal-content h3 {
  font-size: 16px;
  font-weight: 600;
  margin-top: 24px;
  margin-bottom: 12px;
}

.modal-content p {
  color: #49454e;
  margin-bottom: 16px;
}

.modal-content ul {
  list-style: none;
  padding: 0;
  margin-bottom: 24px;
}

.modal-content li {
  padding: 8px 0;
  color: #49454e;
  font-size: 14px;
}

/* Survey Modal */
.survey-content {
  max-width: 440px;
  padding: 28px;
}

.survey-content p {
  font-size: 14px;
  color: #5f5a6b;
}

.survey-options {
  display: grid;
  gap: 10px;
  margin: 12px 0 18px;
}

.survey-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid #e7e0ec;
  border-radius: 10px;
  background: #faf8ff;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 14px;
}

.survey-option input {
  margin: 0;
}

.survey-option:hover {
  border-color: var(--primary);
  background: #f3e9ff;
}

.survey-actions {
  justify-content: space-between;
  align-items: center;
}

.survey-actions .btn {
  min-width: 120px;
}

/* Video Modal */
.video-content {
  max-width: 500px;
  width: 90vw;
  max-height: 90vh;
  padding: 24px;
}

.video-container {
  position: relative;
  width: 100%;
  height: auto;
  overflow: hidden;
  border-radius: 8px;
  background: #000;
}

.video-container iframe {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  border-radius: 8px;
}

#video-modal .modal-close {
  z-index: 10;
  background: rgba(255, 255, 255, 0.9);
  color: #1c1b1f;
}

/* Support Options */
.support-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.support-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px 12px;
  background: var(--primary);
  color: white;
  border-radius: var(--radius-md);
  text-decoration: none;
  transition: all 0.2s;
  box-shadow: 0 2px 4px rgba(103, 80, 164, 0.3);
  gap: 4px;
}

.support-option:hover {
  background: #5b4c95;
  box-shadow: 0 4px 8px rgba(103, 80, 164, 0.4);
  transform: translateY(-2px);
}

.support-amount {
  font-size: 15px;
  font-weight: 600;
}

.support-credits {
  font-size: 12px;
  opacity: 0.9;
}

/* Support History Section */
.support-history-section {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid #e7e0ec;
}

.support-history-section h3 {
  font-size: 18px;
  margin-bottom: 16px;
  color: #1c1b1f;
}

.support-history-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.support-history-table thead {
  background: var(--primary-container);
}

.support-history-table th {
  padding: 12px 16px;
  text-align: left;
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
}

.support-history-table td {
  padding: 12px 16px;
  border-top: 1px solid #e7e0ec;
  font-size: 14px;
  color: #49454e;
}

.support-history-table tbody tr:hover {
  background: #f9f8fc;
}

.loading-message {
  text-align: center;
  padding: 24px;
  color: #79747e;
  font-size: 14px;
}

.error-message {
  text-align: center;
  padding: 24px;
  color: var(--error);
  font-size: 14px;
  background: #fff4f4;
  border-radius: var(--radius-md);
}

/* Responsive */
@media (max-width: 768px) {
  .app-header {
    flex-direction: column;
    gap: 16px;
    text-align: center;
  }

  .search-container {
    padding: 24px 16px;
  }

  .search-input-group {
    flex-direction: column;
    min-width: auto;
  }

  #query {
    width: 100%;
  }

  .info-section {
    margin-top: 32px;
  }

  .info-card {
    max-width: 100%;
  }

  .modal-content {
    margin: 16px;
    max-width: none;
  }
}

.loading-text {
  text-align: center;
  color: var(--outline);
  padding: 32px 16px;
  font-style: italic;
}

/* Use Cases Modal */
.use-cases-table {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: 60vh;
  overflow-y: auto;
  padding: 16px 0;
}

/* Feedback form styles */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.form-group label {
  color: #1c1b1f;
  font-weight: 600;
}

.form-group input,
.form-group textarea {
  padding: 10px 12px;
  border: 1px solid #e7e0ec;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
}

.form-group input:focus,
.form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(103, 80, 164, 0.12);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.app-footer {
  margin: 32px auto 24px;
  text-align: center;
  color: #625b71;
  font-size: 14px;
}

.app-footer a {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
}

.app-footer a:hover {
  text-decoration: underline;
}

.use-case-item {
  background: #f3e9ff;
  border-left: 4px solid var(--primary);
  padding: 16px;
  border-radius: 8px;
}

.use-case-item h3 {
  margin: 0 0 12px 0;
  color: var(--primary);
  font-size: 1rem;
}

.use-case-item ul {
  margin: 0;
  padding-left: 20px;
  list-style: none;
}

.use-case-item li {
  margin: 8px 0;
  color: #1c1b1f;
  line-height: 1.5;
  font-size: 0.9rem;
}

.use-case-item strong {
  color: var(--primary);
  font-weight: 600;
}

@media (max-width: 600px) {
  .use-cases-table {
    max-height: 50vh;
  }

  .use-case-item {
    padding: 12px;
  }

  .use-case-item h3 {
    font-size: 0.95rem;
  }

  .use-case-item li {
    font-size: 0.85rem;
  }
}
/* Thesis Progress Styles */
.thesis-progress-container {
  background: white;
  padding: 2rem;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  margin-bottom: 2rem;
}

.progress-header {
  text-align: center;
  margin-bottom: 2rem;
}

.progress-header h2 {
  margin-bottom: 0.5rem;
  color: var(--primary);
}

.progress-header p {
  color: #666;
  font-size: 0.95rem;
}

.progress-tracker {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.agent-step {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: #f9f9f9;
  border-radius: 8px;
  border-left: 4px solid #ddd;
  transition: all 0.3s ease;
}

.agent-step.in-progress {
  background: #f0f8ff;
  border-left-color: #007bff;
}

.agent-step.completed {
  background: #f0fdf4;
  border-left-color: #10b981;
}

.agent-step.failed {
  background: #fef2f2;
  border-left-color: #ef4444;
}

.step-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: #e0e0e0;
  border-radius: 50%;
  font-weight: 600;
  color: white;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.agent-step.in-progress .step-indicator {
  background: #007bff;
}

.agent-step.completed .step-indicator {
  background: #10b981;
}

.agent-step.failed .step-indicator {
  background: #ef4444;
}

.step-info {
  flex: 1;
}

.step-info h4 {
  margin: 0 0 0.3rem 0;
  font-size: 0.95rem;
  color: #333;
}

.step-info p {
  margin: 0;
  font-size: 0.85rem;
  color: #666;
}

.step-status {
  font-size: 1.5rem;
  text-align: center;
  min-width: 30px;
}

.agent-step.completed .step-status {
  font-size: 1.3rem;
}

.thesis-download-section {
  text-align: center;
  padding: 2rem;
  background: #f0fdf4;
  border-radius: 8px;
  border: 2px solid #10b981;
}

.thesis-download-section h3 {
  color: #10b981;
  margin-bottom: 1rem;
}