:root {
  --bg-deep: #07111e;
  --bg-card: rgba(14, 27, 46, 0.88);
  --bg-input: rgba(8, 17, 30, 0.9);
  --border-subtle: rgba(148, 197, 255, 0.18);
  --border-strong: rgba(56, 189, 248, 0.45);
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --accent: #38bdf8;
  --accent-hover: #0ea5e9;
  --accent-soft: rgba(56, 189, 248, 0.14);
  --danger: #f87171;
  --danger-bg: rgba(239, 68, 68, 0.12);
  --danger-border: rgba(248, 113, 113, 0.4);
  --warn-bg: rgba(251, 191, 36, 0.12);
  --warn-border: rgba(251, 191, 36, 0.4);
  --radius-lg: 20px;
  --radius-md: 12px;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  color: var(--text-main);
  background: radial-gradient(circle at top, #102a49 0%, var(--bg-deep) 65%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.bg-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(600px circle at 15% 15%, rgba(56, 189, 248, 0.12), transparent 60%),
    radial-gradient(500px circle at 85% 80%, rgba(99, 102, 241, 0.12), transparent 60%);
  z-index: 0;
}

.app-shell {
  position: relative;
  z-index: 1;
  width: 100%;
  display: flex;
  justify-content: center;
}

.hidden {
  display: none !important;
}

.card {
  width: 100%;
  max-width: 480px;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  box-shadow: var(--shadow);
  animation: fadeIn 0.2s ease-out;
}

.wide-card {
  max-width: 860px;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid rgba(56, 189, 248, 0.25);
  margin-bottom: 14px;
}

h1 {
  margin: 0 0 10px;
  font-size: clamp(1.65rem, 3vw, 2.1rem);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 0 0 24px;
  color: var(--text-muted);
  line-height: 1.55;
  font-size: 0.98rem;
}

/* Notices */
.notice-banner {
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  color: #fde68a;
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-size: 0.88rem;
  line-height: 1.5;
  margin-bottom: 20px;
}

.notice-banner code {
  background: rgba(0, 0, 0, 0.3);
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 0.84em;
}

/* Buttons */
button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: transform 0.12s ease, background-color 0.15s ease, border-color 0.15s ease,
    opacity 0.15s ease;
}

button:active {
  transform: scale(0.98);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-google {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: #ffffff;
  color: #1f2937;
  font-weight: 700;
  font-size: 1rem;
  padding: 14px 20px;
  border-radius: var(--radius-md);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

.btn-google:hover:not(:disabled) {
  background: #f8fafc;
}

.google-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.btn-primary {
  background: var(--accent);
  color: #041322;
  font-weight: 700;
  font-size: 0.96rem;
  padding: 12px 22px;
  border-radius: var(--radius-md);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-secondary {
  background: rgba(148, 163, 184, 0.14);
  color: var(--text-main);
  font-weight: 600;
  font-size: 0.95rem;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.btn-secondary:hover {
  background: rgba(148, 163, 184, 0.22);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
}

.btn-ghost:hover {
  color: var(--text-main);
  border-color: var(--border-strong);
  background: rgba(255, 255, 255, 0.04);
}

.btn-small {
  background: rgba(56, 189, 248, 0.14);
  color: var(--accent);
  font-weight: 600;
  font-size: 0.8rem;
  padding: 5px 12px;
  border-radius: 8px;
  border: 1px solid rgba(56, 189, 248, 0.28);
}

.btn-small:hover {
  background: rgba(56, 189, 248, 0.24);
}

.status-text {
  margin: 16px 0 0;
  min-height: 20px;
  font-size: 0.88rem;
  color: var(--text-muted);
  text-align: center;
}

/* Access Denied */
.denied-card {
  text-align: center;
  border-color: var(--danger-border);
}

.denied-icon {
  font-size: 2.6rem;
  margin-bottom: 10px;
}

.denied-heading {
  color: var(--danger);
}

.denied-note {
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: #fecaca;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  line-height: 1.5;
  margin-bottom: 24px;
}

/* Top bar & User pill */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-bottom: 18px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border-subtle);
}

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

.user-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 10px #34d399;
}

.user-name {
  font-weight: 700;
  font-size: 0.95rem;
}

.user-email {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* Main Screen Mode Cards */
.home-hero {
  margin-bottom: 22px;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.mode-card {
  text-align: left;
  background: rgba(15, 31, 54, 0.85);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 24px;
  color: var(--text-main);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mode-card:hover {
  border-color: var(--border-strong);
  background: rgba(20, 42, 72, 0.95);
  transform: translateY(-2px);
}

.mode-tag {
  display: inline-block;
  width: fit-content;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
}

.mode-title {
  font-size: 1.25rem;
  font-weight: 800;
}

.mode-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.45;
}

/* Translator Workspace */
.translator-header {
  margin-bottom: 20px;
}

.translator-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.io-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.output-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 28px;
}

.field-label {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-muted);
}

textarea,
.output-box {
  width: 100%;
  min-height: 155px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  color: var(--text-main);
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.55;
}

textarea {
  resize: vertical;
}

textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.16);
}

.output-box {
  white-space: pre-wrap;
  word-break: break-word;
  overflow-y: auto;
}

.output-box:empty::before {
  content: attr(data-placeholder);
  color: rgba(148, 163, 184, 0.55);
}

.action-row {
  display: flex;
  gap: 10px;
  margin-top: 2px;
}

.quick-chars {
  display: flex;
  gap: 6px;
}

.char-pill {
  background: rgba(148, 163, 184, 0.14);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 3px 10px;
  font-size: 0.9rem;
  font-weight: 600;
}

.char-pill:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Word Chart Reference */
.chart-details {
  margin-top: 24px;
  border-top: 1px solid var(--border-subtle);
  padding-top: 16px;
}

.chart-details summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--accent);
  user-select: none;
}

.chart-table-wrap {
  margin-top: 14px;
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.chart-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.chart-table th,
.chart-table td {
  text-align: left;
  padding: 9px 14px;
  border-bottom: 1px solid rgba(148, 197, 255, 0.08);
}

.chart-table th {
  position: sticky;
  top: 0;
  background: #0d1d33;
  color: var(--text-muted);
  font-weight: 700;
}

/* Error Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 8, 16, 0.76);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
}

.modal-card {
  width: 100%;
  max-width: 420px;
  background: #0e1b2e;
  border: 1px solid var(--danger-border);
  border-radius: var(--radius-lg);
  padding: 28px 26px;
  text-align: center;
  box-shadow: var(--shadow);
  animation: fadeIn 0.16s ease-out;
}

.modal-icon {
  font-size: 2.2rem;
  margin-bottom: 8px;
}

.modal-card h2 {
  margin: 0 0 8px;
  color: var(--danger);
  font-size: 1.35rem;
}

.modal-message {
  margin: 0 0 14px;
  color: var(--text-muted);
  font-size: 0.94rem;
  line-height: 1.5;
}

.missing-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-bottom: 20px;
}

.missing-chip {
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: #fecaca;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.86rem;
  font-weight: 600;
}

.modal-ok {
  width: 100%;
}

@media (max-width: 720px) {
  .card {
    padding: 26px 20px;
  }

  .mode-grid,
  .translator-grid {
    grid-template-columns: 1fr;
  }
}
