/* =========================================================
   Kith — Monochrome Editorial & Mobile-First UI
   ========================================================= */

:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --surface-subtle: #f4f4f5;
  --surface-hover: #f0f0f2;
  --border: #e4e4e7;
  --border-strong: #d4d4d8;

  --text-primary: #09090b;
  --text-secondary: #52525b;
  --text-muted: #a1a1aa;

  --ink: #09090b;
  --ink-hover: #27272a;
  --ink-soft: #f4f4f5;

  --danger: #b91c1c;
  --danger-soft: #fef2f2;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --shadow-xs: 0 1px 2px rgba(9, 9, 11, 0.04);
  --shadow-sm: 0 2px 8px rgba(9, 9, 11, 0.04), 0 1px 2px rgba(9, 9, 11, 0.03);
  --shadow-md: 0 12px 32px rgba(9, 9, 11, 0.08), 0 2px 6px rgba(9, 9, 11, 0.04);
  --shadow-lg: 0 24px 48px rgba(9, 9, 11, 0.16);

  --transition: 180ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

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

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text-primary);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, h4 {
  margin: 0;
  font-family: "Plus Jakarta Sans", "Inter", sans-serif;
  letter-spacing: -0.02em;
}

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
}

.hidden {
  display: none !important;
}

/* =========================================================
   Topbar
   ========================================================= */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--ink);
  color: #ffffff;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1.1;
  color: var(--text-primary);
}

.brand-subtitle {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* =========================================================
   Buttons
   ========================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 15px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  min-height: 38px;
}

.btn-sm {
  padding: 6px 11px;
  font-size: 12.5px;
  border-radius: 9px;
  min-height: 32px;
}

.btn-primary {
  background: var(--ink);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(9, 9, 11, 0.16);
}

.btn-primary:hover {
  background: var(--ink-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(9, 9, 11, 0.2);
}

.btn-ghost {
  background: var(--surface);
  color: var(--text-secondary);
  border-color: var(--border);
}

.btn-ghost:hover {
  background: var(--surface-subtle);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

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

.btn-danger-text:hover {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: #fecaca;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--transition);
}

.icon-btn:hover {
  background: var(--surface-subtle);
  color: var(--text-primary);
}

/* =========================================================
   Main Content & Search / Filters
   ========================================================= */
.main-content {
  max-width: 1120px;
  margin: 0 auto;
  padding: 22px 20px 64px;
}

.controls-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 15px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 12px 42px 12px 44px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 14px;
  box-shadow: var(--shadow-xs);
  transition: all var(--transition);
}

.search-input::placeholder {
  color: var(--text-muted);
}

.search-input:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(9, 9, 11, 0.08);
}

.search-clear {
  position: absolute;
  right: 10px;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  border: none;
  background: var(--surface-subtle);
  color: var(--text-secondary);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.search-clear:hover {
  background: var(--border);
  color: var(--text-primary);
}

.filter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.filter-pills {
  display: flex;
  align-items: center;
  gap: 7px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding-bottom: 2px;
}

.filter-pills::-webkit-scrollbar {
  display: none;
}

.filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all var(--transition);
}

.filter-pill:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.filter-pill.active {
  background: var(--ink);
  color: #ffffff;
  border-color: var(--ink);
}

.filter-pill .pill-count {
  font-size: 11px;
  opacity: 0.7;
}

.result-count {
  font-size: 12.5px;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
}

/* =========================================================
   People Grid & Cards
   ========================================================= */
.people-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr));
  gap: 14px;
}

.person-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  cursor: pointer;
  min-width: 0;
  box-shadow: var(--shadow-xs);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}

.person-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 13px;
}

.avatar {
  width: 46px;
  height: 46px;
  border-radius: 13px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  font-family: "Plus Jakarta Sans", sans-serif;
  font-weight: 700;
  font-size: 16px;
  color: #ffffff;
  overflow: hidden;
  border: 1px solid rgba(9, 9, 11, 0.08);
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-lg {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  font-size: 21px;
}

.card-title-wrap {
  min-width: 0;
  flex: 1;
}

.card-name-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}

.card-name {
  font-size: 15.5px;
  font-weight: 700;
  color: var(--text-primary);
}

.card-nickname {
  font-size: 12.5px;
  color: var(--text-muted);
  font-weight: 500;
}

