@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;600;700&family=Source+Sans+3:wght@400;600;700&family=Montserrat:wght@400;600;700&family=Merriweather:wght@400;700&family=Work+Sans:wght@400;600;700&display=swap');

:root {
  --bg: #e9eef4;
  --surface: #f7f9fc;
  --surface-alt: #edf1f6;
  --border: #cfd7e3;
  --text: #1b2533;
  --muted: #4a5565;
  --accent: #0f4a7f;
  --accent-weak: #dde7f2;
  --danger: #b42318;
  --shadow: 0 12px 28px rgba(16, 24, 40, 0.12);
  --panel-shadow: 0 1px 0 rgba(16, 24, 40, 0.04), 0 12px 24px rgba(16, 24, 40, 0.06);
  --header-height: 64px;
}

body.theme-dark {
  color-scheme: dark;
  --bg: #0f1722;
  --surface: #15202c;
  --surface-alt: #1b2734;
  --border: #2a3846;
  --text: #e4e9f0;
  --muted: #a2adbb;
  --accent: #5b8db8;
  --accent-weak: #1f2f3d;
  --danger: #f97066;
  --shadow: 0 14px 30px rgba(0, 0, 0, 0.45);
  --panel-shadow: 0 1px 0 rgba(255, 255, 255, 0.04), 0 14px 28px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "IBM Plex Sans", "Source Sans 3", "Segoe UI", "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
}

a {
  color: inherit;
  text-decoration: none;
}

.editor-header {
  height: var(--header-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  box-shadow: 0 1px 0 rgba(16, 24, 40, 0.04);
}

.header-inner {
  width: 100%;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 24px;
  background: var(--accent);
  color: #fff;
  padding: 0 10px;
  border-radius: 8px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 0;
}

.brand-mark img {
  height: 16px;
  width: auto;
  display: block;
}

.brand-text {
  font-size: 16px;
}

.theme-toggle {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.08);
  transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
  stroke: var(--muted);
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.theme-toggle:hover {
  background: var(--surface-alt);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(16, 24, 40, 0.12);
}

.theme-toggle:focus-visible {
  outline: 2px solid rgba(15, 74, 127, 0.35);
  outline-offset: 2px;
}

.theme-toggle .icon-sun {
  display: inline;
}

.theme-toggle .icon-moon {
  display: none;
}

.language-form {
  margin: 0;
}

.language-select {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  height: 38px;
  min-width: 0;
  width: auto;
  padding: 0 12px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  line-height: 1;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
}

.language-select:focus-visible {
  outline: 2px solid rgba(15, 74, 127, 0.35);
  outline-offset: 2px;
}

body.theme-dark .theme-toggle {
  background: #1b2734;
  border-color: #2a3846;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
}

body.theme-dark .theme-toggle:hover {
  background: #223244;
}

body.theme-dark .theme-toggle:focus-visible {
  outline-color: rgba(91, 141, 184, 0.5);
}

body.theme-dark .theme-toggle .icon-sun {
  display: none;
}

body.theme-dark .theme-toggle .icon-moon {
  display: inline;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.nav-item {
  padding: 8px 12px;
  border-radius: 6px;
  font-weight: 600;
  color: var(--text);
}

.nav-item:hover {
  background: var(--surface-alt);
}

.user-area {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.user-dropdown summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  font-weight: 600;
}

.user-dropdown summary::-webkit-details-marker {
  display: none;
}

.user-dropdown[open] summary {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(15, 74, 127, 0.12);
}

.chevron {
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--muted);
  transition: transform 0.2s ease;
}

.user-dropdown[open] .chevron {
  transform: rotate(180deg);
}

.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 20;
}

.dropdown-item {
  padding: 8px 10px;
  border-radius: 6px;
  font-weight: 500;
  color: var(--text);
}

.dropdown-item:hover {
  background: var(--surface-alt);
}

.dropdown-item:last-child {
  color: var(--danger);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.projects-page {
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.projects-toolbar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--panel-shadow);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.banner {
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  overflow: hidden;
}

.banner.success {
  border-color: rgba(34, 197, 94, 0.35);
  background: rgba(34, 197, 94, 0.12);
  color: #166534;
}

body.theme-dark .banner.success {
  color: #86efac;
}

.banner.warning {
  border-color: rgba(245, 158, 11, 0.4);
  background: rgba(245, 158, 11, 0.12);
  color: #92400e;
}

body.theme-dark .banner.warning {
  color: #fcd34d;
}

.banner[data-autohide] {
  animation: bannerFade 0.35s ease 3s forwards;
}

@keyframes bannerFade {
  to {
    opacity: 0;
    max-height: 0;
    margin: 0;
    padding: 0;
    border-width: 0;
  }
}

.projects-toolbar h1 {
  margin: 0 0 4px;
}

.subtitle {
  margin: 0;
  color: var(--muted);
}

.new-project-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.inline-label {
  font-weight: 600;
  color: var(--muted);
}

.form-row input,
.form-row select {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  font-family: inherit;
}

.lang-row {
  align-items: flex-start;
}

.hint {
  color: var(--muted);
  font-weight: 600;
}

.lang-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.lang-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  font-size: 12px;
  cursor: pointer;
}

