/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: arial, sans-serif;
  background: #fff;
  color: #202124;
  overflow-x: hidden;
}

body { display: flex; flex-direction: column; align-items: center; }

/* ===== Top Bar ===== */
.top-bar {
  width: 100%;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: 10px 30px;
  gap: 14px;
  font-size: 13px;
}
.top-bar a {
  color: rgba(0,0,0,.87);
  text-decoration: none;
}
.top-bar a:hover { text-decoration: underline; }

/* Services grid button */
.services-btn {
  width: 40px; height: 40px;
  border: none; background: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
.services-btn:hover { background: rgba(60,64,67,.08); }
.services-btn svg { width: 24px; height: 24px; fill: #5f6368; }

/* ===== Services Dropdown ===== */
.services-dropdown {
  position: absolute;
  top: 52px;
  right: 20px;
  width: 340px;
  max-height: 440px;
  overflow-y: auto;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 2px 10px 0 rgba(0,0,0,.2);
  padding: 20px 12px;
  z-index: 200;
  display: none;
}
.services-dropdown.visible { display: block; }
.services-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}
.service-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  color: #202124;
  padding: 10px 6px;
  border-radius: 12px;
  font-size: 12px;
  text-align: center;
}
.service-item:hover { background: #f1f3f4; }
.service-item img {
  width: 38px; height: 38px;
  margin-bottom: 8px;
  object-fit: contain;
}
.service-item span {
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== Main Content ===== */
.main-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 72px;
  width: 100%;
}

/* Banner logo above search */
.hero-brand {
  width: 100%;
  max-width: 361px;
  padding: 0 12px;
  margin-bottom: 28px;
  box-sizing: border-box;
}
.main-logo {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  object-fit: contain;
}

/* ===== Search Wrapper ===== */
.search-wrapper {
  position: relative;
  width: 768px;
  max-width: 95vw;
}
.search-bar {
  width: 100%;
  height: 56px;
  border: 1px solid #dfe1e5;
  border-radius: 28px;
  display: flex;
  align-items: center;
  padding: 0 6px 0 18px;
  background: #fff;
  transition: box-shadow .2s;
}
.search-bar:hover,
.search-bar.focused {
  box-shadow: 0 1px 6px rgba(32,33,36,.28);
  border-color: rgba(223,225,229,0);
}
.search-bar.open-top {
  border-radius: 28px 28px 0 0;
  box-shadow: 0 1px 6px rgba(32,33,36,.28);
  border-color: rgba(223,225,229,0);
}

.search-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 12px;
  flex-shrink: 0;
  border: none;
  background: none;
  padding: 6px;
  margin-left: -2px;
  cursor: pointer;
  border-radius: 50%;
}
.search-icon-btn:focus-visible {
  outline: 2px solid #1a73e8;
  outline-offset: 1px;
}
.search-icon-img {
  width: 22px;
  height: 22px;
  display: block;
  object-fit: contain;
}

#searchInput {
  flex: 1;
  border: none;
  outline: none;
  font-size: 18px;
  background: transparent;
  color: #202124;
  height: 100%;
  padding: 0;
  margin: 0;
  -webkit-appearance: none;
  appearance: none;
  min-width: 0;
}
#searchInput::placeholder {
  color: #9aa0a6;
  opacity: 1;
}

.voice-btn {
  width: 40px; height: 40px;
  border: none; background: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  margin-left: 12px;
  flex-shrink: 0;
  padding: 0;
}
.voice-btn svg { width: 26px; height: 26px; }

