:root {
  --primary: #5b4eff;
  --primary-light: #ede9ff;
  --primary-dark: #4035cc;
  --bg: #f0f2f8;
  --surface: #ffffff;
  --surface-2: #f7f7fc;
  --border: #e4e4ef;
  --text: #1a1a2e;
  --text-muted: #7b7b9a;
  --error: #ef4444;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.07);
  --shadow-md: 0 4px 20px rgba(0,0,0,.09);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.hidden { display: none !important; }

/* ===== LOGIN ===== */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, #f0f2f8 0%, #e6e1ff 100%);
  padding: 16px;
}

.login-card {
  background: var(--surface);
  border-radius: 20px;
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
}

.login-head {
  text-align: center;
  margin-bottom: 28px;
}

.login-icon {
  width: 52px;
  height: 52px;
  background: var(--primary);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  margin: 0 auto 14px;
  box-shadow: 0 6px 18px rgba(91,78,255,.3);
}

.login-title {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -.4px;
}

.login-sub {
  font-size: .8rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.login-field { margin-bottom: 13px; }

.login-field label {
  display: block;
  font-size: .77rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 5px;
  letter-spacing: .2px;
}

.login-field input {
  width: 100%;
  padding: 10px 13px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: .92rem;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.login-field input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(91,78,255,.1);
}

.btn-login {
  width: 100%;
  padding: 13px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 11px;
  font-size: .95rem;
  font-weight: 700;
  cursor: pointer;
  margin-top: 6px;
  box-shadow: 0 4px 14px rgba(91,78,255,.3);
  transition: all .15s;
  letter-spacing: -.2px;
}

.btn-login:hover { background: var(--primary-dark); }

/* ===== APP ===== */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.app-header {
  height: 52px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
  z-index: 10;
}

.logo {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 800;
  font-size: .92rem;
  color: var(--primary);
  letter-spacing: -.3px;
}

.logo-icon {
  width: 26px;
  height: 26px;
  background: var(--primary);
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: .8rem;
}

.header-right { display: flex; align-items: center; gap: 10px; }

.chip {
  background: var(--primary-light);
  color: var(--primary);
  font-size: .7rem;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 99px;
  letter-spacing: .3px;
}

.btn-ghost {
  padding: 5px 13px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}
.btn-ghost:hover { background: var(--bg); color: var(--text); }

/* ===== LAYOUT ===== */
.app-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: 360px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-inner {
  flex: 1;
  overflow-y: auto;
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.section-label {
  font-size: .72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .9px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.field { margin-bottom: 11px; }
.field:last-child { margin-bottom: 0; }

.field label {
  display: block;
  font-size: .75rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 5px;
  letter-spacing: .2px;
}

.field input,
.field textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  font-size: .88rem;
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  background: var(--surface);
}

.field input:focus,
.field textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(91,78,255,.1);
}

.field textarea { min-height: 72px; resize: vertical; }

.input-row { display: flex; gap: 7px; }
.input-row input { flex: 1; }

.btn-sm {
  padding: 8px 13px;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  font-size: .82rem;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s;
}
.btn-sm:hover { background: var(--bg); border-color: var(--text-muted); }

/* ===== PRESET ===== */
.preset-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
  margin-bottom: 8px;
}

.preset-btn {
  padding: 8px 4px;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  font-size: .78rem;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  text-align: center;
  transition: all .15s;
  line-height: 1.3;
}

.preset-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.preset-btn.active {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}

#custom-style {
  width: 100%;
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  font-size: .85rem;
  color: var(--text);
  outline: none;
  resize: vertical;
  min-height: 80px;
  transition: border-color .15s, box-shadow .15s;
}

#custom-style:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(91,78,255,.1);
}

/* ===== SIDEBAR FOOTER ===== */
.sidebar-footer {
  padding: 14px 18px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.btn-generate {
  width: 100%;
  padding: 13px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 11px;
  font-size: .95rem;
  font-weight: 800;
  cursor: pointer;
  letter-spacing: -.2px;
  box-shadow: 0 4px 14px rgba(91,78,255,.3);
  transition: all .15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.btn-generate:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(91,78,255,.38);
}

.btn-generate:active { transform: translateY(0); }
.btn-generate:disabled { opacity: .6; transform: none; cursor: not-allowed; }

/* ===== MAIN PANEL ===== */
.main-panel {
  flex: 1;
  overflow-y: auto;
  padding: 24px 24px 48px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ===== EMPTY STATE ===== */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  gap: 12px;
  min-height: 300px;
}

.empty-icon { font-size: 2.8rem; opacity: .25; }

.empty-text { font-size: .88rem; font-weight: 600; }

/* ===== RESULT META ===== */
.result-meta {
  font-size: .75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.meta-dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--border);
}

/* ===== RESULT CARDS ===== */
.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}

.result-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.result-num {
  width: 22px;
  height: 22px;
  background: var(--primary);
  color: white;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .72rem;
  font-weight: 800;
  flex-shrink: 0;
}

.result-card-title {
  font-size: .75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--text-muted);
}

.result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 13px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  margin-bottom: 6px;
  font-size: .88rem;
  line-height: 1.55;
}
.result-item:last-child { margin-bottom: 0; }
.result-item span { flex: 1; }

.btn-copy {
  padding: 4px 11px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  font-size: .73rem;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all .15s;
}
.btn-copy:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }

.result-description {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 13px;
  font-size: .88rem;
  line-height: 1.85;
  white-space: pre-wrap;
  font-family: inherit;
}

.copy-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

.category-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 13px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  margin-bottom: 6px;
  font-size: .85rem;
}
.category-item:last-child { margin-bottom: 0; }

.cat-code {
  font-size: .73rem;
  color: var(--text-muted);
  font-family: monospace;
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 5px;
  flex-shrink: 0;
}

/* ===== ERROR ===== */
.error {
  color: var(--error);
  font-size: .82rem;
  margin-bottom: 8px;
}

/* ===== MOBILE ===== */
@media (max-width: 680px) {
  .app-body { flex-direction: column; overflow: visible; }
  #app { height: auto; }
  .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); overflow: visible; }
  .sidebar-inner { overflow: visible; }
  .main-panel { padding: 16px 16px 40px; }
}

/* ===== パスワードリセット・アカウント設定 ===== */
.forgot-link {
  display: block;
  text-align: right;
  font-size: .77rem;
  color: var(--primary);
  margin-top: -4px;
  margin-bottom: 14px;
  text-decoration: none;
  font-weight: 600;
}
.forgot-link:hover { text-decoration: underline; }
.reset-panel-title {
  font-size: .85rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 12px;
}
.reset-ok {
  font-size: .8rem;
  color: #16a34a;
  margin-bottom: 10px;
}

/* アカウント設定パネル（右サイドドロワー） */
.account-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.25);
  z-index: 100;
}
.account-drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 360px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -4px 0 24px rgba(0,0,0,.08);
  z-index: 101;
  overflow-y: auto;
  padding: 0 0 32px;
}
.account-drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-size: .92rem;
  font-weight: 700;
  position: sticky; top: 0;
  background: var(--surface);
}
.account-section {
  padding: 20px;
  border-bottom: 1px solid var(--border);
}
.account-section:last-child { border-bottom: none; }
.account-section-label {
  font-size: .72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .9px;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.account-info-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: .85rem;
}
.account-info-key { color: var(--text-muted); }
.account-info-val { font-family: monospace; color: var(--text); font-weight: 600; }
