:root {
  --bg: #0a0a0f;
  --accent: #0085ff;
  --accent-light: #4da6ff;
  --green: #16a34a;
  --text: #e8eaed;
  --muted: #7a818a;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
}

body {
  font-family: 'Noto Sans JP', 'Hiragino Sans', 'Apple SD Gothic Neo', 'Microsoft YaHei', sans-serif;
  color: var(--text);
}

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.09); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.16); }
::-webkit-scrollbar-track { background: transparent; }

textarea:focus, input:focus { outline: none; }
textarea { resize: none; }

@keyframes pulseDot { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ============ APP SHELL ============ */
.app {
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: var(--bg);
  overflow: hidden;
}

/* ============ HEADER ============ */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 22px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  background: rgba(255,255,255,.012);
  flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 13px; }
.brand__logo { width: 34px; height: 34px; border-radius: 9px; object-fit: cover; flex-shrink: 0; display: block; box-shadow: 0 2px 10px rgba(0,133,255,.35); }
.brand__logo--fallback { display: flex; align-items: center; justify-content: center; font-size: 24px; box-shadow: none; filter: drop-shadow(0 2px 6px rgba(0,133,255,.45)); }
.brand__text { display: flex; flex-direction: column; gap: 2px; }
.brand__name { font-size: 16px; font-weight: 700; letter-spacing: -.2px; line-height: 1; }
.brand__tag { font-size: 11.5px; color: var(--muted); line-height: 1; }

/* language switch */
.lang { position: relative; }
.lang__btn {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: 10px;
  border: 1px solid rgba(255,255,255,.1);
  background: rgba(255,255,255,.04);
  color: #d6d9dd; font-size: 13px; cursor: pointer; font-family: inherit;
  transition: border-color .15s, background .15s;
}
.lang__btn:hover { border-color: rgba(255,255,255,.2); background: rgba(255,255,255,.06); }
.lang__flag { font-size: 15px; line-height: 1; }
.lang__code { font-family: var(--mono); letter-spacing: .5px; font-weight: 500; }
.lang__caret { font-size: 9px; color: var(--muted); }
.lang__backdrop { position: fixed; inset: 0; z-index: 40; }
.lang__menu {
  position: absolute; top: 46px; right: 0; z-index: 50;
  min-width: 178px; padding: 6px;
  border-radius: 12px; border: 1px solid rgba(255,255,255,.1);
  background: rgba(20,20,28,.96); backdrop-filter: blur(18px);
  box-shadow: 0 16px 44px rgba(0,0,0,.6);
}
.lang__item {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px; border: none; cursor: pointer;
  font-family: inherit; color: var(--text); background: transparent; font-size: 13.5px;
}
.lang__item:hover { background: rgba(255,255,255,.05); }
.lang__item--active { background: rgba(0,133,255,.14); }
.lang__item .name { flex: 1; text-align: left; }
.lang__item .code { font-family: var(--mono); font-size: 11px; color: var(--muted); letter-spacing: .5px; }
.lang__item .check { color: var(--accent); font-size: 13px; font-weight: 700; }

/* ============ BODY ============ */
.body { display: flex; min-height: 0; overflow: hidden; }

