:root {
  --bg: #eef1f5;
  --bg-accent: #e4eaf1;
  --surface: #ffffff;
  --text: #152033;
  --text-muted: #6a7383;
  --text-soft: #9aa3b2;
  --border: #e6eaf0;
  --accent: #2a5f9e;
  --accent-soft: #e8f0fa;
  --action-bg: #f5f7fa;
  --shadow: 0 1px 2px rgba(21, 32, 51, 0.04), 0 8px 24px rgba(21, 32, 51, 0.06);
  --shadow-hover: 0 2px 4px rgba(21, 32, 51, 0.05), 0 14px 28px rgba(21, 32, 51, 0.1);
  --radius: 18px;
  --app-max: 520px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --font: "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(1200px 500px at 50% -10%, #f7f9fc 0%, transparent 60%),
    linear-gradient(180deg, var(--bg-accent) 0%, var(--bg) 45%);
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app {
  position: relative;
  max-width: var(--app-max);
  min-height: 100dvh;
  margin: 0 auto;
  padding: 14px 16px 36px;
}

body.notebook-page {
  height: 100dvh;
  overflow: hidden;
}

body.notebook-page .app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-height: 100dvh;
  min-height: 0;
  padding-bottom: 12px;
  overflow: hidden;
}

body.notebook-page .header {
  flex-shrink: 0;
}

body.notebook-page .main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  gap: 12px;
}

body.notebook-page .search-card--sticky {
  flex-shrink: 0;
  position: relative;
  z-index: 4;
}

body.notebook-page .list-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 20px;
}

