/* ═══════════════════════════════════════════════════════
   MISAKA Wallet — CSS (Linear-style Dark Mode)
   ═══════════════════════════════════════════════════════ */

.hidden { display: none !important; }

:root {
  /* Ultra-dark, low contrast backgrounds */
  --bg: #000000;
  --bg2: #0a0a0a;
  --bg3: #111111;
  --bg4: #1a1a1a;
  
  /* Borders and dividers */
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.15);
  
  /* Text colors */
  --text: #eeeeee;
  --text2: #999999;
  --text3: #666666;
  
  /* Accents */
  --accent: #5e6ad2;
  --accent2: #737fe3;
  --accent-bg: rgba(94, 106, 210, 0.15);
  
  /* Functional */
  --green: #2ecc71;
  --green-bg: rgba(46, 204, 113, 0.1);
  --red: #e74c3c;
  --red-bg: rgba(231, 76, 60, 0.1);
  --orange: #f39c12;
  
  /* Radii */
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  
  /* Fonts */
  --font: 'Inter', -apple-system, sans-serif;
  --mono: 'JetBrains Mono', monospace;
  
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  height: 100%; width: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* ── Lucide Icons ── */
i[data-lucide] {
  width: 1em;
  height: 1em;
  display: inline-block;
  stroke-width: 2;
}

/* ── Views ── */
.view { display: none; height: 100%; width: 100%; position: fixed; inset: 0; }
.view.active { display: flex; flex-direction: column; }

/* ── Loading ── */
.center-box {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  flex: 1; padding: 32px; text-align: center;
}
.spinner {
  width: 40px; height: 40px; border: 2px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin 1s cubic-bezier(0.55, 0.15, 0.45, 0.85) infinite; 
  margin-bottom: 24px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { color: var(--text2); font-size: 13px; letter-spacing: 1px; text-transform: uppercase; }

/* ── Welcome ── */
.welcome-box { gap: 8px; }
.logo-icon {
  width: 64px; height: 64px; border-radius: 16px;
  background: linear-gradient(135deg, rgba(255,255,255,0.1), rgba(255,255,255,0.02));
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; color: var(--text);
  margin-bottom: 24px;
}
.welcome-box h1 { font-size: 24px; font-weight: 600; letter-spacing: -0.5px; }
.subtitle { color: var(--text2); font-size: 14px; margin-top: 8px; }
.subtitle.dim { color: var(--text3); font-size: 12px; margin-top: 4px; }
.welcome-buttons { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 320px; margin-top: 40px; }

.divider {
  display: flex; align-items: center; text-align: center; margin: 12px 0;
  color: var(--text3); font-size: 12px; text-transform: uppercase; letter-spacing: 1px;
}
.divider::before, .divider::after {
  content: ''; flex: 1; border-bottom: 1px solid var(--border);
}
.divider span { padding: 0 12px; }

/* ── Buttons ── */
.btn {
  border: 1px solid transparent; border-radius: var(--radius-sm); font-family: var(--font);
  font-weight: 500; font-size: 14px; cursor: pointer;
  padding: 10px 20px; transition: all .15s ease;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--text); color: var(--bg); }
.btn-primary:hover:not(:disabled) { background: #fff; box-shadow: 0 0 15px rgba(255,255,255,0.1); }
.btn-outline { background: var(--bg2); color: var(--text); border-color: var(--border); }
.btn-outline:hover:not(:disabled) { border-color: var(--border-hover); background: var(--bg3); }
.btn-danger { background: transparent; color: var(--red); border-color: var(--border); }
.btn-danger:hover:not(:disabled) { background: var(--red-bg); border-color: rgba(231, 76, 60, 0.3); }
.btn-lg { padding: 12px 24px; font-size: 15px; border-radius: var(--radius-sm); }
.btn-full { width: 100%; }
.btn-row { display: flex; gap: 12px; margin-top: 24px; }
.btn-row .btn { flex: 1; }

.icon-btn {
  background: none; border: none; color: var(--text2); font-size: 18px;
  cursor: pointer; padding: 8px; border-radius: var(--radius-xs); line-height: 1;
  transition: color .15s, background .15s;
}
.icon-btn:hover { color: var(--text); background: var(--bg2); }

.back-btn {
  background: none; border: none; color: var(--text2); font-size: 13px;
  cursor: pointer; padding: 8px 0; margin-bottom: 16px; font-family: var(--font);
  display: inline-flex; align-items: center; gap: 4px; transition: color .15s;
}
.back-btn:hover { color: var(--text); }

/* ── Page Box ── */
.page-box {
  flex: 1; padding: 24px; max-width: 480px; margin: 0 auto; width: 100%;
  overflow-y: auto;
}
.page-box h2 { font-size: 20px; font-weight: 600; margin-bottom: 12px; letter-spacing: -0.3px; }
.desc { color: var(--text2); font-size: 14px; line-height: 1.6; margin-bottom: 24px; }

/* ── Seed Grid ── */
.seed-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  margin: 16px 0;
}
.seed-word {
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius-xs);
  padding: 8px; font-size: 13px; font-family: var(--mono);
  display: flex; gap: 8px; align-items: center;
}
.seed-word .num { color: var(--text3); font-size: 11px; min-width: 16px; text-align: right; }
.seed-word .word { color: var(--text); }