/* ---------- SIDEBAR ---------- */
.sidebar {
  width: 368px; flex-shrink: 0;
  border-right: 1px solid rgba(255,255,255,.07);
  overflow-y: auto; padding: 22px;
  display: flex; flex-direction: column; gap: 22px;
  background: rgba(255,255,255,.008);
}
.step { display: flex; flex-direction: column; gap: 12px; }
.step__head { display: flex; align-items: center; gap: 10px; }
.step__num {
  width: 24px; height: 24px; border-radius: 50%;
  background: rgba(0,133,255,.14); border: 1px solid rgba(0,133,255,.5);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: var(--accent-light); flex-shrink: 0;
}
.step__num--active { background: rgba(0,133,255,.14); border: 1px solid rgba(0,133,255,.5); color: var(--accent-light); }
.step__num--done { background: var(--green); border: none; color: #fff; box-shadow: 0 0 0 4px rgba(22,163,74,.12); }
.step__title { font-size: 13.5px; font-weight: 700; }
.step__done { margin-left: auto; font-size: 10.5px; font-family: var(--mono); color: var(--green); letter-spacing: .4px; }

/* login form */
.login { display: flex; flex-direction: column; gap: 9px; }
.login__input {
  width: 100%; padding: 11px 13px; border-radius: 11px;
  border: 1px solid rgba(255,255,255,.12); background: rgba(255,255,255,.04);
  color: var(--text); font-size: 13.5px; font-family: var(--mono); letter-spacing: .3px;
}
.login__input:focus { border-color: rgba(0,133,255,.5); }
.login__btn {
  width: 100%; padding: 11px; border-radius: 11px; border: none;
  background: linear-gradient(135deg, #0085ff, #00a2ff); color: #fff;
  font-weight: 700; font-size: 13.5px; cursor: pointer; font-family: inherit;
  box-shadow: 0 6px 18px rgba(0,133,255,.3); transition: filter .15s, opacity .15s;
}
.login__btn:hover { filter: brightness(1.08); }
.login__btn:disabled { opacity: .6; cursor: progress; }
.login__error { font-size: 11.5px; color: #ff6b6b; line-height: 1.5; }

/* profile card */
.profile {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 11px;
  border: 1px solid rgba(255,255,255,.08); background: rgba(255,255,255,.03);
}
.profile__avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, #0085ff, #00c4ff); background-size: cover; background-position: center;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 14px; font-weight: 700; flex-shrink: 0;
}
.profile__meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.profile__name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile__handle { font-size: 11.5px; color: var(--muted); font-family: var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile__logout { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 15px; padding: 4px; border-radius: 6px; }
.profile__logout:hover { color: #ff6b6b; background: rgba(255,255,255,.05); }

/* condition */
.cond {
  width: 100%; min-height: 78px; padding: 12px 13px; border-radius: 11px;
  border: 1px solid rgba(0,133,255,.32); background: rgba(0,133,255,.05);
  color: var(--text); font-size: 13.5px; line-height: 1.55; font-family: inherit;
}
.cond:focus { border-color: rgba(0,133,255,.55); }
.cond__hint { font-size: 11px; color: #5f6368; line-height: 1.5; }

/* run button */
.run-btn {
  width: 100%; padding: 11px; border-radius: 11px;
  border: 1px solid rgba(0,133,255,.4); background: rgba(0,133,255,.08);
  color: var(--accent-light); font-weight: 600; font-size: 13.5px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  cursor: pointer; font-family: inherit; transition: background .15s, border-color .15s;
}
.run-btn:hover { background: rgba(0,133,255,.15); border-color: rgba(0,133,255,.6); }
.run-btn:disabled { opacity: .5; cursor: not-allowed; }
.run-btn--stop { border-color: rgba(234,179,8,.5); background: rgba(234,179,8,.1); color: #eab308; }
.run-btn--stop:hover { background: rgba(234,179,8,.18); border-color: rgba(234,179,8,.7); }
.run-btn--stop .spinner { border-top-color: #eab308; }
.run-btn .spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(255,255,255,.25); border-top-color: var(--accent-light); animation: spin .7s linear infinite; }

/* delete button */
.del-btn {
  width: 100%; padding: 12px; border-radius: 11px; border: none;
  font-size: 14px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-family: inherit; transition: all .15s;
  background: #ef4444; color: #fff; cursor: pointer;
  box-shadow: 0 6px 18px rgba(239,68,68,.32);
}
.del-btn:hover:not(:disabled) { filter: brightness(1.08); }
.del-btn:disabled {
  background: rgba(255,255,255,.05); color: rgba(255,255,255,.28);
  cursor: not-allowed; box-shadow: none;
}

/* ---------- MAIN ---------- */
.main { flex: 1; min-width: 0; overflow-y: auto; padding: 20px 24px 28px; }

.sec-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.sec-head--divider { padding-top: 20px; margin-top: 4px; border-top: 1px solid rgba(255,255,255,.06); }
.dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.dot--green { background: var(--green); box-shadow: 0 0 8px rgba(22,163,74,.7); }
.dot--grey { background: #4b5158; }
.sec-head__title { font-size: 12px; font-weight: 700; letter-spacing: .3px; text-transform: uppercase; color: #aab0b6; }
.sec-head__title--muted { color: #6b7178; }
.sec-head__count {
  font-family: var(--mono); font-size: 11px; padding: 2px 8px; border-radius: 20px;
  background: rgba(255,255,255,.05); color: var(--muted); font-weight: 500;
}
.sec-head__count--green { background: rgba(22,163,74,.16); color: #4ade80; }
.sec-head__actions { margin-left: auto; display: flex; gap: 6px; }
.mini-btn {
  font-size: 11px; padding: 4px 10px; border-radius: 8px;
  border: 1px solid rgba(255,255,255,.1); background: rgba(255,255,255,.03);
  color: #aab0b6; cursor: pointer; font-family: inherit;
}
.mini-btn:hover { background: rgba(255,255,255,.07); color: var(--text); }

.post-list { display: flex; flex-direction: column; gap: 2px; margin-bottom: 4px; }

.post {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 13px; border-radius: 9px; cursor: pointer;
  transition: background .12s; animation: fadeIn .25s ease both;
}
.post:hover { background: rgba(255,255,255,.04); }
.post--unmatched { opacity: .5; }
.post--unmatched:hover { background: rgba(255,255,255,.03); opacity: .72; }

.post__box {
  width: 19px; height: 19px; border-radius: 5px; flex-shrink: 0;
  border: 1.5px solid rgba(255,255,255,.22); background: transparent;
  display: flex; align-items: center; justify-content: center;
  transition: all .18s cubic-bezier(.4,0,.2,1);
}
.post__box--checked { border-color: var(--accent); background: var(--accent); box-shadow: 0 0 0 4px rgba(0,133,255,.13); }
.post__check { display: flex; line-height: 0; transform: scale(.3); opacity: 0; transition: all .18s cubic-bezier(.4,0,.2,1); }
.post__box--checked .post__check { transform: scale(1); opacity: 1; }

.post__avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: linear-gradient(135deg, #0085ff, #00c4ff); background-size: cover; background-position: center;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 11px; font-weight: 700; flex-shrink: 0;
}
.post__text {
  flex: 1; min-width: 0; font-size: 13.5px; color: #d6d9dd;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.post--unmatched .post__text { color: #c2c6cb; }
.post__time { font-family: var(--mono); font-size: 11px; color: #5f6368; flex-shrink: 0; }
.post__badge {
  flex-shrink: 0; font-size: 10.5px; font-weight: 700;
  padding: 3px 9px; border-radius: 20px; letter-spacing: .2px; white-space: nowrap;
}
.post__badge--high { background: var(--green); color: #eafff1; }
.post__badge--medium { background: #eab308; color: #241c00; }

.empty { font-size: 12.5px; color: #5f6368; padding: 8px 13px; }
.empty[hidden] { display: none; }

/* ============ STATUS BAR ============ */
.statusbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 22px; border-top: 1px solid rgba(255,255,255,.07);
  background: rgba(255,255,255,.012); flex-shrink: 0;
  font-family: var(--mono); font-size: 12px;
}
.statusbar__text { color: #aab0b6; letter-spacing: .2px; }
.statusbar__engine { display: flex; align-items: center; gap: 7px; color: #6b7178; }
.statusbar__pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 7px rgba(22,163,74,.8); animation: pulseDot 2s ease-in-out infinite; }

/* ============ MODAL ============ */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; }
.modal[hidden] { display: none; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.6); backdrop-filter: blur(4px); }
.modal__card {
  position: relative; z-index: 1; width: 340px; max-width: calc(100vw - 40px);
  padding: 24px; border-radius: 16px; text-align: center;
  border: 1px solid rgba(255,255,255,.1); background: rgba(20,20,28,.98);
  box-shadow: 0 24px 64px rgba(0,0,0,.7); animation: fadeIn .2s ease both;
}
.modal__icon { font-size: 30px; margin-bottom: 10px; }
.modal__title { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.modal__body { font-size: 13px; color: #aab0b6; line-height: 1.6; margin-bottom: 20px; }
.modal__actions { display: flex; gap: 10px; }
.modal__btn { flex: 1; padding: 11px; border-radius: 10px; border: none; font-size: 13.5px; font-weight: 700; cursor: pointer; font-family: inherit; }
.modal__btn--ghost { background: rgba(255,255,255,.06); color: #d6d9dd; }
.modal__btn--ghost:hover { background: rgba(255,255,255,.1); }
.modal__btn--danger { background: #ef4444; color: #fff; box-shadow: 0 6px 18px rgba(239,68,68,.32); }
.modal__btn--danger:hover { filter: brightness(1.08); }

/* ============ TOAST ============ */
.toast {
  position: fixed; bottom: 56px; left: 50%; transform: translateX(-50%);
  z-index: 120; padding: 11px 18px; border-radius: 12px;
  background: rgba(20,20,28,.97); border: 1px solid rgba(255,255,255,.12);
  color: var(--text); font-size: 13px; box-shadow: 0 12px 36px rgba(0,0,0,.55);
  animation: fadeIn .2s ease both; max-width: calc(100vw - 40px);
}
.toast[hidden] { display: none; }
.toast--error { border-color: rgba(239,68,68,.5); }

/* ============ RESPONSIVE ============ */
@media (max-width: 820px) {
  .body { flex-direction: column; overflow-y: auto; }
  .sidebar { width: 100%; border-right: none; border-bottom: 1px solid rgba(255,255,255,.07); }
  .app { overflow: auto; }
}
