:root {
  --bg: #edeafb;
  --card: #ffffff;
  --ink: #1b1730;
  --muted: #8a84a6;
  --purple: #5b4fe8;
  --purple-dim: #eceafb;
  --yellow: #f5c518;
  --red: #f0665b;
  --green-bg: #c9f2de;
  --green-ink: #1d8a5c;
  --shadow: 0 10px 24px rgba(43, 33, 92, 0.08);
  --shadow-lg: 0 24px 50px rgba(30, 20, 70, 0.16);
  --nav-h: 84px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
}

body.modal-open {
  overflow: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font-family: inherit;
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(91, 79, 232, 0.3);
  outline-offset: 2px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 56px;
  background: rgba(237, 234, 251, 0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid #dedaf3;
}

.brand,
.topbar-actions,
.modal-title,
.search-box,
.result-row,
.chan-top,
.pill-group,
.time-dot {
  display: flex;
  align-items: center;
}

.brand {
  gap: 12px;
}

.brand-logo {
  width: 42px;
  height: 42px;
  object-fit: contain;
  display: block;
  flex-shrink: 0;
}

.bell-badge {
  width: 42px;
  height: 42px;
  background: var(--yellow);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.bell-badge-small {
  width: 36px;
  height: 36px;
  font-size: 17px;
}

.brand-name {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.3px;
}

.topbar-actions {
  gap: 10px;
}

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--card);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  cursor: pointer;
  font-size: 17px;
  color: var(--purple);
}

.main {
  max-width: 980px;
  margin: 0 auto;
  padding: 36px 56px calc(var(--nav-h) + 60px);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  gap: 20px;
}

h1 {
  font-size: 32px;
  margin: 0;
  letter-spacing: -0.7px;
  font-weight: 800;
}

.subline {
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
  margin: 6px 0 28px;
}

.link-btn {
  background: none;
  border: 0;
  color: var(--purple);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.hist-card {
  background: var(--card);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 18px 20px;
  display: flex;
  gap: 16px;
  align-items: center;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.hist-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.avatar {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  object-fit: cover;
  background: #ccc;
  flex-shrink: 0;
}

.avatar-small {
  width: 44px;
  height: 44px;
}

.avatar-initials {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
}

.avatar-red {
  background: var(--red);
}

.avatar-blue {
  background: #3b4c9e;
}

.avatar-violet {
  background: #7a4cc7;
}

.hist-body {
  flex: 1;
  min-width: 0;
}

.hist-row-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 3px;
  gap: 10px;
}

.channel-name {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--muted);
}

.time-dot {
  gap: 8px;
  flex-shrink: 0;
}

.time {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

.unread-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--purple);
  flex-shrink: 0;
}

.hist-title {
  font-size: 17.5px;
  font-weight: 800;
  margin: 2px 0 10px;
}

.tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 8px;
  color: #fff;
}

.tag.long {
  background: var(--red);
}

.tag.short {
  background: var(--purple);
  width: 26px;
  padding: 4px 0;
}

.chan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}

.chan-card {
  background: var(--card);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 20px;
}

.chan-top {
  gap: 12px;
  margin-bottom: 16px;
}

.chan-top .chan-info {
  flex: 1;
  min-width: 0;
}

.remove-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 18px;
  padding: 8px;
}

.chan-info .name {
  font-size: 16.5px;
  font-weight: 800;
}