.seed-textarea {
  width: 100%; padding: 16px; background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-family: var(--mono);
  font-size: 14px; resize: none; outline: none; line-height: 1.6; transition: border-color .15s;
}
.seed-textarea:focus { border-color: var(--text3); }

.warning-box {
  background: rgba(243, 156, 18, 0.05); border: 1px solid rgba(243, 156, 18, 0.2);
  border-radius: var(--radius-sm); padding: 12px 16px;
  color: var(--orange); font-size: 13px; margin-bottom: 20px;
  display: flex; align-items: center; gap: 8px;
}
.error-msg { color: var(--red); font-size: 13px; margin: 12px 0; min-height: 20px; }

/* ── App Header ── */
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  background: rgba(0,0,0,0.8); backdrop-filter: blur(12px);
  position: sticky; top: 0; z-index: 10;
}
.header-left { display: flex; align-items: center; gap: 12px; }
.header-right { display: flex; align-items: center; gap: 4px; }
.chain-pill {
  font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px;
  padding: 4px 8px; border-radius: 4px;
  background: var(--bg2); border: 1px solid var(--border); color: var(--text2);
}
.conn-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text3); display: inline-block;
}
.conn-dot.green { background: var(--green); box-shadow: 0 0 8px rgba(46,204,113,0.4); }
.conn-dot.red { background: var(--red); box-shadow: 0 0 8px rgba(231,76,60,0.4); }

/* ── Tab Content ── */
.tab-content {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding-bottom: calc(80px + var(--safe-bottom));
}
.tab { display: none; padding: 24px 20px; }
.tab.active { display: block; animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

.tab-header { font-size: 18px; font-weight: 600; margin-bottom: 24px; letter-spacing: -0.3px; }

/* ── Balance Card ── */
.balance-card {
  padding: 12px 0 32px; text-align: center;
}
.balance-label { font-size: 13px; color: var(--text2); margin-bottom: 12px; font-weight: 500; }
.balance-row { display: flex; align-items: baseline; justify-content: center; gap: 8px; }
.balance-amount { font-size: 42px; font-weight: 600; color: var(--text); letter-spacing: -1px; }
.balance-ticker { font-size: 16px; font-weight: 500; color: var(--text3); }
.balance-sub { font-size: 12px; color: var(--text3); margin-top: 12px; }

/* ── Quick Actions ── */
.quick-actions { display: flex; gap: 12px; margin-bottom: 32px; }
.qa-btn {
  flex: 1; background: transparent; border: none;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  cursor: pointer; color: var(--text2); font-family: var(--font);
  font-size: 12px; font-weight: 500; transition: all .15s;
}
.qa-btn:hover { color: var(--text); }
.qa-btn:active .qa-icon { transform: scale(.92); }
.qa-icon {
  width: 48px; height: 48px; border-radius: 50%; display: flex;
  align-items: center; justify-content: center; font-size: 20px;
  background: var(--bg2); border: 1px solid var(--border); color: var(--text);
  transition: all .15s;
}
.qa-btn:hover .qa-icon { border-color: var(--border-hover); background: var(--bg3); }

/* ── 残高0: Faucet 案内 ── */
.zero-hint {
  font-size: 13px; color: var(--text3); line-height: 1.5;
  padding: 10px 14px; margin-bottom: 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg2);
}

