:root {
  --friends-bg: #fff;
  --friends-ink: #000;
  --friends-line: #000;
  --friends-link: #78bce8;
  --page-gutter: 20px;
  color-scheme: light dark;
}

html[data-theme="dark"],
[data-theme="dark"] {
  --friends-bg: #121212;
  --friends-ink: #f0f0f0;
  --friends-line: rgba(240, 240, 240, 0.25);
  --friends-link: #6ea8fe;
}

html[data-theme="dark"] .friend-popup::backdrop,
[data-theme="dark"] .friend-popup::backdrop {
  background: rgba(0, 0, 0, 0.7);
}

html[data-theme="light"],
[data-theme="light"] {
  --friends-bg: #fff;
  --friends-ink: #000;
  --friends-line: #000;
  --friends-link: #78bce8;
}

html[data-theme="light"] .friend-popup::backdrop,
[data-theme="light"] .friend-popup::backdrop {
  background: rgba(0, 0, 0, 0.18);
}

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

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
  background: var(--friends-bg);
  color: var(--friends-ink);
}

body,
button {
  font-family: Arial, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button,
a {
  color: inherit;
}

button:focus-visible,
a:focus-visible,
.friends-table-wrap:focus-visible {
  outline: 1px solid var(--friends-ink);
  outline-offset: 2px;
}

.friends-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--page-gutter);
}

.header-lang-switch {
  margin-left: auto;
}

.lang-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.2;
  text-decoration: none;
  color: var(--friends-ink);
  opacity: 0.6;
  transition: opacity 200ms ease, color 200ms ease;
}

.lang-switch::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  min-width: 44px;
  min-height: 44px;
  width: 100%;
  height: 100%;
}

.lang-switch:hover,
.lang-switch:focus-visible {
  opacity: 1;
  color: var(--friends-link);
}

.theme-toggle-btn {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9999;
  width: 10px;
  height: 10px;
  padding: 0;
  margin: 0;
  border: none;
  border-radius: 50%;
  background-color: #000000;
  cursor: pointer;
  outline: none;
  opacity: 0.85;
  transition: transform 150ms ease, opacity 200ms ease, background-color 200ms ease;
}

.theme-toggle-btn:hover {
  opacity: 1;
  transform: scale(1.3);
}

.theme-toggle-btn:focus-visible {
  outline: 2px solid var(--friends-link);
  outline-offset: 3px;
}

.theme-toggle-btn::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  min-width: 44px;
  min-height: 44px;
  width: 100%;
  height: 100%;
}

html[data-theme="dark"] .theme-toggle-btn,
[data-theme="dark"] .theme-toggle-btn {
  background-color: #ffffff;
}

.friends-nav {
  display: flex;
  align-items: center;
  gap: 28px;
  font-size: 20px;
  line-height: 25px;
}

.friends-nav a {
  text-decoration: none;
}

.friends-nav a[aria-current="page"] {
  text-decoration-line: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 5px;
}

.friends-main {
  min-width: 0;
  padding: 32px var(--page-gutter) var(--page-gutter);
}

.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;
}

.friends-table-wrap {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  -webkit-overflow-scrolling: touch;
}

.friends-table {
  width: 1120px;
  min-width: 1120px;
  border-collapse: collapse;
  table-layout: fixed;
  background: var(--friends-bg);
  color: var(--friends-ink);
  font-size: 13px;
  line-height: 1.25;
}

.friend-col-photo {
  width: 72px;
}

.friend-col-name {
  width: 120px;
}

.friend-col-instagram {
  width: 150px;
}

.friend-col-website {
  width: 220px;
}

.friend-col-introduction {
  width: 408px;
}

.friend-col-last-met {
  width: 150px;
}

.friends-table th,
.friends-table td {
  padding: 6px 8px;
  border: 1px solid var(--friends-line);
  background: var(--friends-bg);
  text-align: center;
  vertical-align: middle;
  overflow-wrap: anywhere;
}

.friends-table th:last-child,
.friends-table td:last-child {
  box-shadow: inset -1px 0 0 var(--friends-line);
}

.friends-table th {
  font-size: 12px;
  font-weight: 700;
  vertical-align: middle;
}

.friends-table td.friend-photo-cell {
  padding: 4px;
}