.lang-pill input {
  margin: 0;
}

.lang-pill.is-main {
  border-color: var(--accent);
  background: var(--accent-weak);
  color: var(--text);
}

.tag-select-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 180px;
  overflow-y: auto;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-alt);
}

.tag-option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
}

.tag-option input {
  margin: 0;
}

.tag-count {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.success-note {
  margin: 0;
  font-weight: 600;
  color: var(--accent);
}

.projects-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.section-title {
  margin: 0;
  font-size: 16px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.project-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  box-shadow: var(--panel-shadow);
}

.project-card.shared {
  border-color: rgba(37, 99, 235, 0.45);
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.15), var(--panel-shadow);
}

.project-card.inactive {
  opacity: 0.7;
}

.project-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.project-main {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.project-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  font-weight: 700;
  font-size: 16px;
}

.project-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #1d4ed8;
  background: rgba(37, 99, 235, 0.14);
  border: 1px solid rgba(37, 99, 235, 0.24);
}

body.theme-dark .project-badge {
  color: #93c5fd;
}

.project-meta {
  color: var(--muted);
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 13px;
}

.project-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.expand-btn {
  border: 1px solid var(--border);
  background: var(--surface-alt);
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  font-weight: 600;
}

.expand-btn.open {
  transform: rotate(90deg);
}

.project-details {
  margin-top: 16px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.details-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.details-block h3 {
  margin-top: 0;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.share-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.share-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-alt);
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.share-user {
  font-size: 13px;
}

.share-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.share-permission-select {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 6px 8px;
  font-family: inherit;
  font-size: 12px;
}

.tag-list {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tag-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
}

.tag-actions {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.tag-meta {
  color: var(--muted);
  margin-left: 6px;
}

.inline-form {
  margin: 0;
}

.btn-primary,
.btn-secondary,
.btn-danger,
.btn-ghost {
  border-radius: 6px;
  border: 1px solid var(--border);
  padding: 8px 12px;
  font-weight: 600;
  cursor: pointer;
  background: var(--surface);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-secondary {
  background: var(--surface);
  color: var(--accent);
  border-color: var(--accent);
}

.btn-danger {
  background: #fff;
  color: var(--danger);
  border-color: var(--danger);
}

.btn-small {
  padding: 6px 10px;
  font-size: 12px;
}

.btn-ghost {
  background: var(--surface-alt);
}

.share-modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(8, 15, 26, 0.62);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.share-modal[hidden] {
  display: none;
}

.share-modal-panel {
  width: min(460px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.share-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.share-modal-head h3 {
  margin: 0;
}

.share-modal-close {
  border: 1px solid var(--border);
  border-radius: 999px;
  width: 32px;
  height: 32px;
  background: var(--surface-alt);
  color: var(--muted);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

.share-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.share-field input,
.share-field select {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-alt);
  color: var(--text);
  padding: 10px 12px;
  font-family: inherit;
}

.share-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.empty-state {
  text-align: center;
  padding: 40px;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 12px;
}

.muted {
  color: var(--muted);
}

/* TOGGLE */
.toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.toggle-input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-track {
  position: relative;
  width: 38px;
  height: 20px;
  cursor: pointer;
  background: #2f2f2f;
  border-radius: 999px;
  transition: all 0.2s ease;
}

.toggle-track:before {
  content: "";
  position: absolute;
  height: 16px;
  width: 16px;
  left: 2px;
  top: 2px;
  background: white;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.toggle-input:checked + .toggle-track {
  background: #22c55e;
}

.toggle-input:checked + .toggle-track:before {
  transform: translateX(18px);
}

.toggle-text {
  position: relative;
  width: 28px;
  height: 16px;
}

.toggle-label {
  position: absolute;
  left: 0;
  top: 0;
  font-size: 11px;
  font-weight: 700;
  line-height: 16px;
  display: none;
}

.toggle-input:checked ~ .toggle-text .toggle-label.on {
  display: block;
  color: #16a34a;
}

.toggle-input:checked ~ .toggle-text .toggle-label.off {
  display: none;
}

.toggle-input:not(:checked) ~ .toggle-text .toggle-label.on {
  display: none;
}

.toggle-input:not(:checked) ~ .toggle-text .toggle-label.off {
  display: block;
  color: #374151;
}

@media (max-width: 900px) {
  .project-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .project-actions {
    width: 100%;
  }
}

.footer {
  background: #101826;
  color: #d4dbe4;
  padding: 40px 28px;
  margin-top: 48px;
}

.footer-grid {
  display: grid;
  gap: 24px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.footer a {
  color: #c6d2e3;
  display: block;
  margin-top: 6px;
}

.footer .socials {
  display: flex;
  gap: 10px;
  margin-top: 10px;
  font-size: 12px;
}
