:root {
  color-scheme: light;
  --ink: #232a31;
  --muted: #6d655c;
  --line: #e4dcd1;
  --paper: #fffdfb;
  --bg: #f3efe7;
  --red: #cf7566;
  --yellow: #f2d492;
  --blue: #6096ba;
  --cream: #f6e7b8;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(1100px 480px at 8% -12%, #f8e7c2 0%, transparent 58%),
    radial-gradient(820px 420px at 110% -8%, #f4d5cf 0%, transparent 52%),
    var(--bg);
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

::selection {
  background: var(--yellow);
  color: var(--ink);
}

button, input, select { font: inherit; color: inherit; }

button { cursor: pointer; }

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.wrap {
  width: min(1120px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.7rem 0 9rem;
}

.when {
  display: block;
  margin-top: 0.22rem;
  color: var(--muted);
  font-size: 0.75rem;
}

.top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 1.5rem;
  align-items: center;
  margin-bottom: 1.15rem;
}

.kicker { grid-column: 1; grid-row: 1; }

.ff {
  grid-column: 2;
  grid-row: 2;
  line-height: 0;
}

.ff img {
  display: block;
  width: auto;
  height: calc(3 * 1.05 * clamp(1.85rem, 3.2vw, 2.55rem));
}

.kicker {
  margin: 0 0 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #8a7368;
}

.chip {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  background: var(--yellow);
  color: var(--ink);
  letter-spacing: 0.08em;
  vertical-align: 0.12em;
}

h1, h2, .btn, .period {
  font-family: "IBM Plex Sans Condensed", "IBM Plex Sans", "Segoe UI", sans-serif;
}

h1 {
  grid-column: 1;
  grid-row: 2;
  margin: 0;
  max-width: 22ch;
  font-size: clamp(1.85rem, 3.2vw, 2.55rem);
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.01em;
}

.period {
  grid-column: 1;
  grid-row: 3;
  margin: 0.45rem 0 0;
  font-size: 1.2rem;
  font-weight: 500;
  color: var(--red);
}

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1.05rem 1.1rem 1.15rem;
  margin-bottom: 0.85rem;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset, 0 10px 30px rgba(35, 42, 49, 0.04);
}

h2 {
  margin: 0 0 0.85rem;
  font-size: 1.2rem;
  font-weight: 600;
}

.identity {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 0.9rem 1rem;
}

.field label {
  display: block;
  margin-bottom: 0.28rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: #5e564e;
}

input, select {
  width: 100%;
  min-width: 0;
  height: 2.7rem;
  padding: 0 0.7rem;
  border: 1px solid #d9d0c4;
  border-radius: 10px;
  background: #fff;
}

input:focus, select:focus, .editor:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(96, 150, 186, 0.22);
  outline: none;
}

.fields-head { display: none; }

#entries { display: grid; gap: 0.75rem; }

.entry {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.field-write,
.remove,
.row-error { grid-column: 1 / -1; }

.editor {
  border: 1px solid #d9d0c4;
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
}

.toolbar {
  display: flex;
  gap: 0.15rem;
  padding: 0.28rem;
  background: #f7f4ee;
  border-bottom: 1px solid var(--line);
}

.toolbar button {
  width: 2rem;
  height: 2rem;
  border: 0;
  border-radius: 7px;
  background: transparent;
  font-weight: 700;
}

.toolbar button:hover { background: #fff; }

.toolbar button.is-on {
  background: var(--ink);
  color: var(--cream);
}

.write {
  min-height: 6.2rem;
  max-height: 16rem;
  overflow: auto;
  padding: 0.65rem 0.75rem 0.8rem;
  outline: none;
}

.write:empty::before {
  content: attr(data-placeholder);
  color: #9a9186;
}

.write ul { margin: 0.25rem 0 0.25rem 1.15rem; padding: 0; }

.row-error {
  margin: 0;
  color: #9c3b32;
  font-size: 0.88rem;
}

.remove {
  justify-self: start;
  border: 0;
  background: transparent;
  padding: 0;
  color: #8a8176;
  font-size: 0.88rem;
  text-decoration: underline;
  text-underline-offset: 0.16em;
}

.remove:hover { color: #9c3b32; }

.site-foot {
  margin-top: 0.4rem;
  padding: 0.85rem 0.15rem 0.2rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.92rem;
}

.foot-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.85rem 1.15rem;
}

.foot-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--ink);
  font-family: "IBM Plex Sans Condensed", "IBM Plex Sans", sans-serif;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-decoration: none;
}

