:root {
  --bg-base: #eef3f6;
  --bg-strong: #dce6ec;
  --panel: rgba(255, 255, 255, 0.88);
  --ink: #111827;
  --muted: #5b6475;
  --accent: #0f766e;
  --accent-strong: #0c5f58;
  --line: #d2d9e2;
  --error: #b42318;
  --success: #067647;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Sora", "Avenir Next", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 15%, rgba(15, 118, 110, 0.16), transparent 35%),
    radial-gradient(circle at 85% 0%, rgba(17, 24, 39, 0.12), transparent 40%),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.18) 0, rgba(255, 255, 255, 0.18) 2px, transparent 2px, transparent 12px),
    linear-gradient(150deg, var(--bg-base), var(--bg-strong));
}

.app {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px 16px;
}

.panel {
  width: min(760px, 100%);
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.65);
  background: var(--panel);
  backdrop-filter: blur(6px);
  box-shadow: 0 24px 48px rgba(8, 15, 28, 0.12);
  padding: 26px;
}

.panel-header h1 {
  margin: 0;
  font-size: clamp(1.35rem, 3.6vw, 1.9rem);
  letter-spacing: -0.02em;
}

.panel-header p {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.45;
  max-width: 60ch;
}

#cmr-form {
  margin-top: 22px;
  display: grid;
  gap: 16px;
}

.field {
  display: grid;
  gap: 7px;
}

.field span {
  font-size: 0.92rem;
  font-weight: 600;
}

input,
textarea,
button {
  font: inherit;
}

input[type="file"],
textarea {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.96);
  padding: 11px 12px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.drop-zone {
  position: relative;
  display: grid;
  gap: 8px;
  border: 2px dashed #7ea1be;
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(244, 251, 250, 0.95)),
    rgba(255, 255, 255, 0.95);
  padding: 15px 12px;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.drop-zone:hover {
  border-color: var(--accent);
  box-shadow: 0 8px 20px rgba(15, 118, 110, 0.13);
}

.drop-zone.is-dragover {
  border-color: var(--accent);
  background: #eaf8f5;
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.12);
}

.drop-zone-title {
  position: relative;
  z-index: 2;
  font-size: 0.92rem;
  color: #113238;
  pointer-events: none;
}

.file-name {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  width: fit-content;
  max-width: 100%;
  font-size: 0.8rem;
  color: #254764;
  background: rgba(125, 161, 190, 0.18);
  border: 1px solid rgba(125, 161, 190, 0.45);
  border-radius: 999px;
  padding: 5px 8px 5px 10px;
  font-weight: 600;
  position: relative;
  z-index: 5;
}

.file-name::before {
  content: "\2191";
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: rgba(36, 71, 100, 0.12);
  color: #1d3f56;
  font-size: 0.8rem;
  line-height: 1;
}

.file-name-text {
  max-width: 340px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-remove {
  all: unset;
  position: relative;
  z-index: 6;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  font-size: 0.95rem;
  line-height: 1;
  color: #1d3f56;
  background: rgba(36, 71, 100, 0.12);
  cursor: pointer;
  opacity: 0;
  transform: scale(0.9);
  pointer-events: none;
  transition: opacity 0.16s ease, transform 0.16s ease, background 0.16s ease;
}

.drop-zone.has-file:hover .file-remove,
.file-remove:focus-visible {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}

.file-remove:hover {
  background: rgba(180, 35, 24, 0.16);
  color: #7a2019;
}

input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  z-index: 3;
}

textarea {
  resize: vertical;
  min-height: 245px;
  line-height: 1.4;
}

.copies-view {
  color: var(--ink);
  font-weight: 700;
  font-size: 1.15rem;
  line-height: 1.2;
  padding: 2px 0 0;
}

.codes-wrap {
  position: relative;
}

.codes-wrap textarea {
  width: 100%;
  padding-right: 42px;
}

.codes-wrap textarea::placeholder {
  color: #7d8593;
  opacity: 1;
  font-weight: 400;
  letter-spacing: 0.01em;
}

.codes-clear {
  all: unset;
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 3;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  font-size: 1rem;
  line-height: 1;
  color: #1d3f56;
  background: rgba(36, 71, 100, 0.12);
  cursor: pointer;
  opacity: 0;
  transform: scale(0.9);
  pointer-events: none;
  transition: background 0.16s ease, color 0.16s ease, opacity 0.16s ease, transform 0.16s ease;
}

.codes-wrap.has-content .codes-clear {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
  color: #1d3f56;
  background: rgba(36, 71, 100, 0.12);
}

.codes-wrap.has-content .codes-clear:hover {
  background: rgba(180, 35, 24, 0.16);
  color: #7a2019;
}

input:focus,
textarea:focus,
button:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.12);
}

.grid {
  display: grid;
  grid-template-columns: minmax(190px, 230px) 1fr;
  gap: 14px;
  align-items: end;
}

.note {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
  border: 1px dashed #bfccd8;
  border-radius: 10px;
  padding: 12px;
  background: rgba(245, 249, 252, 0.85);
}

.actions {
  margin-top: 2px;
}

button {
  border: none;
  border-radius: 10px;
  padding: 12px 18px;
  font-weight: 700;
  cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
  letter-spacing: 0.01em;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

button:hover:not(.codes-clear):not(.file-remove) {
  transform: translateY(-1px);
  box-shadow: 0 12px 22px rgba(15, 118, 110, 0.25);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
  box-shadow: none;
}

.status-block {
  margin-top: 16px;
  border-top: 1px solid #e4e8ee;
  padding-top: 14px;
}

#status,
#stats {
  margin: 0;
  font-size: 0.9rem;
}

#status:empty {
  display: none;
}

#stats {
  margin-top: 6px;
  color: var(--muted);
}

#status[data-state="idle"] {
  color: var(--muted);
}

#status[data-state="working"] {
  color: var(--ink);
}

#status[data-state="success"] {
  color: var(--success);
  font-weight: 600;
}

#status[data-state="error"] {
  color: var(--error);
  font-weight: 600;
}

@media (max-width: 720px) {
  .panel {
    padding: 18px;
    border-radius: 14px;
  }

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

  button {
    width: 100%;
  }
}