.chan-info .handle,
.result-info .handle {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

.chan-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.pill-group {
  gap: 8px;
}

.pill {
  border-radius: 12px;
  padding: 10px 16px;
  font-size: 13.5px;
  font-weight: 800;
  border: 2px solid #d9d5f2;
  cursor: pointer;
  background: transparent;
  color: var(--ink);
}

.pill.on {
  background: var(--purple);
  color: #fff;
  border-color: var(--purple);
}

.status-txt {
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
  text-align: right;
}

.empty-card {
  border: 2px dashed #cfc9ec;
  border-radius: 20px;
  padding: 30px 18px;
  text-align: center;
  color: var(--muted);
  font-weight: 700;
  font-size: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  background: transparent;
}

.empty-card:hover {
  border-color: var(--purple);
  color: var(--purple);
}

.plus-large {
  font-size: 22px;
}

.bottomnav-wrap {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 20px;
  display: flex;
  justify-content: center;
  z-index: 40;
  padding: 0 16px;
}

.bottomnav {
  background: var(--card);
  border-radius: 22px;
  box-shadow: var(--shadow-lg);
  display: flex;
  padding: 8px;
  gap: 6px;
  width: 100%;
  max-width: 360px;
}

.nav-btn {
  flex: 1;
  border: 0;
  background: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 4px;
  border-radius: 16px;
  font-size: 12.5px;
  font-weight: 800;
  color: var(--muted);
  cursor: pointer;
  position: relative;
}

.nav-btn.active {
  background: var(--purple-dim);
  color: var(--purple);
}

.nav-icon {
  font-size: 18px;
}

.badge {
  position: absolute;
  top: 2px;
  right: 28%;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  border-radius: 50%;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 10, 35, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}

.modal-overlay.show {
  display: flex;
}

.modal {
  background: var(--bg);
  width: 460px;
  max-width: 100%;
  border-radius: 24px;
  padding: 26px 26px 30px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.modal-title {
  gap: 10px;
}

.modal-title h2 {
  font-size: 21px;
  margin: 0;
  font-weight: 800;
}

.search-box {
  gap: 10px;
  background: var(--card);
  border: 2px solid var(--purple);
  border-radius: 14px;
  padding: 11px 14px;
  margin-bottom: 16px;
}

.search-box input {
  border: 0;
  outline: 0;
  background: none;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  flex: 1;
  min-width: 0;
}

.clear-search {
  color: var(--muted);
  cursor: pointer;
  border: 0;
  background: none;
  font-size: 16px;
}

.result-row {
  background: var(--card);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 11px 14px;
  gap: 12px;
  margin-bottom: 10px;
}

.result-row.hidden {
  display: none;
}

.result-info {
  flex: 1;
  min-width: 0;
}

.result-info .name {
  font-size: 14.5px;
  font-weight: 800;
}

.result-info .handle {
  font-size: 12.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.add-btn {
  border: 0;
  border-radius: 20px;
  padding: 8px 15px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  background: var(--purple);
  color: #fff;
  white-space: nowrap;
}

.add-btn.added {
  background: var(--green-bg);
  color: var(--green-ink);
}

.add-btn:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.state-card {
  border: 2px dashed #cfc9ec;
  border-radius: 16px;
  padding: 24px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.state-card.error {
  border-color: #efaaa4;
  color: #a7372e;
}

.video-thumb {
  width: 128px;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  object-fit: cover;
  flex-shrink: 0;
}

.quiet-card {
  background: var(--card);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.quiet-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  padding-bottom: 16px;
  border-bottom: 1px solid #efedfa;
  margin-bottom: 16px;
}

.quiet-row .label {
  font-size: 15.5px;
  font-weight: 800;
  margin-bottom: 4px;
}

.quiet-row .desc {
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 500;
  line-height: 1.4;
  max-width: 250px;
}

.switch {
  width: 48px;
  height: 28px;
  border-radius: 20px;
  background: var(--purple);
  position: relative;
  flex-shrink: 0;
  cursor: pointer;
  border: 0;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 23px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  transition: left 0.15s ease;
}

.switch.off {
  background: #d9d5f2;
}

.switch.off::after {
  left: 3px;
}

.time-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
}

.time-row .label {
  font-size: 15px;
  font-weight: 700;
}

.time-pill {
  background: #efedfa;
  color: var(--ink);
  border: 0;
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 14.5px;
  font-weight: 800;
}

.notification-btn {
  width: 100%;
  margin-top: 14px;
  border: 0;
  border-radius: 12px;
  padding: 11px 14px;
  background: var(--purple);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.notification-btn:disabled {
  background: var(--green-bg);
  color: var(--green-ink);
  cursor: default;
}

.quiet-footer {
  text-align: center;
  margin-top: 16px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--muted);
}

@media (max-width: 720px) {
  :root {
    --nav-h: 76px;
  }

  .topbar {
    padding: 14px 18px;
  }

  .brand-name {
    font-size: 16px;
  }

  .brand-logo {
    width: 36px;
    height: 36px;
  }

  .bell-badge {
    width: 36px;
    height: 36px;
    font-size: 17px;
    border-radius: 10px;
  }

  .icon-btn {
    width: 38px;
    height: 38px;
    font-size: 15px;
  }

  .main {
    padding: 24px 18px calc(var(--nav-h) + 40px);
  }

  h1 {
    font-size: 26px;
  }

  .subline {
    margin-bottom: 20px;
  }

  .chan-grid {
    grid-template-columns: 1fr;
  }

  .hist-card {
    padding: 14px 16px;
    gap: 12px;
  }

  .avatar {
    width: 46px;
    height: 46px;
  }

  .video-thumb {
    width: 96px;
  }

  .avatar-small {
    width: 44px;
    height: 44px;
  }

  .hist-title {
    font-size: 16px;
  }

  .hist-row-top {
    flex-wrap: wrap;
  }

  .chan-controls {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .status-txt {
    text-align: left;
  }

  .bottomnav-wrap {
    bottom: 14px;
    padding: 0 14px;
  }

  .bottomnav {
    max-width: 100%;
  }

  .modal {
    border-radius: 20px;
    padding: 20px;
  }
}

@media (max-width: 480px) {
  .hist-card {
    align-items: flex-start;
  }

  .video-thumb {
    width: 82px;
  }
}

@media (max-width: 400px) {
  .topbar {
    padding: 12px 14px;
  }

  .main {
    padding-left: 14px;
    padding-right: 14px;
  }
}
