:root {
  --bg: #f3f0e8;
  --surface: #fffdf8;
  --surface-strong: #f8f3e6;
  --text: #231910;
  --muted: #76675a;
  --line: #dccfbd;
  --accent: #0e7a53;
  --accent-dark: #095b3d;
  --accent-soft: #e7f7ef;
  --danger-bg: #fff3eb;
  --danger-text: #b44a1f;
  --shadow: 0 20px 45px rgba(48, 34, 18, 0.08);
  --radius: 24px;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.92), transparent 38%),
    linear-gradient(180deg, #f8f4ec 0%, var(--bg) 100%);
  color: var(--text);
}

button,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  border-radius: 16px;
  min-height: 48px;
  padding: 12px 18px;
  font-weight: 700;
  transition: transform 0.18s ease, background-color 0.18s ease, box-shadow 0.18s ease;
}

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

textarea {
  width: 100%;
  min-height: 152px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fffefb;
  color: var(--text);
  outline: none;
  resize: vertical;
  line-height: 1.55;
  font-size: 15px;
  font-weight: 600;
}

textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(14, 122, 83, 0.12);
}

label {
  display: block;
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
}

.shell {
  width: min(960px, calc(100% - 24px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.card {
  background: rgba(255, 253, 248, 0.92);
  border: 1px solid rgba(220, 207, 189, 0.8);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.hero,
.composer {
  padding: 24px;
}

.hero {
  margin-bottom: 16px;
}

.home-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
  color: var(--accent-dark);
  font-weight: 700;
  text-decoration: none;
}

.hero h1 {
  margin: 0;
  max-width: 700px;
  font-size: clamp(30px, 5vw, 52px);
  line-height: 0.98;
}

.intro {
  max-width: 640px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.55;
}

.helper-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 20px;
}

.count-pill {
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--accent);
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
}

.small-note {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.section-head h2 {
  margin: 0;
  font-size: 24px;
}

.section-head p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.address-stack {
  display: grid;
  gap: 16px;
}

.address-block {
  position: relative;
  padding: 18px;
  border: 1px solid rgba(220, 207, 189, 0.9);
  border-radius: 20px;
  background: rgba(248, 243, 230, 0.56);
}

.address-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.address-block-header label {
  margin: 0;
}

.edit-toggle {
  min-height: 34px;
  min-width: 34px;
  padding: 0;
  border: 1px solid rgba(220, 207, 189, 0.95);
  border-radius: 10px;
  background: rgba(255, 253, 248, 0.92);
  color: var(--accent-dark);
  box-shadow: 0 4px 10px rgba(35, 25, 16, 0.06);
  font-size: 15px;
  line-height: 1;
}

.edit-icon {
  display: inline-block;
  transform: translateY(-1px);
}

.edit-toggle:hover {
  background: rgba(231, 247, 239, 0.72);
}

.edit-toggle[data-mode="save"] {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

.address-block.is-empty textarea {
  display: none;
}

.address-block.is-readonly textarea {
  background: rgba(255, 253, 248, 0.72);
  color: rgba(35, 25, 16, 0.86);
  cursor: default;
  pointer-events: none;
}

.address-block.is-readonly textarea:focus {
  border-color: var(--line);
  box-shadow: none;
}

.paste-trigger {
  display: none;
  width: 100%;
  min-height: 152px;
  padding: 20px;
  border: 1px dashed rgba(14, 122, 83, 0.26);
  border-radius: 18px;
  background: rgba(255, 253, 248, 0.96);
  color: var(--accent-dark);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.address-block.is-empty .paste-trigger {
  display: grid;
  place-items: center;
}

.paste-trigger:hover {
  background: rgba(231, 247, 239, 0.72);
}

.paste-icon {
  display: block;
  font-size: 52px;
  line-height: 1;
  font-weight: 500;
}

.controls {
  margin-top: 20px;
}

.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.primary-btn {
  background: var(--accent);
  color: #ffffff;
}

.dark-btn {
  background: #1f3028;
}

.progress-btn {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.progress-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--progress-width, 0%);
  background: linear-gradient(90deg, rgba(22, 163, 110, 0.94), rgba(48, 213, 148, 0.82));
  transition: width 0.2s ease;
  z-index: -1;
}

.progress-label {
  position: relative;
}

.progress-btn.is-loading {
  cursor: wait;
}

.secondary-btn {
  background: var(--accent-soft);
  color: var(--accent);
}

.ghost-btn {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}

.remove-btn {
  background: var(--danger-bg);
  color: var(--danger-text);
}

.note {
  margin: 18px 0 0;
  color: var(--muted);
  line-height: 1.5;
  font-weight: 600;
}

dialog {
  width: min(760px, calc(100vw - 24px));
  border: 0;
  border-radius: 28px;
  padding: 0;
  margin: auto;
  box-shadow: 0 30px 70px rgba(21, 19, 16, 0.24);
}

dialog::backdrop {
  background: rgba(18, 15, 11, 0.55);
}

.modal-body {
  padding: 22px;
  background: var(--surface);
  width: 100%;
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.modal-head h2 {
  margin: 0;
  font-size: 28px;
}

.modal-head p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.bulk-textarea {
  display: block;
  width: 100%;
  min-height: 280px;
  margin: 0;
  font-family: Consolas, "Courier New", monospace;
  font-size: 14px;
  font-weight: 600;
}

.modal-actions {
  justify-content: flex-end;
  margin-top: 18px;
}

@media (max-width: 900px) {
  .shell {
    width: min(100% - 16px, 100%);
    padding: 16px 0 24px;
  }

  .hero,
  .composer,
  .modal-body {
    padding: 18px;
  }

  .section-head,
  .modal-head {
    flex-direction: column;
  }

  .actions-row button {
    width: 100%;
  }

  dialog {
    width: 100vw;
    max-width: 100vw;
    min-height: 100dvh;
    border-radius: 0;
  }
}

@media (max-width: 520px) {
  .hero h1 {
    font-size: 34px;
  }

  textarea {
    min-height: 136px;
    padding: 14px 16px;
  }

  .paste-trigger {
    min-height: 136px;
  }
}