.section-title { font-size: 13px; font-weight: 500; color: var(--text3); margin-bottom: 16px; text-transform: uppercase; letter-spacing: 0.5px; }

/* ── Activity List ── */
.activity-list, .tx-list { display: flex; flex-direction: column; gap: 0; }
.empty-state {
  text-align: center; color: var(--text3); font-size: 13px;
  padding: 32px 20px; border: 1px dashed var(--border); border-radius: var(--radius-sm);
}
.tx-item {
  display: flex; align-items: center; gap: 16px;
  padding: 16px 8px; margin: 0 -8px;
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: background .15s ease, opacity .15s ease;
}
.tx-item:last-child { border-bottom: none; }
.tx-item:hover { background: rgba(255,255,255,0.04); }
.tx-item:active { opacity: 0.92; }
.tx-icon {
  width: 40px; height: 40px; border-radius: 50%; display: flex;
  align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0;
  background: var(--bg2); border: 1px solid var(--border);
}
.tx-info { flex: 1; min-width: 0; }
.tx-label { font-size: 14px; font-weight: 500; margin-bottom: 4px; color: var(--text); }
.tx-addr { font-size: 12px; color: var(--text3); font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-right { text-align: right; flex-shrink: 0; }
.tx-amount { font-size: 14px; font-weight: 500; }
.tx-amount.neg { color: var(--text); }
.tx-amount.pos { color: var(--green); }
.tx-time { font-size: 12px; color: var(--text3); margin-top: 4px; }

.tx-item.tx-pending { opacity: 0.6; }
.tx-item.tx-pending .tx-icon { animation: pulse-pending 2s ease-in-out infinite; }
@keyframes pulse-pending { 0%, 100% { opacity: 0.5; } 50% { opacity: 1; } }
.tx-icon.pending { background: rgba(255,255,255,0.06); color: var(--text3); }
.tx-badge-pending {
  display: inline-block; font-size: 10px; font-weight: 600;
  padding: 1px 6px; border-radius: 4px;
  background: rgba(255,193,7,0.15); color: #ffc107;
  margin-left: 6px; vertical-align: middle;
}

/* ── Send Form ── */
.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-size: 13px; color: var(--text2); margin-bottom: 8px; font-weight: 500; }
.input {
  width: 100%; padding: 12px 16px; background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-family: var(--font);
  font-size: 15px; outline: none; transition: border-color .15s;
}
.input:focus { border-color: var(--text3); }
.input::placeholder { color: var(--text3); }
.input-with-btn { position: relative; }
.input-with-btn .input { padding-right: 64px; }
.btn-inline {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: var(--bg3); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius-xs);
  padding: 4px 10px; font-size: 11px; font-weight: 500; cursor: pointer;
  font-family: var(--font); transition: background .15s;
}
.btn-inline:hover { background: var(--bg4); }
.btn-inline i, .btn-inline svg { width: 16px; height: 16px; }

.qr-scanner-box {
  position: relative; width: 100%; border-radius: var(--radius-sm);
  overflow: hidden; background: #000;
}
.qr-scanner-box video {
  width: 100%; display: block; border-radius: var(--radius-sm);
  max-height: 400px; object-fit: cover;
}
.qr-scanner-overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.qr-scanner-frame {
  width: 180px; height: 180px; border: 2px solid rgba(255,255,255,0.7);
  border-radius: 12px; box-shadow: 0 0 0 9999px rgba(0,0,0,0.4);
}
.info-row {
  display: flex; justify-content: space-between; font-size: 13px;
  color: var(--text2); padding: 12px 0; border-bottom: 1px solid var(--border);
}
.info-row:last-of-type { border-bottom: none; margin-bottom: 24px; }
.status-msg { margin-top: 16px; font-size: 13px; text-align: center; min-height: 20px; }
.status-msg.ok { color: var(--green); }
.status-msg.err { color: var(--red); }

