:root {
  color-scheme: light;
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-strong: #f0eee8;
  --text: #171717;
  --muted: #65635f;
  --line: #dedbd2;
  --accent: #0d766e;
  --accent-dark: #075e58;
  --danger: #b42318;
  --shadow: 0 18px 50px rgba(31, 28, 22, 0.1);
  --radius: 8px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  background:
    linear-gradient(90deg, rgba(13, 118, 110, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(26, 26, 26, 0.06) 1px, transparent 1px), var(--bg);
  background-size: 48px 48px;
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

a {
  color: inherit;
}

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

.app-shell {
  width: min(1440px, calc(100% - 32px));
  min-height: 100dvh;
  margin: 0 auto;
  padding: 28px 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 0.95;
  letter-spacing: 0;
}

h2 {
  font-size: 1.35rem;
  line-height: 1.15;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 420px);
  gap: 18px;
  align-items: start;
}

.panel {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.library-panel {
  min-height: calc(100dvh - 142px);
  padding: 18px;
}

.detail-panel {
  position: sticky;
  top: 18px;
  min-height: 520px;
  padding: 18px;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px;
  gap: 10px;
}

.search-field,
.project-form label {
  display: grid;
  gap: 7px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  outline: none;
}

input,
select {
  height: 42px;
  padding: 0 12px;
}

textarea {
  resize: vertical;
  padding: 10px 12px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13, 118, 110, 0.16);
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0 18px;
}

.stats div {
  min-height: 72px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
}

.stats span {
  display: block;
  font-size: 1.7rem;
  font-weight: 800;
}

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

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.project-card {
  display: grid;
  gap: 12px;
  min-height: 288px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: left;
  color: inherit;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.project-card:hover,
.project-card:focus-visible,
.project-card.active {
  border-color: var(--accent);
  box-shadow: 0 12px 26px rgba(13, 118, 110, 0.14);
  transform: translateY(-2px);
}

.thumb,
.preview-frame {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(13, 118, 110, 0.26), transparent 46%),
    linear-gradient(45deg, rgba(180, 35, 24, 0.16), transparent 52%),
    #e8e2d3;
}

.thumb {
  aspect-ratio: 16 / 10;
}

.preview-frame {
  aspect-ratio: 16 / 10;
  margin-bottom: 16px;
  border: 1px solid var(--line);
}

.thumb img,
.preview-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.thumb-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  color: rgba(23, 23, 23, 0.72);
  font-size: clamp(1.7rem, 8vw, 3rem);
  font-weight: 900;
  line-height: 1;
  text-align: center;
}

.card-body {
  display: grid;
  gap: 8px;
}

.card-topline,
.detail-heading,
.form-header,
.form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.project-card h3 {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.2;
}

.project-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.status-pill {
  width: fit-content;
  margin: 0;
  padding: 5px 8px;
  border-radius: 999px;
  background: #e7f2f0;
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 800;
}

.status-draft {
  background: #ebe9e0;
  color: #5b584f;
}

.status-ready {
  background: #e8f3e3;
  color: #28633b;
}

.status-archived {
  background: #f7e8e5;
  color: var(--danger);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  max-width: 100%;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.8rem;
  overflow-wrap: anywhere;
}

.detail-empty,
.empty-state {
  min-height: 300px;
  display: grid;
  align-content: center;
  justify-items: start;
  gap: 10px;
  color: var(--muted);
}

.empty-state {
  min-height: 420px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 28px;
}

.detail-empty h2,
.empty-state h2 {
  color: var(--text);
  margin-bottom: 0;
}

.project-detail h2 {
  margin-bottom: 0;
}

.detail-description {
  color: var(--muted);
  line-height: 1.55;
}

.meta-list {
  display: grid;
  gap: 10px;
  margin: 18px 0;
}

.meta-list div {
  display: grid;
  gap: 4px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.meta-list dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.meta-list dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.notes-block {
  margin-bottom: 18px;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--surface-strong);
}

.notes-block h3 {
  margin-bottom: 6px;
  font-size: 0.95rem;
}

.notes-block p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.5;
  white-space: pre-wrap;
}

.primary-button,
.secondary-button,
.primary-link,
.icon-button {
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-weight: 800;
  text-decoration: none;
}

.primary-button,
.secondary-button,
.primary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 14px;
}

.primary-button,
.primary-link {
  background: var(--accent);
  color: #fff;
}

.primary-button:hover,
.primary-link:hover {
  background: var(--accent-dark);
}

.secondary-button {
  background: #fff;
  border-color: var(--line);
  color: var(--text);
}

.secondary-button:hover,
.icon-button:hover {
  border-color: var(--accent);
}

.icon-actions {
  display: flex;
  gap: 8px;
}

.icon-button {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  background: #fff;
  border-color: var(--line);
  color: var(--text);
  font-size: 1.2rem;
}

.icon-button.danger {
  color: var(--danger);
}

.project-dialog {
  width: min(620px, calc(100% - 24px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.project-dialog::backdrop {
  background: rgba(23, 23, 23, 0.32);
}

.project-form {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.project-form span {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 800;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 980px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .detail-panel {
    position: static;
    min-height: auto;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 20px, 1440px);
    padding: 16px 0;
  }

  .topbar,
  .detail-heading,
  .form-header {
    align-items: flex-start;
  }

  .toolbar,
  .stats,
  .form-row {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
  }

  .primary-button,
  .secondary-button,
  .primary-link {
    width: 100%;
  }

  .project-grid {
    grid-template-columns: 1fr;
  }
}
