:root {
  --bg: #faf7f2;
  --bg-alt: #f5efe6;
  --card: #ffffff;
  --card-2: #f9f5ee;
  --line: #e8dfd0;
  --text: #1a3a3a;
  --muted: #7a8b8b;
  --accent: #2ec4b6;
  --accent-2: #1fa89b;
  --accent-soft: rgba(46, 196, 182, 0.12);
  --orange: #ff9f1c;
  --orange-2: #f77f00;
  --shadow: 0 4px 20px rgba(26, 58, 58, 0.08);
  --shadow-lg: 0 10px 40px rgba(26, 58, 58, 0.12);
  --radius: 20px;
  --radius-sm: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

body {
  padding: 18px 16px calc(28px + env(safe-area-inset-bottom));
  max-width: 640px;
  margin: 0 auto;
}

.notes-bg { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.note { position: absolute; color: var(--accent); opacity: 0.08; font-size: 60px; animation: float 8s ease-in-out infinite; }
.n1 { top: 8%; left: 5%; }
.n2 { top: 20%; right: 8%; font-size: 80px; animation-delay: 1s; }
.n3 { top: 45%; left: 3%; font-size: 50px; animation-delay: 2s; }
.n4 { top: 60%; right: 5%; animation-delay: 3s; }
.n5 { bottom: 15%; left: 8%; font-size: 70px; animation-delay: 4s; }
.n6 { bottom: 25%; right: 10%; font-size: 45px; animation-delay: 5s; }
@keyframes float { 0%,100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-20px) rotate(10deg); } }

.screen { display: none; animation: fade .3s ease; position: relative; z-index: 1; }
.screen.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.topbar-title { font-size: 22px; font-weight: 800; color: var(--text); letter-spacing: -0.5px; }
.icon-btn {
  width: 48px; height: 48px; border-radius: 16px;
  background: var(--card); border: 2px solid var(--line);
  color: var(--text); font-size: 22px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow);
  transition: transform .15s, border-color .2s;
}
.icon-btn:active { transform: scale(.92); border-color: var(--accent); }