.friend-photo-placeholder {
  text-align: center;
}

.friend-photo-button {
  display: block;
  width: 56px;
  margin: 0 auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  cursor: pointer;
}

.friend-photo-button img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  object-position: center center;
  padding: 2px;
  box-sizing: border-box;
}

.friends-table td:nth-child(3) a,
.friends-table td:nth-child(4) a,
.friend-popup-info a {
  color: var(--friends-link);
}

.friend-introduction-copy {
  position: relative;
  min-width: 0;
  height: 2.5em;
  overflow: hidden;
}

.friend-introduction-copy:not(.has-more) {
  display: flex;
  align-items: center;
}

.friend-introduction-copy:not(.has-more) .friend-introduction-preview {
  width: 100%;
  height: auto;
}

.friend-introduction-preview {
  display: -webkit-box;
  height: 100%;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.friend-introduction-measure {
  position: absolute;
  top: 0;
  left: 0;
  display: block;
  width: 100%;
  height: auto;
  max-height: none;
  overflow: visible;
  visibility: hidden;
  white-space: normal;
  -webkit-line-clamp: unset;
}

.friend-introduction-more {
  position: absolute;
  right: 0;
  bottom: 0;
  display: inline;
  margin: 0;
  padding: 0 0 0 0.35em;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.friend-introduction-more[hidden] {
  display: none;
}

.sort-button {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  font: inherit;
  font-weight: inherit;
  line-height: inherit;
  text-align: center;
  cursor: pointer;
}

.sort-button::after {
  display: none;
  width: 6px;
  height: 6px;
  margin-left: 4px;
  border: solid currentColor;
  border-width: 0 1.5px 1.5px 0;
  content: "";
  vertical-align: 2px;
}

.friends-table th[aria-sort="ascending"] .sort-button::after {
  display: inline-block;
  transform: rotate(-135deg);
}

.friends-table th[aria-sort="descending"] .sort-button::after {
  display: inline-block;
  transform: rotate(45deg);
}

.sort-button:hover .sort-label,
.friends-table th[aria-sort="ascending"] .sort-label,
.friends-table th[aria-sort="descending"] .sort-label {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.friend-popup {
  width: min(600px, calc(100vw - 40px));
  max-width: none;
  max-height: calc(100dvh - 40px);
  margin: auto;
  padding: 0;
  overflow: auto;
  border: 1px solid var(--friends-line);
  border-radius: 0;
  background: var(--friends-bg);
  color: var(--friends-ink);
}

.friend-popup::backdrop {
  background: rgba(0, 0, 0, 0.28);
}

.friend-popup-card {
  position: relative;
}

.friend-popup-media {
  width: 100%;
  background: var(--friends-bg);
}

.friend-popup-media[hidden] {
  display: none;
}

.friend-popup-media img {
  display: block;
  width: 100%;
  max-height: 480px;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  object-position: center center;
  padding: 8px;
  box-sizing: border-box;
}

.friend-popup-info {
  width: calc(100% + 2px);
  margin: 0 -1px -1px;
  border-collapse: collapse;
  table-layout: fixed;
  background: var(--friends-bg);
  color: var(--friends-ink);
  font-size: 13px;
  line-height: 1.25;
}

.friend-popup-info th,
.friend-popup-info td {
  padding: 7px 8px;
  border: 1px solid var(--friends-line);
  background: var(--friends-bg);
  text-align: center;
  vertical-align: middle;
  overflow-wrap: anywhere;
}

.friend-popup-info th {
  width: 34%;
  font-size: 12px;
  font-weight: 700;
}

.friend-popup-close {
  position: absolute;
  z-index: 1;
  top: 6px;
  right: 6px;
  display: grid;
  width: 44px;
  height: 44px;
  margin: 0;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 0;
  outline: 0;
  background: transparent;
  box-shadow: none;
  font-family: Arial, sans-serif;
  font-size: 30px;
  font-weight: 400;
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.friend-popup-close:hover,
.friend-popup-close:focus-visible {
  outline: 0;
  background: transparent;
  box-shadow: none;
  text-decoration: none;
  opacity: 0.55;
}

@media (max-width: 767px) {
  :root {
    --page-gutter: 15px;
  }

  .theme-toggle-btn {
    right: 24px;
    bottom: 24px;
  }

  .friends-nav {
    gap: 20px;
    font-size: 16px;
    line-height: 22px;
  }

  .friends-table-wrap {
    max-width: none;
    overflow: hidden;
  }

  .friends-table {
    width: 100%;
    min-width: 0;
    display: block;
    border-collapse: separate;
    box-shadow: none;
  }

  .friends-table colgroup {
    display: none;
  }

  .friends-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    clip-path: inset(50%);
    border: 0;
    white-space: nowrap;
  }

  .friends-table tbody {
    display: grid;
    gap: 15px;
  }

  .friends-table tr {
    display: grid;
    width: 100%;
    min-width: 0;
    grid-template-columns: minmax(0, 1fr) 96px;
    grid-template-rows: 48px 48px 48px auto 48px;
    overflow: hidden;
    border: 1px solid var(--friends-line);
    background: var(--friends-bg);
  }

  .friends-table td {
    display: grid;
    min-width: 0;
    grid-column: 1 / -1;
    grid-template-columns: 88px minmax(0, 1fr);
    gap: 8px;
    align-items: start;
    padding: 7px 8px;
    border: 0;
    border-bottom: 1px solid var(--friends-line);
    text-align: left;
  }

  .friends-table td:first-child {
    grid-row: 1 / span 2;
    grid-column: 2;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    height: 96px;
    min-width: 0;
    max-width: none;
    padding: 0;
    overflow: hidden;
    place-items: center;
    border-left: 1px solid var(--friends-line);
    border-bottom: 1px solid var(--friends-line);
    text-align: center;
  }

  .friends-table td:nth-child(2) {
    grid-row: 1;
    grid-column: 1;
    align-items: center;
  }

  .friends-table td:nth-child(3) {
    grid-row: 2;
    grid-column: 1;
    align-items: center;
  }

  .friends-table td:nth-child(4),
  .friends-table td:nth-child(6) {
    align-items: center;
  }

  .friends-table td:nth-child(n + 4) {
    grid-column: 1 / -1;
  }

  .friends-table td:last-child {
    border-bottom: 0;
    box-shadow: none;
  }

  .friends-table td:not(:first-child)::before {
    color: var(--friends-ink);
    font-size: 11px;
    font-weight: 700;
    line-height: 1.35;
  }

  .friends-table td:nth-child(2)::before {
    content: "이름";
  }

  .friends-table td:nth-child(3)::before {
    content: "인스타그램";
  }

  .friends-table td:nth-child(4)::before {
    content: "웹사이트";
  }

  .friends-table td:nth-child(5)::before {
    content: "소개";
  }

  .friends-table td:nth-child(6)::before {
    content: "마지막으로 만난 날";
  }

  html[lang="en"] .friends-table td:nth-child(2)::before {
    content: "Name";
  }

  html[lang="en"] .friends-table td:nth-child(3)::before {
    content: "Instagram";
  }

  html[lang="en"] .friends-table td:nth-child(4)::before {
    content: "Website";
  }

  html[lang="en"] .friends-table td:nth-child(5)::before {
    content: "Introduction";
  }

  html[lang="en"] .friends-table td:nth-child(6)::before {
    content: "Last Met";
  }

  .friend-photo-button {
    width: 100%;
    height: 100%;
    max-width: 100%;
    padding: 0;
    box-sizing: border-box;
    overflow: hidden;
  }

  .friend-photo-button img {
    width: 100%;
    max-width: 100%;
    height: 100%;
    aspect-ratio: 1 / 1;
    object-fit: contain;
    object-position: center center;
    padding: 3px;
    box-sizing: border-box;
  }

  .friend-popup {
    width: calc(100vw - 30px);
    max-height: calc(100dvh - 30px);
  }
}

@media (max-width: 380px) {
  .friends-nav {
    gap: 12px;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --friends-bg: #121212;
    --friends-ink: #f0f0f0;
    --friends-line: rgba(240, 240, 240, 0.25);
    --friends-link: #6ea8fe;
  }

  .friend-popup::backdrop {
    background: rgba(0, 0, 0, 0.7);
  }

  :root:not([data-theme="light"]) .theme-toggle-btn {
    background-color: #ffffff;
  }
}
