*, *::before, *::after {
  box-sizing: border-box; margin: 0; padding: 0;
  -webkit-tap-highlight-color: transparent;
}
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans KR", sans-serif;
  background: #f4f4f4; color: #222; font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

/* Views */
.view { display: none; flex-direction: column; height: 100%; height: -webkit-fill-available; }
.view.active { display: flex; }

/* Header */
.app-hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid #ddd;
  font-weight: 700; font-size: 15px; background: #fff; flex-shrink: 0;
}
.hdr-btn {
  font-size: 27px; font-weight: 600; color: #444;
  background: none; border: none; cursor: pointer;
  font-family: inherit; padding: 4px; text-decoration: none;
}

/* Scroll body */
.scroll {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 14px 12px 32px; background: #fafafa;
}

/* Login */
.login-wrap {
  min-height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 14px; text-align: center; padding: 24px;
}
.app-name { font-size: 26px; font-weight: 800; }
.login-desc { font-size: 13px; color: #666; line-height: 1.7; }
.g-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px; background: #fff;
  border: 1px solid #222; border-radius: 10px;
  font-size: 14px; font-weight: 600; color: #222;
  cursor: pointer; font-family: inherit; text-decoration: none;
}
.cfg-warn {
  background: #fff3e0; border: 1px solid #ffcc80; border-radius: 10px;
  padding: 10px 14px; font-size: 12px; color: #bf360c;
  line-height: 1.6; max-width: 280px; text-align: center;
}