.brand__logo {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  object-fit: contain;
  background: #fff;
  box-shadow: 0 2px 8px rgba(26, 74, 122, 0.18);
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 2px 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand__text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.brand__name {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.brand__sub {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.menu-btn {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 42px;
  height: 42px;
  padding: 10px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  cursor: pointer;
  transition: background 0.2s var(--ease), transform 0.2s var(--ease);
}

.menu-btn:hover,
.menu-btn:focus-visible {
  background: rgba(255, 255, 255, 0.7);
  outline: none;
}

.menu-btn:active {
  transform: scale(0.96);
}

.menu-btn__bar {
  display: block;
  width: 100%;
  height: 2px;
  border-radius: 2px;
  background: #243044;
  transition: transform 0.25s var(--ease), opacity 0.2s ease;
}

.menu-btn[aria-expanded="true"] .menu-btn__bar:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.menu-btn[aria-expanded="true"] .menu-btn__bar:nth-child(2) {
  opacity: 0;
}

.menu-btn[aria-expanded="true"] .menu-btn__bar:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* Drawer */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(15, 23, 42, 0.38);
  backdrop-filter: blur(2px);
  opacity: 0;
  animation: fadeIn 0.22s var(--ease) forwards;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 50;
  width: min(300px, 84vw);
  height: 100dvh;
  padding: 32px 22px;
  background: var(--surface);
  box-shadow: -8px 0 32px rgba(15, 23, 42, 0.14);
  transform: translateX(100%);
  transition: transform 0.32s var(--ease);
}

.drawer.is-open {
  transform: translateX(0);
}

.drawer__title {
  margin: 0 0 20px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.drawer__nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.drawer__link {
  display: block;
  width: 100%;
  padding: 13px 14px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}

.drawer__link[hidden] {
  display: none !important;
}

.drawer__link:hover,
.drawer__link.is-active {
  background: var(--accent-soft);
  color: var(--accent);
}

.drawer__link--btn {
  font: inherit;
  color: inherit;
}

/* Search card */
.search-card {
  padding: 16px 16px 12px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  animation: riseIn 0.45s var(--ease) both;
}

.search-bar {
  position: relative;
  display: flex;
  align-items: center;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.search-bar__input {
  width: 100%;
  padding: 10px 40px 10px 4px;
  border: 0;
  background: transparent;
  outline: none;
  font-size: 0.98rem;
  letter-spacing: -0.01em;
  transition: color 0.2s ease;
}

.search-bar__input::placeholder {
  color: var(--text-soft);
  font-weight: 400;
}

.search-bar__icon {
  position: absolute;
  right: 2px;
  display: flex;
  color: var(--text-muted);
  pointer-events: none;
  transition: color 0.2s ease, transform 0.2s var(--ease);
}

.search-bar:focus-within .search-bar__icon {
  color: var(--accent);
  transform: scale(1.05);
}

.filters {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding-top: 6px;
}

.filter {
  position: relative;
  display: block;
  min-width: 0;
}

.filter__select {
  width: 100%;
  height: 46px;
  appearance: none;
  -webkit-appearance: none;
  padding: 12px 22px 12px 2px;
  border: 0;
  border-bottom: 1.5px solid var(--border);
  border-radius: 0;
  background: transparent;
  font-size: 0.88rem;
  font-weight: 500;
  line-height: 1.2;
  color: var(--text);
  cursor: pointer;
  outline: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.filter__select:hover {
  border-bottom-color: #c9d2de;
}

.filter__select:focus {
  border-bottom-color: var(--accent);
  color: var(--accent);
}

.filter__chevron {
  position: absolute;
  top: 50%;
  right: 2px;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid #7b8798;
  transform: translateY(-35%);
  pointer-events: none;
  transition: border-top-color 0.2s ease;
}

.filter:focus-within .filter__chevron {
  border-top-color: var(--accent);
}

.result-count {
  margin: 18px 6px 10px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.01em;
  animation: fadeIn 0.4s var(--ease) both;
}

.contact-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.empty-state {
  margin: 48px 0;
  text-align: center;
  color: var(--text-muted);
  animation: fadeIn 0.3s ease both;
}

/* Contact card */
.contact-card {
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: box-shadow 0.28s var(--ease), transform 0.28s var(--ease);
  animation: riseIn 0.45s var(--ease) both;
}

.contact-card:nth-child(1) { animation-delay: 0.04s; }
.contact-card:nth-child(2) { animation-delay: 0.08s; }
.contact-card:nth-child(3) { animation-delay: 0.12s; }
.contact-card:nth-child(4) { animation-delay: 0.16s; }
.contact-card:nth-child(5) { animation-delay: 0.2s; }
.contact-card:nth-child(6) { animation-delay: 0.24s; }
.contact-card:nth-child(n + 7) { animation-delay: 0.28s; }

.contact-card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.contact-card__main {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 16px 16px 14px;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background 0.2s ease;
}

.contact-card__main:hover,
.contact-card__main:focus-visible {
  background: #fafbfd;
  outline: none;
}

.contact-card__avatar {
  flex-shrink: 0;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  object-fit: cover;
  background: #e5eaf0;
  box-shadow: inset 0 0 0 1px rgba(21, 32, 51, 0.06);
  transition: transform 0.28s var(--ease);
}

.contact-card:hover .contact-card__avatar {
  transform: scale(1.03);
}

.contact-card__info {
  flex: 1;
  min-width: 0;
}

.contact-card__title {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.contact-card__position {
  margin: 3px 0 0;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-muted);
}

.contact-card__phone {
  margin: 3px 0 0;
  font-size: 0.88rem;
  font-weight: 500;
  color: #4a5568;
  font-variant-numeric: tabular-nums;
}

.contact-card__toggle {
  flex-shrink: 0;
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 8px solid var(--accent);
  transition: transform 0.28s var(--ease);
}

.contact-card.is-expanded .contact-card__toggle {
  transform: rotate(180deg);
}

.contact-card__details {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.32s var(--ease);
}

.contact-card.is-expanded .contact-card__details {
  grid-template-rows: 1fr;
}

.contact-card__details-inner {
  overflow: hidden;
  padding: 0 16px 0 88px;
  font-size: 0.84rem;
  color: var(--text-muted);
}

.contact-card.is-expanded .contact-card__details-inner {
  padding-bottom: 14px;
}

.contact-card__details p {
  margin: 0 0 6px;
  line-height: 1.45;
}

.contact-card__details p:last-child {
  margin-bottom: 0;
}

.contact-card__details strong {
  display: inline-block;
  min-width: 3.2em;
  margin-right: 6px;
  font-weight: 600;
  color: #526074;
}

.contact-card__actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--border);
  background: var(--action-bg);
}

.action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 13px 6px;
  border: 0;
  border-right: 1px solid #e2e6ec;
  background: transparent;
  font-size: 0.74rem;
  font-weight: 500;
  color: #3d4656;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s var(--ease);
}

.action-btn:last-child {
  border-right: 0;
}

.action-btn:hover,
.action-btn:focus-visible {
  background: #e9edf3;
  color: var(--accent);
  outline: none;
}

.action-btn:active {
  transform: scale(0.97);
}

.action-btn svg {
  width: 20px;
  height: 20px;
  color: #526074;
  transition: color 0.2s ease, transform 0.2s var(--ease);
}

.action-btn:hover svg,
.action-btn:focus-visible svg {
  color: var(--accent);
  transform: translateY(-1px);
}

@keyframes riseIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

@media (max-width: 380px) {
  .filters {
    gap: 4px;
  }

  .filter__select {
    font-size: 0.78rem;
    padding-right: 16px;
  }

  .contact-card__avatar {
    width: 50px;
    height: 50px;
  }

  .contact-card__details-inner {
    padding-left: 16px;
  }

  .action-btn {
    font-size: 0.68rem;
  }
}

@media (min-width: 560px) {
  .app {
    margin-top: 28px;
    margin-bottom: 28px;
    min-height: calc(100dvh - 56px);
    padding: 20px 20px 36px;
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.35);
    box-shadow: 0 12px 40px rgba(21, 32, 51, 0.08);
    backdrop-filter: blur(8px);
  }

  body.notebook-page .app {
    margin-top: 0;
    margin-bottom: 0;
    height: 100dvh;
    max-height: 100dvh;
    min-height: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
    padding: 14px 16px 12px;
  }
}

.status-msg {
  margin: 24px 4px;
  padding: 18px 16px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: center;
  color: var(--text-muted);
  font-size: 0.92rem;
  animation: fadeIn 0.3s var(--ease) both;
}

.status-msg--error p {
  margin: 0 0 12px;
}

.retry-btn {
  padding: 10px 16px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s var(--ease), opacity 0.2s ease;
}

.retry-btn:hover {
  opacity: 0.92;
}

.retry-btn:active {
  transform: scale(0.97);
}