.hero {
  text-align: center; padding: 36px 20px 30px; margin-bottom: 22px;
  background: linear-gradient(160deg, var(--card) 0%, var(--bg-alt) 100%);
  border: 2px solid var(--line); border-radius: 28px;
  box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.hero::before { content: '♫'; position: absolute; top: -30px; right: -20px; font-size: 140px; color: var(--accent); opacity: 0.06; transform: rotate(-15deg); }
.hero-logo { font-size: 60px; color: var(--accent); line-height: 1; margin-bottom: 8px; text-shadow: 0 4px 16px rgba(46,196,182,0.3); }
.hero-title { font-size: 44px; font-weight: 800; letter-spacing: 2px; color: var(--text); margin: 0; }
.hero-title::after { content: '♪'; color: var(--orange); margin-left: 8px; font-size: 32px; vertical-align: middle; }
.hero-tagline { color: var(--muted); margin-top: 10px; font-size: 15px; font-weight: 500; }
.hero-hi { margin-top: 16px; font-weight: 800; font-size: 18px; color: var(--accent-2); }

.btn {
  width: 100%; border: none; border-radius: var(--radius);
  font-size: 18px; font-weight: 800; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 18px; margin-bottom: 14px;
  font-family: 'Manrope', sans-serif;
  transition: transform .15s, box-shadow .2s;
  letter-spacing: 0.3px;
}
.btn:active { transform: scale(.98); }
.btn-lg { padding: 22px; }
.btn-primary { background: linear-gradient(180deg, var(--accent), var(--accent-2)); color: #fff; box-shadow: 0 6px 20px rgba(46,196,182,0.35); }
.btn-primary:disabled { filter: grayscale(.5) brightness(.9); box-shadow: none; }
.btn-ghost { background: var(--card); border: 2px solid var(--line); color: var(--text); box-shadow: var(--shadow); }
.btn-ghost:active { border-color: var(--accent); }
.ic { font-size: 20px; color: inherit; }
.mt { margin-top: 8px; }

.field-label { display: block; font-size: 17px; font-weight: 800; margin: 22px 0 12px; color: var(--text); letter-spacing: -0.3px; }
.field-label.nomargin { margin: 0; }
.input-wrap {
  background: var(--card); border: 2px solid var(--line);
  border-radius: var(--radius); padding: 4px 20px;
  transition: border-color .2s, box-shadow .2s;
  box-shadow: var(--shadow);
}
.input-wrap.accent { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.input-wrap input {
  width: 100%; background: none; border: none; outline: none;
  color: var(--text); font-size: 17px; padding: 18px 0;
  font-family: 'Manrope', sans-serif; font-weight: 500;
}
.input-wrap input::placeholder { color: var(--muted); }

.input-wrap textarea {
  width: 100%; background: none; border: none; outline: none;
  resize: vertical; color: var(--text); font-size: 15px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  line-height: 1.5; padding: 14px 0; font-weight: 600;
}

.translate-preview {
  display: flex; align-items: center; gap: 10px;
  margin: 14px 0; padding: 12px 16px;
  background: var(--accent-soft); border: 2px solid var(--accent);
  border-radius: var(--radius-sm); font-size: 14px; font-weight: 600;
}
.translate-preview b { color: var(--accent-2); font-weight: 800; }

.slider-head { display: flex; justify-content: space-between; align-items: center; margin: 26px 0 16px; }
.slider-value { font-size: 30px; font-weight: 800; color: var(--accent-2); }
.slider {
  -webkit-appearance: none; width: 100%; height: 10px; border-radius: 10px;
  background: linear-gradient(90deg, var(--accent) var(--fill, 33%), var(--line) var(--fill, 33%));
  outline: none;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 28px; height: 28px; border-radius: 50%;
  background: var(--card); border: 3px solid var(--accent);
  box-shadow: 0 2px 8px rgba(46,196,182,0.4); cursor: pointer;
}

.progress-card {
  background: var(--card); border: 2px solid var(--line);
  border-radius: 24px; padding: 34px 24px; text-align: center;
  box-shadow: var(--shadow-lg);
}
.spinner {
  width: 60px; height: 60px; margin: 0 auto 24px; border-radius: 50%;
  border: 5px solid var(--line); border-top-color: var(--accent);
  border-right-color: var(--orange); animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.progress-stage { font-size: 17px; font-weight: 700; margin-bottom: 20px; min-height: 44px; color: var(--text); }
.progress-bar { height: 14px; border-radius: 10px; background: var(--line); overflow: hidden; }
.progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), var(--orange)); border-radius: 10px; transition: width .5s; }
.progress-nums { display: flex; justify-content: space-between; margin-top: 16px; color: var(--muted); font-size: 15px; font-weight: 600; }
.progress-nums b { color: var(--text); }
.progress-timer { font-size: 34px; font-weight: 800; margin: 20px 0; color: var(--accent-2); letter-spacing: 1px; }

.done-card {
  background: linear-gradient(160deg, var(--accent-soft), transparent);
  border: 2px solid var(--accent); border-radius: 24px;
  padding: 30px; text-align: center; margin-bottom: 22px;
  box-shadow: var(--shadow);
}
.done-check {
  width: 70px; height: 70px; margin: 0 auto 16px; border-radius: 50%;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  color: #fff; font-size: 36px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 24px rgba(46,196,182,0.4);
}
.done-title { font-size: 28px; font-weight: 800; color: var(--text); letter-spacing: -0.5px; }
.done-sub { color: var(--muted); margin-top: 8px; font-size: 16px; font-weight: 600; }
.done-sub b { color: var(--accent-2); font-weight: 800; }

.input-wrap.search { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; padding: 4px 20px; }
.search-ic { color: var(--accent); font-size: 20px; }

.contact-list { display: flex; flex-direction: column; gap: 14px; }
.contact-card {
  background: var(--card); border: 2px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); transition: border-color .2s;
}
.contact-card.open { border-color: var(--accent); }
.cc-head { display: flex; align-items: center; gap: 12px; padding: 18px; cursor: pointer; }
.cc-badge {
  font-size: 11px; font-weight: 800; padding: 5px 10px; border-radius: 8px;
  background: var(--accent-soft); color: var(--accent-2);
  border: 1.5px solid var(--accent); text-transform: uppercase; letter-spacing: 0.5px;
}
.cc-name { font-weight: 800; font-size: 16px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.cc-chev { color: var(--accent); transition: transform .2s; font-size: 18px; }
.contact-card.open .cc-chev { transform: rotate(180deg); }
.cc-body { display: none; padding: 0 18px 18px; }
.contact-card.open .cc-body { display: block; }
.cc-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1.5px dashed var(--line); }
.cc-row > span:first-child { color: var(--accent); font-size: 16px; min-width: 20px; }
.cc-val { flex: 1; font-size: 15px; word-break: break-all; font-weight: 600; color: var(--text); }
.cc-val a { color: var(--accent-2); text-decoration: none; font-weight: 700; }
.cc-phone .cc-val { color: var(--orange-2); font-weight: 700; }
.cc-meta { color: var(--muted); font-size: 13px; padding-top: 12px; border-top: 1.5px dashed var(--line); font-weight: 600; }

