* {
  box-sizing: border-box;
}

body {
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  margin: 0;
  padding: 0.5rem;
  background: #f5f5f5;
  color: #1a1a1a;
  -webkit-text-size-adjust: 100%;
}

.container {
  max-width: 32rem;
  margin: 0 auto;
  background: #fff;
  padding: 1rem;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

@media (min-width: 480px) {
  body { padding: 1rem; }
  .container { padding: 1.5rem; }
}

/* model-bar and execution time styles removed; model selection now lives on profile page */

.app-header {
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

h1 {
  font-size: 1.35rem;
  font-weight: 600;
  margin: 0;
}

.greeting-text {
  margin: 0.15rem 0 0;
  font-size: 0.9rem;
  color: #4b5563;
}

.app-header-main {
  display: flex;
  flex-direction: column;
}

.app-header-menu {
  position: relative;
}

.menu-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border-radius: 999px;
  border: 1px solid #d1d5db;
  background: #f9fafb;
}

.menu-toggle-icon {
  display: inline-block;
  width: 1.2rem;
  height: 1.2rem;
  position: relative;
}

.menu-toggle-icon span {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  border-radius: 999px;
  background: #111827;
  transition: transform 0.18s ease, opacity 0.18s ease, top 0.18s ease, bottom 0.18s ease;
}

.menu-toggle-icon span:nth-child(1) {
  top: 0.2rem;
}

.menu-toggle-icon span:nth-child(2) {
  top: 50%;
  transform: translateY(-50%);
}

.menu-toggle-icon span:nth-child(3) {
  bottom: 0.2rem;
}

.menu-toggle.is-open .menu-toggle-icon span:nth-child(1) {
  top: 50%;
  transform: translateY(-50%) rotate(45deg);
}

.menu-toggle.is-open .menu-toggle-icon span:nth-child(2) {
  opacity: 0;
}

.menu-toggle.is-open .menu-toggle-icon span:nth-child(3) {
  bottom: auto;
  top: 50%;
  transform: translateY(-50%) rotate(-45deg);
}

.menu-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 0.35rem);
  min-width: 11rem;
  padding: 0.35rem 0;
  background: #111827;
  color: #f9fafb;
  border-radius: 10px;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.28);
  z-index: 10;
}

.menu-dropdown[hidden] {
  display: none;
}

.menu-item {
  width: 100%;
  padding: 0.55rem 0.9rem;
  border: none;
  background: transparent;
  color: inherit;
  text-align: left;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
}

.menu-item:hover {
  background: rgba(249, 250, 251, 0.07);
}

.menu-item + .menu-item {
  border-top: 1px solid rgba(55, 65, 81, 0.75);
}

@media (min-width: 480px) {
  .app-header {
    align-items: flex-start;
  }
}

.section-title {
  margin: 0 0 0.5rem 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: #1a1a1a;
}

.section-hint {
  margin: 0 0 0.75rem 0;
  font-size: 0.8rem;
  color: #666;
  line-height: 1.35;
}

.form-section {
  margin-bottom: 0.75rem;
  padding: 0.75rem 1rem;
  background: #f8f9fa;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.form-section:last-of-type {
  margin-bottom: 0;
}

.field {
  margin-bottom: 0.75rem;
}

.field:last-child {
  margin-bottom: 0;
}

.sample-video-output .sample-video-player {
  display: block;
  max-width: 100%;
  margin-bottom: 0.5rem;
}

.label,
label:not(.radio) {
  display: block;
  font-weight: 500;
  margin-bottom: 0.25rem;
  font-size: 0.9rem;
}

.button-label {
  display: block;
  margin-bottom: 0.25rem;
}

input[type="text"] {
  display: block;
  width: 100%;
  padding: 0.4rem 0.6rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 16px; /* prevents iOS zoom on focus */
}