.foot-brand img {
  width: 1.85rem;
  height: 1.85rem;
}

.foot-contact,
.foot-legal {
  color: inherit;
  text-decoration: none;
}

.foot-contact:hover,
.foot-legal:hover,
.foot-brand:hover {
  color: var(--ink);
}

.foot-social {
  display: inline-flex;
  color: var(--ink);
}

.foot-legal {
  margin-left: auto;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.foot-copy {
  margin: 0.45rem 0 0;
  font-size: 0.8rem;
}

.actionbar {
  position: fixed;
  z-index: 5;
  left: 50%;
  bottom: calc(0.7rem + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: min(1120px, calc(100% - 1.2rem));
  padding: 0.75rem 0.75rem 0.75rem 1.05rem;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 252, 248, 0.94);
  box-shadow: 0 14px 40px rgba(35, 42, 49, 0.12);
  backdrop-filter: blur(12px);
}

.total {
  margin: 0;
  font-size: 1.05rem;
}

.total strong { font-size: 1.25rem; }

.fine, .status {
  margin: 0.1rem 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.status:empty { display: none; }

.actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border-radius: 999px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.btn-ghost {
  padding: 0.78rem 1.1rem;
  border: 1.5px solid var(--ink);
  background: transparent;
}

.btn-ghost:hover { background: #fff; }

.btn-send {
  padding: 0.9rem 1.25rem 0.9rem 1.35rem;
  border: 0;
  background: var(--ink);
  color: var(--cream);
  font-size: 1.15rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  box-shadow: 0 10px 24px rgba(35, 42, 49, 0.18);
}

.btn-send:hover {
  background: var(--yellow);
  color: var(--ink);
}

.modal[hidden] { display: none !important; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 1.2rem;
  background: rgba(35, 42, 49, 0.46);
}

.dialog {
  width: min(26rem, 100%);
  padding: 1.5rem 1.4rem 1.25rem;
  border-radius: 20px;
  background: var(--paper);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.22);
}

.dialog h2 {
  margin-bottom: 0.35rem;
  font-size: 1.7rem;
}

.dialog p { margin: 0 0 1.1rem; color: var(--muted); }

.stamp {
  display: grid;
  place-items: center;
  width: 3.25rem;
  height: 3.25rem;
  margin-bottom: 0.8rem;
  border-radius: 50%;
  background: #e7f2dc;
  color: #3f6a32;
}

.dialog-close {
  width: 100%;
  font-size: 1.05rem;
  letter-spacing: 0.04em;
  text-transform: none;
}

body.modal-open { overflow: hidden; }

@media (min-width: 981px) {
  .fields-head,
  .entry {
    grid-template-columns: 10.4rem 7.5rem 7.5rem 6.7rem minmax(14rem, 1fr) auto;
    gap: 0.55rem 0.65rem;
  }

  .fields-head {
    display: grid;
    margin: 0 0 0.45rem;
    padding: 0 0.15rem;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 600;
  }

  .entry {
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
  }

  .entry + .entry {
    margin-top: 0.85rem;
    padding-top: 0.85rem;
    border-top: 1px solid #efe8de;
  }

  #entries { display: block; }

  .field-write,
  .remove { grid-column: auto; }

  .field label {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
  }

  .remove { margin-top: 0.55rem; }
}

@media (max-width: 800px) {
  .identity { grid-template-columns: 1fr; }

  .actionbar {
    flex-direction: column;
    align-items: stretch;
    padding: 0.75rem;
  }

  .actions { display: grid; }

  .btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}
