@import url('https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@500;700&display=swap');

:root {
  --primary-cyan: #23f7dd;
  --accent-violet: #8a3ffc;
  --surface-card: rgba(255, 255, 255, 0.06);
  --border-line: rgba(255, 255, 255, 0.1);
  --max-w: min(520px, 94vw);
  --gap-md: clamp(20px, 3vw, 32px);
  --logo-dim: clamp(60px, 6vw, 88px);
  --text-h1: clamp(26px, 2.2vw, 34px);
  --text-body: clamp(13px, 1.1vw, 15px);
  --btn-height: clamp(54px, 4.2vw, 64px);
  --btn-text: clamp(14px, 1.15vw, 16px);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Inter', sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  background: #000;
  color: #fff;
  min-height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
  background: radial-gradient(circle at 50% -10%, #1a0a30 0%, #000 75%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.wallet-container {
  width: 100%;
  max-width: var(--max-w);
  min-height: auto;
  margin: 0 auto;
  padding: var(--gap-md);
  display: flex;
  flex-direction: column;
}

.app-header {
  text-align: center;
  margin: 16px 0 24px;
}

.logo-wrapper {
  width: var(--logo-dim);
  height: var(--logo-dim);
  margin: 0 auto;
  position: relative;
  display: grid;
  place-items: center;
}

.logo-wrapper::before {
  content: "";
  position: absolute;
  inset: -20px;
  background: radial-gradient(circle, rgba(138, 63, 252, 0.35) 0%, transparent 70%);
  filter: blur(12px);
  z-index: 0;
}

.brand-logo {
  width: var(--logo-dim);
  height: var(--logo-dim);
  border-radius: 18px;
  object-fit: contain;
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.55));
  position: relative;
  z-index: 1;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.brand-text {
  margin-top: 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 2px;
  color: rgba(255, 255, 255, 0.75);
  text-transform: uppercase;
}

.screen-view {
  display: none;
  animation: fadeUp 0.28s ease;
  padding-bottom: 60px;
}

.screen-view.active-screen {
  display: block;
}

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

h1 {
  font-size: var(--text-h1);
  font-weight: 800;
  text-align: center;
  letter-spacing: -1px;
  margin-bottom: 8px;
}

.title-gradient {
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.98), rgba(255, 255, 255, 0.75));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.subtitle {
  font-size: var(--text-body);
  color: rgba(255, 255, 255, 0.55);
  text-align: center;
  line-height: 1.55;
  margin-bottom: 32px;
}

.nav-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 12px;
}

.btn-back {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: .15s;
}

.btn-back svg {
  width: 17px;
  height: 17px;
  opacity: 0.85;
}

.btn-back:hover {
  border-color: rgba(35, 247, 221, 0.25);
  background: rgba(35, 247, 221, 0.07);
}

.screen-title {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.8px;
  color: rgba(255, 255, 255, 0.6);
}

.nav-spacer {
  width: 42px;
  height: 42px;
}

.action-btn {
  width: 100%;
  height: var(--btn-height);
  border-radius: 100px;
  font-size: var(--btn-text);
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: .18s;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.1px;
}

.btn-primary {
  background: #fff;
  color: #000;
  margin-bottom: 10px;
}

.btn-primary:hover {
  background: rgba(255, 255, 255, 0.92);
}

.btn-secondary {
  background: var(--surface-card);
  color: #fff;
  border: 1px solid var(--border-line);
}

.action-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.length-selector {
  display: flex;
  justify-content: center;
  gap: 5px;
  margin-bottom: 18px;
}

.len-option {
  padding: 7px 11px;
  background: var(--surface-card);
  border: 1px solid var(--border-line);
  border-radius: 9px;
  font-size: 11px;
  font-weight: 700;
  color: #555;
  cursor: pointer;
  transition: .15s;
}

.len-option.selected {
  background: var(--accent-violet);
  color: #fff;
  border-color: var(--accent-violet);
}

.phrase-container {
  background: #110c22;
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 12px;
  padding: 16px 16px 12px 16px;
  position: relative;
  margin-bottom: 24px;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  transition: border-color 0.2s;
  cursor: text;
}

.phrase-container:focus-within {
  border-color: rgba(255,255,255,0.2);
}

.word-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
  flex: 1;
}

.import-words-flow {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  align-content: flex-start;
  flex: 1;
  margin-bottom: 24px;
}

.master-input {
  background: transparent;
  border: none;
  outline: none;
  color: #fff;
  font-size: 15px;
  font-weight: 500;
  flex: 1 1 20px;
  min-width: 20px;
  max-width: 100%;
  padding: 0;
  margin: 0;
  font-family: 'Roboto Mono', 'Fira Code', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  line-height: 1;
  letter-spacing: 0.5px;
}

.master-input::placeholder {
  color: rgba(255,255,255,0.3);
}