/* ── Receive ── */
.receive-card { text-align: center; }
.qr-box {
  background: #fff; border-radius: var(--radius-sm); padding: 16px;
  display: inline-block; margin: 0 auto 32px;
}
.qr-box canvas, .qr-box img { display: block; }
.addr-label { display: block; font-size: 13px; color: var(--text2); margin-bottom: 12px; font-weight: 500; }
.addr-copy-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 16px; margin-bottom: 24px;
}
.addr-text {
  flex: 1; font-size: 12px; font-family: var(--mono); word-break: break-all;
  color: var(--text); line-height: 1.5; text-align: left;
}
.btn-copy {
  background: none; border: none; font-size: 16px; color: var(--text2); cursor: pointer;
  padding: 4px; flex-shrink: 0; transition: color .15s;
}
.btn-copy:hover { color: var(--text); }

/* ── Bottom Nav ── */
.bottom-nav {
  display: flex; border-top: 1px solid var(--border); background: rgba(0,0,0,0.8); backdrop-filter: blur(12px);
  padding-bottom: var(--safe-bottom); position: fixed; bottom: 0; left: 0; right: 0;
  z-index: 20;
}
.nav-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 12px 0; background: none; border: none; color: var(--text3);
  font-family: var(--font); font-size: 11px; font-weight: 500; cursor: pointer; transition: color .15s;
}
.nav-btn .nav-icon { font-size: 20px; }
.nav-btn.active { color: var(--text); }

/* ── Modals ── */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-end; justify-content: center; }
.modal.hidden { display: none; }
.modal-bg { position: absolute; inset: 0; background: rgba(0,0,0,.8); backdrop-filter: blur(4px); }
.modal-box {
  position: relative; background: var(--bg); border: 1px solid var(--border); border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%; max-width: 480px; max-height: 85vh; overflow-y: auto;
  animation: slideUp .25s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--bg); z-index: 1;
}
.modal-top h3 { font-size: 16px; font-weight: 600; }
.modal-close {
  background: none; border: none; color: var(--text2); font-size: 20px;
  cursor: pointer; padding: 4px; transition: color .15s;
}
.modal-close:hover { color: var(--text); }
.modal-inner { padding: 8px 24px 32px; }
.modal-inner .btn { margin-top: 16px; }

.setting-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 0; font-size: 14px; border-bottom: 1px solid var(--border);
}
.setting-row:last-of-type { border-bottom: none; margin-bottom: 8px; }
.setting-row span:first-child { color: var(--text2); }
.setting-row span:last-child { color: var(--text); font-weight: 500; font-family: var(--mono); font-size: 13px; }
.setting-divider { display: none; }

.confirm-row {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 16px 0; font-size: 14px; border-bottom: 1px solid var(--border);
}
.confirm-row span:first-child { color: var(--text2); flex-shrink: 0; }
.c-val { color: var(--text); font-weight: 500; text-align: right; word-break: break-all; }
code.c-val { font-family: var(--mono); font-size: 12px; max-width: 240px; color: var(--text2); }
.confirm-row.total { font-size: 16px; font-weight: 600; border-bottom: none; padding-top: 24px; }
.confirm-note { text-align: center; color: var(--text3); font-size: 12px; margin-top: 16px; }

.setting-row-stack {
  flex-direction: column; align-items: stretch !important; gap: 8px;
}
.setting-row-stack > span:first-child { color: var(--text2); }
.txd-hash-row {
  display: flex; align-items: flex-start; gap: 10px;
}
.txd-hash {
  display: block; font-family: var(--mono); font-size: 11px; line-height: 1.5;
  word-break: break-all; color: var(--text); text-align: left;
}
.txd-explorer-link {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin-top: 16px; text-decoration: none; font-size: 13px;
}
.txd-explorer-link svg { width: 15px; height: 15px; }
.txd-note {
  font-size: 12px; color: var(--text3); line-height: 1.5; margin-top: 12px;
}

/* ── Toast ── */
.toast {
  position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg);
  padding: 12px 24px; border-radius: 100px; font-size: 13px; font-weight: 500;
  z-index: 200; animation: toastIn .3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ── Responsive ── */
@media (min-width: 520px) {
  .seed-grid { grid-template-columns: repeat(4, 1fr); }
  .modal-box { border-radius: var(--radius); border: 1px solid var(--border); margin-bottom: 24px; }
  .modal { align-items: center; }
}

@media (min-width: 768px) {
  .tab-content { max-width: 520px; margin: 0 auto; }
}
