:root {
  color-scheme: light;
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #eceff3;
  --text: #1f252b;
  --muted: #64707d;
  --line: #d8dee6;
  --brand: #136f63;
  --brand-strong: #0d4f48;
  --accent: #b85d2c;
  --danger: #b3261e;
  --shadow: 0 18px 45px rgba(24, 34, 43, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
  letter-spacing: 0;
}

img {
  display: block;
  max-width: 100%;
}

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

button,
input,
textarea {
  font: inherit;
}

.site-body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    linear-gradient(180deg, rgba(246, 244, 239, 0.96), rgba(246, 244, 239, 1)),
    url("data:image/svg+xml,%3Csvg width='160' height='160' viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='%23d6d0c4' stroke-width='1'%3E%3Cpath d='M0 80h160M80 0v160'/%3E%3C/g%3E%3C/svg%3E");
}

.site-header,
.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 36px 0 24px;
}

.site-header h1,
.admin-header h1 {
  margin: 0;
  font-size: clamp(32px, 5vw, 58px);
  line-height: 1;
}

.admin-header h1 {
  font-size: clamp(28px, 4vw, 42px);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.admin-link {
  border-bottom: 1px solid currentColor;
  color: var(--muted);
  font-size: 14px;
}

.announcement-board {
  display: grid;
  gap: 8px;
  width: min(760px, 100%);
  margin-top: 16px;
}

.announcement-board p {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 0;
  padding: 11px 13px;
  border: 1px solid rgba(19, 111, 99, 0.24);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  color: #2f3a35;
  box-shadow: 0 10px 28px rgba(24, 34, 43, 0.08);
}

.announcement-board span {
  flex: 0 0 auto;
  color: var(--brand);
  font-size: 13px;
  font-weight: 800;
}

.front-search {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 10px;
  width: min(760px, 100%);
  margin-top: 14px;
}

.front-search input {
  min-width: 0;
  flex: 1;
  height: 42px;
  padding: 0 12px;
  border: 1px solid rgba(31, 37, 43, 0.14);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.88);
  color: var(--text);
  box-shadow: 0 8px 22px rgba(24, 34, 43, 0.07);
}

.front-search .button {
  flex: 0 0 auto;
  white-space: nowrap;
}

.gallery-wrap {
  flex: 1 0 auto;
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 8px 0 36px;
}

.work-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 22px;
  align-items: start;
}

.work-card {
  overflow: hidden;
  border: 1px solid rgba(31, 37, 43, 0.1);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 12px 34px rgba(24, 34, 43, 0.08);
  content-visibility: auto;
  contain-intrinsic-size: 390px 430px;
}

.image-button {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
}

.image-button img,
.image-placeholder {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #dfe4e9;
}

.image-button img {
  height: auto;
}

.deferred-image {
  opacity: 0;
}

.image-placeholder,
.thumb.empty {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.work-copy {
  padding: 18px;
}

.work-copy h2 {
  margin: 0;
  font-size: 19px;
  line-height: 1.25;
}

.work-copy p {
  display: -webkit-box;
  margin: 10px 0 0;
  overflow: hidden;
  color: var(--muted);
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(12, 16, 20, 0.88);
}

.lightbox.open {
  display: flex;
}

.lightbox figure {
  width: min(100%, 1100px);
  max-height: 92vh;
  margin: 0;
}

.lightbox img {
  width: 100%;
  max-height: 84vh;
  object-fit: contain;
}

.lightbox figcaption {
  min-height: 24px;
  padding-top: 12px;
  color: #f6f4ef;
  text-align: center;
}

.lightbox-close {
  position: fixed;
  top: 18px;
  right: 18px;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  cursor: pointer;
  font-size: 30px;
  line-height: 1;
}

.admin-body {
  min-height: 100vh;
  background: #f4f6f8;
}

.admin-actions,
.inline-actions,
.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.admin-main {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding-bottom: 56px;
}

.admin-main.narrow {
  width: min(820px, calc(100% - 40px));
}

.button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 7px;
  cursor: pointer;
  font-weight: 750;
  line-height: 1;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}

.button:hover,
.icon-button:hover {
  transform: translateY(-1px);
}

.button {
  padding: 0 16px;
}

.button.small {
  min-height: 34px;
  padding: 0 12px;
  font-size: 14px;
}

.button.primary {
  background: var(--brand);
  color: #fff;
}

