:root {
  /* Color Palette */
  --bg-main: #0B0F19;
  --bg-card: rgba(18, 24, 40, 0.7);
  --bg-card-hover: rgba(26, 34, 53, 0.85);
  --primary: #3B82F6;
  --primary-hover: #2563EB;
  --primary-glow: rgba(59, 130, 246, 0.5);
  --danger: #EF4444;
  --danger-hover: #DC2626;
  --danger-glow: rgba(239, 68, 68, 0.5);
  --success: #10B981;
  --success-glow: rgba(16, 185, 129, 0.3);
  --text-active: #F8FAFC;
  --text-muted: #94A3B8;
  --border-color: rgba(255, 255, 255, 0.1);
  --glass-border: rgba(255, 255, 255, 0.05);

  /* Typography */
  --font-base: 'Inter', 'Noto Sans JP', sans-serif;
  
  /* Utils */
  --radius-sm: 0.5rem;
  --radius-md: 0.75rem;
  --radius-lg: 1.25rem;
  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: var(--font-base);
  background: var(--bg-main);
  background-image: radial-gradient(circle at 15% 50%, rgba(59, 130, 246, 0.12), transparent 25%),
                    radial-gradient(circle at 85% 30%, rgba(239, 68, 68, 0.08), transparent 25%);
  color: var(--text-active);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  line-height: 1.6;
}

/* Navbar */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  background: rgba(11, 15, 25, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.navbar-logo {
  font-size: 1.5rem;
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.navbar-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-avatar {
  background: linear-gradient(135deg, var(--primary), #8B5CF6);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 1rem;
  color: #fff;
  box-shadow: 0 0 15px rgba(139, 92, 246, 0.4);
}

.user-name {
  font-size: 0.95rem;
  font-weight: 500;
}

/* Layout */
.main-content {
  flex: 1;
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
}

.login-layout {
  padding-top: 3rem;
}

/* App App-Shell Layout (Sidebar + Main) */
.app-layout {
  display: flex;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background: rgba(11, 15, 25, 0.95);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform var(--transition-normal);
  z-index: 1000;
}

.sidebar-header {
  height: 70px;
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 0.75rem;
  font-size: 1.15rem;
  font-weight: 700;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-logo {
  font-size: 1.5rem;
}

.sidebar-nav {
  flex: 1;
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow-y: auto;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: var(--radius-md);
  transition: var(--transition-fast);
  font-weight: 500;
}

.sidebar-link:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-active);
}

.sidebar-link.active {
  background: rgba(59, 130, 246, 0.15);
  color: var(--primary);
  box-shadow: inset 3px 0 0 var(--primary);
}

.nav-icon {
  font-size: 1.25rem;
}

.sidebar-footer {
  padding: 1.5rem 1rem;
  border-top: 1px solid var(--border-color);
  background: rgba(0, 0, 0, 0.2);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.mt-3 { margin-top: 1rem; }

/* Main Wrapper */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  position: relative;
  background-image: radial-gradient(circle at 10% 40%, rgba(59, 130, 246, 0.08), transparent 25%),
                    radial-gradient(circle at 90% 60%, rgba(239, 68, 68, 0.05), transparent 25%);
}

/* Mobile Header */
.mobile-header {
  display: none;
  height: 48px;
  background: rgba(11, 15, 25, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-color);
  align-items: center;
  justify-content: space-between;
  padding: 0 0.75rem;
  position: sticky;
  top: 0;
  z-index: 900;
}

.hamburger-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 0.5rem;
}

.hamburger-line {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--text-active);
  border-radius: 2px;
}

.mobile-title {
  font-weight: 600;
  font-size: 1.1rem;
}

.mobile-placeholder {
  width: 40px;
}

/* Sidebar Overlay for Mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 999;
  opacity: 0;
  transition: opacity var(--transition-normal);
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    height: 100%;
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .mobile-header {
    display: flex;
  }
  .sidebar-overlay.open {
    display: block;
    opacity: 1;
  }
}

.footer {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
  font-size: 0.875rem;
  border-top: 1px solid var(--border-color);
  background: rgba(11, 15, 25, 0.5);
}

/* Component: Cards (Glassmorphism) */
.login-container, .form-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 2rem;
}