.pill-word {
  background: #23203b;
  border-radius: 20px;
  padding: 6px 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  font-family: 'Roboto Mono', 'Fira Code', 'Courier New', Courier, monospace;
  letter-spacing: 0.5px;
  transition: all 0.2s;
}

.pill-word.input-mode {
  background: #23203b;
  cursor: pointer;
}

.pill-word.input-mode:hover {
  background: #322e54;
}

.pill-word.active-pill-input {
  background: #0a0616;
  cursor: text;
  width: 100px;
  max-width: 100%;
  box-shadow: none;
  padding: 6px 12px;
}

.pill-word.active-pill-input:focus-within {
  background: #0a0616;
  box-shadow: none;
}

.pill-word.active-pill-input.is-full {
  background: transparent;
  width: 1px;
  padding: 0;
  margin-left: 4px;
}

.pill-word.active-pill-input.is-full:focus-within {
  background: transparent;
}

.pill-word.active-pill-input .master-input {
  display: block;
  caret-color: var(--accent-violet);
}

.pill-num {
  color: rgba(255,255,255,0.4);
  font-size: 13px;
  font-weight: 700;
}

.pill-text {
  color: #fff;
}

.phrase-container.import-container {
  position: relative;
  min-height: 220px;
  display: flex;
  flex-direction: column;
}

.autocomplete-dropdown {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 20px;
  background: #1b162c;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  max-height: 160px;
  overflow-y: auto;
  z-index: 100;
  margin-bottom: 8px;
  padding: 4px 0;
  min-width: 140px;
}

.autocomplete-dropdown.show {
  display: block;
}

.autocomplete-item {
  padding: 8px 16px;
  cursor: pointer;
  color: #fff;
  font-family: 'Roboto Mono', 'Fira Code', 'Courier New', Courier, monospace;
  font-size: 14px;
  transition: background 0.2s;
}

.autocomplete-item:hover, .autocomplete-item.active {
  background: rgba(138, 63, 252, 0.3);
}

.autocomplete-item .match {
  color: var(--primary-cyan);
  font-weight: 700;
}

.pill-word.has-error {
  background: rgba(255, 59, 48, 0.15);
  box-shadow: 0 0 0 1px #ff3b30;
  animation: errorWiggle 0.4s ease;
}

.pill-word.has-error .pill-num,
.pill-word.has-error .pill-text {
  color: #ff3b30;
}

.inline-phrase-error {
  color: #ff3b30;
  font-size: 13px;
  font-weight: 500;
  margin-top: 8px;
  margin-bottom: 16px;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 4px;
}

.security-warning {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #1b162c;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 24px;
}

.shield-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  margin-top: 0;
}

.shield-icon svg {
  width: 100%;
  height: 100%;
  color: var(--accent-violet);
  stroke-width: 2px;
}

.security-warning p {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.85);
  line-height: 1.4;
  font-weight: 500;
  margin: 0;
  max-width: 100%;
  text-align: left;
}

.security-warning strong {
  color: #fff;
  font-weight: 700;
}

.phrase-container.create-container {
  padding: 24px 20px 16px;
  background: #0a0616;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.05);
  display: flex;
  flex-direction: column;
}

.create-word-grid {
  display: grid;
  grid-auto-flow: column;
  gap: 16px 20px;
  margin-bottom: 24px;
}

.create-word-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Roboto Mono', 'Fira Code', 'Courier New', Courier, monospace;
  font-size: 14px;
  letter-spacing: 0.5px;
}

.create-word-num {
  color: rgba(255,255,255,0.4);
  font-weight: 500;
  width: 24px;
  text-align: right;
}

.create-word-text {
  color: #fff;
  font-weight: 700;
}

.copy-action-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
  padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.copy-action-wrapper:hover {
  opacity: 0.8;
}

.copy-action-wrapper svg {
  color: #fff;
}

.security-warning-inline {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.security-warning-inline .warning-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.security-warning-inline svg {
  width: 20px;
  height: 20px;
  color: #ff9d4a;
  flex-shrink: 0;
}

.security-warning-inline .warning-title {
  color: #ffffff;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.security-warning-inline p {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.85);
  line-height: 1.6;
  font-weight: 400;
  padding-left: 28px;
}

@keyframes errorWiggle {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

#loading-overlay {
  display: none;
  text-align: center;
  margin-top: 50px;
}

.loading-spinner {
  width: 28px;
  height: 28px;
  border: 2.5px solid rgba(35, 247, 221, 0.1);
  border-top: 2.5px solid var(--primary-cyan);
  border-radius: 50%;
  animation: rotateSpin .8s linear infinite;
  margin: 0 auto 13px;
}

@keyframes rotateSpin {
  to { transform: rotate(360deg); }
}

.phrase-actions {
  display: flex;
  justify-content: flex-end;
  position: absolute;
  bottom: 16px;
  right: 20px;
}

.copy-trigger {
  color: rgba(255,255,255,0.4);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.2s;
}

.copy-trigger:hover {
  color: #fff;
}

.notification-toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%) translateY(8px);
  opacity: 0;
  pointer-events: none;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(10, 10, 14, 0.88);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.5);
  padding: 9px 14px;
  color: rgba(255, 255, 255, 0.9);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.2px;
  transition: opacity .16s ease, transform .16s ease;
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100vw - 24px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.toast-indicator {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: radial-gradient(circle at 30% 30%, var(--primary-cyan), rgba(35, 247, 221, 0.1));
  box-shadow: 0 0 0 3px rgba(35, 247, 221, 0.1);
  flex: 0 0 auto;
}