.button.primary:hover {
  background: var(--brand-strong);
}

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

.button.ghost {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

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

.icon-button {
  width: 36px;
  height: 36px;
  background: #fff;
  border-color: var(--line);
}

.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.35;
  transform: none;
}

.search-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
}

.admin-section {
  display: grid;
  gap: 14px;
  margin-bottom: 24px;
}

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

.section-heading h2 {
  margin: 0;
  font-size: 22px;
}

.search-bar input {
  min-width: 0;
  flex: 1;
}

.table-panel,
.edit-form,
.message-panel,
.empty-state {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.table-panel {
  overflow-x: auto;
}

.works-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

.works-table th,
.works-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.works-table th {
  background: #eef2f5;
  color: #3d4853;
  font-size: 13px;
}

.works-table tr:last-child td {
  border-bottom: 0;
}

.thumb {
  width: 88px;
  height: 62px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--surface-2);
}

.muted {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.edit-form {
  display: grid;
  gap: 18px;
  padding: 24px;
}

.edit-form label {
  display: grid;
  gap: 7px;
  color: #303942;
  font-weight: 750;
}

.edit-form input,
.edit-form textarea,
.search-bar input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
}

.edit-form input,
.search-bar input {
  height: 42px;
  padding: 0 12px;
}

.edit-form input[type="file"] {
  height: auto;
  padding: 10px 12px;
}

.edit-form textarea {
  resize: vertical;
  padding: 10px 12px;
}

.field-grid {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(220px, 2fr);
  gap: 18px;
}

.announcement-form {
  box-shadow: none;
}

.compact-form {
  box-shadow: none;
}

.announcement-options {
  align-items: end;
}

.checkbox-field {
  display: flex !important;
  flex-direction: row;
  align-items: center;
  gap: 10px !important;
  min-height: 42px;
  padding-bottom: 2px;
}

.checkbox-field input {
  width: 18px;
  height: 18px;
}

.announcement-list {
  display: grid;
  gap: 10px;
}

.announcement-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.announcement-item p {
  margin: 0;
}

.cover-preview {
  margin: 0;
}

.cover-preview img {
  width: min(100%, 380px);
  max-height: 260px;
  border-radius: 8px;
  object-fit: cover;
}

.alert {
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid #efb7b2;
  border-radius: 8px;
  background: #fff2f0;
  color: #8f1d16;
}

.empty-state {
  padding: 40px;
  text-align: center;
}

.empty-state.compact {
  box-shadow: none;
}

.empty-state h2,
.message-panel h1 {
  margin: 0 0 8px;
}

.empty-state p,
.message-panel p {
  margin: 0;
  color: var(--muted);
}

.search-empty {
  margin-top: 22px;
}

.site-footer {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px 24px;
  width: min(1180px, calc(100% - 40px));
  margin: 4px auto 0;
  padding: 20px 0 30px;
  color: #52606c;
  font-size: 13px;
}

.site-footer::before {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 1px;
  background: linear-gradient(90deg, rgba(19, 111, 99, 0), rgba(19, 111, 99, 0.32), rgba(184, 93, 44, 0.28), rgba(19, 111, 99, 0));
  content: "";
}

.site-footer p {
  margin: 0;
}

.site-footer p:first-child {
  color: var(--brand-strong);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.site-footer p:last-child {
  justify-self: end;
  text-align: right;
}

.center-body {
  display: grid;
  place-items: center;
  padding: 24px;
}

.message-panel {
  width: min(460px, 100%);
  padding: 28px;
  text-align: center;
}

.message-panel .button {
  margin-top: 20px;
}

@media (max-width: 680px) {
  .site-header,
  .admin-header {
    align-items: flex-start;
    flex-direction: column;
    width: min(100% - 28px, 1180px);
    padding-top: 26px;
  }

  .gallery-wrap,
  .admin-main,
  .admin-main.narrow {
    width: min(100% - 28px, 1180px);
  }

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

  .search-bar {
    flex-wrap: wrap;
  }

  .site-footer {
    grid-template-columns: 1fr;
    align-items: start;
    width: min(100% - 28px, 1180px);
    gap: 6px;
    padding: 16px 0 24px;
  }

  .site-footer p:last-child {
    justify-self: start;
    text-align: left;
  }

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

  .edit-form {
    padding: 18px;
  }
}
