 :root {
  --bg-color: #f5f5f7;
  --text-color: #1f2933;
  --muted-text-color: #6b7280;
  --card-bg-color: #ffffff;
  --card-soft-bg-color: #f9fafb;
  --border-color: #e5e7eb;
  --input-border-color: #d1d5db;
}

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

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg-color);
  color: var(--text-color);
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px;
}

.app-header {
  width: 100%;
  max-width: 900px;
  margin-bottom: 16px;
  text-align: center;
}

.app-header h1 {
  margin: 0;
}

.subtitle {
  margin-top: 6px;
}

.app-main {
  width: 100%;
  max-width: 900px;
  background: var(--card-bg-color);
  border-radius: 16px;
  box-shadow:
    0 10px 30px rgba(15, 23, 42, 0.07),
    0 2px 8px rgba(15, 23, 42, 0.05);
  padding: 16px 16px 20px;
  flex: 1;
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.app-footer {
  width: 100%;
  max-width: 900px;
  margin-top: 16px;
  padding: 10px 0 8px;
  text-align: center;
  font-size: 0.78rem;
  color: var(--footer-text-color);
}

.app-footer a {
  display: inline-block;
  margin-top: 4px;
  font-size: 0.78rem;
  color: var(--footer-link-color);
  text-decoration: none;
  border-bottom: 1px dotted rgba(107, 114, 128, 0.5);
}

.app-footer a:hover {
  color: var(--footer-link-hover-color);
  border-bottom-color: rgba(55, 65, 81, 0.7);
}

@media (min-width: 768px) {
  .app-main {
    grid-template-columns: 1.1fr 1.4fr;
    grid-template-rows: auto 1fr;
    grid-template-areas:
      "keyboard keyboard"
      "search results";
  }

  .keyboard-section {
    grid-area: keyboard;
  }

  .search-section {
    grid-area: search;
  }

  .results-section {
    grid-area: results;
  }
}

.section-title {
  margin: 0 0 8px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--muted-text-color);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-align: center;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card-soft-bg-color);
  color: #2563eb;
  box-shadow:
    0 8px 20px rgba(15, 23, 42, 0.12),
    0 0 0 1px rgba(15, 23, 42, 0.04);
}

.logo-text {
  text-align: left;
}

.logo-text h1 {
  margin: 0;
  font-size: 1.9rem;
  letter-spacing: 0.04em;
}

.logo-text .subtitle {
  margin-top: 4px;
}

.keyboard-section {
  border-right: 0;
  padding-right: 0;
}

@media (min-width: 768px) {
  .keyboard-section {
    border-right: 0;
    padding-right: 0;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 16px;
  }
}

.alphabet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(34px, 1fr));
  gap: 6px;
}

.alphabet-button {
  border: 1px solid var(--border-color);
  background: var(--card-soft-bg-color);
  border-radius: 999px;
  padding: 6px 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-color);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.05s ease, box-shadow 0.1s ease,
    border-color 0.15s ease, color 0.15s ease;
}

.alphabet-button:hover {
  background: #e5f0ff;
  border-color: #2563eb;
  color: #1d4ed8;
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.2);
}

.alphabet-button:active {
  transform: scale(0.97);
  background: #dbeafe;
}

.alphabet-button.active {
  background: #2563eb;
  border-color: #2563eb;
  color: #ffffff;
  box-shadow:
    0 6px 16px rgba(37, 99, 235, 0.35),
    0 0 0 1px rgba(37, 99, 235, 0.45);
}

.alphabet-button.alphabet-clear {
  grid-column: 1 / -1;
  border-radius: 12px;
  padding: 8px 0;
  background: #fff7ed;
  border-color: #fed7aa;
  color: #9a3412;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.alphabet-button.alphabet-clear:hover {
  background: #ffedd5;
  border-color: #fdba74;
  color: #7c2d12;
  box-shadow: 0 0 0 1px rgba(234, 88, 12, 0.14);
}

.search-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

.search-section .section-title {
  width: 100%;
  text-align: center;
}

#search-input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 999px;
  border: 1px solid var(--input-border-color);
  font-size: 0.97rem;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s;
  background: var(--card-soft-bg-color);
}

#search-input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
  background: var(--card-bg-color);
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 0.83rem;
}

#result-count {
  font-weight: 500;
  color: var(--text-color);
}

.meta-hint {
  color: var(--muted-text-color);
}

.results-section {
  margin-top: 4px;
}

.results-list {
  border-radius: 12px;
  border: 1px solid var(--border-color);
  background: var(--card-soft-bg-color);
  padding: 6px;
  max-height: 360px;
  overflow-y: auto;
  font-size: 0.93rem;
}

.result-item {
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  margin: 2px;
  background: var(--card-bg-color);
  border: 1px solid var(--border-color);
  transition: background 0.15s ease, transform 0.05s ease, box-shadow 0.1s ease,
    border-color 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}

.result-item:hover {
  background: #eff6ff;
  border-color: #2563eb;
  color: #1d4ed8;
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.2);
}

.result-item:active {
  transform: scale(0.97);
}

.results-empty {
  padding: 8px 4px;
  color: var(--results-empty-color);
  font-size: 0.86rem;
}

.toast {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  padding: 10px 14px;
  background: var(--toast-bg-color);
  color: var(--toast-text-color);
  border-radius: 999px;
  font-size: 0.85rem;
  box-shadow:
    0 10px 25px rgba(15, 23, 42, 0.4),
    0 0 0 1px rgba(31, 41, 55, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 50;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

