:root {
  --bg: #0f172a;
  --panel-bg: #1e293b;
  --fg: #f8fafc;
  --muted: #94a3b8;
  --border: #334155;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --paper-bg: #ffffff;
  --paper-fg: #1e293b;
  --paper-sidebar: #f8fafc;
  --accent: #1e293b;
}

body.dark-mode {
  --bg: #020617;
  --panel-bg: #0f172a;
  --border: #1e293b;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

body {
  background-color: var(--bg);
  color: var(--fg);
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  background-color: var(--panel-bg);
  border-bottom: 1px solid var(--border);
}

.topbar h1 {
  font-size: 1.25rem;
}

.actions {
  display: flex;
  gap: 0.5rem;
}

button {
  cursor: pointer;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--panel-bg);
  color: var(--fg);
  font-weight: 500;
  transition: all 0.2s ease;
}

button:hover {
  background: var(--border);
}

.primary-btn {
  background: var(--primary);
  color: #fff;
  border: none;
}

.primary-btn:hover {
  background: var(--primary-hover);
}

.container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  padding: 2rem;
  max-width: 1400px;
  margin: 0 auto;
  flex: 1;
}

@media (max-width: 1024px) {
  .container {
    grid-template-columns: 1fr;
  }
}

.editor {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

details {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
}

summary {
  font-weight: 600;
  cursor: pointer;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 1rem;
}

.image-upload-wrapper {
  margin-top: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
}

.image-upload-wrapper input[type="file"] {
  width: auto;
  padding: 0.2rem;
  background: transparent;
  border: none;
}

input, textarea {
  width: 100%;
  padding: 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--fg);
}

textarea {
  margin-top: 0.75rem;
  resize: vertical;
}

.dynamic-item {
  border: 1px dashed var(--border);
  padding: 1rem;
  border-radius: 6px;
  margin-top: 0.75rem;
}

.remove-btn {
  background: #ef4444;
  color: white;
  border: none;
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  margin-top: 0.5rem;
}

.add-btn {
  width: 100%;
  margin-top: 0.75rem;
  border-style: dashed;
}

.preview-wrapper {
  display: flex;
  justify-content: center;
}

.cv-paper {
  background: var(--paper-bg);
  color: var(--paper-fg);
  width: 100%;
  width: 210mm;
  min-height: 297mm;
  padding: 2.5rem;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
}

.cv-header {
  border-bottom: 2px solid var(--accent);
  padding-bottom: 0.75rem;
  margin-bottom: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.cv-header-text {
  flex: 1;
}

.cv-header h1 {
  font-size: 2rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  line-height: 1.1;
  min-height: 2.2rem;
}

.cv-role {
  font-size: 1rem;
  color: var(--primary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  min-height: 1.2rem;
}

.cv-photo-container {
  width: 85px;
  height: 85px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--accent);
  margin-left: 1rem;
  flex-shrink: 0;
}

.cv-photo-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cv-body {
  display: grid;
  grid-template-columns: 1fr 2.2fr;
  gap: 1.5rem;
  flex: 1;
}

.cv-sidebar {
  background: var(--paper-sidebar);
  padding: 1rem;
  border-radius: 4px;
  border-right: 1px solid #e2e8f0;
}

.cv-contact-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-size: 0.8rem;
  word-break: break-all;
  color: #475569;
}

.cv-section {
  margin-bottom: 1.25rem;
}

.cv-section h3 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  border-bottom: 1.5px solid #cbd5e1;
  padding-bottom: 0.2rem;
  margin-bottom: 0.6rem;
}

.entry-item {
  margin-bottom: 0.85rem;
}

.entry-header {
  display: flex;
  justify-content: space-between;
  font-weight: 600;
  font-size: 0.9rem;
}

.entry-sub {
  color: #64748b;
  font-size: 0.8rem;
  font-weight: 500;
  margin-bottom: 0.2rem;
}

.entry-desc {
  font-size: 0.8rem;
  color: #334155;
  white-space: pre-line;
}

.skills-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.skill-badge {
  background: #e2e8f0;
  color: #1e293b;
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  font-size: 0.75rem;
  font-weight: 600;
}

.references-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.ref-item {
  font-size: 0.8rem;
}

.ref-name {
  font-weight: 600;
  color: #0f172a;
}

.ref-detail {
  color: #64748b;
  font-size: 0.75rem;
}

.site-footer {
  text-align: center;
  padding: 1.5rem;
  background-color: var(--panel-bg);
  border-top: 1px solid var(--border);
  margin-top: auto;
  font-size: 0.875rem;
  color: var(--muted);
}

.site-footer a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}

.site-footer a:hover {
  text-decoration: underline;
}

@media print {
  body {
    background: white;
  }
  .topbar, .editor, .site-footer {
    display: none !important;
  }
  .container {
    display: block;
    padding: 0;
  }
  .preview-wrapper {
    width: 100%;
  }
  .cv-paper {
    box-shadow: none;
    padding: 0;
    width: 100%;
  }
}