textarea {
  display: block;
  width: 100%;
  min-height: 4em;
  padding: 0.4rem 0.6rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 16px;
  font-family: inherit;
  resize: vertical;
}

input[type="file"] {
  display: block;
  width: 100%;
  padding: 0.4rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  background: #fff;
  font-size: 0.9rem;
}

.radio-group {
  display: flex;
  gap: 1rem;
  margin-top: 0.15rem;
}

.radio {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 400;
  cursor: pointer;
}

.radio input {
  margin: 0;
}

select {
  width: 100%;
  padding: 0.4rem 0.6rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 16px;
  background: #fff;
}

.btn-primary {
  padding: 0.5rem 0.75rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff;
  background: #0d6efd;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.btn-primary.btn-full {
  width: 100%;
}

.btn-primary:hover {
  background: #0b5ed7;
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-secondary {
  padding: 0.5rem 0.75rem;
  font-size: 0.95rem;
  background: #f3f4f6;
  color: #374151;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

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

.btn-secondary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

button[type="submit"] {
  width: 100%;
  padding: 0.6rem 0.75rem;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  background: #0d6efd;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button[type="submit"]:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

button[type="submit"]:hover {
  background: #0b5ed7;
}

.generate-error-msg {
  margin-top: 0.5rem;
  font-size: 0.9rem;
  color: #b91c1c;
}

.generate-error-msg[hidden] {
  display: none;
}

.generated-story-section {
  margin-top: 1rem;
}

.generated-story-content {
  padding: 0.5rem 0;
  font-size: 0.95rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.play-podcast-block {
  margin-top: 1rem;
}

.sample-play-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.sample-play-buttons .btn-primary {
  flex: 0 1 auto;
}

.hint {
  display: block;
  font-size: 0.75rem;
  color: #666;
  margin-top: 0.15rem;
  margin-bottom: 0.35rem;
}

.results {
  margin-top: 0.75rem;
  padding: 0.75rem;
  border-radius: 6px;
  min-height: 2rem;
  font-size: 0.9rem;
}

.results.success {
  background: #d1e7dd;
  color: #0a3622;
}

.results.error {
  background: #f8d7da;
  color: #58151c;
}

.results:empty {
  display: none;
}

.person-photo-field.has-thumbnail {
  display: grid;
  grid-template-columns: 1fr 80px;
  grid-template-rows: auto auto;
  column-gap: 0.75rem;
  row-gap: 0.35rem;
}

.person-photo-field.has-thumbnail > label {
  grid-column: 1;
  grid-row: 1;
}

.person-photo-field.has-thumbnail input[type="file"] {
  grid-column: 1;
  grid-row: 2;
  min-width: 0;
}

.person-photo-field.has-thumbnail .thumbnail-wrap {
  grid-column: 2;
  grid-row: 1 / -1;
  align-self: stretch;
  min-height: 3.5rem;
  display: flex;
}

.optional {
  font-weight: 400;
  color: #666;
  font-size: 0.85em;
}

.required {
  font-weight: 400;
  color: #666;
  font-size: 0.85em;
}

.thumbnail-wrap {
  width: 80px;
  min-height: 3.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
  background: #fff;
  overflow: hidden;
}

.thumbnail-wrap:empty {
  display: none;
}

.thumbnail-wrap:empty {
  display: none;
}

.thumbnail-wrap .thumbnail {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 3.5rem;
  object-fit: cover;
}

.file-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.25rem 0.75rem;
  margin-top: 0.5rem;
}

.file-list:empty {
  display: none;
}

.file-list-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  min-width: 0;
}

.file-list-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-list-remove {
  flex-shrink: 0;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: #e5e7eb;
  color: #374151;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

.file-list-remove:hover {
  background: #d1d5db;
  color: #1f2937;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
}

.modal-content {
  position: relative;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  max-width: 20rem;
  width: 100%;
  max-height: 85vh;
  overflow: auto;
}

.modal-title {
  margin: 0;
  padding: 1rem 1rem 0.5rem;
  font-size: 1.1rem;
  font-weight: 600;
}

.modal-body {
  padding: 0 1rem 1rem;
  font-size: 0.9rem;
}

.confirm-section {
  margin: 0 0 0.75rem 0;
}

.confirm-section:last-child {
  margin-bottom: 0;
}

.confirm-filename {
  word-break: break-word;
}

.confirm-file-list {
  margin: 0.25rem 0 0;
  padding-left: 1.25rem;
  word-break: break-word;
}

.confirm-file-list li {
  margin-bottom: 0.25rem;
}

.confirm-prompt {
  margin-top: 0.25rem;
  padding: 0.75rem;
  background: #f3f4f6;
  border-radius: 6px;
  font-size: 0.85rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.identify-prompt-modal-body {
  padding: 0.75rem;
  background: #f3f4f6;
  border-radius: 6px;
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(255, 255, 255, 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}

.loading-overlay[hidden] {
  display: none;
}

body.loading-cursor {
  cursor: wait;
}

body.loading-cursor * {
  cursor: wait !important;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #e5e7eb;
  border-top-color: #0d6efd;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loading-text {
  margin: 0;
  font-size: 1rem;
  color: #374151;
}

.identify-prompt-wrap {
  margin-top: 0.75rem;
}

.identify-prompt-label {
  display: block;
  font-weight: 500;
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
}

.identify-prompt-text {
  padding: 0.75rem;
  background: #f3f4f6;
  border-radius: 6px;
  font-size: 0.85rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.ancestor-names-wrap {
  margin-top: 0.75rem;
}

.ancestor-select-label {
  display: block;
  font-weight: 500;
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
}

.ancestor-names-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 12rem;
  overflow-y: auto;
}

.ancestor-name-option {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  cursor: pointer;
}

.ancestor-name-option input {
  margin: 0;
}

.identify-response-error {
  margin: 0;
  color: #b91c1c;
  font-size: 0.95rem;
}

.error-modal-body {
  color: #b91c1c;
  font-size: 0.95rem;
  line-height: 1.45;
}

/* Dev/troubleshooting only: remove .identify-prompt-* for production */
.identify-prompt-block {
  margin-bottom: 1rem;
  padding: 0.75rem;
  background: #f8f9fa;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
}

.identify-prompt-label {
  margin: 0 0 0.35rem 0;
  font-weight: 600;
  font-size: 0.9rem;
}

.identify-prompt-text {
  margin: 0 0 0.5rem 0;
  padding: 0.5rem;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  font-size: 0.8rem;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 12rem;
  overflow-y: auto;
}

.identify-vector-label {
  margin: 0;
  font-size: 0.85rem;
  color: #555;
}

#identifiedPeopleSection .ancestor-select-label {
  margin-bottom: 0.5rem;
}

#identifiedPeopleSection .ancestor-names-list {
  max-height: 14rem;
  overflow-y: auto;
}

.modal-actions {
  display: flex;
  gap: 0.5rem;
  padding: 1rem;
  border-top: 1px solid #e5e7eb;
}

.modal-actions .btn-secondary {
  flex: 1;
  padding: 0.5rem 0.75rem;
  font-size: 0.95rem;
  background: #f3f4f6;
  color: #374151;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

.modal-actions .btn-primary {
  flex: 1;
  padding: 0.5rem 0.75rem;
  font-size: 0.95rem;
  background: #0d6efd;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
}

.auth-methods-tabs {
  display: inline-flex;
  padding: 0.12rem;
  border-radius: 999px;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  margin-bottom: 0.75rem;
}

.auth-tab {
  border: none;
  background: transparent;
  padding: 0.4rem 0.9rem;
  font-size: 0.9rem;
  border-radius: 999px;
  color: #4b5563;
  cursor: pointer;
}

.auth-tab.active {
  background: #0d6efd;
  color: #ffffff;
}
