@font-face {
  font-family: 'EB Garamond';
  src: url('fonts/EBGaramond-SemiBold.ttf') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Fira Sans';
  src: url('fonts/FiraSans-Regular.ttf') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Fira Sans';
  src: url('fonts/FiraSans-Medium.ttf') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Fira Sans';
  src: url('fonts/FiraSans-SemiBold.ttf') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #C0C0C0;
  --surface: #FFFEFB;
  --ink: #1A1A1A;
  --muted: #6B6B6B;
  --hairline: #D8D2C4;
  --hairline-strong: #B8AF98;
  --accent: #7A2E1F;
  --accent-soft: #F3E5DF;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

.wrap {
  max-width: 780px;
  margin: 0 auto;
  padding: 48px 24px 96px;
}

header {
  border-bottom: 1px solid var(--hairline);
  padding-bottom: 24px;
  margin-bottom: 32px;
}

h1 {
  font-family: 'Lora', serif;
  font-weight: 600;
  font-size: 32px;
  margin: 0 0 8px;
  letter-spacing: -0.01em;
}

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

.status {
  background: var(--surface);
  border: 1px solid var(--hairline);
  padding: 10px 14px;
  border-radius: 4px;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.status.ready { border-color: #B5C9A8; background: #F0F5EA; color: #3B5928; }
.status.error { border-color: #D9A89A; background: #F9ECE7; color: var(--accent); }

.spinner {
  width: 12px; height: 12px;
  border: 2px solid var(--hairline);
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.table-header, .row {
  display: grid;
  grid-template-columns: 32px 1fr 130px 110px 170px;
  gap: 10px;
  align-items: center;
}

@media (max-width: 640px) {
  .table-header { display: none; }
  .row {
    display: grid;
    grid-template-columns: 24px 1fr 1fr;
    grid-template-rows: auto auto;
    gap: 5px;
    padding: 6px 0;
    border-bottom: 1px solid var(--hairline);
  }
  .row .num {
    grid-column: 1;
    grid-row: 1 / 3;
    align-self: center;
    font-size: 12px;
  }
  .row input.name {
    grid-column: 2 / 4;
    grid-row: 1;
  }
  .row .cell-level, .row .cell-iron {
    display: flex;
    flex-direction: column;
    gap: 2px;
    grid-row: 2;
  }
  .row .cell-level { grid-column: 2; }
  .row .cell-iron { grid-column: 3; }
  .row .m-lbl {
    display: block;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    padding-left: 2px;
  }
  .row .opening-cell {
    grid-column: 2 / 4;
    grid-row: 3;
  }
  .row.has-iron .opening-cell {
    visibility: visible;
  }
  input[type="text"], select {
    font-size: 14px;
    height: 34px;
    padding: 0 8px;
  }
}

.table-header {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 0 4px 8px;
  border-bottom: 1px solid var(--hairline);
  margin-bottom: 8px;
}

.row { padding: 4px 0; }
.row .num {
  font-family: 'Lora', serif;
  font-size: 14px;
  color: var(--muted);
  text-align: right;
  padding-right: 4px;
}

input[type="text"], select {
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--hairline);
  background: var(--surface);
  border-radius: 3px;
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
  width: 100%;
  transition: border-color 0.15s, background 0.15s;
}
input[type="text"]:focus, select:focus {
  outline: none;
  border-color: var(--ink);
}
input[type="text"]:hover, select:hover { border-color: var(--hairline-strong); }

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' stroke='%236B6B6B' stroke-width='1.5' fill='none' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

.opening-cell { visibility: hidden; }
.row.has-iron .opening-cell { visibility: visible; }

.section {
  margin-top: 40px;
  padding-top: 28px;
  border-top: 1px solid var(--hairline);
}

.section-title {
  font-family: 'Lora', serif;
  font-weight: 600;
  font-size: 18px;
  margin: 0 0 16px;
}

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

.mode-card {
  border: 1px solid var(--hairline);
  background: var(--surface);
  padding: 16px 18px;
  border-radius: 4px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  position: relative;
}
.mode-card input { position: absolute; opacity: 0; }
.mode-card:hover { border-color: var(--hairline-strong); }
.mode-card.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.mode-name {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
}
.mode-desc {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.4;
}

.submit-area {
  margin-top: 40px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

button.primary {
  height: 48px;
  background: var(--ink);
  color: var(--bg);
  border: none;
  border-radius: 3px;
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  letter-spacing: 0.01em;
  transition: background 0.15s, opacity 0.15s;
}
button.primary:hover:not(:disabled) { background: var(--accent); }
button.primary:disabled { opacity: 0.4; cursor: not-allowed; }

.footnote {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  margin-top: 4px;
}

.error-msg {
  background: #F9ECE7;
  border: 1px solid #D9A89A;
  color: var(--accent);
  padding: 12px 14px;
  border-radius: 4px;
  font-size: 13px;
  display: none;
}
.error-msg.visible { display: block; }

.m-lbl { display: none; }
.cell-level, .cell-iron { display: contents; }
/* === Редактируемые имена в итоговой таблице === */
.editable-name {
  display: inline-block;
  min-width: 40px;
  padding: 1px 3px;
  border-radius: 4px;
  border-bottom: 1px dashed rgba(0, 0, 0, 0.25);
  cursor: text;
  transition: background 0.15s;
}
.editable-name:hover { background: rgba(0, 0, 0, 0.05); }
.editable-name:focus {
  outline: 2px solid var(--accent, #4a6fa5);
  outline-offset: 1px;
  background: #fff;
  border-bottom-color: transparent;
}

/* === Блок "места подготовки" === */
.prep-area {
  margin-top: 24px;
  text-align: center;
}
#prep-image-area {
  margin-top: 20px;
}
#prep-image-area img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--hairline, #ddd);
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.07);
}
.prep-download {
  display: inline-block;
  margin-top: 10px;
  font-size: 13px;
  color: var(--accent, #4a6fa5);
}