.login-card, .form-card, .status-card, .info-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  animation: fadeUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.info-card {
  padding: 2rem;
  border: 1px solid rgba(59, 130, 246, 0.2);
  background: rgba(15, 23, 42, 0.6);
  animation-delay: 0.1s;
}

.info-card h2 {
  font-size: 1.25rem;
  margin-bottom: 1rem;
  color: var(--text-active);
}

.info-card ul {
  padding-left: 1.5rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.info-card li { margin-bottom: 0.5rem; }
.info-card strong { color: var(--text-active); }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

.login-header, .form-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.form-header h1 {
  font-size: 1.5rem;
  margin-bottom: 0.375rem;
}

.login-icon {
  font-size: 3.5rem;
  margin-bottom: 1rem;
  filter: drop-shadow(0 0 20px rgba(59, 130, 246, 0.6));
  animation: float 4s ease-in-out infinite;
}

@keyframes float {
  0% { transform: translateY(0px); }
  50% { transform: translateY(-10px); }
  100% { transform: translateY(0px); }
}

.login-subtitle, .form-description {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-top: 0.5rem;
  line-height: 1.5;
}

.login-note {
  margin-top: 2rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.5;
}

/* Component: Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius-md);
  font-weight: 500;
  font-size: 0.95rem;
  cursor: pointer;
  transition: var(--transition-normal);
  border: none;
  text-decoration: none;
  font-family: inherit;
}

.btn-lg {
  padding: 0.875rem 1.75rem;
  font-size: 1.05rem;
  font-weight: 600;
}

.btn-sm {
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 14px 0 rgba(59, 130, 246, 0.39);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.5);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-active);
}

.btn-icon {
  width: 1.25em;
  height: 1.25em;
}

/* Component: Alerts */
.alert-floating {
  position: fixed;
  top: 2rem;
  right: 2rem;
  left: auto;
  transform: none;
  width: 350px;
  max-width: calc(100vw - 4rem);
  z-index: 9999;
  box-shadow: 0 15px 35px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.05);
  margin-bottom: 0 !important;
  animation: slideInToast 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards !important;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

@keyframes slideInToast {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 768px) {
  .alert-floating {
    top: 5rem; /* Navbarの下 */
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: 90%;
  }
  @keyframes slideInToast {
    from { opacity: 0; transform: translate(-50%, -20px); }
    to { opacity: 1; transform: translate(-50%, 0); }
  }
}

.alert {
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  display: flex;
  flex-direction: column;
  margin-bottom: 2rem;
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-10px); }
  to { opacity: 1; transform: translateX(0); }
}

.alert-error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #F87171;
}

.alert-success {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #34D399;
}

.alert-detail {
  margin-top: 0.5rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Forms */
.segmented-control {
  display: flex;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.35rem;
  margin-bottom: 2rem;
  position: relative;
}

.segmented-control input[type="radio"] {
  display: none;
}

.segmented-control label {
  flex: 1;
  text-align: center;
  padding: 0.75rem 1rem;
  border-radius: calc(var(--radius-md) - 0.25rem);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition-normal);
  user-select: none;
}

.segmented-control label:hover {
  color: var(--text-active);
}

.segmented-control input[type="radio"]:checked + label {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: var(--text-active);
}

.required {
  color: var(--danger);
  margin-left: 0.25rem;
}

.form-input {
  width: 100%;
  padding: 0.7rem 0.875rem;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-active);
  font-size: 0.95rem;
  transition: var(--transition-normal);
  font-family: inherit;
}

.form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
  background: rgba(15, 23, 42, 0.8);
}

.form-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

.simple-checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.simple-checkbox-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.5rem;
}