.progress-card {
  margin-top: 10px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(255, 255, 255, 0.05);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.4);
  padding: 13px;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 11px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid rgba(35, 247, 221, 0.2);
  background: rgba(35, 247, 221, 0.07);
  color: rgba(255, 255, 255, 0.88);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  white-space: nowrap;
}

.tiny-spinner {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  border: 2px solid rgba(35, 247, 221, 0.15);
  border-top-color: var(--primary-cyan);
  animation: rotateSpin .8s linear infinite;
  flex: 0 0 auto;
}

.progress-info {
  color: rgba(255, 255, 255, 0.60);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  text-align: right;
  line-height: 1.25;
}

.track-bg {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.track-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(35, 247, 221, 0.15), rgba(35, 247, 221, 0.9), rgba(138, 63, 252, 0.8));
  transition: width .22s ease;
}

.task-list {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.task-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 10px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(0, 0, 0, 0.2);
}

.task-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.task-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.15);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.05);
  flex: 0 0 auto;
}

.task-item.is-current .task-dot {
  background: var(--primary-cyan);
  box-shadow: 0 0 0 3px rgba(35, 247, 221, 0.1), 0 0 14px rgba(35, 247, 221, 0.3);
}

.task-item.is-finished .task-dot {
  background: rgba(35, 247, 221, 0.9);
  box-shadow: 0 0 0 3px rgba(35, 247, 221, 0.1);
}

.task-name {
  font-size: 12px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.88);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-state {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: rgba(255, 255, 255, 0.5);
  text-transform: uppercase;
  flex: 0 0 auto;
}

.task-item.is-current .task-state { color: rgba(35, 247, 221, 0.9); }
.task-item.is-finished .task-state { color: rgba(255, 255, 255, 0.65); }

.error-panel {
  display: none;
  border: 1px solid rgba(255, 77, 77, 0.3);
  background: rgba(255, 77, 77, 0.08);
  border-radius: 12px;
  padding: 11px 12px;
  margin-bottom: 12px;
}

.error-panel strong {
  display: block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.5px;
  margin-bottom: 3px;
}

.error-panel span {
  display: block;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.7);
  line-height: 1.45;
}

.autocomplete-box {
  position: fixed;
  z-index: 9999;
  display: none;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(8, 8, 12, 0.92);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  max-height: 200px;
}

.autocomplete-box button {
  width: 100%;
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.88);
  padding: 9px 11px;
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.autocomplete-box button span {
  color: rgba(255, 255, 255, 0.55);
  font-weight: 800;
  font-size: 10px;
  letter-spacing: 0.5px;
}

.autocomplete-box button:hover, .autocomplete-box button[aria-selected="true"] {
  background: rgba(35, 247, 221, 0.08);
}

/* Lang switcher */
.lang-module {
  position: fixed;
  top: 11px;
  right: 13px;
  z-index: 1000;
}

.lang-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px 4px 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 20px;
  cursor: pointer;
  font-size: 10px;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.6);
  letter-spacing: 0.4px;
  transition: .15s;
  user-select: none;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.lang-toggle:hover {
  background: rgba(255, 255, 255, 0.09);
  color: rgba(255, 255, 255, 0.88);
}

.lang-flag { font-size: 12px; line-height: 1; }
.lang-arrow { font-size: 7px; opacity: 0.45; transition: transform .15s; }
.lang-toggle.is-expanded .lang-arrow { transform: rotate(180deg); }

.lang-list {
  display: none;
  position: absolute;
  top: calc(100% + 5px);
  right: 0;
  min-width: 140px;
  background: rgba(14, 14, 20, 0.97);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 11px;
  overflow: hidden;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  animation: dropIn .14s ease;
}

@keyframes dropIn {
  from { opacity: 0; transform: translateY(-3px); }
  to { opacity: 1; transform: translateY(0); }
}

.lang-list.is-expanded { display: block; }

.lang-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.6);
  transition: .12s;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.lang-item:last-child { border-bottom: none; }
.lang-item:hover { background: rgba(255, 255, 255, 0.05); color: rgba(255, 255, 255, 0.9); }
.lang-item.is-selected { color: var(--primary-cyan); }
.lang-item .lf { font-size: 14px; }
.lang-item .ln { flex: 1; }
.lang-item .lc { font-size: 10px; color: var(--primary-cyan); opacity: 0; }
.lang-item.is-selected .lc { opacity: 1; }
