:root {
  --ink: #251b17;
  --paper: #f3e7c6;
  --paper-deep: #dfc995;
  --red: #b93427;
  --green: #265c46;
  --yellow: #e6aa20;
  --white: #fffaf0;
  --shadow: 5px 5px 0 var(--ink);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--paper); }
html.modal-open { overflow: hidden; }
body {
  min-height: 100vh; margin: 0; color: var(--ink);
  font-family: "Yu Gothic", "Hiragino Kaku Gothic ProN", system-ui, sans-serif;
  background-color: var(--paper);
  background-image: radial-gradient(rgba(37, 27, 23, .1) 1px, transparent 1px);
  background-size: 7px 7px;
}
button, input, textarea { font: inherit; }
select { font: inherit; }
button { color: inherit; }
[hidden] { display: none !important; }

main { width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 28px 0 80px; }
.eyebrow { margin: 0 0 4px; font: 800 11px/1.2 ui-monospace, monospace; letter-spacing: .18em; color: var(--red); }
h1 { margin: 0; font-family: serif; font-size: clamp(30px, 5vw, 52px); letter-spacing: .08em; }

.login {
  width: min(460px, 100%); margin: max(7vh, 40px) auto 0; padding: 44px;
  border: 3px solid var(--ink); background: var(--white); box-shadow: 10px 10px 0 var(--ink);
}
.login__mark {
  display: grid; place-items: center; width: 68px; height: 68px; margin-bottom: 24px;
  border: 3px solid var(--ink); border-radius: 50%; background: var(--red); color: var(--white);
  font: 900 34px/1 serif; transform: rotate(-5deg);
}
.login__lead { margin: 10px 0 26px; }
.login form { display: grid; gap: 10px; }
label { display: grid; gap: 7px; font-weight: 800; font-size: 14px; }
input, textarea {
  width: 100%; border: 2px solid var(--ink); border-radius: 0; background: var(--white);
  padding: 11px 12px; outline: none;
}
input:focus, textarea:focus { box-shadow: 0 0 0 3px var(--yellow); }
textarea { resize: vertical; line-height: 1.65; }
.login button, .button {
  border: 2px solid var(--ink); background: var(--yellow); padding: 10px 16px;
  font-weight: 900; cursor: pointer; box-shadow: 3px 3px 0 var(--ink);
}
.login button { margin-top: 8px; }
button:disabled { cursor: wait; opacity: .48; box-shadow: none; }
.message { min-height: 1.5em; color: var(--red); font-weight: 800; }

.sync-alert {
  margin: 0 0 20px; padding: 18px 20px; border: 4px solid var(--ink);
  background: var(--red); color: var(--white); box-shadow: 7px 7px 0 var(--ink);
  font-size: clamp(15px, 2vw, 18px); font-weight: 900; line-height: 1.65;
}
.sync-alert__detail { margin: 8px 0 0; font-size: 13px; font-weight: 800; }

