#address-book-root {
  min-width: 0;
  padding: 24px;
  color: var(--ink, #182c26);
  font-size: 1rem;
}
#address-book-root button,
#address-book-root input,
#address-book-root summary { font-family: inherit; }
#address-book-root button { min-height: 44px; cursor: pointer; }
#address-book-root button:disabled { cursor: default; opacity: .45; }
#address-book-root button:focus-visible,
#address-book-root summary:focus-visible,
#address-book-root input:focus-visible {
  outline: 3px solid var(--green, #174d40);
  outline-offset: 3px;
}
.ab-file-tools {
  margin-bottom: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border, #dfe5e1);
}
.ab-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 10px;
  font-size: .875rem;
}
.ab-heading label { font-weight: 600; }
.ab-heading > span { color: var(--muted, #66746e); }
.ab-search-row { display: flex; align-items: stretch; gap: 12px; }
.ab-search-row input {
  flex: 1;
  min-width: 0;
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--border, #dfe5e1);
  border-radius: 9px;
  padding: 12px 14px;
  background: var(--surface, #fff);
  color: var(--ink, #182c26);
  font-size: 1rem;
}
.ab-search-row input::placeholder { color: var(--muted, #66746e); opacity: 1; }
.ab-add,
.ab-save {
  border: 1px solid var(--green, #174d40);
  border-radius: 9px;
  background: var(--green, #174d40);
  color: #fff;
  padding: 11px 20px;
  font-size: 1rem;
  font-weight: 600;
  white-space: nowrap;
}
.ab-add:hover,
.ab-save:hover { background: var(--green-dark, #103c32); }
.ab-selection {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin: 16px 0 12px;
  font-size: .875rem;
  color: var(--ink, #182c26);
}
.ab-selection label { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.ab-selection [hidden] { display: none; }
.ab-selection input,
.ab-contact input { width: 22px; height: 22px; flex: none; margin: 0; accent-color: var(--green, #174d40); }
#address-book-root .text-button { min-height: 44px; padding: 10px 4px; font-size: .875rem; color: var(--green, #174d40); }
.ab-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; min-width: 0; }
.ab-contact {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--border, #dfe5e1);
  border-radius: 10px;
  background: var(--surface, #fff);
}
.ab-contact.is-selected { background: var(--green-light, #e9f1ed); border-color: #a9c4b8; }
.ab-contact label { display: flex; align-items: center; gap: 13px; flex: 1; min-width: 0; min-height: 56px; cursor: pointer; }
.ab-contact-copy { display: block; min-width: 0; line-height: 1.45; overflow-wrap: anywhere; }
.ab-contact strong { display: block; font-size: 1rem; font-weight: 650; }
.ab-contact-company { display: block; margin-top: 2px; color: var(--muted, #66746e); font-size: .875rem; }
.ab-contact-address { display: block; margin-top: 5px; font-size: 1rem; color: var(--muted, #66746e); }
.ab-contact-address > span { display: block; }
.ab-contact-address > span:empty { display: none; }
.ab-contact > button,
.ab-option,
.ab-cancel {
  min-width: 64px;
  border: 1px solid var(--border, #dfe5e1);
  border-radius: 8px;
  padding: 10px 14px;
  background: var(--surface, #fff);
  color: var(--green, #174d40);
  font-size: .875rem;
  font-weight: 600;
  line-height: 1.4;
}
.ab-contact > button { flex: none; }
.ab-contact > button:hover,
.ab-option:hover,
.ab-cancel:hover { border-color: #a0b7aa; background: #f5f8f6; }
.ab-empty {
  grid-column: 1 / -1;
  padding: 28px 20px;
  border: 1px dashed var(--border, #dfe5e1);
  border-radius: 10px;
  text-align: center;
}
.ab-empty strong { display: block; font-size: 1.125rem; font-weight: 600; }
.ab-empty p { max-width: 460px; margin: 8px auto 0; font-size: 1rem; line-height: 1.6; color: var(--muted, #66746e); }
.ab-empty-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.ab-empty-actions .ab-option { font-size: 1rem; }
.ab-pagination { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px 20px; margin-top: 16px; font-size: .875rem; color: var(--muted, #66746e); }
.ab-pagination > div { display: flex; align-items: center; gap: 12px; }
.ab-pagination button { min-width: 80px; padding: 10px 12px; border: 1px solid var(--border, #dfe5e1); border-radius: 8px; background: var(--surface, #fff); color: var(--green, #174d40); font-size: .875rem; font-weight: 600; }
.ab-pagination button:not(:disabled):hover { background: var(--green-light, #e9f1ed); }
#ab-selected-count { color: var(--ink, #182c26); font-weight: 500; }
.ab-status { padding: 12px 16px; margin-top: 16px; border: 1px solid #cbded1; border-radius: 8px; background: #edf6ef; color: #315f45; font-size: 1rem; line-height: 1.6; overflow-wrap: anywhere; }
.ab-status.error { border-color: #eac9bb; background: #fff3ed; color: #923e29; }
.ab-undo { margin-top: 6px; }
.ab-tools { border-top: 1px solid var(--border, #dfe5e1); margin-top: 24px; padding-top: 8px; }
.ab-tools summary { min-height: 44px; padding: 12px 0; color: var(--ink, #182c26); font-size: 1rem; font-weight: 600; cursor: pointer; }
.ab-tools summary::marker { color: var(--green, #174d40); }
.ab-tools-actions { display: flex; flex-wrap: wrap; gap: 10px; padding: 8px 0 0; }
.ab-tools-actions button { flex: 1 1 180px; min-width: 0; font-size: .875rem; }
.ab-tools p { margin: 14px 0 0; color: var(--muted, #66746e); font-size: .875rem; line-height: 1.65; }
.ab-storage-note { margin: 18px 0 0; color: var(--muted, #66746e); font-size: .875rem; line-height: 1.6; }

.ab-dialog {
  width: min(680px, calc(100% - 32px));
  max-width: none;
  max-height: calc(100dvh - 32px);
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border, #dfe5e1);
  border-radius: 16px;
  box-shadow: 0 20px 80px #102d3c30;
  color: var(--ink, #182c26);
  background: var(--surface, #fff);
}
.ab-dialog::backdrop { background: #102b266b; backdrop-filter: blur(3px); }
.ab-dialog form { display: flex; flex-direction: column; min-height: 0; max-height: calc(100dvh - 34px); margin: 0; padding: 0; }
.ab-dialog-heading { display: flex; align-items: center; justify-content: space-between; flex: none; gap: 16px; padding: 18px 24px; border-bottom: 1px solid var(--border, #dfe5e1); }
.ab-dialog-heading h2 { margin: 0; font-size: 1.375rem; line-height: 1.3; letter-spacing: -.3px; font-weight: 650; }
.ab-dialog-heading button { width: 44px; flex: none; border: 1px solid transparent; border-radius: 8px; padding: 0; background: #f0f5f2; color: var(--ink, #182c26); font-size: 1.75rem; line-height: 1; }
.ab-dialog-body { flex: 1 1 auto; min-height: 0; padding: 22px 24px 24px; overflow-y: auto; overscroll-behavior: contain; }
.ab-form-hint { margin: 0 0 20px; font-size: .875rem; line-height: 1.6; color: var(--muted, #66746e); }
.ab-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 20px; }
.ab-form-grid > div { min-width: 0; }
.ab-field-wide { grid-column: 1 / -1; }
.ab-form-grid label { display: block; margin-bottom: 8px; color: var(--ink, #182c26); font-size: .875rem; font-weight: 600; line-height: 1.45; }
.ab-form-grid label > span { margin-left: 3px; font-size: .875rem; font-weight: 400; color: var(--muted, #66746e); }
.ab-form-grid input { display: block; width: 100%; min-width: 0; min-height: 48px; padding: 11px 13px; border: 1px solid var(--border, #dfe5e1); border-radius: 8px; background: var(--surface, #fff); color: var(--ink, #182c26); font-size: 1rem; line-height: 1.4; }
.ab-address-preview { margin-top: 24px; border: 1px solid var(--border, #dfe5e1); border-radius: 9px; padding: 16px; background: #f5f8f6; }
.ab-address-preview > span { color: var(--muted, #66746e); font-size: .875rem; font-weight: 600; }
.ab-address-preview pre { margin: 10px 0 0; font-family: inherit; font-size: 1rem; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.ab-form-error { margin: 16px 0 0; padding: 12px 14px; border: 1px solid #eac9bb; border-radius: 8px; color: #923e29; background: #fff3ed; font-size: 1rem; line-height: 1.5; overflow-wrap: anywhere; }
.ab-dialog form > .ab-form-error { flex: none; margin: 0; padding: 12px 24px; border-width: 0 0 1px; border-radius: 0; }
.ab-dialog-actions { display: flex; align-items: center; flex: none; gap: 12px; padding: 18px 24px; border-top: 1px solid var(--border, #dfe5e1); background: var(--surface, #fff); }
.ab-dialog-actions > span { flex: 1; }
.ab-dialog-actions button { min-height: 44px; font-size: 1rem; }
.ab-dialog-actions .ab-delete { border: 1px solid transparent; border-radius: 8px; background: transparent; padding: 10px 4px; color: #9b4434; font-weight: 600; }
.ab-delete:hover { text-decoration: underline; text-underline-offset: 3px; }

@media (max-width: 900px) {
  .ab-list { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  #address-book-root { padding: 18px 16px; }
  .ab-search-row { flex-direction: column; gap: 10px; }
  .ab-add { padding-inline: 16px; }
  .ab-selection { margin-top: 12px; }
  .ab-contact { gap: 10px; padding: 14px 12px; }
  .ab-contact label { gap: 10px; }
  .ab-contact > button { min-width: 56px; padding-inline: 10px; }
  .ab-pagination { align-items: flex-start; }
  .ab-pagination > div { width: 100%; justify-content: space-between; gap: 8px; }
  .ab-tools-actions { display: grid; grid-template-columns: minmax(0, 1fr); }
  .ab-empty { padding: 24px 14px; }
  .ab-empty-actions { display: grid; grid-template-columns: minmax(0, 1fr); }
  .ab-dialog { width: calc(100% - 20px); max-height: calc(100dvh - 20px); border-radius: 12px; }
  .ab-dialog form { max-height: calc(100dvh - 22px); }
  .ab-dialog-heading { padding: 14px 16px; }
  .ab-dialog-heading h2 { font-size: 1.25rem; }
  .ab-dialog-body { padding: 18px 16px 20px; }
  .ab-dialog form > .ab-form-error { padding-inline: 16px; }
  .ab-form-grid { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .ab-dialog-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 14px 16px max(14px, env(safe-area-inset-bottom)); }
  .ab-dialog-actions > span { display: none; }
  .ab-dialog-actions .ab-cancel { order: 1; }
  .ab-dialog-actions .ab-save { order: 2; padding-inline: 10px; }
  .ab-dialog-actions .ab-delete { order: 3; grid-column: 1 / -1; border-color: #ecd9d2; }
}
@media print { #ab-dialog { display: none !important; } }