.card-role {
  margin-top: 2px;
  font-size: 12.5px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.group-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  background: var(--surface-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  margin-top: 6px;
}

.card-note-preview {
  margin: 0;
  padding-top: 11px;
  border-top: 1px solid var(--surface-subtle);
  font-size: 13px;
  color: var(--text-secondary);
  white-space: pre-line;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.55;
}

.card-footer {
  margin-top: auto;
  padding-top: 2px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.card-socials-mini {
  display: flex;
  align-items: center;
  gap: 5px;
}

.social-dot {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  color: var(--text-primary);
  display: grid;
  place-items: center;
}

.social-dot svg {
  width: 13px;
  height: 13px;
}

/* =========================================================
   Empty State
   ========================================================= */
.empty-state {
  text-align: center;
  padding: 56px 20px;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
}

.empty-icon {
  width: 60px;
  height: 60px;
  margin: 0 auto 14px;
  border-radius: 16px;
  background: var(--surface-subtle);
  color: var(--text-muted);
  display: grid;
  place-items: center;
}

.empty-state h3 {
  font-size: 17px;
  margin-bottom: 6px;
}

.empty-state p {
  margin: 0 auto 18px;
  max-width: 360px;
  color: var(--text-secondary);
  font-size: 13.5px;
}

/* =========================================================
   Slide-over Detail Drawer
   ========================================================= */
.drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(9, 9, 11, 0.42);
  backdrop-filter: blur(4px);
  display: flex;
  justify-content: flex-end;
  animation: fadeIn 180ms ease-out;
}

.drawer {
  width: 100%;
  max-width: 500px;
  height: 100%;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  animation: slideInRight 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.drawer-topbar {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.drawer-label {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.drawer-topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.drawer-body {
  padding: 20px;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
  min-width: 0;
}

.profile-hero {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

.profile-hero-info {
  min-width: 0;
}

.profile-hero-info h2 {
  font-size: 20px;
  font-weight: 800;
  line-height: 1.25;
}

.profile-nickname {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 14px;
}

.profile-role {
  margin: 3px 0 6px;
  color: var(--text-secondary);
  font-size: 13.5px;
}

.bento-block {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  min-width: 0;
  max-width: 100%;
  flex-shrink: 0;
}

.bento-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.social-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
}

.social-link-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  min-width: 0;
  width: 100%;
  overflow: hidden;
  transition: all var(--transition);
}

.social-link-card:hover {
  border-color: var(--ink);
  background: var(--surface);
}

.social-link-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.social-icon-wrap {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: var(--surface-subtle);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.social-icon-wrap svg {
  width: 14px;
  height: 14px;
}

.social-link-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.copy-btn {
  border: 1px solid var(--border);
  background: var(--surface-subtle);
  color: var(--text-secondary);
  border-radius: 6px;
  padding: 4px 9px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--transition);
}

.copy-btn:hover {
  background: var(--ink);
  border-color: var(--ink);
  color: #ffffff;
}

.note-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
}

.note-box-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.note-save-status {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-muted);
}

.note-editor-textarea {
  width: 100%;
  min-height: 240px;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.65;
  resize: vertical;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.note-editor-textarea:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(9, 9, 11, 0.08);
}

/* =========================================================
   Add / Edit Modal
   ========================================================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(9, 9, 11, 0.5);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: 16px;
  animation: fadeIn 160ms ease-out;
}

.modal {
  width: 100%;
  max-width: 620px;
  max-height: 92vh;
  background: var(--surface);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: popIn 200ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h2 {
  font-size: 17px;
  font-weight: 700;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-section-title {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-group-full {
  grid-column: 1 / -1;
}

.form-group label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
}

.req {
  color: var(--danger);
}

.opt,
.hint {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 11.5px;
}

.section-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-group input,
.form-group select,
.form-group textarea {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-primary);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(9, 9, 11, 0.08);
}

/* =========================================================
   Dynamic Social Rows & Custom Logo Dropdown
   ========================================================= */
.section-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.social-rows-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.social-empty-hint {
  margin: 0;
  padding: 12px 14px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 12.5px;
  text-align: center;
}

.social-row {
  display: grid;
  grid-template-columns: 185px 1fr 36px;
  gap: 8px;
  align-items: center;
}

.social-row input {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-primary);
  min-width: 0;
  height: 40px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.social-row input:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(9, 9, 11, 0.08);
}

/* Custom Platform Dropdown with Real Logos */
.platform-dropdown {
  position: relative;
}

.platform-trigger {
  width: 100%;
  height: 40px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.platform-trigger:hover {
  border-color: var(--border-strong);
}

.platform-dropdown.open .platform-trigger {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(9, 9, 11, 0.08);
}

.platform-trigger-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.platform-trigger-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.platform-logo {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.platform-logo svg {
  width: 16px;
  height: 16px;
  display: block;
}

.platform-caret {
  color: var(--text-muted);
  flex-shrink: 0;
  transition: transform var(--transition);
}

.platform-dropdown.open .platform-caret {
  transform: rotate(180deg);
}

.platform-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 230px;
  max-height: 260px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  padding: 6px;
  z-index: 90;
  animation: fadeIn 120ms ease-out;
}

.platform-cat-label {
  padding: 6px 8px 4px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.platform-option {
  width: 100%;
  padding: 7px 9px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background var(--transition);
}

.platform-option:hover {
  background: var(--surface-subtle);
}

.platform-option.selected {
  background: var(--ink);
  color: #ffffff;
}

.note-textarea {
  min-height: 160px;
  line-height: 1.6;
  resize: vertical;
}

.modal-footer {
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* =========================================================
   Toast
   ========================================================= */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  background: var(--ink);
  color: #ffffff;
  padding: 9px 16px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: fadeIn 150ms ease-out;
}

/* =========================================================
   Animations & Mobile Portrait Optimization
   ========================================================= */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideInRight {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1); }
}

@media (max-width: 640px) {
  .topbar-inner {
    padding: 10px 14px;
  }

  .brand-subtitle {
    display: none;
  }

  .hide-sm {
    display: none;
  }

  .main-content {
    padding: 14px 14px 48px;
  }

  .controls-section {
    gap: 10px;
    margin-bottom: 14px;
  }

  .search-input {
    padding: 11px 38px 11px 40px;
    font-size: 14px;
  }

  .people-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .person-card {
    padding: 15px;
    gap: 10px;
  }

  /* Full-screen clean modal on mobile portrait */
  .modal-overlay {
    padding: 0;
  }

  .modal {
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
  }

  .modal-body {
    padding: 16px;
  }

  .form-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .social-row {
    grid-template-columns: 1fr 36px;
    gap: 8px;
  }

  .social-row .platform-dropdown {
    grid-column: 1 / -1;
  }

  .platform-menu {
    width: 100%;
  }

  .drawer {
    max-width: 100%;
  }

  .drawer-body {
    padding: 16px;
  }
}