/* ===== Suggestions Dropdown ===== */
.suggestions-dropdown {
  position: absolute;
  top: 55px;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid rgba(223,225,229,0);
  border-top: 1px solid #e8eaed;
  border-radius: 0 0 28px 28px;
  box-shadow: 0 4px 6px rgba(32,33,36,.28);
  z-index: 150;
  display: none;
  overflow: hidden;
}
.suggestions-dropdown.visible { display: block; }
.suggestion-item {
  display: flex;
  align-items: center;
  padding: 10px 20px;
  cursor: pointer;
  font-size: 15px;
  color: #202124;
  text-decoration: none;
  position: relative;
}
.suggestion-item:hover,
.suggestion-item.active {
  background: #f1f3f4;
}
.suggestion-item .sug-icon {
  width: 22px; height: 22px;
  margin-right: 16px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.suggestion-item .sug-icon svg { width: 18px; height: 18px; fill: #9aa0a6; }
.suggestion-item .sug-text { flex: 1; }
.suggestion-item .sug-delete {
  width: 24px; height: 24px;
  border: none; background: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #70757a;
  font-size: 16px;
  border-radius: 50%;
  opacity: 0;
  transition: opacity .15s;
}
.suggestion-item:hover .sug-delete,
.suggestion-item.active .sug-delete { opacity: 1; }
.suggestion-item .sug-delete:hover { background: #dadce0; }
.suggestions-separator {
  height: 1px;
  background: #e8eaed;
  margin: 4px 20px;
}

/* ===== Shortcuts Grid ===== */
.shortcuts-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;
  gap: 16px;
  margin-top: 32px;
  width: 100%;
  max-width: min(1200px, 100%);
  padding: 0 16px;
  box-sizing: border-box;
}
.shortcut-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 110px;
  flex: 0 0 auto;
  cursor: pointer;
  border-radius: 8px;
  padding: 12px 4px 10px;
  position: relative;
  text-decoration: none;
  color: inherit;
}
.shortcut-item:hover { background: #f1f3f4; }
.shortcut-icon-wrap {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: #f1f3f4;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 8px;
  position: relative;
  overflow: hidden;
}
.shortcut-icon-wrap img {
  position: relative;
  z-index: 1;
  width: 24px; height: 24px;
  border-radius: 2px;
  object-fit: contain;
}
.shortcut-icon-wrap img.is-hidden {
  display: none;
}
.shortcut-letter-avatar {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 600;
  color: #fff;
  line-height: 1;
  z-index: 2;
}
.shortcut-letter-avatar.is-visible {
  display: flex;
}
.shortcut-label {
  font-size: 12px;
  color: #70757a;
  max-width: 96px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
}
.shortcut-add-icon {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: #f1f3f4;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 8px;
}
.shortcut-add-icon svg { width: 24px; height: 24px; fill: #70757a; }

/* Shortcut context menu (3-dot) */
.shortcut-menu-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px; height: 24px;
  border: none; background: none;
  border-radius: 50%;
  cursor: pointer;
  display: none;
  align-items: center; justify-content: center;
  font-size: 16px; color: #70757a;
}
.shortcut-item:hover .shortcut-menu-btn { display: flex; }
.shortcut-menu-btn:hover { background: #dadce0; }

.shortcut-context-menu {
  position: absolute;
  top: 28px; right: 4px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0,0,0,.2);
  z-index: 100;
  display: none;
  min-width: 120px;
  overflow: hidden;
}
.shortcut-context-menu.visible { display: block; }
.shortcut-ctx-item {
  padding: 10px 16px;
  cursor: pointer;
  font-size: 13px;
  color: #202124;
}
.shortcut-ctx-item:hover { background: #f1f3f4; }

@media (max-width: 540px) {
  .shortcuts-container {
    gap: 14px 12px;
    padding: 0 12px;
  }
  .shortcut-item {
    width: 96px;
    padding: 10px 2px 8px;
  }
  .shortcut-icon-wrap,
  .shortcut-add-icon {
    width: 44px;
    height: 44px;
  }
  .shortcut-icon-wrap img {
    width: 22px;
    height: 22px;
  }
  .shortcut-letter-avatar {
    font-size: 18px;
  }
  .shortcut-label {
    max-width: 88px;
    font-size: 11px;
  }
  .shortcut-menu-btn {
    top: 2px;
    right: 2px;
    width: 22px;
    height: 22px;
    font-size: 14px;
  }
}

@media (max-width: 360px) {
  .shortcuts-container {
    gap: 12px 8px;
    padding: 0 8px;
  }
  .shortcut-item {
    width: 86px;
    padding: 8px 2px 6px;
  }
  .shortcut-icon-wrap,
  .shortcut-add-icon {
    width: 40px;
    height: 40px;
  }
  .shortcut-icon-wrap img {
    width: 20px;
    height: 20px;
  }
  .shortcut-letter-avatar {
    font-size: 16px;
  }
  .shortcut-label {
    max-width: 80px;
    font-size: 10px;
  }
}

/* ===== Shortcut Modal ===== */
.modal-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,.6);
  z-index: 500;
  display: none;
  align-items: center; justify-content: center;
}
.modal-overlay.visible { display: flex; }
.modal {
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  width: 360px;
  max-width: 90vw;
}
.modal h2 {
  font-size: 16px;
  font-weight: 500;
  margin-bottom: 20px;
}
.modal-field {
  display: flex;
  flex-direction: column;
  margin-bottom: 16px;
}
.modal-field label {
  font-size: 12px;
  color: #70757a;
  margin-bottom: 6px;
}
.modal-field input {
  border: 1px solid #dadce0;
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
}
.modal-field input:focus { border-color: #1a73e8; }
.modal-error {
  color: #d93025;
  font-size: 12px;
  margin-top: 4px;
  min-height: 16px;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}
.modal-actions button {
  padding: 8px 24px;
  border-radius: 4px;
  font-size: 14px;
  cursor: pointer;
  border: none;
}
.btn-cancel { background: none; color: #1a73e8; }
.btn-cancel:hover { background: rgba(26,115,232,.04); }
.btn-done { background: #1a73e8; color: #fff; }
.btn-done:hover { background: #1765cc; }

/* ===== Voice Overlay ===== */
.voice-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: #fff;
  z-index: 1000;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.voice-overlay.visible { display: flex; }
.voice-overlay-close {
  position: absolute;
  top: 20px; right: 20px;
  width: 40px; height: 40px;
  border: none; background: none;
  cursor: pointer;
  border-radius: 50%;
  font-size: 24px;
  color: #5f6368;
  display: flex; align-items: center; justify-content: center;
}
.voice-overlay-close:hover { background: #f1f3f4; }
.voice-status {
  font-size: 24px;
  color: #202124;
  margin-bottom: 40px;
}
.voice-mic-wrap {
  width: 96px; height: 96px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  position: relative;
  cursor: pointer;
}
.voice-mic-wrap.waiting { background: #f1f3f4; }
.voice-mic-wrap.listening {
  background: #ea4335;
  animation: pulse 1.2s ease-in-out infinite;
}
.voice-mic-wrap svg { width: 40px; height: 40px; }
.voice-mic-wrap.waiting svg { fill: #4285f4; }
.voice-mic-wrap.listening svg { fill: #fff; }
.voice-error {
  margin-top: 24px;
  color: #d93025;
  font-size: 16px;
  text-align: center;
}
.voice-retry-btn {
  margin-top: 16px;
  padding: 10px 24px;
  border-radius: 4px;
  border: 1px solid #dadce0;
  background: #fff;
  cursor: pointer;
  font-size: 14px;
  color: #1a73e8;
}
.voice-retry-btn:hover { background: #f1f3f4; }

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(234,67,53,.4); }
  70% { box-shadow: 0 0 0 30px rgba(234,67,53,0); }
  100% { box-shadow: 0 0 0 0 rgba(234,67,53,0); }
}

/* ===== Language Switcher ===== */
.lang-switcher {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 12px;
  font-size: 12px;
}
.lang-switcher button {
  border: none;
  background: none;
  cursor: pointer;
  color: #70757a;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 4px;
}
.lang-switcher button:hover { background: #f1f3f4; }
.lang-switcher button.active { color: #1a73e8; font-weight: 500; }

/* ===== Accessibility ===== */
:focus-visible {
  outline: 2px solid #1a73e8;
  outline-offset: 2px;
}

/* ===== Dark mode (browser / OS «prefers dark») ===== */
@media (prefers-color-scheme: dark) {
  html { color-scheme: dark; }

  html, body {
    background: #202124;
    color: #e8eaed;
  }

  .top-bar a {
    color: #e8eaed;
  }
  .services-btn:hover { background: rgba(255,255,255,.08); }
  .services-btn svg { fill: #bdc1c6; }

  .services-dropdown {
    background: #303134;
    box-shadow: 0 4px 24px rgba(0,0,0,.45);
  }
  .service-item {
    color: #e8eaed;
  }
  .service-item:hover { background: #3c4043; }

  .search-bar {
    background: #303134;
    border-color: #5f6368;
  }
  .search-bar:hover,
  .search-bar.focused,
  .search-bar.open-top {
    box-shadow: 0 1px 8px rgba(0,0,0,.4);
    border-color: transparent;
  }

  .search-icon-btn:focus-visible {
    outline-color: #8ab4f8;
  }

  .search-icon-img {
    filter: brightness(1.15);
  }

  #searchInput {
    color: #e8eaed;
  }
  #searchInput::placeholder {
    color: #9aa0a6;
  }

  .suggestions-dropdown {
    background: #303134;
    border-top-color: #3c4043;
    box-shadow: 0 4px 12px rgba(0,0,0,.45);
  }
  .suggestion-item {
    color: #e8eaed;
  }
  .suggestion-item:hover,
  .suggestion-item.active {
    background: #3c4043;
  }
  .suggestion-item .sug-icon svg { fill: #9aa0a6; }
  .suggestion-item .sug-delete {
    color: #bdc1c6;
  }
  .suggestion-item .sug-delete:hover { background: #5f6368; }
  .suggestions-separator {
    background: #3c4043;
  }

  .shortcut-item:hover { background: #3c4043; }
  .shortcut-icon-wrap,
  .shortcut-add-icon {
    background: #3c4043;
  }
  .shortcut-label {
    color: #bdc1c6;
  }
  .shortcut-add-icon svg { fill: #bdc1c6; }
  .shortcut-menu-btn { color: #bdc1c6; }
  .shortcut-menu-btn:hover { background: #5f6368; }

  .shortcut-context-menu {
    background: #303134;
    box-shadow: 0 4px 16px rgba(0,0,0,.5);
  }
  .shortcut-ctx-item {
    color: #e8eaed;
  }
  .shortcut-ctx-item:hover { background: #3c4043; }

  .modal-overlay {
    background: rgba(0,0,0,.75);
  }
  .modal {
    background: #303134;
    color: #e8eaed;
  }
  .modal-field label {
    color: #bdc1c6;
  }
  .modal-field input {
    background: #202124;
    border-color: #5f6368;
    color: #e8eaed;
  }
  .modal-field input:focus { border-color: #8ab4f8; }
  .modal-error {
    color: #f28b82;
  }
  .btn-cancel {
    color: #8ab4f8;
  }
  .btn-cancel:hover { background: rgba(138,180,248,.12); }
  .btn-done {
    background: #8ab4f8;
    color: #202124;
  }
  .btn-done:hover { background: #aecbfa; }

  .voice-overlay {
    background: #202124;
  }
  .voice-overlay-close {
    color: #bdc1c6;
  }
  .voice-overlay-close:hover { background: #3c4043; }
  .voice-status {
    color: #e8eaed;
  }
  .voice-mic-wrap.waiting { background: #3c4043; }
  .voice-error {
    color: #f28b82;
  }
  .voice-retry-btn {
    background: #303134;
    border-color: #5f6368;
    color: #8ab4f8;
  }
  .voice-retry-btn:hover { background: #3c4043; }

  .lang-switcher button {
    color: #bdc1c6;
  }
  .lang-switcher button:hover { background: #3c4043; }
  .lang-switcher button.active {
    color: #8ab4f8;
  }

  :focus-visible {
    outline-color: #8ab4f8;
  }
}
