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

:root {
  --bg: #0b0e13;
  --surface: #141820;
  --surface2: #1c2230;
  --border: #252d3d;
  --text: #e2e8f0;
  --text-muted: #64748b;
  --accent: #f0b90b;
  --accent-dim: rgba(240, 185, 11, 0.12);
  --green: #22c55e;
  --green-dim: rgba(34, 197, 94, 0.12);
  --red: #ef4444;
  --red-dim: rgba(239, 68, 68, 0.12);
  --blue: #3b82f6;
  --radius: 12px;
  --radius-sm: 8px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 0 40px;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--accent);
}

.chain-tag {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid var(--accent);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 20px;
  letter-spacing: 0.5px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-label {
  font-size: 12px;
  color: var(--text-muted);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background 0.3s;
}

.status-dot.running {
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Cards */
.cards {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.card-full {
  grid-column: 1 / -1;
}

.card-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 6px;
}

.card-value {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  word-break: break-all;
}

.card-value.small {
  font-size: 12px;
  font-weight: 400;
}

.card-value.accent {
  color: var(--accent);
}

.mono {
  font-family: 'SF Mono', 'Fira Code', monospace;
}

/* Section */
.section {
  padding: 0 16px;
  margin-top: 20px;
}

.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 14px;
}

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.section-title-row .section-title {
  margin-bottom: 0;
}

/* Form */
.form-group {
  margin-bottom: 12px;
}

.form-group.half {
  margin-bottom: 0;
}

.form-label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.input-wrap {
  position: relative;
}

.input-wrap .input {
  padding-right: 40px;
  width: 100%;
}

.eye-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  opacity: 0.5;
  padding: 0;
  line-height: 1;
}

.eye-btn:hover {
  opacity: 1;
}

.input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.2s;
  appearance: none;
  -webkit-appearance: none;
}

.input:focus {
  border-color: var(--accent);
}

.input::placeholder {
  color: var(--text-muted);
}

select.input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2364748b' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
}

/* Button */
.btn {
  width: 100%;
  padding: 14px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 6px;
  transition: opacity 0.2s, transform 0.1s;
  background: var(--accent);
  color: #000;
  letter-spacing: 0.3px;
}

.btn:active {
  transform: scale(0.98);
  opacity: 0.9;
}

.btn.stop {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid var(--red);
}

/* Log */
.log {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 120px;
  max-height: 320px;
  overflow-y: auto;
}

.log-empty {
  padding: 32px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.log-item {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 12px;
  line-height: 1.6;
}

.log-item:last-child {
  border-bottom: none;
}

.log-time {
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
  font-family: monospace;
  font-size: 11px;
  margin-top: 2px;
}

.log-icon {
  flex-shrink: 0;
  font-size: 13px;
  margin-top: 1px;
}

.log-msg {
  flex: 1;
  word-break: break-all;
}

.log-msg a {
  color: var(--blue);
  text-decoration: none;
}

.log-msg a:hover {
  text-decoration: underline;
}

.log-item.info .log-icon::before { content: 'ℹ'; color: var(--blue); }
.log-item.success .log-icon::before { content: '✓'; color: var(--green); }
.log-item.warn .log-icon::before { content: '⚠'; color: var(--accent); }
.log-item.error .log-icon::before { content: '✕'; color: var(--red); }

.log-item.success { background: var(--green-dim); }
.log-item.error { background: var(--red-dim); }

.clear-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
}

.clear-btn:hover {
  border-color: var(--text-muted);
  color: var(--text);
}

/* Modal */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
  backdrop-filter: blur(4px);
}

.modal-mask.hidden {
  display: none;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  max-width: 360px;
  width: 100%;
  text-align: center;
}

.modal-icon {
  font-size: 36px;
  margin-bottom: 14px;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 16px;
}

.modal-body {
  font-size: 14px;
  color: var(--text);
  line-height: 1.8;
  margin-bottom: 24px;
  text-align: left;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
}

.modal-btn {
  width: 100%;
  padding: 13px;
  background: var(--accent);
  color: #000;
  font-size: 15px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: opacity 0.2s;
}

.modal-btn:active {
  opacity: 0.85;
}

/* Scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
