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

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --error: #dc2626;
  --radius: 12px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", "Hiragino Sans", Meiryo, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  min-height: 100dvh;
}

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 1.25rem;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* Auth screen */
.auth-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  z-index: 1000;
}

.auth-box {
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  max-width: 360px;
  width: 100%;
  margin: 1rem;
}

.auth-box h1 {
  margin-bottom: 0.5rem;
}

.auth-box p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.25rem;
}

.auth-box input {
  width: 100%;
  padding: 0.85rem 1rem;
  font-size: 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  margin-bottom: 0.75rem;
  transition: border-color 0.2s;
}

.auth-box input:focus {
  border-color: var(--primary);
}

.auth-box button {
  width: 100%;
  padding: 0.85rem;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  background: var(--primary);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.2s;
}

.auth-box button:hover {
  background: var(--primary-hover);
}

.auth-error {
  color: var(--error) !important;
  margin-top: 0.75rem !important;
  margin-bottom: 0 !important;
}

.fade-out {
  animation: fadeOut 0.3s ease forwards;
}

.fade-in {
  animation: fadeIn 0.4s ease;
}

@keyframes fadeOut {
  to { opacity: 0; transform: scale(0.97); }
}

/* Icon */
.icon {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 0.75rem;
}

.icon-small {
  width: 64px;
  height: 64px;
  margin-bottom: 0.5rem;
}

/* Header */
header {
  text-align: center;
  margin-bottom: 1.5rem;
}

h1 {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: 0.02em;
}

.subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.description {
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.description strong {
  color: var(--text);
}

/* Tabs */
.tabs {
  display: flex;
  gap: 0;
  margin-bottom: 1.5rem;
  border-bottom: 2px solid var(--border);
}

.tab {
  flex: 1;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-weight: 700;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: color 0.2s, border-color 0.2s;
}

.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab:hover {
  color: var(--primary);
}

/* Tab content */
.tab-content {
  display: none;
}

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

/* Form */
.input-group {
  display: flex;
  gap: 0.5rem;
}

#facultyInput {
  flex: 1;
  padding: 0.85rem 1rem;
  font-size: 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.2s;
  background: var(--surface);
}

#facultyInput:focus {
  border-color: var(--primary);
}

#submitBtn,
.submit-btn {
  padding: 0.85rem 1.5rem;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  background: var(--primary);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}

#submitBtn:hover,
.submit-btn:hover {
  background: var(--primary-hover);
}

#submitBtn:disabled,
.submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.submit-btn {
  width: 100%;
  margin-top: 1rem;
  padding: 1rem;
  font-size: 1.1rem;
}

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-right: 0.4rem;
  vertical-align: middle;
}

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

/* Question cards */
.question-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.question-card h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.choice {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.5rem 0;
  font-size: 0.95rem;
  cursor: pointer;
}

.choice input[type="checkbox"] {
  margin-top: 0.3rem;
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.free-input,
textarea {
  width: 100%;
  padding: 0.75rem;
  font-size: 0.95rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.2s;
  background: var(--surface);
  font-family: inherit;
  margin-top: 0.5rem;
}

.free-input:focus,
textarea:focus {
  border-color: var(--primary);
}

textarea {
  resize: vertical;
}

/* Result */
.result {
  margin-top: 2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  animation: fadeIn 0.3s ease;
}

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

.result-content h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--primary);
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  padding-bottom: 0.3rem;
  border-bottom: 2px solid var(--border);
}

.result-content h2:first-child {
  margin-top: 0;
}

.result-content h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-top: 1rem;
  margin-bottom: 0.3rem;
}

.result-content p {
  margin-bottom: 0.6rem;
}

.result-content ul,
.result-content ol {
  margin-left: 1.25rem;
  margin-bottom: 0.6rem;
}

.result-content li {
  margin-bottom: 0.25rem;
}

.result-content strong {
  color: var(--text);
}

/* Clear button */
.clear-btn {
  display: block;
  margin: 1.5rem auto 0;
  padding: 0.6rem 1.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

.clear-btn:hover {
  color: var(--primary);
  border-color: var(--primary);
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  margin: 0.75rem 0;
}

.result-content table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.result-content th,
.result-content td {
  border: 1px solid var(--border);
  padding: 0.5rem 0.75rem;
  text-align: left;
}

.result-content th {
  background: var(--bg);
  font-weight: 700;
}

.result-content tr:nth-child(even) td {
  background: #f9fafb;
}

/* Error */
.error {
  margin-top: 1rem;
  padding: 1rem;
  background: #fef2f2;
  color: var(--error);
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  font-size: 0.9rem;
}

/* Footer */
footer {
  margin-top: auto;
  padding-top: 2rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Responsive */
@media (max-width: 480px) {
  .container {
    padding: 1.25rem 1rem;
  }

  h1 {
    font-size: 1.5rem;
  }

  .input-group {
    flex-direction: column;
  }

  #submitBtn {
    width: 100%;
  }

  .result {
    padding: 1rem;
  }

  .question-card {
    padding: 1rem;
  }
}
