:root {
  --bg: #0f0f0f;
  --bg-card: #1a1a1a;
  --text: #e8e8e8;
  --text-muted: #888;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --border: #2a2a2a;
  --success: #22c55e;
  --error: #ef4444;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
}

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

.header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0 0 0.25rem 0;
  letter-spacing: -0.02em;
}

.tagline {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin: 0 0 1rem 0;
}

.auth-status {
  font-size: 0.875rem;
}

.auth-status .logged-in {
  color: var(--success);
}

.auth-status a {
  color: var(--accent);
  text-decoration: none;
}

.auth-status a:hover {
  text-decoration: underline;
}

.lang-selector {
  position: absolute;
  top: 1rem;
  right: 1.5rem;
}

.lang-select {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
  font-size: 0.875rem;
  cursor: pointer;
}

.lang-select:hover {
  border-color: var(--accent);
}

.main {
  flex: 1;
}

.section {
  margin-bottom: 1.5rem;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
}

.status-link {
  display: inline-block;
  margin-bottom: 1rem;
  padding: 0.5rem 1rem;
  background: var(--bg);
  border: 1px solid var(--accent);
  color: var(--accent);
  text-decoration: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 500;
}

.status-link:hover {
  background: var(--accent);
  color: white;
}

.nav-links {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.resume-hint {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin: -0.5rem 0 0.75rem 0;
}

.optional-hint {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0.75rem 0 0.25rem 0;
}

.resume-upload-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.file-label {
  padding: 0.5rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  color: var(--text-muted);
}

.file-label:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.file-input {
  font-size: 0.85rem;
  color: var(--text);
}

.file-input::file-selector-button {
  padding: 0.4rem 0.75rem;
  background: var(--border);
  border: none;
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
}

.file-name {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.resume-divider {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
  margin: 0.25rem 0;
}

.resume-sections {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin: 1rem 0;
}
.resume-sections label {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
}
.resume-sections textarea {
  width: 100%;
  min-height: 4rem;
}

.tailored-list {
  margin-top: 1rem;
}
.tailored-item {
  margin-bottom: 1rem;
  padding: 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.tailored-item summary {
  cursor: pointer;
  font-size: 0.95rem;
}
.tailored-date {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: normal;
}

.result-rationale {
  font-size: 0.95rem;
  color: var(--text);
  line-height: 1.5;
}

.cover-letter-text {
  white-space: pre-wrap;
  font-size: 0.9rem;
  line-height: 1.6;
  padding: 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-top: 0.5rem;
  max-height: 400px;
  overflow-y: auto;
}
.tailored-text {
  margin: 1rem 0 0.5rem 0;
  padding: 1rem;
  background: var(--bg-card);
  border-radius: 6px;
  font-size: 0.85rem;
  white-space: pre-wrap;
  max-height: 300px;
  overflow-y: auto;
}
.tailored-item .copy-btn {
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  background: var(--border);
  color: var(--text);
  border: none;
  border-radius: 6px;
  cursor: pointer;
}
.tailored-item .copy-btn:hover {
  background: var(--accent);
  color: white;
}

.profile-form .form-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.profile-form .form-row input.short {
  flex: 0 0 80px;
}

.card h2 {
  font-size: 1.125rem;
  font-weight: 600;
  margin: 0 0 1rem 0;
}

.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.tab {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
}

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

.tab.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.form input,
.form textarea {
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
}

.form input::placeholder,
.form textarea::placeholder {
  color: var(--text-muted);
}

.form textarea {
  resize: vertical;
  min-height: 120px;
}

.form button {
  padding: 0.75rem 1.25rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
}

.form button:hover {
  background: var(--accent-hover);
}

.form button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.secondary-btn {
  padding: 0.5rem 1rem;
  background: var(--border);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}
.secondary-btn:hover {
  background: var(--bg-card);
  border-color: var(--accent);
  color: var(--accent);
}
.secondary-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.tailored-cta {
  margin-top: 1rem;
  margin-bottom: 0.25rem;
}

.tailored-sections {
  margin-top: 1.5rem;
  margin-bottom: 1rem;
}
.tailored-sections .tailored-block {
  margin-bottom: 1.25rem;
  padding: 1rem;
  background: var(--bg-soft, #f5f5f5);
  border-radius: 8px;
  border: 1px solid var(--border, #e0e0e0);
}
.tailored-sections .tailored-block h4 {
  margin: 0 0 0.5rem 0;
  font-size: 1rem;
}
.tailored-sections .tailored-content {
  margin-bottom: 0.5rem;
}
.tailored-sections .tailored-text {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.9rem;
  line-height: 1.4;
}
.tailored-sections .copy-tailored-btn {
  font-size: 0.8rem;
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  border: 1px solid var(--border, #ccc);
  background: var(--bg, #fff);
  cursor: pointer;
}
.tailored-sections .copy-tailored-btn:hover {
  background: var(--bg-soft, #eee);
}

.hidden {
  display: none !important;
}

.empty-row {
  color: var(--text-muted);
  font-style: italic;
  padding: 1rem;
}

.message {
  margin-top: 1rem;
  font-size: 0.875rem;
}

.message a {
  color: var(--accent);
  text-decoration: none;
}

.message a:hover {
  text-decoration: underline;
}

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

.message.success {
  color: var(--success);
}

.analyze-progress {
  margin-top: 1rem;
  padding: 1.5rem;
  background: var(--bg);
  border-radius: 8px;
  border: 1px solid var(--border);
}
.progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 1rem;
}
.progress-fill {
  height: 100%;
  width: 30%;
  background: var(--accent);
  border-radius: 3px;
  animation: progress-indeterminate 1.5s ease-in-out infinite;
}
@keyframes progress-indeterminate {
  0% { transform: translateX(-100%); }
  50% { transform: translateX(233%); }
  100% { transform: translateX(-100%); }
}
.progress-status {
  margin: 0 0 0.25rem 0;
  font-size: 0.95rem;
}
.progress-elapsed {
  margin: 0;
  font-size: 0.85rem;
}
.progress-hint {
  margin: 0.5rem 0 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.result {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--bg);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.result h3 {
  font-size: 1rem;
  margin: 0 0 0.5rem 0;
}

.result ul {
  margin: 0;
  padding-left: 1.25rem;
}

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

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

.footer a {
  color: var(--accent);
}

/* Status page (status.html) */
.nav-links-inline {
  margin: 0.5rem 0;
  font-size: 0.9rem;
}
.nav-links-inline a {
  color: var(--accent);
  text-decoration: none;
}
.nav-links-inline a:hover {
  text-decoration: underline;
}
.back-home {
  display: inline-block;
  margin-bottom: 1rem;
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9rem;
}
.back-home:hover {
  text-decoration: underline;
}
body .container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
  position: relative;
}
body .container header {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}
.section-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 1rem;
}
.subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
th, td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
th {
  font-weight: 500;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
tr:last-child td {
  border-bottom: none;
}
tr:hover td {
  background: var(--bg-card);
}
.company {
  font-weight: 600;
}
.match {
  font-weight: 500;
  color: var(--accent);
}
.action-highlight {
  color: #d29922;
  font-weight: 500;
}
.calendar-grid {
  display: grid;
  gap: 0.5rem;
}
.calendar-item {
  display: grid;
  grid-template-columns: 100px 60px 1fr;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  align-items: center;
}
.calendar-day {
  font-weight: 600;
}
.calendar-time {
  color: var(--text-muted);
  font-size: 0.875rem;
}
.notes {
  display: grid;
  gap: 1rem;
}
.note-block {
  padding: 1rem 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.note-block h3 {
  font-size: 0.9rem;
  font-weight: 600;
  margin: 0 0 0.5rem 0;
}
.note-block p {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.6;
}
@media (max-width: 768px) {
  .calendar-item {
    grid-template-columns: 1fr;
  }
}

/* Status page: wider layout, dark table, responsive (previous “way better” look) */
.status-page .app {
  max-width: 1280px;
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}
.status-page .header {
  text-align: left;
  margin-bottom: 1.5rem;
}
.status-page .header h1 {
  font-size: 1.5rem;
}
.status-content {
  margin-top: 0;
}
.status-content h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 0.35rem 0;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border);
  letter-spacing: -0.02em;
}
.status-content h1 + p {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0 0 1.25rem 0;
}
.status-content h2 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  margin: 1.5rem 0 0.6rem 0;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.status-content table {
  width: 100%;
  margin-bottom: 1.25rem;
  border-collapse: collapse;
  font-size: 0.875rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.status-content th,
.status-content td {
  padding: 0.65rem 0.85rem;
  text-align: left;
  border: 1px solid var(--border);
  vertical-align: top;
}
.status-content th {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(0, 0, 0, 0.25);
  white-space: nowrap;
}
.status-content tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}
.status-content tr:last-child td {
  border-bottom: 1px solid var(--border);
}
.status-content p {
  font-size: 0.9rem;
  color: var(--text);
  margin: 0.5rem 0;
  line-height: 1.55;
}
.status-content p strong {
  color: var(--text);
}
/* Responsive: horizontal scroll for wide tables on small screens */
.status-content {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.status-content table {
  min-width: 700px;
}
.nav-links-inline {
  font-size: 0.9rem;
  margin: 0 0 1rem 0;
}
.nav-links-inline a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}
.nav-links-inline a:hover {
  text-decoration: underline;
}
.status-page .back-home {
  display: inline-block;
  margin-bottom: 0.5rem;
}

/* Discuss this analysis – chat section */
.chat-section {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.chat-section h4 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 0.35rem 0;
}
.chat-messages {
  max-height: 200px;
  overflow-y: auto;
  margin: 0.75rem 0;
  padding: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
}
.chat-msg {
  margin-bottom: 0.75rem;
  line-height: 1.45;
}
.chat-msg:last-child {
  margin-bottom: 0;
}
.chat-msg strong {
  display: block;
  margin-bottom: 0.25rem;
  color: var(--text-muted);
  font-size: 0.8rem;
}
.chat-form {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
  margin-top: 0.5rem;
}
.chat-form textarea {
  flex: 1;
  min-height: 60px;
  padding: 0.5rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  resize: vertical;
}
.chat-form textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.chat-form button {
  flex-shrink: 0;
}