.history-list { display: flex; flex-direction: column; gap: 14px; }
.hist-card {
  background: var(--card); border: 2px solid var(--line);
  border-radius: var(--radius); padding: 18px; cursor: pointer;
  box-shadow: var(--shadow); transition: border-color .2s, transform .15s;
}
.hist-card:active { transform: scale(.98); border-color: var(--accent); }
.hist-q { font-weight: 800; font-size: 16px; margin-bottom: 8px; color: var(--text); }
.hist-meta { color: var(--muted); font-size: 14px; display: flex; justify-content: space-between; font-weight: 600; }
.hist-status { font-weight: 800; }
.hist-status.done { color: var(--accent-2); }
.hist-status.error { color: var(--orange-2); }
.empty { color: var(--muted); text-align: center; padding: 60px 20px; font-size: 16px; font-weight: 600; }

.toast {
  position: fixed; left: 50%; bottom: 30px;
  transform: translateX(-50%) translateY(200%);
  background: var(--accent); color: #fff; font-weight: 800; font-size: 15px;
  padding: 14px 24px; border-radius: 14px; z-index: 99;
  opacity: 0; visibility: hidden;
  box-shadow: 0 8px 24px rgba(46,196,182,0.4);
  transition: transform .3s, opacity .3s, visibility .3s;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; visibility: visible; }
.toast.err { background: var(--orange-2); box-shadow: 0 8px 24px rgba(247,127,0,0.4); }

.stat-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 18px; }
.stat-box { background: var(--card); border: 2px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.stat-label { color: var(--muted); font-size: 14px; font-weight: 700; }
.stat-value { font-size: 32px; font-weight: 800; margin: 8px 0 4px; color: var(--text); }
.stat-value.ok { color: var(--accent-2); }
.stat-sub { color: var(--muted); font-size: 13px; font-weight: 600; }

.key-badge { margin-left: 8px; padding: 2px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-2); font-size: 12px; font-weight: 800; }
.key-badge.low { background: rgba(247,127,0,0.15); color: var(--orange-2); }

.key-card { cursor: default; }
.key-card .hist-q { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 14px; }
.key-del { background: none; border: 2px solid var(--line); color: var(--orange-2); border-radius: 8px; padding: 4px 12px; font-size: 14px; font-weight: 800; cursor: pointer; transition: border-color .2s; }
.key-del:active { transform: scale(.94); }
.key-del:hover { border-color: var(--orange-2); }
.key-lock { color: var(--muted); font-size: 12px; font-weight: 700; }

.slider-hint { color: var(--muted); font-size: 14px; margin-top: 14px; line-height: 1.5; font-weight: 500; }
.shown-count { color: var(--muted); font-size: 14px; margin: 20px 0 12px; font-weight: 700; }