.custom-checkbox {
  appearance: none;
  background-color: rgba(15, 23, 42, 0.6);
  margin: 0;
  font: inherit;
  color: currentColor;
  width: 1.25em;
  height: 1.25em;
  border: 1px solid var(--border-color);
  border-radius: 0.25em;
  display: grid;
  place-content: center;
  cursor: pointer;
  transition: var(--transition-normal);
  flex-shrink: 0;
  margin-top: 0.15rem;
}

.custom-checkbox::before {
  content: "";
  width: 0.65em;
  height: 0.65em;
  transform: scale(0);
  transition: 120ms transform ease-in-out;
  box-shadow: inset 1em 1em var(--primary);
  background-color: var(--primary);
  transform-origin: center;
  clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
}

.custom-checkbox:checked::before {
  transform: scale(1);
}

.custom-checkbox:hover {
  border-color: rgba(255, 255, 255, 0.3);
}

.custom-checkbox:focus {
  outline: max(2px, 0.15em) solid rgba(59, 130, 246, 0.3);
  outline-offset: max(2px, 0.15em);
}

.custom-checkbox.custom-checkbox-danger::before {
  box-shadow: inset 1em 1em var(--danger);
  background-color: var(--danger);
}

.checkbox-label-title {
  display: block;
  font-weight: 600;
  font-size: 1rem;
  color: var(--text-active);
}

.checkbox-label-desc {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.text-danger {
  color: #F87171 !important;
}

.badge-danger {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.4rem;
  border-radius: 9999px;
  background: rgba(239, 68, 68, 0.15);
  color: #FCA5A5;
  border: 1px solid rgba(239, 68, 68, 0.3);
  margin-left: 0.25rem;
  vertical-align: middle;
}

.form-actions {
  margin-top: 1.5rem;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(5px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  width: 90%;
  max-width: 500px;
  max-height: 90vh; /* デフォルトでも画面をハミ出ないようにスクロールさせる */
  max-height: 90dvh;
  overflow-y: auto;
  transform: translateY(20px);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.modal-overlay.open .modal-content {
  transform: translateY(0);
}

/* スマホ向けの余白と調整 */
@media (max-width: 768px) {
  .login-card, .form-card, .status-card, .info-card {
    padding: 1.25rem;
  }

  .login-header, .form-header {
    margin-bottom: 1rem;
  }

  .form-header h1 {
    font-size: 1.25rem;
  }

  .form-description {
    font-size: 0.85rem;
  }

  .main-content {
    padding: 0.75rem;
  }

  .form-container {
    justify-content: flex-start;
    padding-top: 0.5rem;
  }

  .form-group {
    margin-bottom: 1rem;
  }

  .form-input {
    padding: 0.625rem 0.75rem;
    font-size: 0.9rem;
  }

  textarea.form-input {
    min-height: 3.5rem !important;
    rows: 2;
  }

  .simple-checkbox-group {
    gap: 0.625rem;
  }

  .simple-checkbox-item {
    padding: 0.375rem;
  }

  .checkbox-label-title {
    font-size: 0.9rem;
  }

  .btn-lg {
    padding: 0.75rem 1.25rem;
    font-size: 0.95rem;
  }

  .modal-content {
    padding: 1.25rem;
    width: 95%;
  }

  .form-actions {
    margin-top: 1rem;
  }
}

/* iPhone SE 専用（375px以下） */
@media (max-width: 390px) {
  .mobile-header {
    height: 44px;
  }

  .main-content {
    padding: 0.5rem;
  }

  .login-card, .form-card {
    padding: 1rem;
    border-radius: var(--radius-md);
  }

  .form-header h1 {
    font-size: 1.125rem;
  }

  .form-group {
    margin-bottom: 0.875rem;
  }

  .form-label {
    font-size: 0.8rem;
    margin-bottom: 0.375rem;
  }

  .form-input {
    padding: 0.55rem 0.7rem;
    font-size: 0.875rem;
  }

  textarea.form-input {
    min-height: 3rem !important;
  }

  .btn-lg {
    padding: 0.65rem 1rem;
    font-size: 0.9rem;
  }

  .form-actions {
    margin-top: 0.875rem;
  }

  .modal-content {
    padding: 1rem;
  }
}