.editor__header {
  display: flex; justify-content: space-between; align-items: end; gap: 24px;
  padding-bottom: 20px; border-bottom: 4px double var(--ink);
}
.editor__status, .toolbar__actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.status { border: 2px solid var(--ink); background: var(--paper-deep); padding: 6px 10px; font-size: 12px; font-weight: 900; }
.status--dirty { background: var(--yellow); }
.status--warning {
  border-color: var(--ink); background: var(--red); color: var(--white);
  box-shadow: 3px 3px 0 var(--ink); font-size: 13px;
}
.button--quiet { background: var(--white); }
.button--publish { background: var(--green); color: var(--white); }
.toolbar {
  position: sticky; top: 0; z-index: 10; display: flex; justify-content: space-between; align-items: center;
  gap: 18px; margin: 22px 0; padding: 14px 16px; border: 2px solid var(--ink);
  background: rgba(243, 231, 198, .96); box-shadow: var(--shadow); backdrop-filter: blur(6px);
}
.toolbar p { margin: 0; }
.notice { margin: 0 0 20px; padding: 13px 16px; border: 2px solid var(--ink); background: var(--white); font-weight: 800; }
.notice--error { background: #f5c2ba; }
.notice--publish { background: #b9dbc9; }
.notice--warning {
  padding: 18px 20px; border: 4px solid var(--ink); background: var(--red); color: var(--white);
  box-shadow: 7px 7px 0 var(--ink); font-size: clamp(15px, 2vw, 18px); font-weight: 900; line-height: 1.65;
}
.projects { display: grid; gap: 22px; }
.project {
  display: grid; grid-template-columns: 54px 230px 1fr; min-width: 0;
  border: 3px solid var(--ink); background: var(--white); box-shadow: var(--shadow);
}
.project__rail {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 14px 8px; border-right: 2px solid var(--ink); background: var(--green); color: var(--white);
}
.project__number { margin-bottom: auto; font: 900 19px/1 ui-monospace, monospace; }
.icon-button {
  width: 32px; height: 32px; border: 2px solid var(--ink); background: var(--paper); cursor: pointer; font-weight: 900;
}
.project__image { padding: 16px; border-right: 2px dashed var(--ink); }
.image-preview {
  display: grid; place-items: center; width: 100%; aspect-ratio: 4 / 3; overflow: hidden;
  border: 2px solid var(--ink); background: repeating-linear-gradient(135deg, var(--paper), var(--paper) 10px, var(--paper-deep) 10px, var(--paper-deep) 20px);
  color: rgba(37, 27, 23, .6); font-weight: 900;
}
.image-preview img { width: 100%; height: 100%; object-fit: cover; }
.upload-button {
  display: block; margin-top: 12px; border: 2px solid var(--ink); background: var(--yellow);
  padding: 8px; text-align: center; cursor: pointer;
}
.upload-button input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.image-remove, .delete-button { border: 0; background: transparent; color: var(--red); text-decoration: underline; cursor: pointer; }
.image-remove { display: block; margin: 10px auto 0; font-size: 12px; }
.project__fields { display: grid; gap: 14px; padding: 18px; min-width: 0; }
.project__fields small { font-weight: 400; }
.delete-button { justify-self: end; margin-top: 4px; }
.project__actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.panel {
  margin-top: 28px; padding: 22px; border: 3px solid var(--ink); background: var(--white);
  box-shadow: var(--shadow);
}
.modal {
  width: min(860px, calc(100vw - 32px)); max-width: none; max-height: min(820px, calc(100dvh - 32px));
  margin: auto; overflow: auto;
}
.modal::backdrop { background: rgba(37, 27, 23, .58); }
.modal-notice { margin: 16px 0 0; }
.panel > header { display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 2px solid var(--ink); padding-bottom: 14px; }
.panel h2, .panel h3 { margin: 0; font-family: serif; }
.account-form { display: grid; gap: 12px; margin: 20px 0; padding: 18px; border: 2px dashed var(--ink); }
.account-form select { width: 100%; min-height: 42px; border: 2px solid var(--ink); background: var(--white); padding: 7px; }
.account-form select[multiple] { min-height: 100px; }
#accounts-list { display: grid; gap: 14px; }
#audit-list { max-height: 480px; overflow: auto; margin: 18px 0; border: 2px solid var(--ink); background: var(--paper); }
#audit-list p { margin: 0; padding: 10px; border-bottom: 1px solid var(--paper-deep); font: 12px/1.5 ui-monospace, monospace; overflow-wrap: anywhere; }
#account-label { font-size: 12px; font-weight: 900; }

@media (max-width: 760px) {
  main { width: min(100% - 20px, 560px); padding-top: 14px; }
  .login { padding: 28px 22px; box-shadow: 6px 6px 0 var(--ink); }
  .editor__header, .toolbar { align-items: flex-start; flex-direction: column; }
  .toolbar { position: static; }
  .toolbar__actions { width: 100%; }
  .toolbar__actions .button { flex: 1 1 140px; }
  .project { grid-template-columns: 46px 1fr; }
  .project__rail { grid-row: 1 / 3; }
  .project__image { border-right: 0; border-bottom: 2px dashed var(--ink); }
  .modal { width: calc(100vw - 20px); max-height: calc(100dvh - 20px); margin: auto; padding: 16px; box-shadow: 5px 5px 0 var(--ink); }
}

@media (max-width: 420px) {
  .project { grid-template-columns: 42px minmax(0, 1fr); }
  .project__image, .project__fields { padding: 12px; }
  .editor__status { align-items: flex-end; flex-direction: column; }
}