/* Form elements */
.std {
  height: 38px; border: 1px solid #222; border-radius: 10px;
  background: #fff; font-size: 14px; padding: 0 10px;
  font-family: inherit; width: 100%; outline: none;
  -webkit-appearance: none; appearance: none;
}
select.std {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23444'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; padding-right: 28px;
}
.field { display: grid; gap: 4px; }
.field label { font-size: 12px; color: #555; font-weight: 600; }
.field input {
  height: 36px; border: 1px solid #222; border-radius: 10px;
  background: #fff; font-size: 14px; padding: 0 10px;
  font-family: inherit; width: 100%; outline: none;
}

/* Buttons */
.btn {
  height: 38px; border: 1px solid #222; border-radius: 10px;
  background: #fff; font-size: 14px; font-weight: 600;
  padding: 0 12px; cursor: pointer; font-family: inherit;
  white-space: nowrap; display: inline-flex;
  align-items: center; justify-content: center;
  text-decoration: none; color: #222;
}
.btn:disabled { opacity: 0.5; pointer-events: none; }
.btn-primary { background: #222; color: #fff; }
.btn-light   { background: #fff7cc; }
.btn-danger  { background: #fff0f0; color: #b00020; border-color: #b00020; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }

/* Connect card */
.connect-card {
  background: #fff; border: 1px solid #222; border-radius: 14px;
  padding: 12px; margin-top: 12px;
}
.connect-card.error { border-color: #b00020; }
.err-msg { font-size: 13px; color: #b00020; }

/* Toolbar */
.toolbar {
  display: grid; grid-template-columns: 1fr auto auto;
  gap: 8px; margin-bottom: 12px; align-items: center;
}

/* Inline form */
.inline-form {
  background: #fff; border: 1px solid #222;
  border-radius: 14px; padding: 12px; margin-bottom: 12px;
}
.form-title { font-size: 15px; font-weight: 700; margin-bottom: 10px; }
.form-grid { display: grid; gap: 8px; }

/* Flash messages */
.flash {
  padding: 10px 14px; border-radius: 10px; font-size: 13px;
  margin-bottom: 10px; line-height: 1.5;
}
.flash-success { background: #e8f5e9; color: #2e7d32; border: 1px solid #a5d6a7; }
.flash-error   { background: #ffebee; color: #b00020; border: 1px solid #ef9a9a; }
.flash-warning { background: #fff8e1; color: #e65100; border: 1px solid #ffcc02; }

/* Site card */
.site-card {
  background: #fff; border: 1px solid #222;
  border-radius: 14px; padding: 12px; margin-bottom: 12px;
}
.site-card.hidden { display: none; }
.site-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px; font-weight: 700; font-size: 15px;
}
.site-count { font-size: 13px; color: #666; font-weight: 600; }
.divider { border-top: 1px solid #e3e3e3; margin: 0 0 4px; }

/* Account row */
.account-row { padding: 7px 0; border-bottom: 1px solid #f0f0f0; }
.account-row:last-child { border-bottom: none; }
.account-row.match { background: #fffde7; margin: 0 -4px; padding: 7px 4px; border-radius: 6px; }
.account-row.hidden { display: none; }
.account-main {
  display: grid;
  grid-template-columns: 1.6fr 1fr 0.8fr auto auto auto;
  gap: 5px; align-items: center; font-size: 13px;
}
.ac-id, .ac-pass, .ac-memo {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ac-id, .ac-pass { position: relative; }
.ac-id .text-inner, .ac-pass .text-inner {
  display: inline-block; white-space: nowrap;
}
.ac-id.marquee .text-inner, .ac-pass.marquee .text-inner {
  animation: scroll-text var(--slide-duration, 4.5s) ease-in-out infinite;
  animation-delay: 0.6s;
  padding-right: 0.75rem;
}
.ac-id.marquee, .ac-pass.marquee { text-overflow: clip; }
.ac-pass { color: #999; letter-spacing: 1px; }
.ac-pass.show { color: #222; letter-spacing: 0; font-weight: 600; }

@keyframes scroll-text {
  0%   { transform: translateX(0); }
  12%  { transform: translateX(0); }
  88%  { transform: translateX(calc(var(--slide-distance, 0px) * -1)); }
  100% { transform: translateX(calc(var(--slide-distance, 0px) * -1)); }
}
.mini-btn {
  min-width: 34px; height: 34px; border: 1px solid #ccc;
  border-radius: 8px; background: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; cursor: pointer; flex-shrink: 0; padding: 0;
  text-decoration: none; color: #222;
}
.mini-btn.active { background: #fff7cc; border-color: #888; }

/* Expanded detail */
.account-detail {
  margin-top: 7px; padding: 6px 2px 2px;
  font-size: 11px; color: #666; border-top: 1px dashed #eee;
  display: flex; justify-content: space-between; align-items: center;
}
.del-link {
  color: #b00020; font-weight: 700; cursor: pointer;
  padding: 2px 4px; background: none; border: none;
  font-family: inherit; font-size: 11px;
}

/* Settings */
.setting-list { display: grid; gap: 10px; }
.setting-item {
  padding: 12px; border: 1px solid #222;
  border-radius: 12px; background: #fff;
}
.setting-item.clickable { cursor: pointer; }
.setting-item.clickable:active { background: #f8f8f8; }
.setting-item strong { display: block; margin-bottom: 4px; }
.hint { font-size: 12px; color: #666; line-height: 1.5; }

/* Empty / spinner */
.empty-msg { text-align: center; padding: 2.5rem 1rem; color: #888; line-height: 1.8; }
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  width: 28px; height: 28px; margin: 2.5rem auto;
  border: 2.5px solid #ddd; border-top-color: #222;
  border-radius: 50%; animation: spin .7s linear infinite;
}

/* Toast */
.toast {
  position: fixed; z-index: 999; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(6px);
  background: #323232; color: #fff;
  padding: 8px 18px; border-radius: 20px;
  font-size: 13px; white-space: nowrap;
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.loading-overlay {
  position: fixed; inset: 0; z-index: 998;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, 0.8);
  pointer-events: auto;
}
.loading-panel {
  display: flex; flex-direction: column; align-items: center;
  padding: 20px 22px; border-radius: 18px;
  background: #ffffff; box-shadow: 0 16px 40px rgba(0, 0, 0, 0.12);
}
.loading-text {
  margin-top: 12px; font-size: 14px; font-weight: 700;
  color: #222;
}

/* 목록 조회 중 로딩 표시 */
#list-body {
  position: relative;
  transition: opacity 0.15s;
}
#list-body.list-loading {
  opacity: 0.4;
  pointer-events: none;
}
#list-body.list-loading::after {
  content: '';
  position: absolute;
  top: 24px; left: 50%;
  transform: translateX(-50%);
  width: 28px; height: 28px;
  border: 3px solid #e0e0e0;
  border-top-color: #444;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
