/* Google 暗色新标签页风格 —— 纯原生 CSS，无外部资源 */

:root {
  --bg: #202124;
  --surface: #303134;
  --surface-hover: #3c4043;
  --text: #e8eaed;
  --text-dim: #9aa0a6;
  --line: #5f6368;
  --accent: #8ab4f8;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Roboto, "Segoe UI", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* ---------- 顶部右侧链接与头像 ---------- */

.topbar {
  flex: 0 0 auto;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: 12px 18px;
}

.topbar__nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.topbar__link {
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  line-height: 1;
  padding: 9px 10px;
  border-radius: 4px;
}

.topbar__link:hover {
  text-decoration: underline;
}

.avatar {
  width: 32px;
  height: 32px;
  margin-left: 6px;
  border-radius: 50%;
  background: var(--surface-hover);
  display: inline-grid;
  place-items: center;
  user-select: none;
}

/* ---------- 页面主体 ---------- */

.page {
  flex: 1 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: clamp(32px, 10vh, 120px) 24px 56px;
}

.logo {
  margin: 0 0 26px;
  font-family: "Product Sans", Roboto, Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: clamp(40px, 5.5vw, 56px);
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -1.5px;
  color: #fff;
  user-select: none;
}

/* ---------- 搜索框 ---------- */

.search {
  width: 100%;
  max-width: 584px;
  height: 48px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px 0 18px;
  background: #fff;
  border: 1px solid #fff;
  border-radius: 999px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

.search:focus-within {
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.55);
}

.search__icon {
  flex: 0 0 auto;
  display: inline-flex;
  color: #5f6368;
}

.search__input {
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: none;
  background: transparent;
  color: #202124;
  font-family: inherit;
  font-size: 16px;
  line-height: 1;
}

.search__input::placeholder {
  color: #5f6368;
}

.search__mic {
  flex: 0 0 auto;
  display: inline-flex;
}

/* ---------- 快捷方式网格：数量无上限，自动换行 ---------- */

.shortcuts-section {
  width: 100%;
  max-width: 720px;
  margin-top: 34px;
}

.shortcuts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  column-gap: 8px;
  row-gap: 16px;
}

.tile {
  position: relative;
  min-width: 0;
}

.tile__link {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 4px 10px;
  border-radius: 8px;
  color: inherit;
  text-decoration: none;
}

.tile__link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.tile__icon {
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--surface);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.tile:hover .tile__icon,
.tile:focus-within .tile__icon {
  background: var(--surface-hover);
}

.tile__favicon {
  width: 24px;
  height: 24px;
  object-fit: contain;
  border-radius: 4px;
  display: block;
}

.tile__letter {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  margin: 0;
  font-size: 20px;
  font-weight: 500;
  color: var(--text);
  text-transform: uppercase;
}

.tile__name {
  display: block;
  max-width: 100%;
  margin-top: 11px;
  font-size: 13px;
  line-height: 1.35;
  color: var(--text);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tile__actions {
  position: absolute;
  top: 2px;
  right: 2px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  opacity: 0;
  pointer-events: none;
}

.tile:hover .tile__actions,
.tile:focus-within .tile__actions {
  opacity: 1;
  pointer-events: auto;
}

.tile__action {
  width: 20px;
  height: 20px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #202124;
  color: var(--text);
  cursor: pointer;
  font-size: 0;
}

.tile__action:hover {
  background: var(--surface-hover);
}

.tile__action:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* 网格末尾的“+”按钮 */

.tile--add {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  padding: 8px 4px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-dim);
  font-family: inherit;
  cursor: pointer;
}

.tile--add:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.tile--add .tile__icon {
  color: var(--text);
}

.tile--add .tile__name {
  color: var(--text-dim);
}

/* ---------- 添加 / 编辑弹窗（自定义 dialog） ---------- */

.modal {
  width: min(380px, calc(100vw - 40px));
  margin: auto;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #202124;
  color: var(--text);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.6);
}

.modal__form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px;
}

.modal__title {
  margin: 0;
  font-size: 18px;
  font-weight: 500;
  line-height: 1.3;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field__label {
  font-size: 13px;
  color: var(--text-dim);
}

.field__input {
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #202124;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
}

.field__input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.modal__error {
  margin: -4px 0 0;
  color: #f28b82;
  font-size: 13px;
  line-height: 1.4;
}

.modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.btn {
  height: 34px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 4px;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
}

.btn--ghost {
  background: transparent;
  color: var(--text);
}

.btn--ghost:hover {
  background: rgba(255, 255, 255, 0.08);
}

.btn--primary {
  background: var(--accent);
  color: #202124;
  font-weight: 500;
}

.btn--primary:hover {
  background: #aecbfa;
}

/* ---------- 轻提示 / 撤销 ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 10;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100vw - 40px);
  padding: 12px 16px;
  border-radius: 8px;
  background: #3c4043;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  font-size: 13px;
  color: var(--text);
}

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

.toast__action {
  flex: 0 0 auto;
  padding: 4px 8px;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.toast__action:hover {
  text-decoration: underline;
}

/* ---------- 窄屏适配 ---------- */

@media (max-width: 480px) {
  .topbar {
    padding: 10px 12px;
  }

  .page {
    padding: 40px 16px 40px;
  }

  .logo {
    margin-bottom: 22px;
  }

  .shortcuts-section {
    margin-top: 26px;
  }

  .shortcuts {
    row-gap: 12px;
  }
}
